|
- namespace SafeCampus.Application.Services.Business.AttendanceService;
-
- public class AttendanceService:DbRepository<Attendance>, IAttendanceService
- {
- public async Task<bool> Add(AttendanceDto input)
- {
- var model = input.Adapt<Attendance>();
- await InsertAsync(model);
- return true;
- }
-
- public async Task<SqlSugarPagedList<AttendanceList>> GetPageList(AttendanceSearch search)
- {
- var query = Context.Queryable<Attendance>()
- //.Includes(x => x.CameraInfoItem)
- .WhereIF(search.IsAuto.HasValue, x => x.IsAuto == search.IsAuto)
- .WhereIF(!string.IsNullOrEmpty(search.PersonSetId), x => x.PersonSetId == search.PersonSetId)
- .WhereIF(!string.IsNullOrEmpty(search.PersonId), x => x.PersonId == search.PersonId)
- .WhereIF(!string.IsNullOrEmpty(search.TrackId), x => x.TrackId == search.TrackId)
- .WhereIF(!string.IsNullOrEmpty(search.CameraId), x => x.CameraId == search.CameraId)
- .WhereIF(search.StartTick.HasValue, x => x.Tick >= search.StartTick)
- .WhereIF(search.EndTick.HasValue, x => x.Tick <= search.EndTick);
-
- var list = await query.OrderByDescending(x => x.Tick)
- .ToPagedListAsyncMapster<Attendance, AttendanceList>(search.PageNum, search.PageSize);
- return list;
- }
-
- public async Task<List<AttendanceList>> GetNoPageList(AttendanceSearch search)
- {
- var query = Context.Queryable<Attendance>()
- //.Includes(x => x.CameraInfoItem)
- .WhereIF(search.IsAuto.HasValue, x => x.IsAuto == search.IsAuto)
- .WhereIF(!string.IsNullOrEmpty(search.PersonSetId), x => x.PersonSetId == search.PersonSetId)
- .WhereIF(!string.IsNullOrEmpty(search.PersonId), x => x.PersonId == search.PersonId)
- .WhereIF(!string.IsNullOrEmpty(search.TrackId), x => x.TrackId == search.TrackId)
- .WhereIF(!string.IsNullOrEmpty(search.CameraId), x => x.CameraId == search.CameraId)
- .WhereIF(search.StartTick.HasValue, x => x.Tick >= search.StartTick)
- .WhereIF(search.EndTick.HasValue, x => x.Tick <= search.EndTick);
-
- var list = await query.OrderByDescending(x => x.Tick)
- .ToListAsync();
- return list.Adapt<List<AttendanceList>>();
- }
- }
|