fix 查询我的餐补接口迁移
This commit is contained in:
@@ -32,4 +32,15 @@ public class MealSupplementsRecordController
|
||||
{
|
||||
return await _mealSupplementRecordService.GetPageAsync(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取我的餐补数据
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("my")]
|
||||
public async Task<List<MealSupplementRecordMyResponse>> GetMyMealSupplementRecords(MealSupplementRecordMyRequest request)
|
||||
{
|
||||
return await _mealSupplementRecordService.GetMyMealSupplementRecords(request);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Kurisu.Core.CustomClass;
|
||||
|
||||
namespace Dlhis.Canteen.MealSupplementRecord.Request;
|
||||
|
||||
public class MealSupplementRecordMyRequest : IValidatableObject
|
||||
{
|
||||
public DateTimePeriod SearchDateTimePeriod { get; set; }
|
||||
|
||||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||
{
|
||||
SearchDateTimePeriod.End = SearchDateTimePeriod.End.Value.AddDays(1).AddSeconds(-1);
|
||||
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,20 @@
|
||||
using Kurisu.Core.CustomClass;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Kurisu.Core.CustomClass;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
|
||||
namespace Dlhis.Canteen.MealSupplementRecord.Request;
|
||||
|
||||
public class MealSupplementRecordRequest : PageDto
|
||||
public class MealSupplementRecordRequest : PageDto, IValidatableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// 餐补日期范围
|
||||
/// </summary>
|
||||
public DateTimePeriod DateTimePeriod { get; set; }
|
||||
|
||||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||
{
|
||||
DateTimePeriod.End = DateTimePeriod.End.Value.AddDays(1).AddSeconds(-1);
|
||||
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Dlhis.Canteen.MealSupplementRecord.Response;
|
||||
|
||||
public class MealSupplementRecordMyResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// 餐补日期
|
||||
/// </summary>
|
||||
public DateTime Date { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public decimal CurrentAmount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 餐补金额
|
||||
/// </summary>
|
||||
public string Amount => CurrentAmount.ToString("f2");
|
||||
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
public string Remark { get; set; }
|
||||
}
|
||||
@@ -7,4 +7,6 @@ namespace Dlhis.Canteen.MealSupplementRecord.Services;
|
||||
public interface IMealSupplementRecordService : IScopeDependency
|
||||
{
|
||||
Task<Pagination<MealSupplementRecordResponse>> GetPageAsync(MealSupplementRecordRequest request);
|
||||
|
||||
Task<List<MealSupplementRecordMyResponse>> GetMyMealSupplementRecords(MealSupplementRecordMyRequest request);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
using Dlhis.Canteen.MealSupplementRecord.Request;
|
||||
using Dlhis.Canteen.MealSupplementRecord.Response;
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.Entity.Basic.Enums;
|
||||
using Dlhis.Entity.Canteen.Entities;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
using Kurisu.Core.User.Abstractions;
|
||||
using Kurisu.SqlSugar.Extensions;
|
||||
using Kurisu.SqlSugar.Services;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Dlhis.Canteen.MealSupplementRecord.Services.Implements;
|
||||
|
||||
@@ -13,10 +16,12 @@ public class MealSupplementRecordService : IMealSupplementRecordService
|
||||
{
|
||||
|
||||
private readonly IDbContext _dbContext;
|
||||
private readonly ICurrentUser _currentUser;
|
||||
|
||||
public MealSupplementRecordService(IDbContext dbContext)
|
||||
public MealSupplementRecordService(IDbContext dbContext, ICurrentUser currentUser)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
_currentUser = currentUser;
|
||||
}
|
||||
|
||||
public async Task<Pagination<MealSupplementRecordResponse>> GetPageAsync(MealSupplementRecordRequest request)
|
||||
@@ -44,4 +49,22 @@ public class MealSupplementRecordService : IMealSupplementRecordService
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
public async Task<List<MealSupplementRecordMyResponse>> GetMyMealSupplementRecords(MealSupplementRecordMyRequest request)
|
||||
{
|
||||
var code = _currentUser.GetUserClaim("jinko-code") ?? string.Empty;
|
||||
|
||||
return await _dbContext.Queryable<MealSupplementRecordEntity>()
|
||||
.Where(x => x.Date >= request.SearchDateTimePeriod.Start && x.Date <= request.SearchDateTimePeriod.End)
|
||||
.Where(x => x.Status == MealSupplementStatusEnumtype.Success)
|
||||
.Where(x => x.Code == code)
|
||||
.OrderBy(x => x.Date, OrderByType.Desc)
|
||||
.Select(x => new MealSupplementRecordMyResponse
|
||||
{
|
||||
CurrentAmount = x.Amount,
|
||||
Date = x.Date,
|
||||
Remark = x.Remark
|
||||
})
|
||||
.ToListAsync();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user