AdmDoorController.java 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. package com.persagy.proxy.adm.controller;
  2. import cn.hutool.core.collection.CollUtil;
  3. import com.persagy.proxy.adm.model.AdmDoor;
  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.IAdmDoorService;
  8. import com.persagy.proxy.adm.utils.AdmContextUtil;
  9. import com.persagy.proxy.common.entity.InstanceUrlParam;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.beans.factory.annotation.Value;
  12. import org.springframework.web.bind.annotation.PostMapping;
  13. import org.springframework.web.bind.annotation.RequestBody;
  14. import org.springframework.web.bind.annotation.RequestMapping;
  15. import org.springframework.web.bind.annotation.RestController;
  16. import java.util.List;
  17. /**
  18. * ADM 门 API
  19. * @author xujiaheng
  20. * @date 2021-09-06
  21. */
  22. @RestController
  23. @RequestMapping("/object/door")
  24. public class AdmDoorController {
  25. @Autowired
  26. private IAdmDoorService service;
  27. @Value("${middleware.group.code}")
  28. private String groupCode;
  29. /**
  30. * 创建
  31. * @param createRequest
  32. * @return
  33. * @throws Exception
  34. */
  35. @PostMapping("/create")
  36. public AdmResponse create(@RequestBody AdmCreateRequest<AdmDoor> createRequest) throws Exception {
  37. // 组装上下文条件
  38. List<AdmDoor> vos = CollUtil.newArrayList(createRequest.getContent());
  39. vos = service.doInsert(AdmContextUtil.toDmpContext(), AdmDoor.class, vos);
  40. return AdmResponse.success(vos);
  41. }
  42. /**
  43. * 创建(主键重复则忽略)
  44. * @param createRequest
  45. * @return
  46. * @throws Exception
  47. */
  48. @PostMapping("/create_ignore")
  49. public AdmResponse createIgnore(@RequestBody AdmCreateRequest<AdmDoor> createRequest) throws Exception {
  50. // 组装上下文条件
  51. InstanceUrlParam context = AdmContextUtil.toDmpContext();
  52. createRequest.getContent().forEach(request->{
  53. //TODO
  54. });
  55. return AdmResponse.success();
  56. }
  57. /**
  58. * 根据ID删除
  59. * @param vos
  60. * @return
  61. * @throws Exception
  62. */
  63. @PostMapping("/delete")
  64. public AdmResponse delete(@RequestBody List<AdmDoor> vos) throws Exception {
  65. // 组装上下文条件
  66. service.doDelete(AdmContextUtil.toDmpContext(), vos);
  67. return AdmResponse.success();
  68. }
  69. /**
  70. * 更新
  71. * @param createRequest
  72. * @return
  73. * @throws Exception
  74. */
  75. @PostMapping("/update")
  76. public AdmResponse update(@RequestBody AdmCreateRequest<AdmDoor> createRequest) throws Exception {
  77. List<AdmDoor> vos = CollUtil.newArrayList(createRequest.getContent());
  78. vos = service.doUpdate(AdmContextUtil.toDmpContext(), AdmDoor.class, vos);
  79. return AdmResponse.success(vos);
  80. }
  81. /**
  82. * 查询
  83. * @param request
  84. * @return
  85. * @throws Exception
  86. */
  87. @PostMapping("/query")
  88. public AdmResponse query(@RequestBody AdmQueryCriteria request) throws Exception {
  89. request.setName("equipment");
  90. request.setFilters("classCode = 'CFBEDR'");
  91. return service.doQuery(AdmContextUtil.toDmpContext(), request, AdmDoor.class);
  92. }
  93. /**
  94. * 统计
  95. * @param request
  96. * @return
  97. * @throws Exception
  98. */
  99. @PostMapping("/count")
  100. public AdmResponse count(@RequestBody AdmQueryCriteria request) throws Exception {
  101. request.setName("equipment");
  102. request.setOnlyCount(true);
  103. return service.doQuery(AdmContextUtil.toDmpContext(), request, AdmDoor.class);
  104. }
  105. }