|
12345678910111213141516171819202122232425262728293031323334353637 |
- using SafeCampus.Application.Services.Business.PassengerFlowService.Dto;
-
- namespace SafeCampus.Application.Services.Business.PassengerFlowService;
-
- public class PassengerFlowService:DbRepository<PassengerFlow>, IPassengerFlowService
- {
- public async Task<bool> Add(PassengerFlowDto input)
- {
- //var model = input.Adapt<PassengerFlow>();
- var model = new PassengerFlow
- {
- CameraIds = input.CameraIds!=null? string.Join("、", input.CameraIds):"",
- CameraNames = input.CameraNames!=null?string.Join("、",input.CameraNames):"",
- EndTime = input.EndTime,
- ExtJson = input.ExtJson,
- QueryTime = DateTime.Now,
- Split = input.Split,
- StartTime = input.StartTime,
- Total = input.Total
- };
- await InsertAsync(model);
- return true;
- }
-
- public async Task<SqlSugarPagedList<PassengerFlowDto>> GetPageList(PassengerFlowSearch search)
- {
- var query = Context.Queryable<PassengerFlow>()
- .WhereIF(search.Split.HasValue, x => x.Split == search.Split)
- .WhereIF(!string.IsNullOrEmpty(search.CameraId), x => x.CameraIds.Contains(search.CameraId))
- .WhereIF(search.StartTime.HasValue, x => x.QueryTime >= search.StartTime)
- .WhereIF(search.EndTime.HasValue, x => x.QueryTime <= search.EndTime);
-
- var list = await query.OrderByDescending(x => x.QueryTime)
- .ToPagedListAsyncMapster<PassengerFlow, PassengerFlowDto>(search.PageNum, search.PageSize);
- return list;
- }
- }
|