namespace SafeCampus.Application.Services.Business.BuildingService; public class BuildingService:DbRepository,IBuildingService { public async Task Add(BuildingInfoDto input) { var model = input.Adapt(); await InsertAsync(model); return true; } public async Task Update(BuildingInfoDto 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 GetInfo(long id) { var model = await Context.Queryable() .FirstAsync(x => x.Id == id); if (model == null) { return null; } return model.Adapt(); } public async Task Delete(long id) { var model = await GetFirstAsync(x => x.Id == id); if (model == null) { throw Oops.Oh("信息不存在"); } var dor = ChangeRepository>();//切换仓储 var build = await dor.GetListAsync(x=>x.BuildId==model.Id); if (build.Any()) { throw Oops.Oh("宿舍楼下还有寝室不可删除!"); } await DeleteAsync(model); return true; } public async Task> GetNoPageList() { var list = await Context.Queryable() .Includes(x => x.InsCameraInfoItem) .Includes(x => x.OutCameraInfoItem) .ToListAsync(); //var list = await GetListAsync(); return list.Adapt>(); } }