平安校园
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 
 
 
 

59 satır
1.7 KiB

  1. namespace SafeCampus.Application.Services.Business.CameraGroupService;
  2. public class CameraGroupService :DbRepository<CameraGroup>, ICameraGroupService
  3. {
  4. public async Task<bool> Add(CameraGroupAddInput input)
  5. {
  6. var model = input.Adapt<CameraGroup>();
  7. await InsertAsync(model);
  8. return true;
  9. }
  10. public async Task<bool> Update(CameraGroupInput input)
  11. {
  12. if (!input.Id.HasValue)
  13. {
  14. throw Oops.Oh("请填写ID");
  15. }
  16. var model = await GetFirstAsync(p => p.Id == input.Id);
  17. if (model == null)
  18. {
  19. throw Oops.Oh("信息不存在");
  20. }
  21. var res = input.Adapt(model);
  22. await UpdateAsync(res);
  23. return true;
  24. }
  25. public async Task<bool> Delete(long id)
  26. {
  27. var cameraInfo = ChangeRepository<DbRepository<CameraInfo>>();//切换仓储
  28. var model = await GetFirstAsync(x => x.Id == id);
  29. if (model == null)
  30. {
  31. throw Oops.Oh("信息不存在");
  32. }
  33. var isOK = await cameraInfo.IsAnyAsync(x => x.GroupId == model.Id);
  34. if (isOK)
  35. {
  36. throw Oops.Oh("分组下存在摄像头,请转移至其他分组后在删除!");
  37. }
  38. await DeleteAsync(model);
  39. return true;
  40. }
  41. public async Task<List<CameraGroup>> GetNoPageList()
  42. {
  43. var list = await Context.Queryable<CameraGroup>()
  44. .ToTreeAsync(x => x.Children, x => x.ParentId, null);
  45. //var list = await GetListAsync();
  46. return list;
  47. }
  48. public async Task<List<CameraGroup>> GetBIList()
  49. {
  50. var list = await Context.Queryable<CameraGroup>().Includes(x => x.CameraInfos).ToListAsync();
  51. return list;
  52. }
  53. }