平安校园
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

BuildingService.cs 1.6 KiB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. namespace SafeCampus.Application.Services.Business.BuildingService;
  2. public class BuildingService:DbRepository<BuildingInfo>,IBuildingService
  3. {
  4. public async Task<bool> Add(BuildingInfoDto input)
  5. {
  6. var model = input.Adapt<BuildingInfo>();
  7. await InsertAsync(model);
  8. return true;
  9. }
  10. public async Task<bool> Update(BuildingInfoDto 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<BuildingInfoDto> GetInfo(long id)
  26. {
  27. var model = await Context.Queryable<BuildingInfo>()
  28. .FirstAsync(x => x.Id == id);
  29. if (model == null)
  30. {
  31. return null;
  32. }
  33. return model.Adapt<BuildingInfoDto>();
  34. }
  35. public async Task<bool> Delete(long id)
  36. {
  37. var model = await GetFirstAsync(x => x.Id == id);
  38. if (model == null)
  39. {
  40. throw Oops.Oh("信息不存在");
  41. }
  42. await DeleteAsync(model);
  43. return true;
  44. }
  45. public async Task<List<BuildingInfoDto>> GetNoPageList()
  46. {
  47. var list = await Context.Queryable<BuildingInfo>()
  48. .Includes(x => x.InsCameraInfoItem)
  49. .Includes(x => x.OutCameraInfoItem)
  50. .ToListAsync();
  51. //var list = await GetListAsync();
  52. return list.Adapt<List<BuildingInfoDto>>();
  53. }
  54. }