Browse Source

deal 项目信息点按照需求过滤所需字段 Constructor -> contractor 兼容前端js

lvxianyun 2 years ago
parent
commit
5de5c458cb

+ 2 - 2
adm-business/adm-middleware/src/main/java/com/persagy/proxy/object/controller/AdmProjectController.java

@@ -34,7 +34,7 @@ public class AdmProjectController {
     public AdmResponse query(@RequestParam(value = "projectId",required = false) String projectId,
                              @RequestBody AdmQueryCriteria request) throws Exception {
         request.setName(AdmProject.OBJ_TYPE);
-        return service.doQuery(AdmContextUtil.toDmpContext(), request, AdmProject.class);
+        return service.doQuery(AdmContextUtil.toDmpContext(), request);
     }
 
     /**
@@ -58,7 +58,7 @@ public class AdmProjectController {
     @PostMapping("/update")
     public AdmResponse update(@RequestBody AdmCreateRequest<AdmProject> createRequest) throws Exception {
         List<AdmProject> vos = CollUtil.newArrayList(createRequest.getContent());
-        vos = service.doUpdate(AdmContextUtil.toDmpContext(), AdmProject.class, vos);
+        vos = service.doUpdate(AdmContextUtil.toDmpContext(), vos);
         return AdmResponse.success(vos);
     }
 }

+ 22 - 1
adm-business/adm-middleware/src/main/java/com/persagy/proxy/object/service/IAdmProjectService.java

@@ -1,7 +1,13 @@
 package com.persagy.proxy.object.service;
 
+import com.persagy.proxy.adm.request.AdmQueryCriteria;
+import com.persagy.proxy.adm.request.AdmResponse;
 import com.persagy.proxy.adm.service.IAdmBaseService;
+import com.persagy.proxy.common.entity.InstanceUrlParam;
 import com.persagy.proxy.object.model.AdmProject;
+import org.apache.poi.ss.formula.functions.T;
+
+import java.util.List;
 
 /**
  * ADM 项目 接口类
@@ -9,5 +15,20 @@ import com.persagy.proxy.object.model.AdmProject;
  * @date 2021-08-16
  */
 public interface IAdmProjectService extends IAdmBaseService<AdmProject> {
-
+    /**
+     * 查询
+     * @param context
+     * @param request
+     * @return
+     */
+    AdmResponse doQuery(InstanceUrlParam context, AdmQueryCriteria request);
+    /**
+     * 修改
+     * @param context
+     * @param voList
+     * @return
+     */
+    List<AdmProject> doUpdate(InstanceUrlParam context, List<AdmProject> voList);
+    List<AdmProject> processDataEdit(List<AdmProject> vos);
+    List<AdmProject> processDataQuery(List<AdmProject> vos);
 }

+ 61 - 0
adm-business/adm-middleware/src/main/java/com/persagy/proxy/object/service/impl/AdmProjectServiceImpl.java

@@ -1,10 +1,16 @@
 package com.persagy.proxy.object.service.impl;
 
+import cn.hutool.core.collection.CollUtil;
+import com.persagy.proxy.adm.request.AdmQueryCriteria;
+import com.persagy.proxy.adm.request.AdmResponse;
 import com.persagy.proxy.adm.service.impl.AbstractAdmBaseServiceImpl;
+import com.persagy.proxy.common.entity.InstanceUrlParam;
 import com.persagy.proxy.object.model.AdmProject;
 import com.persagy.proxy.object.service.IAdmProjectService;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * ADM 项目 实现类
  * @author Charlie Yu
@@ -13,4 +19,59 @@ import org.springframework.stereotype.Service;
 @Service
 public class AdmProjectServiceImpl extends AbstractAdmBaseServiceImpl<AdmProject> implements IAdmProjectService {
 
+    /**
+     * 查询
+     *
+     * @param context
+     * @param request
+     * @return
+     */
+    @Override
+    public AdmResponse doQuery(InstanceUrlParam context, AdmQueryCriteria request) {
+        AdmResponse response = super.doQuery(context,request,AdmProject.class);
+        List<AdmProject> vos = (List<AdmProject>) response.getContent();
+        response.setContent(processDataQuery(vos));
+        return response;
+    }
+
+    /**
+     * 修改
+     *
+     * @param context
+     * @param voList
+     * @return
+     */
+    @Override
+    public List<AdmProject> doUpdate(InstanceUrlParam context, List<AdmProject> voList) {
+        List<AdmProject> admProjects = super.doUpdate(context, AdmProject.class, processDataEdit(voList));
+        return processDataQuery(admProjects);
+    }
+
+    @Override
+    public List<AdmProject> processDataEdit(List<AdmProject> vos) {
+        for(AdmProject admProject : vos){
+            if(CollUtil.isEmpty(admProject.getInfos())){
+                continue;
+            }
+            if(admProject.getInfos().containsKey("contractor")){
+                admProject.getInfos().put("constructor",admProject.getInfos().get("contractor"));
+                admProject.getInfos().remove("contractor");
+            }
+        }
+        return vos;
+    }
+
+    @Override
+    public List<AdmProject> processDataQuery(List<AdmProject> vos) {
+        for(AdmProject admProject : vos){
+            if(CollUtil.isEmpty(admProject.getInfos())){
+                continue;
+            }
+            if(admProject.getInfos().containsKey("constructor")){
+                admProject.getInfos().put("contractor",admProject.getInfos().get("constructor"));
+                admProject.getInfos().remove("constructor");
+            }
+        }
+        return vos;
+    }
 }