平安校园
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.

AttendanceService.cs 2.3 KiB

4 months ago
3 months ago
4 months ago
3 months ago
4 months ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. }