namespace SafeCampus.Application.Services.Business.ClassRoomCallTaskService; public class ClassRoomCallTaskService : DbRepository ,IClassRoomCallTaskService { public async Task Add(ClassRoomCallTaskDto input) { var model = input.Adapt(); await InsertAsync(model); return true; } public async Task Remove(long id) { var model = await GetFirstAsync(x => x.Id == id); if (model == null) { throw Oops.Oh("信息不存在"); } await DeleteAsync(model); var classRoomCall = ChangeRepository>();//切换仓储 await classRoomCall.DeleteAsync(x => x.TaskId == model.TaskId); return true; } public async Task> GetPageList(ClassRoomCallTaskSearch search) { var query = Context.Queryable() .Includes(x => x.CameraInfoItem) .Includes(x=>x.PersonSetInfoItem,x=>x.MajorInfoItem,x=>x.DepartmentInfoItem ) .WhereIF(!string.IsNullOrEmpty(search.PersonSetId), x => x.PersonSetId == search.PersonSetId) .WhereIF(!string.IsNullOrEmpty(search.TaskId), x => x.TaskId == search.TaskId) .WhereIF(!string.IsNullOrEmpty(search.CameraId), x => x.CameraId == search.CameraId) .WhereIF(search.StartTime.HasValue, x => x.CreateTime >= search.StartTime) .WhereIF(search.DepId.HasValue, x => x.PersonSetInfoItem.MajorInfoItem.DepId == search.DepId) .WhereIF(search.MajorId.HasValue, x => x.PersonSetInfoItem.MajorId == search.MajorId) .WhereIF(search.EndTime.HasValue, x => x.EndTime <= search.EndTime); var list = await query.OrderByDescending(x => x.CreateTime) .ToPagedListAsyncMapster(search.PageNum, search.PageSize); return list; } }