Browse Source

查询项目接口 调整

lvxianyun 3 years ago
parent
commit
e65fe27479

+ 16 - 4
src/main/java/com/persagy/proxy/adm/controller/AdmProjectController.java

@@ -1,16 +1,21 @@
 package com.persagy.proxy.adm.controller;
 
+import cn.hutool.core.util.StrUtil;
+import com.persagy.dmp.common.context.AppContext;
 import com.persagy.proxy.adm.model.AdmProject;
 import com.persagy.proxy.adm.request.AdmQueryCriteria;
 import com.persagy.proxy.adm.request.AdmResponse;
 import com.persagy.proxy.adm.service.IAdmProjectService;
-import com.persagy.proxy.adm.utils.AdmContextUtil;
+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;
+
 /**
  * ADM 项目 API
  * @author Charlie Yu
@@ -23,6 +28,9 @@ public class AdmProjectController {
     @Autowired
     private IAdmProjectService service;
 
+    @Value("${middleware.group.code}")
+    private String groupCode;
+
     /**
      * 查询项目信息
      * @param request
@@ -30,9 +38,13 @@ public class AdmProjectController {
      * @throws Exception
      */
     @PostMapping("/query")
-    public AdmResponse query(@RequestBody AdmQueryCriteria request) throws Exception {
+    public AdmResponse query(@QueryParam("projectId") String projectId, @RequestBody AdmQueryCriteria request) throws Exception {
         request.setName(AdmProject.OBJ_TYPE);
-        return service.doQuery(AdmContextUtil.toDmpContext(), request, AdmProject.class);
+        String group = StrUtil.isBlank(AppContext.getContext().getGroupCode()) ? groupCode:AppContext.getContext().getGroupCode();
+        InstanceUrlParam param = InstanceUrlParam.builder().groupCode(group)
+                .projectId(projectId).userId(AppContext.getContext().getAccountId())
+                .appId(AppContext.getContext().getAppId()).build();
+        return service.doQuery(param, request, AdmProject.class);
     }
 
     /**
@@ -43,6 +55,6 @@ public class AdmProjectController {
      */
     @PostMapping("/query/obj")
     public AdmResponse queryObj(@RequestBody AdmQueryCriteria request) throws Exception {
-        return query(request);
+        return query(null, request);
     }
 }