AdmVirtualWallController.java 4.4 KB

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