|
@@ -0,0 +1,129 @@
|
|
|
+package com.persagy.proxy.adm.controller;
|
|
|
+
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
+import com.persagy.proxy.adm.constant.AdmCommonConstant;
|
|
|
+import com.persagy.proxy.adm.model.AdmDoor;
|
|
|
+import com.persagy.proxy.adm.request.AdmCreateRequest;
|
|
|
+import com.persagy.proxy.adm.request.AdmQueryCriteria;
|
|
|
+import com.persagy.proxy.adm.request.AdmResponse;
|
|
|
+import com.persagy.proxy.adm.service.IAdmDoorService;
|
|
|
+import com.persagy.proxy.adm.service.IAdmDoorService;
|
|
|
+import com.persagy.proxy.common.entity.InstanceUrlParam;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import javax.ws.rs.QueryParam;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * ADM 门 API
|
|
|
+ * @author xujiaheng
|
|
|
+ * @date 2021-09-06
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/object/door")
|
|
|
+public class AdmDoorController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IAdmDoorService service;
|
|
|
+ @Value("${middleware.group.code}")
|
|
|
+ private String groupCode;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 创建
|
|
|
+ * @param createRequest
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @PostMapping("/create")
|
|
|
+ public AdmResponse create(@RequestBody AdmCreateRequest<AdmDoor> createRequest, @QueryParam("projectId") String projectId) throws Exception {
|
|
|
+ // 组装上下文条件
|
|
|
+ InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
|
|
|
+ List<AdmDoor> vos = CollUtil.newArrayList(createRequest.getContent());
|
|
|
+ vos = service.doInsert(context, AdmDoor.class, vos);
|
|
|
+ return AdmResponse.success(vos);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 创建(主键重复则忽略)
|
|
|
+ * @param createRequest
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @PostMapping("/create_ignore")
|
|
|
+ public AdmResponse createIgnore(@RequestBody AdmCreateRequest<AdmDoor> createRequest, @QueryParam("projectId") String projectId) throws Exception {
|
|
|
+ // 组装上下文条件
|
|
|
+ InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
|
|
|
+ createRequest.getContent().forEach(request->{
|
|
|
+ //TODO
|
|
|
+ });
|
|
|
+ return AdmResponse.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据ID删除
|
|
|
+ * @param vos
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @PostMapping("/delete")
|
|
|
+ public AdmResponse delete(@RequestBody List<AdmDoor> vos) throws Exception {
|
|
|
+ // 组装上下文条件
|
|
|
+ InstanceUrlParam context = new InstanceUrlParam(groupCode, null, null, AdmCommonConstant.APP_ID);
|
|
|
+ service.doDelete(context, vos);
|
|
|
+ return AdmResponse.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新
|
|
|
+ * @param createRequest
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @PostMapping("/update")
|
|
|
+ public AdmResponse update(@RequestBody AdmCreateRequest<AdmDoor> createRequest, @QueryParam("projectId") String projectId) throws Exception {
|
|
|
+ // 组装上下文条件
|
|
|
+ InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
|
|
|
+ List<AdmDoor> vos = CollUtil.newArrayList(createRequest.getContent());
|
|
|
+ vos = service.doUpdate(context, AdmDoor.class, vos);
|
|
|
+ return AdmResponse.success(vos);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询
|
|
|
+ * @param projectId
|
|
|
+ * @param request
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @PostMapping("/query")
|
|
|
+ public AdmResponse query(@QueryParam("projectId") String projectId,
|
|
|
+ @RequestBody AdmQueryCriteria request) throws Exception {
|
|
|
+ // 组装上下文条件
|
|
|
+ InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
|
|
|
+ request.setName("equipment");
|
|
|
+ request.setFilters("classCode = 'CFBEDR'");
|
|
|
+ return service.doQuery(context, request, AdmDoor.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 统计
|
|
|
+ * @param projectId
|
|
|
+ * @param request
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @PostMapping("/count")
|
|
|
+ public AdmResponse count(@QueryParam("projectId") String projectId,
|
|
|
+ @RequestBody AdmQueryCriteria request) throws Exception {
|
|
|
+ // 组装上下文条件
|
|
|
+ InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
|
|
|
+ request.setName("equipment");
|
|
|
+ request.setOnlyCount(true);
|
|
|
+ return service.doQuery(context, request, AdmDoor.class);
|
|
|
+ }
|
|
|
+}
|