wujiefeng пре 1 година
родитељ
комит
fe6ddb94bf

+ 29 - 17
FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/openAPI/OpenApiConfigManagerController.java

@@ -3,9 +3,13 @@ package com.zhongshu.card.server.core.controller.openAPI;
 import com.github.microservice.auth.client.constant.AuthConstant;
 import com.github.microservice.auth.security.annotations.ResourceAuth;
 import com.github.microservice.auth.security.type.AuthType;
+import com.zhongshu.card.server.core.service.openAPI.OpenApiConfigManagerService;
+import com.zhongshu.card.server.core.service.openAPI.OpenAppManagerService;
 import com.zhongshu.opengateway.client.model.OpenApiConfigModel;
+import com.zhongshu.opengateway.client.model.SignModel;
 import com.zhongshu.opengateway.client.model.param.AddApiParam;
 import com.zhongshu.opengateway.client.model.param.LimitParam;
+import com.zhongshu.opengateway.client.model.param.OpenApiSearchParam;
 import com.zhongshu.opengateway.client.model.ret.ResultContent;
 import com.zhongshu.opengateway.client.service.OpenApiConfigService;
 import io.swagger.v3.oas.annotations.Operation;
@@ -26,14 +30,24 @@ import java.util.List;
 public class OpenApiConfigManagerController {
 
     @Autowired
-    OpenApiConfigService openApiConfigService;
+    OpenApiConfigManagerService openApiConfigManagerService;
+
+//    /** 自定义条件分页查询所有openApi列表 */
+//    @Operation(summary = "分页查询所有openApi列表", description = "分页查询所有openApi列表")
+////    @ResourceAuth(value = AuthConstant.SuperAdmin, type = AuthType.Platform, remark = "")
+////    @ResourceAuth(value = AuthConstant.Admin, type = AuthType.Project, remark = "")
+//    @RequestMapping(value = "page", method = RequestMethod.POST, consumes = {MediaType.ALL_VALUE})
+//    public ResultContent pageByMql(String appId,
+//                                   @PageableDefault(sort = "createTime", direction = Sort.Direction.DESC) Pageable pageable){
+//        return openApiConfigManagerService.pageAll(appId, pageable);
+//    }
 
     @Operation(summary = "添加应用", description = "添加应用")
     @ResourceAuth(value = AuthConstant.SuperAdmin, type = AuthType.Platform, remark = "")
     @ResourceAuth(value = "openapi", type = AuthType.Project, remark = "")
     @RequestMapping(value = "quoteOpenApi", method = RequestMethod.POST, consumes = {MediaType.ALL_VALUE})
     public ResultContent quoteOpenApi(@RequestBody AddApiParam param){
-        return openApiConfigService.quoteOpenApi(param);
+        return openApiConfigManagerService.quoteOpenApi(param);
     }
 
 
@@ -41,18 +55,16 @@ public class OpenApiConfigManagerController {
     @ResourceAuth(value = AuthConstant.SuperAdmin, type = AuthType.Platform, remark = "")
     @ResourceAuth(value = "openapi", type = AuthType.Project, remark = "")
     @RequestMapping(value = "pageByApp", method = RequestMethod.POST, consumes = {MediaType.ALL_VALUE})
-    public ResultContent pageByApp(String appId, @PageableDefault(sort = "createTime", direction = Sort.Direction.DESC) Pageable pageable){
-
-        ResultContent<List<OpenApiConfigModel>> listRet = openApiConfigService.listByAppId(appId);
-        if (listRet.isFailed()){
-            return listRet;
-        }
-        List<OpenApiConfigModel> openApiConfigModelList = listRet.getContent();
-        Object[] openApiPathList = openApiConfigModelList.stream().map(it -> {
-            return it.getOpenApiModel().getPath();
-        }).toArray();
+    public ResultContent pageByApp(@RequestBody OpenApiSearchParam param){
+        return openApiConfigManagerService.pageByApp(param);
+    }
 
-       return openApiConfigService.pageByMql("{\"isDelete\": false, \"appId \" : \""+appId + "\", \"openApi.path\" : { $in: [\""+ StringUtils.join(openApiPathList, "\",\"") + "\"]}}", pageable);
+    @Operation(summary = "分页查询App添加列表", description = "分页查询App下openApi")
+    @ResourceAuth(value = AuthConstant.SuperAdmin, type = AuthType.Platform, remark = "")
+    @ResourceAuth(value = "openapi", type = AuthType.Project, remark = "")
+    @RequestMapping(value = "pageAddList", method = RequestMethod.POST, consumes = {MediaType.ALL_VALUE})
+    public ResultContent pageAddList(@RequestBody OpenApiSearchParam param){
+        return openApiConfigManagerService.pageAddList(param);
     }
 
     @Operation(summary = "禁用/启用", description = "禁用/启用")
@@ -60,7 +72,7 @@ public class OpenApiConfigManagerController {
     @ResourceAuth(value = "openapi", type = AuthType.Project, remark = "")
     @RequestMapping(value = "disable", method = RequestMethod.POST, consumes = {MediaType.ALL_VALUE})
     public ResultContent disable(String id){
-        return openApiConfigService.disable(id);
+        return openApiConfigManagerService.disable(id);
     }
 
     @Operation(summary = "删除", description = "删除")
@@ -68,7 +80,7 @@ public class OpenApiConfigManagerController {
     @ResourceAuth(value = "openapi", type = AuthType.Project, remark = "")
     @RequestMapping(value = "delete", method = RequestMethod.POST, consumes = {MediaType.ALL_VALUE})
     public ResultContent delete(String id){
-        return openApiConfigService.delete(id);
+        return openApiConfigManagerService.delete(id);
     }
 
     @Operation(summary = " 获取openApi详情", description = " 获取openApi详情")
@@ -76,7 +88,7 @@ public class OpenApiConfigManagerController {
     @ResourceAuth(value = "openapi", type = AuthType.Project, remark = "")
     @RequestMapping(value = "get", method = RequestMethod.POST, consumes = {MediaType.ALL_VALUE})
     public ResultContent get(String id){
-        return openApiConfigService.get(id);
+        return openApiConfigManagerService.get(id);
     }
 
     @Operation(summary = "设置限流规则", description = "设置限流规则")
@@ -84,6 +96,6 @@ public class OpenApiConfigManagerController {
     @ResourceAuth(value = "openapi", type = AuthType.Project, remark = "")
     @RequestMapping(value = "setLimit", method = RequestMethod.POST, consumes = {MediaType.ALL_VALUE})
     public ResultContent setLimit(@RequestBody LimitParam limitParam){
-        return openApiConfigService.setLimit(limitParam);
+        return openApiConfigManagerService.setLimit(limitParam);
     }
 }

+ 1 - 16
FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/openAPI/OpenApiManagerController.java

@@ -34,22 +34,7 @@ public class OpenApiManagerController {
     @Autowired
     SignService signService;
 
-    /** 自定义条件分页查询openApi列表 */
-    @Operation(summary = "分页查询所有openApi列表", description = "添加应用")
-    @ResourceAuth(value = AuthConstant.SuperAdmin, type = AuthType.Platform, remark = "")
-    @ResourceAuth(value = AuthConstant.Admin, type = AuthType.Project, remark = "")
-    @RequestMapping(value = "page", method = RequestMethod.POST, consumes = {MediaType.ALL_VALUE})
-    public ResultContent pageByMql(String appId,
-                                                @PageableDefault(sort = "createTime", direction = Sort.Direction.DESC) Pageable pageable){
-        ResultContent<SignModel> signModelResultContent = signService.get(appId);
-        if (signModelResultContent.isFailed()){
-            return signModelResultContent;
-        }
-        SignModel signModel = signModelResultContent.getContent();
-        Object[] array = signModel.getAppType().getApiType().stream().map(Enum::name).toArray();
-        String mql = "\"apiType\" : {$in :["+ StringUtils.join(array, "\",\"")+"], \"isDelete\" : false}";
-        return openApiService.pageByMql(mql, pageable);
-    }
+
 
 
 

+ 17 - 19
FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/openAPI/OpenAppManagerController.java

@@ -10,6 +10,7 @@ import com.zhongshu.opengateway.client.type.AppState;
 import com.zhongshu.opengateway.client.type.AppType;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.Parameters;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Pageable;
@@ -29,28 +30,24 @@ public class OpenAppManagerController {
 
     @Operation(summary = "添加应用", description = "添加应用")
     @RequestMapping(value = "add", method = {RequestMethod.POST})
-    @ResourceAuth(value = AuthConstant.SuperAdmin, type = AuthType.Platform, remark = "")
-    @ResourceAuth(value = AuthConstant.Admin, type = AuthType.Project, remark = "")
+//    @ResourceAuth(value = AuthConstant.SuperAdmin, type = AuthType.Platform, remark = "")
+//    @ResourceAuth(value = AuthConstant.Admin, type = AuthType.Project, remark = "")
     public Object add(@RequestBody SignParam param){
         return openAppManagerService.add(param);
     }
 
-    /**
-     * 删除应用
-     */
+    @Operation(summary = "删除应用", description = "删除应用")
     @RequestMapping(value = "delete", method = {RequestMethod.POST})
-    @ResourceAuth(value = AuthConstant.SuperAdmin, type = AuthType.Platform, remark = "")
-    @ResourceAuth(value = AuthConstant.Admin, type = AuthType.Project, remark = "")
+//    @ResourceAuth(value = AuthConstant.SuperAdmin, type = AuthType.Platform, remark = "")
+//    @ResourceAuth(value = AuthConstant.Admin, type = AuthType.Project, remark = "")
     public Object delete(String appId){
         return openAppManagerService.delete(appId);
     }
 
 
-    /**
-     * 禁用/启用
-     */
-    @ResourceAuth(value = AuthConstant.SuperAdmin, type = AuthType.Platform, remark = "")
-    @ResourceAuth(value = AuthConstant.Admin, type = AuthType.Project, remark = "")
+    @Operation(summary = "禁用/启用", description = "禁用/启用")
+//    @ResourceAuth(value = AuthConstant.SuperAdmin, type = AuthType.Platform, remark = "")
+//    @ResourceAuth(value = AuthConstant.Admin, type = AuthType.Project, remark = "")
     @RequestMapping(value = "disable", method = {RequestMethod.POST})
     public Object disable(String appId, AppState appState){
         return openAppManagerService.disable(appId, appState);
@@ -59,14 +56,15 @@ public class OpenAppManagerController {
     /**
      * 分页获取该项目下的app列表
      */
-    @ResourceAuth(value = AuthConstant.SuperAdmin, type = AuthType.Platform, remark = "")
-    @ResourceAuth(value = AuthConstant.Admin, type = AuthType.Project, remark = "")
+    @Operation(summary = "分页获取该项目下的app列表", description = "分页获取该项目下的app列表")
+//    @ResourceAuth(value = AuthConstant.SuperAdmin, type = AuthType.Platform, remark = "")
+//    @ResourceAuth(value = AuthConstant.Admin, type = AuthType.Project, remark = "")
     @RequestMapping(value = "page", method = {RequestMethod.POST})
-    public Object page(@Parameter(description = "业务id", required = true) String businessId,
-                       @Parameter(description = "应用类型",required = false) AppType appType,
-                       @Parameter(description = "应用状态") AppState appState,
-                       @Parameter(description = "应用名称") String appName,
-                       @Parameter(hidden = true)@PageableDefault(page = 0, size = 10) Pageable pageable){
+    public Object page(@Parameter(name = "businessId", description = "项目id") @RequestParam(name = "businessId")String businessId,
+                       @Parameter(name = "appType", description = "应用类型") @RequestParam(name = "appType", required = false)AppType appType,
+                       @Parameter(name = "appState", description = "应用状态") @RequestParam(name = "appState", required = false)AppState appState,
+                       @Parameter(name = "appName", description = "应用名称") @RequestParam(name = "appName", required = false)String appName,
+                       @Parameter(hidden = true) @PageableDefault(page = 0, size = 10) Pageable pageable){
         return openAppManagerService.page(businessId, appType, appState, appName, pageable);
     }
 }

+ 1 - 1
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/openAPI/OpenAPIRegisterService.java

@@ -39,7 +39,7 @@ public class OpenAPIRegisterService {
         param.setOpenApiInfo(openAPIS);
         param.setApiType(ApiType.FullCard.name());
 
-        ResultContent content = restTemplate.postForObject("http://openapiserver-wjf/manager/apiManager/refresh", param, ResultContent.class);
+        ResultContent content = restTemplate.postForObject("http://openapiserver-wjf/manager/gateway/api/refresh", param, ResultContent.class);
         if (content == null) {
             content = ResultContent.buildSuccess();
         }

+ 65 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/openAPI/OpenApiConfigManagerService.java

@@ -0,0 +1,65 @@
+package com.zhongshu.card.server.core.service.openAPI;
+
+import com.zhongshu.opengateway.client.model.OpenApiConfigModel;
+import com.zhongshu.opengateway.client.model.SignModel;
+import com.zhongshu.opengateway.client.model.param.AddApiParam;
+import com.zhongshu.opengateway.client.model.param.LimitParam;
+import com.zhongshu.opengateway.client.model.param.OpenApiSearchParam;
+import com.zhongshu.opengateway.client.model.ret.ResultContent;
+import com.zhongshu.opengateway.client.service.OpenApiConfigService;
+import com.zhongshu.opengateway.client.service.OpenApiService;
+import com.zhongshu.opengateway.client.service.SignService;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.web.PageableDefault;
+import org.springframework.stereotype.Service;
+import org.springframework.web.bind.annotation.RequestBody;
+
+import java.util.List;
+
+@Slf4j
+@Service
+public class OpenApiConfigManagerService {
+
+    @Autowired
+    OpenApiService openApiService;
+
+    @Autowired
+    SignService signService;
+
+    @Autowired
+    OpenApiConfigService openApiConfigService;
+
+    public ResultContent quoteOpenApi(AddApiParam param){
+        return openApiConfigService.quoteOpenApi(param);
+    }
+
+
+    public ResultContent pageByApp(OpenApiSearchParam param){
+
+        return openApiConfigService.pageByAppId(param);
+    }
+
+    public ResultContent pageAddList(OpenApiSearchParam param){
+        return openApiService.pageAddList(param);
+    }
+
+    public ResultContent disable(String id){
+        return openApiConfigService.disable(id);
+    }
+
+    public ResultContent delete(String id){
+        return openApiConfigService.delete(id);
+    }
+
+    public ResultContent get(String id){
+        return openApiConfigService.get(id);
+    }
+
+    public ResultContent setLimit(@RequestBody LimitParam limitParam){
+        return openApiConfigService.setLimit(limitParam);
+    }
+}

+ 3 - 2
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/openAPI/OpenAppManagerService.java

@@ -1,8 +1,9 @@
 package com.zhongshu.card.server.core.service.openAPI;
 
 import com.github.microservice.auth.security.helper.AuthHelper;
-import com.github.microservice.net.ResultContent;
+import com.zhongshu.opengateway.client.model.SignModel;
 import com.zhongshu.opengateway.client.model.param.SignParam;
+import com.zhongshu.opengateway.client.model.ret.ResultContent;
 import com.zhongshu.opengateway.client.service.OpenApiService;
 import com.zhongshu.opengateway.client.service.SignService;
 import com.zhongshu.opengateway.client.type.AppState;
@@ -54,6 +55,6 @@ public class OpenAppManagerService {
      * 分页获取该项目下的app列表
      */
     public Object page(String businessId, AppType appType, AppState appState, String appName, Pageable pageable) {
-        return signService.pageByBusinessId(businessId, appType, appState, appName, pageable);
+        return signService.pageByBusinessId(businessId, appType, appState, appName, pageable.getPageNumber(), pageable.getPageSize());
     }
 }