| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- using Furion.DatabaseAccessor.Extensions;
- using YBEE.EQM.Core;
- namespace YBEE.EQM.Application.Ncee;
- /// <summary>
- /// 高中划线参照划线管理服务
- /// </summary>
- public class NceeBaseLineService(IRepository<NceeBaseLine> rep) : INceeBaseLineService, ITransient
- {
- /// <summary>
- /// 添加
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- public async Task Add(AddNceeBaseLineInput input)
- {
- var e = await rep.AnyAsync(t => t.NceePlanId == input.NceePlanId && t.NceeLineLevel == input.NceeLineLevel);
- if (e)
- {
- throw Oops.Oh(ErrorCode.E2011, "划线等级");
- }
- var item = input.Adapt<NceeBaseLine>();
- await item.InsertNowAsync();
- }
- /// <summary>
- /// 更新
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- public async Task Update(UpdateNceeBaseLineInput input)
- {
- var item = await rep.FirstOrDefaultAsync(t => t.Id == input.Id) ?? throw Oops.Oh(ErrorCode.E2001);
- await item.UpdateNowAsync();
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- public async Task Del(BaseId input)
- {
- var item = await rep.FirstOrDefaultAsync(t => t.Id == input.Id) ?? throw Oops.Oh(ErrorCode.E2001);
- await item.DeleteNowAsync();
- }
- /// <summary>
- /// 根据计划ID获取划线参考列表
- /// </summary>
- /// <param name="nceePlanId"></param>
- /// <returns></returns>
- public async Task<List<NceeBaseLineOutput>> GetListByNceePlanId(int nceePlanId)
- {
- var items = await rep.DetachedEntities.Where(t => t.NceePlanId == nceePlanId).ProjectToType<NceeBaseLineOutput>().OrderBy(t => t.NceeLineLevel).ToListAsync();
- return items;
- }
- }
|