using Furion.DatabaseAccessor.Extensions; using YBEE.EQM.Core; namespace YBEE.EQM.Application.Ncee; /// /// 高中划线参照划线管理服务 /// public class NceeBaseLineService : INceeBaseLineService, ITransient { private readonly IRepository _rep; public NceeBaseLineService(IRepository rep) { _rep = rep; } /// /// 添加 /// /// /// 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(); await item.InsertNowAsync(); } /// /// 更新 /// /// /// public async Task Update(UpdateNceeBaseLineInput input) { var item = await _rep.FirstOrDefaultAsync(t => t.Id == input.Id) ?? throw Oops.Oh(ErrorCode.E2001); await item.UpdateNowAsync(); } /// /// 删除 /// /// /// public async Task Del(BaseId input) { var item = await _rep.FirstOrDefaultAsync(t => t.Id == input.Id) ?? throw Oops.Oh(ErrorCode.E2001); await item.DeleteNowAsync(); } /// /// 根据计划ID获取划线参考列表 /// /// /// public async Task> GetListByNceePlanId(int nceePlanId) { var items = await _rep.DetachedEntities.Where(t => t.NceePlanId == nceePlanId).ProjectToType().OrderBy(t => t.NceeLineLevel).ToListAsync(); return items; } }