namespace SafeCampus.Application.Services.Business.PersonSetInfoService; public class PersonSetInfoService:DbRepository, IPersonSetInfoService { public async Task Add(PersonSetInfoDto input) { var model = input.Adapt(); var oldModel = await GetFirstAsync(x => x.PersonSetId == input.PersonSetId); if (oldModel != null) { throw Oops.Oh("该班级id已存在"); } await InsertAsync(model); return true; } public async Task Delete(string id) { var model = await GetFirstAsync(x => x.PersonSetId == id); if (model == null) { throw Oops.Oh("信息不存在"); } await DeleteAsync(model); return true; } public async Task Update(PersonSetInfoDto input) { var model = await GetFirstAsync(p => p.PersonSetId == input.PersonSetId); if (model == null) { throw Oops.Oh("信息不存在"); } var res = input.Adapt(model); await UpdateAsync(res); return true; } public async Task> GetPageList(long? majorId, string setName) { var list =await Context.Queryable() .Includes(x=>x.MajorInfoItem,x=>x.DepartmentInfoItem) .Where(x=>x.PersonSetId!=SafeCampusConst.ZDRY) .WhereIF(majorId.HasValue,x=>x.MajorId==majorId) .WhereIF(!string.IsNullOrEmpty(setName),x=>x.PersonSetName.Contains(setName)) .Includes(x => x.ClassTeacherItem, st => st.SysUserItem) .ToListAsync(); return list.Adapt>(); } }