78 lines
2.6 KiB
C#
78 lines
2.6 KiB
C#
using Dlhis.Basic.BusinessPlace.Response;
|
|
using Dlhis.Basic.MealUser.Request;
|
|
using Dlhis.Basic.Organization.Services;
|
|
using Dlhis.Entity.Basic.Entity;
|
|
using Kurisu.AspNetCore.Utils.Extensions;
|
|
using Kurisu.Core.DataAccess.Dto;
|
|
using Kurisu.SqlSugar.Extensions;
|
|
using Kurisu.SqlSugar.Services;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace Dlhis.Basic.MealUser.Services.Implements
|
|
{
|
|
public class GainfoService : IGainfoService
|
|
{
|
|
|
|
private readonly IGainfoStore _gainfoStore;
|
|
|
|
public GainfoService(IDbContext dbContext, IGainfoStore gainfoStore)
|
|
{
|
|
|
|
_gainfoStore = gainfoStore;
|
|
}
|
|
/// <summary>
|
|
///保存档案号
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
/// <returns></returns>
|
|
public async Task SaveAsync(GainfoAddSaveRequest request)
|
|
{
|
|
await CheckGainfoGuestnoAsync(request);//档案号是否重复
|
|
|
|
var gainfos = new List<GainfoEntity>();
|
|
gainfos.Add(request.gainfoEntity);
|
|
await _gainfoStore.InsertAsync(request.gainfoStatus,gainfos);
|
|
}
|
|
/// <summary>
|
|
/// 档案分页
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
/// <returns></returns>
|
|
public Task<Pagination<GainfoEntity>> GetPageAsync( GainfoPageRequest request)
|
|
{
|
|
var page = _gainfoStore.Queryable(request.gainfoStatus)
|
|
.Select<GainfoEntity>()
|
|
.ToPageListAsync(request);
|
|
return page;
|
|
}
|
|
/// <summary>
|
|
///修改档案号
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
/// <returns></returns>
|
|
public async Task UpdateAsync(GainfoAddSaveRequest request)
|
|
{
|
|
var gainfos = new List<GainfoEntity>();
|
|
gainfos.Add(request.gainfoEntity);
|
|
await _gainfoStore.UpdateAsync(request.gainfoStatus,gainfos);
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------help methods-----------------------------------------------
|
|
/// <summary>
|
|
/// 检查档案号是否重复
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
/// <returns></returns>
|
|
private async Task CheckGainfoGuestnoAsync(GainfoAddSaveRequest request)
|
|
{
|
|
|
|
var checkGainfoGuestno = await _gainfoStore.Queryable(request.gainfoStatus)
|
|
.Where(x => x.Guestno == request.gainfoEntity.Guestno)
|
|
.AnyAsync();
|
|
checkGainfoGuestno.ThrowIfTrue($"档案号[{request.gainfoEntity.Guestno}]已存在");
|
|
}
|
|
}
|
|
}
|