平安校园
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

39 lines
1.6 KiB

  1. namespace SafeCampus.Application.Services.Business.ClassRoomCallTaskService;
  2. public class ClassRoomCallTaskService : DbRepository<ClassRoomCallTask> ,IClassRoomCallTaskService
  3. {
  4. public async Task<bool> Add(ClassRoomCallTaskDto input)
  5. {
  6. var model = input.Adapt<ClassRoomCallTask>();
  7. await InsertAsync(model);
  8. return true;
  9. }
  10. public async Task<bool> Remove(long id)
  11. {
  12. var model = await GetFirstAsync(x => x.Id == id);
  13. if (model == null)
  14. {
  15. throw Oops.Oh("信息不存在");
  16. }
  17. await DeleteAsync(model);
  18. var classRoomCall = ChangeRepository<DbRepository<ClassRoomCall>>();//切换仓储
  19. await classRoomCall.DeleteAsync(x => x.TaskId == model.TaskId);
  20. return true;
  21. }
  22. public async Task<SqlSugarPagedList<ClassRoomCallTaskDto>> GetPageList(ClassRoomCallTaskSearch search)
  23. {
  24. var query = Context.Queryable<ClassRoomCallTask>()
  25. .Includes(x => x.CameraInfoItem)
  26. .WhereIF(!string.IsNullOrEmpty(search.PersonSetId), x => x.PersonSetId == search.PersonSetId)
  27. .WhereIF(!string.IsNullOrEmpty(search.TaskId), x => x.TaskId == search.TaskId)
  28. .WhereIF(!string.IsNullOrEmpty(search.CameraId), x => x.CameraId == search.CameraId)
  29. .WhereIF(search.StartTime.HasValue, x => x.CreateTime >= search.StartTime)
  30. .WhereIF(search.EndTime.HasValue, x => x.EndTime <= search.EndTime);
  31. var list = await query.OrderByDescending(x => x.CreateTime)
  32. .ToPagedListAsyncMapster<ClassRoomCallTask, ClassRoomCallTaskDto>(search.PageNum, search.PageSize);
  33. return list;
  34. }
  35. }