TRX hai 1 ano
pai
achega
0eebfd8a68

+ 3 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/model/org/AuthModel.java

@@ -9,6 +9,9 @@ import java.io.Serializable;
 @Data
 public class AuthModel implements Serializable {
 
+    @Schema(description = "数据ID")
+    private String id;
+
     @Schema(description = "大分组名称,如:角色管理")
     private String modularName;
 

+ 2 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/model/org/ModularModel.java

@@ -9,6 +9,8 @@ import java.util.List;
 @Data
 public class ModularModel implements Serializable {
 
+    private String id;
+
     @Schema(description = "分组名称,如:角色管理")
     private String name;
 

+ 54 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/openAPI/ProjectOpenAPIController.java

@@ -0,0 +1,54 @@
+package com.zhongshu.card.server.core.controller.openAPI;
+
+import com.github.microservice.auth.security.annotations.ResourceAuth;
+import com.github.microservice.auth.security.type.AuthType;
+import com.github.microservice.net.ResultContent;
+import com.zhongshu.card.client.model.base.IDParam;
+import com.zhongshu.card.client.model.project.ProjectSaveParam;
+import com.zhongshu.card.client.model.school.BookInfoAddParam;
+import com.zhongshu.card.client.model.school.BookInfoModel;
+import com.zhongshu.card.client.model.school.BookInfoSearch;
+import com.zhongshu.card.client.service.school.BookInfoService;
+import com.zhongshu.card.client.service.school.NoticeInfoService;
+import com.zhongshu.card.client.type.OrganizationUserType;
+import com.zhongshu.card.server.core.service.user.RoleServiceImpl;
+import io.swagger.v3.oas.annotations.Hidden;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.web.PageableDefault;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.validation.Valid;
+
+/**
+ * @author TRX
+ * @date 2024/6/5
+ */
+@RestController
+@RequestMapping("/v1/openAPI/projectManager")
+@Tag(name = "openAPI-项目管理")
+public class ProjectOpenAPIController {
+
+    @Autowired
+    BookInfoService bookInfoService;
+
+    @Operation(summary = "项目添加", description = "项目添加")
+    @RequestMapping(value = "addTeacher", method = {RequestMethod.POST})
+    public ResultContent<BookInfoModel> addTeacher(@RequestBody BookInfoAddParam param) {
+        return ResultContent.buildSuccess();
+    }
+
+    @Operation(summary = "项目保存", description = "项目保存")
+    @RequestMapping(value = "saveProjectInfo", method = {RequestMethod.POST})
+    public ResultContent saveProjectInfo(@RequestBody @Valid ProjectSaveParam param) {
+        return ResultContent.buildSuccess();
+    }
+
+}

+ 5 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/org/TestController.java

@@ -2,6 +2,7 @@ package com.zhongshu.card.server.core.controller.org;
 
 import com.github.microservice.net.ResultContent;
 import com.zhongshu.card.server.core.service.TestService;
+import com.zhongshu.card.server.core.service.openAPI.OpenAPIRegisterService;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -17,9 +18,13 @@ public class TestController {
     @Autowired
     private TestService testService;
 
+    @Autowired
+    OpenAPIRegisterService openAPIRegisterService;
+
     @Operation(summary = "测试接口", description = "测试接口")
     @RequestMapping(value = "text", method = {RequestMethod.GET})
     public ResultContent text() {
+        openAPIRegisterService.initRegisterPAIS();
         return this.testService.text();
     }
 

+ 37 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/init/OpenApiInit.java

@@ -0,0 +1,37 @@
+package com.zhongshu.card.server.core.init;
+
+import com.zhongshu.card.client.service.org.OrganizationService;
+import com.zhongshu.card.server.core.service.openAPI.OpenAPIRegisterService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.CommandLineRunner;
+import org.springframework.stereotype.Component;
+
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * 平台用户的初始化
+ *
+ * @author TRX
+ * @date 2024/6/3
+ */
+@Component
+@Slf4j
+public class OpenApiInit implements CommandLineRunner {
+
+    @Autowired
+    OpenAPIRegisterService openAPIRegisterService;
+
+    @Override
+    public void run(String... args) throws Exception {
+        CompletableFuture.runAsync(() -> {
+            try {
+                TimeUnit.SECONDS.sleep(30);
+                openAPIRegisterService.initRegisterPAIS();
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        });
+    }
+}

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

@@ -0,0 +1,44 @@
+package com.zhongshu.card.server.core.service.openAPI;
+
+import cn.hutool.json.JSONObject;
+import com.github.microservice.net.ResultContent;
+import com.github.microservice.utils.OpenAPIScan;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.ObjectUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+import org.springframework.web.client.RestTemplate;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 注册平台所有的API
+ *
+ * @author TRX
+ * @date 2024/9/29
+ */
+@Slf4j
+@Service
+public class OpenAPIRegisterService {
+
+    @Autowired
+    private RestTemplate restTemplate;
+
+    @Value("${spring.application.name}")
+    private String serviceId;
+
+    public ResultContent initRegisterPAIS() {
+        String str = restTemplate.getForObject("http://" + serviceId + "/v3/api-docs", String.class);
+        List<JSONObject> openAPIS = OpenAPIScan.scanAPI(str);
+        ResultContent content = restTemplate.postForObject("http://opengateway/v3/api-docs", openAPIS, ResultContent.class);
+        if (content.isFailed()) {
+            log.info("openApi注册错误: {}", content.getMsg());
+        } else {
+            log.info("openApi注册成功");
+        }
+        return ResultContent.buildSuccess();
+    }
+
+}

+ 3 - 5
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/user/RoleServiceImpl.java

@@ -303,11 +303,7 @@ public class RoleServiceImpl extends SuperService {
         List<AuthModel> authModels = new ArrayList<>();
 
         if (organizationType != null) {
-//            com.github.microservice.auth.client.content.ResultContent<Page<AuthResourcesNameModel>> content =  authResourcesNameService.list(organizationType, PageRequest.of(0, 200, Sort.by(Sort.Order.desc(
-//                    "createTime"))));
-//            authResourcesNameModels = content.getContent().getContent();
-
-            com.github.microservice.auth.client.content.ResultContent<List<AuthResourcesNameModel>> content =  authResourcesNameService.getAll(organizationType);
+            com.github.microservice.auth.client.content.ResultContent<List<AuthResourcesNameModel>> content = authResourcesNameService.getAll(organizationType);
             authResourcesNameModels = content.getContent();
 
             authResourcesNameModels.forEach(it -> {
@@ -316,6 +312,7 @@ public class RoleServiceImpl extends SuperService {
                     String[] split = remark.split("_");
                     if (split.length >= 2) {
                         AuthModel authModel = new AuthModel();
+                        authModel.setId(CommonUtil.UUID());
                         authModel.setValue(it.getName());
                         authModel.setName(split[1]);
                         authModel.setModularName(split[0]);
@@ -350,6 +347,7 @@ public class RoleServiceImpl extends SuperService {
         List<ModularModel> modularModels = new ArrayList<>();
         maps.forEach((key, val) -> {
             ModularModel modularModel = new ModularModel();
+            modularModel.setId(CommonUtil.UUID());
             modularModel.setName(key);
             // 排序
             if (ObjectUtils.isNotEmpty(val)) {