AdmPropertyController.java 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. package com.persagy.proxy.adm.controller;
  2. import cn.hutool.core.collection.CollUtil;
  3. import com.persagy.proxy.adm.model.AdmProperty;
  4. import com.persagy.proxy.adm.request.AdmCreateRequest;
  5. import com.persagy.proxy.adm.request.AdmQueryCriteria;
  6. import com.persagy.proxy.adm.request.AdmResponse;
  7. import com.persagy.proxy.adm.service.IAdmPropertyService;
  8. import com.persagy.proxy.adm.utils.AdmContextUtil;
  9. import org.springframework.beans.factory.annotation.Autowired;
  10. import org.springframework.web.bind.annotation.PostMapping;
  11. import org.springframework.web.bind.annotation.RequestBody;
  12. import org.springframework.web.bind.annotation.RequestMapping;
  13. import org.springframework.web.bind.annotation.RestController;
  14. import javax.ws.rs.QueryParam;
  15. import java.util.List;
  16. /**
  17. * Adm 资产 API
  18. * @author lvxy
  19. * @date 2021/8/16
  20. */
  21. @RestController
  22. @RequestMapping("/object/property")
  23. public class AdmPropertyController {
  24. @Autowired
  25. private IAdmPropertyService service;
  26. /**
  27. * 创建
  28. * @param createRequest
  29. * @return
  30. * @throws Exception
  31. */
  32. @PostMapping("/create")
  33. public AdmResponse create(@RequestBody AdmCreateRequest<AdmProperty> createRequest) throws Exception {
  34. List<AdmProperty> vos = CollUtil.newArrayList(createRequest.getContent());
  35. vos = service.doInsert(AdmContextUtil.toDmpContext(), AdmProperty.class, vos);
  36. return AdmResponse.success(vos);
  37. }
  38. /**
  39. * 根据ID删除
  40. * @param vos
  41. * @return
  42. * @throws Exception
  43. */
  44. @PostMapping("/delete")
  45. public AdmResponse delete( @RequestBody List<AdmProperty> vos) throws Exception {
  46. service.doDelete(AdmContextUtil.toDmpContext(), vos);
  47. return AdmResponse.success();
  48. }
  49. /**
  50. * 更新
  51. * @param createRequest
  52. * @return
  53. * @throws Exception
  54. */
  55. @PostMapping("/update")
  56. public AdmResponse update(@RequestBody AdmCreateRequest<AdmProperty> createRequest, @QueryParam("projectId") String projectId) throws Exception {
  57. List<AdmProperty> vos = CollUtil.newArrayList(createRequest.getContent());
  58. vos = service.doUpdate(AdmContextUtil.toDmpContext(), AdmProperty.class, vos);
  59. return AdmResponse.success(vos);
  60. }
  61. /**
  62. * 查询
  63. *
  64. * @param request
  65. * @return
  66. * @throws Exception
  67. */
  68. @PostMapping("/query")
  69. public AdmResponse query(@RequestBody AdmQueryCriteria request) throws Exception {
  70. request.setName("equipment");
  71. return service.doQuery(AdmContextUtil.toDmpContext(), request, AdmProperty.class);
  72. }
  73. /**
  74. * 统计 已经关联岗位的资产数量("Filters": " not EquipId isNull"),未关联岗位的资产数量("Filters": " EquipId isNull")
  75. *
  76. * @param request
  77. * @return
  78. * @throws Exception
  79. */
  80. @PostMapping("/count")
  81. public AdmResponse count(@RequestBody AdmQueryCriteria request) throws Exception {
  82. request.setName("equipment");
  83. request.setOnlyCount(true);
  84. return service.doQuery(AdmContextUtil.toDmpContext(), request, AdmProperty.class);
  85. }
  86. }