|
- namespace SafeCampus.Application.Services.Business.ClassRoomCallService;
-
- public class ClassRoomCallService : DbRepository<ClassRoomCall>, IClassRoomCallService
- {
- public async Task<bool> Add(ClassRoomCallDto input)
- {
- var model = input.Adapt<ClassRoomCall>();
- await InsertAsync(model);
- return true;
- }
-
- public async Task<bool> Update(ClassRoomCallUpdate input)
- {
- var model = await GetFirstAsync(p => p.Id == input.Id);
- if (model == null)
- {
- throw Oops.Oh("信息不存在");
- }
- //var res = input.Adapt(model);
- model.PersonSetId = input.PersonSetId;
- model.PersonId = input.PersonId;
- await Context.Updateable<ClassRoomCall>()
- .UpdateColumns(x => new
- {
- x.PersonSetId,
- x.PersonId
- })
- .ExecuteCommandAsync();
- //await UpdateAsync(model);
- return true;
- }
-
- public async Task<bool> Remove(long id)
- {
- var model = await GetFirstAsync(x => x.Id == id);
- if (model == null)
- {
- throw Oops.Oh("信息不存在");
- }
- await DeleteAsync(model);
- return true;
- }
-
- public async Task<SqlSugarPagedList<ClassRoomCallList>> GetPageList(ClassRoomCallSearch search)
- {
- var query = Context.Queryable<ClassRoomCall>()
- .Includes(x => x.CameraInfoItem)
- .WhereIF(!string.IsNullOrEmpty(search.AlarmType), x => x.AlarmType == search.AlarmType)
- .WhereIF(!string.IsNullOrEmpty(search.CameraId), x => x.CameraId == search.CameraId)
- .WhereIF(!string.IsNullOrEmpty(search.PersonSetId), x => x.PersonSetId == search.PersonSetId)
- .WhereIF(!string.IsNullOrEmpty(search.TaskId), x => x.TaskId == search.TaskId)
- .WhereIF(!string.IsNullOrEmpty(search.TrackId), x => x.TrackId == search.TrackId)
- .WhereIF(!string.IsNullOrEmpty(search.PersonId), x => x.PersonId == search.PersonId)
- .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<ClassRoomCall, ClassRoomCallList>(search.PageNum, search.PageSize);
- return list;
- }
-
- public async Task<List<ClassRoomCallList>> GetNoPageList(ClassRoomCallSearch search)
- {
- var query = Context.Queryable<ClassRoomCall>()
- .Includes(x => x.CameraInfoItem)
- .WhereIF(!string.IsNullOrEmpty(search.AlarmType), x => x.AlarmType == search.AlarmType)
- .WhereIF(!string.IsNullOrEmpty(search.CameraId), x => x.CameraId == search.CameraId)
- .WhereIF(!string.IsNullOrEmpty(search.PersonSetId), x => x.PersonSetId == search.PersonSetId)
- .WhereIF(!string.IsNullOrEmpty(search.TaskId), x => x.TaskId == search.TaskId)
- .WhereIF(!string.IsNullOrEmpty(search.TrackId), x => x.TrackId == search.TrackId)
- .WhereIF(!string.IsNullOrEmpty(search.PersonId), x => x.PersonId == search.PersonId)
- .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<ClassRoomCallList>>();
- }
- }
|