AdmWindowController.java 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. package com.persagy.proxy.object.controller;
  2. import cn.hutool.core.collection.CollUtil;
  3. import com.persagy.proxy.adm.request.AdmCreateRequest;
  4. import com.persagy.proxy.adm.request.AdmCreateResponse;
  5. import com.persagy.proxy.adm.request.AdmQueryCriteria;
  6. import com.persagy.proxy.adm.request.AdmResponse;
  7. import com.persagy.proxy.adm.utils.AdmContextUtil;
  8. import com.persagy.proxy.common.entity.InstanceUrlParam;
  9. import com.persagy.proxy.object.model.AdmWindow;
  10. import com.persagy.proxy.object.service.IAdmWindowService;
  11. import org.springframework.beans.factory.annotation.Autowired;
  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 javax.ws.rs.QueryParam;
  17. import java.util.List;
  18. /**
  19. * ADM 窗户 API
  20. * @author xujiaheng
  21. * @date 2021-09-3
  22. */
  23. @RestController
  24. @RequestMapping("/object/window")
  25. public class AdmWindowController {
  26. @Autowired
  27. private IAdmWindowService service;
  28. /**
  29. * 创建
  30. * @param createRequest
  31. * @return
  32. * @throws Exception
  33. */
  34. @PostMapping("/create")
  35. public AdmCreateResponse create(@RequestBody AdmCreateRequest<AdmWindow> createRequest, @QueryParam("projectId") String projectId) throws Exception {
  36. // 组装上下文条件
  37. InstanceUrlParam context = AdmContextUtil.toDmpContext();
  38. List<AdmWindow> vos = CollUtil.newArrayList(createRequest.getContent());
  39. vos = service.doInsert(context, AdmWindow.class, vos);
  40. return AdmCreateResponse.success(vos);
  41. }
  42. /**
  43. * 创建(主键重复则忽略)
  44. * @param createRequest
  45. * @return
  46. * @throws Exception
  47. */
  48. @PostMapping("/create_ignore")
  49. public AdmResponse createIgnore(@RequestBody AdmCreateRequest<AdmWindow> createRequest, @QueryParam("projectId") String projectId) 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<AdmWindow> vos) throws Exception {
  65. service.doDelete(AdmContextUtil.toDmpContext(), vos);
  66. return AdmResponse.success();
  67. }
  68. /**
  69. * 更新
  70. * @param createRequest
  71. * @return
  72. * @throws Exception
  73. */
  74. @PostMapping("/update")
  75. public AdmResponse update(@RequestBody AdmCreateRequest<AdmWindow> createRequest, @QueryParam("projectId") String projectId) throws Exception {
  76. // 组装上下文条件
  77. InstanceUrlParam context = AdmContextUtil.toDmpContext();
  78. List<AdmWindow> vos = CollUtil.newArrayList(createRequest.getContent());
  79. vos = service.doUpdate(context, AdmWindow.class, vos);
  80. return AdmResponse.success(vos);
  81. }
  82. /**
  83. * 查询
  84. * @param projectId
  85. * @param request
  86. * @return
  87. * @throws Exception
  88. */
  89. @PostMapping("/query")
  90. public AdmResponse query(@QueryParam("projectId") String projectId,
  91. @RequestBody AdmQueryCriteria request) throws Exception {
  92. // 组装上下文条件
  93. InstanceUrlParam context = AdmContextUtil.toDmpContext();
  94. request.setName("equipment");
  95. request.setFilters("classCode = 'CFBEWN'");
  96. return service.doQuery(context, request, AdmWindow.class);
  97. }
  98. /**
  99. * 统计
  100. * @param projectId
  101. * @param request
  102. * @return
  103. * @throws Exception
  104. */
  105. @PostMapping("/count")
  106. public AdmResponse count(@QueryParam("projectId") String projectId,
  107. @RequestBody AdmQueryCriteria request) throws Exception {
  108. // 组装上下文条件
  109. InstanceUrlParam context = AdmContextUtil.toDmpContext();
  110. request.setName("equipment");
  111. request.setOnlyCount(true);
  112. return service.doQuery(context, request, AdmWindow.class);
  113. }
  114. }