平安校园
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 
 

45 linhas
2.3 KiB

  1. namespace SafeCampus.Application.Services.Business.AttendanceService;
  2. public class AttendanceService:DbRepository<Attendance>, IAttendanceService
  3. {
  4. public async Task<bool> Add(AttendanceDto input)
  5. {
  6. var model = input.Adapt<Attendance>();
  7. await InsertAsync(model);
  8. return true;
  9. }
  10. public async Task<SqlSugarPagedList<AttendanceList>> GetPageList(AttendanceSearch search)
  11. {
  12. var query = Context.Queryable<Attendance>()
  13. //.Includes(x => x.CameraInfoItem)
  14. .WhereIF(search.IsAuto.HasValue, x => x.IsAuto == search.IsAuto)
  15. .WhereIF(!string.IsNullOrEmpty(search.PersonSetId), x => x.PersonSetId == search.PersonSetId)
  16. .WhereIF(!string.IsNullOrEmpty(search.PersonId), x => x.PersonId == search.PersonId)
  17. .WhereIF(!string.IsNullOrEmpty(search.TrackId), x => x.TrackId == search.TrackId)
  18. .WhereIF(!string.IsNullOrEmpty(search.CameraId), x => x.CameraId == search.CameraId)
  19. .WhereIF(search.StartTick.HasValue, x => x.Tick >= search.StartTick)
  20. .WhereIF(search.EndTick.HasValue, x => x.Tick <= search.EndTick);
  21. var list = await query.OrderByDescending(x => x.Tick)
  22. .ToPagedListAsyncMapster<Attendance, AttendanceList>(search.PageNum, search.PageSize);
  23. return list;
  24. }
  25. public async Task<List<AttendanceList>> GetNoPageList(AttendanceSearch search)
  26. {
  27. var query = Context.Queryable<Attendance>()
  28. //.Includes(x => x.CameraInfoItem)
  29. .WhereIF(search.IsAuto.HasValue, x => x.IsAuto == search.IsAuto)
  30. .WhereIF(!string.IsNullOrEmpty(search.PersonSetId), x => x.PersonSetId == search.PersonSetId)
  31. .WhereIF(!string.IsNullOrEmpty(search.PersonId), x => x.PersonId == search.PersonId)
  32. .WhereIF(!string.IsNullOrEmpty(search.TrackId), x => x.TrackId == search.TrackId)
  33. .WhereIF(!string.IsNullOrEmpty(search.CameraId), x => x.CameraId == search.CameraId)
  34. .WhereIF(search.StartTick.HasValue, x => x.Tick >= search.StartTick)
  35. .WhereIF(search.EndTick.HasValue, x => x.Tick <= search.EndTick);
  36. var list = await query.OrderByDescending(x => x.Tick)
  37. .ToListAsync();
  38. return list.Adapt<List<AttendanceList>>();
  39. }
  40. }