namespace SafeCampus.Application.Services.Business.CameraGroupService; public class CameraGroupService :DbRepository, ICameraGroupService { public async Task Add(CameraGroupAddInput input) { var model = input.Adapt(); await InsertAsync(model); return true; } public async Task Update(CameraGroupInput input) { if (!input.Id.HasValue) { throw Oops.Oh("请填写ID"); } var model = await GetFirstAsync(p => p.Id == input.Id); if (model == null) { throw Oops.Oh("信息不存在"); } var res = input.Adapt(model); await UpdateAsync(res); return true; } public async Task Delete(long id) { var cameraInfo = ChangeRepository>();//切换仓储 var model = await GetFirstAsync(x => x.Id == id); if (model == null) { throw Oops.Oh("信息不存在"); } var isOK = await cameraInfo.IsAnyAsync(x => x.GroupId == model.Id); if (isOK) { throw Oops.Oh("分组下存在摄像头,请转移至其他分组后在删除!"); } await DeleteAsync(model); return true; } public async Task> GetNoPageList() { var list = await Context.Queryable() .ToTreeAsync(x => x.Children, x => x.ParentId, null); //var list = await GetListAsync(); return list; } public async Task> GetBIList() { var list = await Context.Queryable().Includes(x => x.CameraInfos).ToListAsync(); return list; } }