Prechádzať zdrojové kódy

升级springboot和springcloud
去掉冗余代码

lianshufeng 1 rok pred
rodič
commit
7d243c2efc

+ 0 - 1
centers/AuthCenter/AuthClient/pom.xml

@@ -54,7 +54,6 @@
         <dependency>
             <groupId>com.github.ben-manes.caffeine</groupId>
             <artifactId>caffeine</artifactId>
-            <version>${caffeine.version}</version>
         </dependency>
 
 

+ 0 - 1
centers/AuthCenter/AuthServer/src/main/java/com/github/microservice/auth/server/AuthServerApplication.java

@@ -2,7 +2,6 @@ package com.github.microservice.auth.server;
 
 import com.github.microservice.app.annotation.EnableApplicationClient;
 import com.github.microservice.core.boot.ApplicationBootSuper;
-import com.github.microservice.core.util.scan.ClassScanner;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.context.annotation.ComponentScan;

+ 2 - 2
centers/AuthCenter/AuthServer/src/main/java/com/github/microservice/auth/server/core/init/InitCompose.java

@@ -7,6 +7,7 @@ import com.github.microservice.auth.client.service.UserService;
 import com.github.microservice.auth.server.core.conf.InitConf;
 import com.github.microservice.auth.server.core.service.ApplicationClientService;
 import com.github.microservice.auth.server.core.service.local.OrganizationServiceImpl;
+import jakarta.transaction.Transactional;
 import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
@@ -14,7 +15,6 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.ApplicationArguments;
 import org.springframework.boot.ApplicationRunner;
 import org.springframework.stereotype.Component;
-import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.StringUtils;
 
 import java.util.*;
@@ -183,6 +183,6 @@ public class InitCompose implements ApplicationRunner {
     @Override
     public void run(ApplicationArguments args) throws Exception {
         initApplicationClient();
-//        me.makeOrganization();
+        me.makeOrganization();
     }
 }

+ 14 - 4
components/ApplicationClient/pom.xml

@@ -73,7 +73,6 @@
         <dependency>
             <groupId>org.springframework.integration</groupId>
             <artifactId>spring-integration-core</artifactId>
-            <version>${spring-integration-core.version}</version>
         </dependency>
 
 
@@ -141,24 +140,35 @@
         <!--management.endpoints.web.exposure.include=bus-refresh-->
         <!--刷新 POST /actuator/bus-refresh -->
         <!--bus-->
+<!--        <dependency>-->
+<!--            <groupId>org.springframework.cloud</groupId>-->
+<!--            <artifactId>spring-cloud-bus</artifactId>-->
+<!--            <version>${spring-cloud-bus.version}</version>-->
+<!--        </dependency>-->
+
         <dependency>
             <groupId>org.springframework.cloud</groupId>
             <artifactId>spring-cloud-bus</artifactId>
-            <version>${spring-cloud-bus.version}</version>
         </dependency>
 
         <!-- kafka-->
+<!--        <dependency>-->
+<!--            <groupId>org.springframework.cloud</groupId>-->
+<!--            <artifactId>spring-cloud-starter-bus-kafka</artifactId>-->
+<!--            <version>${spring-cloud-bus.version}</version>-->
+<!--        </dependency>-->
+
         <dependency>
             <groupId>org.springframework.cloud</groupId>
             <artifactId>spring-cloud-starter-bus-kafka</artifactId>
-            <version>${spring-cloud-bus.version}</version>
         </dependency>
 
+
+
         <!-- stream -->
         <dependency>
             <groupId>org.springframework.cloud</groupId>
             <artifactId>spring-cloud-starter-stream-kafka</artifactId>
-            <version>${spring-cloud-starter-stream.version}</version>
         </dependency>
 
         <dependency>

+ 3 - 3
components/ApplicationClient/src/test/java/feign/server/controller/UserController.groovy

@@ -12,9 +12,9 @@ import org.springframework.web.bind.annotation.RestController
 @RequestMapping("user")
 class UserController {
 
-    @Autowired
-    @Delegate(methodAnnotations = true, parameterAnnotations = true, includeTypes = UserService.class, interfaces = false)
-    private RemoteUserService userService;
+//    @Autowired
+//    @Delegate(methodAnnotations = true, parameterAnnotations = true, includeTypes = UserService.class, interfaces = false)
+//    private RemoteUserService userService;
 
 
 

+ 0 - 1
pom.xml

@@ -35,7 +35,6 @@
 
 
 
-
     </modules>
 
 

+ 21 - 28
super/MSConfigure/pom.xml

@@ -9,7 +9,7 @@
     <parent>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-dependencies</artifactId>
-        <version>3.3.0</version>
+        <version>3.3.4</version>
         <relativePath/>
     </parent>
 
@@ -29,35 +29,28 @@
         <java.version>17</java.version>
 
         <!-- spring boot  -->
-        <spring-boot.version>3.3.0</spring-boot.version>
+        <spring-boot.version>3.3.4</spring-boot.version>
         <!-- spring mvc -->
-        <spring-mvc.version>6.1.8</spring-mvc.version>
-        <spring-integration-core.version>6.3.0</spring-integration-core.version>
+        <spring-mvc.version>6.1.13</spring-mvc.version>
+<!--        <spring-integration-core.version>6.3.4</spring-integration-core.version>-->
 
         <!-- spring cloud -->
-        <spring-cloud-dependencies.version>2023.0.1</spring-cloud-dependencies.version>
-        <spring-cloud.version>4.1.2</spring-cloud.version>
-        <spring-cloud-starter-stream.version>4.1.1</spring-cloud-starter-stream.version>
-        <spring-cloud-bus.version>4.1.1</spring-cloud-bus.version>
-        <spring-cloud-starter-config.version>4.1.1</spring-cloud-starter-config.version>
-        <spring-cloud-starter-consul-discovery.version>4.1.1</spring-cloud-starter-consul-discovery.version>
-        <spring-cloud-gateway.version>4.1.3</spring-cloud-gateway.version>
+        <spring-cloud-dependencies.version>2023.0.3</spring-cloud-dependencies.version>
+        <spring-cloud.version>4.1.4</spring-cloud.version>
+        <spring-cloud-starter-stream.version>4.1.3</spring-cloud-starter-stream.version>
+        <spring-cloud-bus.version>4.1.2</spring-cloud-bus.version>
+        <spring-cloud-starter-config.version>4.1.3</spring-cloud-starter-config.version>
+        <spring-cloud-starter-consul-discovery.version>4.1.2</spring-cloud-starter-consul-discovery.version>
+        <spring-cloud-gateway.version>4.1.5</spring-cloud-gateway.version>
 
         <netflix-hystrix.version>2.2.10.RELEASE</netflix-hystrix.version>
         <netflix-ribbon.version>2.2.10.RELEASE</netflix-ribbon.version>
 
         <!-- jpa -->
-        <spring-boot-starter-data-jpa.version>3.3.0</spring-boot-starter-data-jpa.version>
-        <spring-data-jpa.version>3.3.0</spring-data-jpa.version>
+        <spring-boot-starter-data-jpa.version>3.3.4</spring-boot-starter-data-jpa.version>
+        <spring-data-jpa.version>3.3.4</spring-data-jpa.version>
 
         <!-- 其他库 -->
-        <groovy.version>4.0.21</groovy.version>
-        <ehcache.version>3.10.8</ehcache.version>
-        <caffeine.version>3.1.8</caffeine.version>
-        <lombok.version>1.18.32</lombok.version>
-        <httpclient.version>4.5.14</httpclient.version>
-        <commons-lang3.version>3.14.0</commons-lang3.version>
-        <junit.version>4.13.2</junit.version>
         <javax.servlet.jsp-api.version>2.3.3</javax.servlet.jsp-api.version>
         <servlets-ssi.version>5.0.16</servlets-ssi.version>
 
@@ -301,26 +294,26 @@
             <version>${javax.servlet.jsp-api.version}</version>
         </dependency>
 
+
         <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <version>${junit.version}</version>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter</artifactId>
+            <scope>test</scope>
         </dependency>
 
+
         <dependency>
             <groupId>org.apache.commons</groupId>
             <artifactId>commons-lang3</artifactId>
-            <version>${commons-lang3.version}</version>
         </dependency>
 
-
         <dependency>
-            <groupId>org.apache.httpcomponents</groupId>
-            <artifactId>httpclient</artifactId>
-            <version>${httpclient.version}</version>
+            <groupId>org.apache.httpcomponents.client5</groupId>
+            <artifactId>httpclient5</artifactId>
         </dependency>
 
 
+
         <dependency>
             <groupId>org.apache.groovy</groupId>
             <artifactId>groovy-all</artifactId>

+ 0 - 510
super/PCore/src/main/java/com/github/microservice/core/endpoints/PostManPoints.java

@@ -1,510 +0,0 @@
-package com.github.microservice.core.endpoints;
-
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.github.microservice.core.conf.PostManConf;
-import com.github.microservice.core.util.JsonUtil;
-import com.github.microservice.core.util.bean.BeanUtil;
-import com.github.microservice.core.util.path.PathUtil;
-import com.github.microservice.core.util.text.CodeCommentUtil;
-import jakarta.servlet.ServletContext;
-import jakarta.servlet.http.HttpServletRequest;
-import lombok.*;
-import org.springframework.beans.factory.BeanFactoryUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.util.DigestUtils;
-import org.springframework.util.StringUtils;
-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.context.WebApplicationContext;
-import org.springframework.web.context.support.WebApplicationContextUtils;
-import org.springframework.web.method.HandlerMethod;
-import org.springframework.web.servlet.HandlerMapping;
-import org.springframework.web.servlet.mvc.condition.PatternsRequestCondition;
-import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
-import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
-import java.util.*;
-import java.util.stream.Collectors;
-
-/**
- * 增加PostMan导入 api
- */
-//@RestController //取消掉
-public class PostManPoints extends SuperEndpoints {
-
-    @Autowired
-    private PostManConf postManConf;
-
-    //bean对象探测的深度
-    private final static int MaxDepthCount = 5;
-
-
-    /**
-     * 给postman导入接口数据
-     *
-     * @param request
-     * @return
-     */
-    @RequestMapping("postman/link")
-    public synchronized Object link(HttpServletRequest request) {
-
-        //获取controller 隐射
-        Set<MappingMethod> mappings = new HashSet<>();
-        getMapping(request, mappings);
-
-        //转换为postman的层级结构
-        PMRoot pmRoot = new PMRoot();
-        PMInfo pmInfo = new PMInfo();
-        setPMName(pmInfo, postManConf.getName());
-        pmRoot.setInfo(pmInfo);
-
-        //构建父级
-        PMItem pmRootItem = new PMItem();
-        pmRootItem.setPath("");
-        //转换为子集
-        toPMItems(pmRootItem, mappings);
-        pmRoot.setItem(pmRootItem.getItem());
-
-        return pmRoot;
-    }
-
-
-    @Data
-    public static class PMInfo extends PMSuperItem {
-        private String schema = "https://schema.getpostman.com/json/collection/v2.0.0/collection.json";
-    }
-
-
-    @Data
-    @JsonInclude(JsonInclude.Include.NON_NULL)
-    public static class PMBody {
-
-        private String mode;
-
-        private String raw;
-
-        private List<Map<String, Object>> formdata;
-
-        private Map<String, Object> options;
-
-
-    }
-
-
-    @Data
-    public static class PMRequest {
-
-        private String url;
-
-        private String method;
-
-        private List<PMValue> header;
-
-        private PMBody body;
-
-    }
-
-    @Data
-    public class PMValue {
-        private String key;
-        private String name;
-        private Object value;
-        private String type;
-    }
-
-
-    @Data
-    @JsonInclude(JsonInclude.Include.NON_NULL)
-    public class PMItem extends PMSuperItem {
-
-        @JsonIgnore
-        private MappingMethod mappingMethod;
-
-        @JsonIgnore
-        private String path;
-
-
-        private List<PMItem> item;
-
-
-        private PMRequest request;
-
-
-        private Object[] response = new Object[0];
-
-
-        public void initParent(String path) {
-            this.path = path;
-            setPMName(this, path);
-        }
-
-
-        /**
-         * 初始化Item
-         *
-         * @param mappingMethod
-         */
-        public void initNode(PMItem parentItem, MappingMethod mappingMethod) {
-            final String url = mappingMethod.getUrl();
-            this.path = url;
-            this.mappingMethod = mappingMethod;
-
-            //添加到父项的子项列表中
-            addChildren(parentItem, this);
-
-            //设置接口名称
-            setPMName(this, url);
-
-            //设置项上面的名称,通过读取源码
-            setItemName(this, mappingMethod);
-
-
-            //取出 @RequestMapping
-            RequestMapping requestMapping = mappingMethod.getMethod().getAnnotation(RequestMapping.class);
-
-            //初始化请求
-            this.request = new PMRequest();
-
-            //设置URL
-            request.setUrl(postManConf.getHostName() + url);
-
-            //设置header
-            setItemHeader(this);
-
-
-            //设置请求方法
-            requestMethod(requestMapping, this);
-
-            //设置请求参数
-            setItemBody(mappingMethod, this);
-
-
-        }
-
-
-    }
-
-
-    /**
-     * 设置请求的header信息
-     *
-     * @param pmItem
-     */
-    private void setItemHeader(PMItem pmItem) {
-        if (postManConf.getHeader() != null) {
-            pmItem.getRequest().setHeader(postManConf.getHeader().entrySet().stream().map((it) -> {
-                PMValue value = new PMValue();
-                value.setKey(it.getKey());
-                value.setName(it.getKey());
-                value.setType("text");
-                value.setValue(it.getValue());
-                return value;
-            }).collect(Collectors.toList()));
-        }
-    }
-
-
-    /**
-     * 设置项的参数部分
-     */
-    @SneakyThrows
-    private void setItemBody(MappingMethod mappingMethod, PMItem pmItem) {
-        //无参数
-        final Method method = mappingMethod.getMethod();
-        if (method.getParameterCount() == 0) {
-            return;
-        }
-
-        //内容部分
-        final PMBody body = new PMBody();
-        pmItem.getRequest().setBody(body);
-
-        //判定类型是否为json
-        boolean isJson = false;
-        for (Annotation[] parameterAnnotation : method.getParameterAnnotations()) {
-            for (Annotation annotation : parameterAnnotation) {
-                if (annotation instanceof RequestBody) {
-                    isJson = true;
-                    break;
-                }
-            }
-            if (isJson) {
-                break;
-            }
-        }
-
-
-        //json数据格式
-        if (isJson) {
-            //构建bean数据,深度为5
-            final Object parm = BeanUtil.buildBean(mappingMethod.getMethod().getParameterTypes()[0], MaxDepthCount);
-            // 构建参数的实例化的bean,支持指定深度
-            body.setMode("raw");
-            body.setRaw(JsonUtil.toJson(parm, true));
-            body.setOptions(new HashMap<>() {{
-                put("raw", new HashMap<>() {{
-                    put("language", "json");
-                }});
-            }});
-            return;
-        }
-
-
-        //表单数据格式
-        body.setMode("formdata");
-        body.setOptions(new HashMap<>() {{
-            put("raw", new HashMap<>() {{
-                put("language", "text");
-            }});
-        }});
-
-        List<Map<String, Object>> formdata = new ArrayList<>();
-        for (Map.Entry<String, BeanUtil.BeanValueInfo> entry : BeanUtil.getControllerMethodParmaInfo(method, 2).entrySet()) {
-            //取出参数类型
-            final BeanUtil.BeanValueInfo paramInfo = entry.getValue();
-            formdata.add(new HashMap<>() {{
-                put("key", entry.getKey());
-                put("value", String.valueOf(paramInfo.getValue()));
-                put("type", "text");
-                put("description", StringUtils.hasText(paramInfo.getCommentText()) ? paramInfo.getCommentText() : "");
-            }});
-        }
-        body.setFormdata(formdata);
-
-    }
-
-
-    /**
-     * 设置请求的名称
-     * 通过读取Java源码上面的注释
-     */
-    @SneakyThrows
-    private void setItemName(PMItem pmItem, MappingMethod mappingMethod) {
-        String commentText = CodeCommentUtil.readMethodComment(mappingMethod.getMethod());
-        //设置项上的名称
-        if (StringUtils.hasText(commentText)) {
-            pmItem.setName(commentText);
-        }
-    }
-
-
-    /**
-     * 设置请求的方法
-     *
-     * @param pmItem
-     * @param requestMapping
-     */
-    private void requestMethod(RequestMapping requestMapping, PMItem pmItem) {
-        String defaultMethod = RequestMethod.POST.name();
-
-        //可能有其他的注解
-        if (requestMapping == null) {
-            pmItem.getRequest().setMethod(defaultMethod);
-            return;
-        }
-
-        //请求的方法
-        RequestMethod[] requestMethods = requestMapping.method();
-        if (requestMethods == null || requestMethods.length == 0) {
-            pmItem.getRequest().setMethod(defaultMethod);
-            return;
-        }
-
-        //如果其中有一个为post,则为post,否则为取出的第一个
-        for (RequestMethod requestMethod : requestMethods) {
-            if (requestMethod == RequestMethod.POST) {
-                pmItem.getRequest().setMethod(defaultMethod);
-                return;
-            }
-        }
-
-        //设置第一个参数
-        pmItem.getRequest().setMethod(requestMethods[0].name());
-        return;
-    }
-
-
-    @Data
-    public static class PMRoot {
-        private PMInfo info;
-        private List<PMItem> item;
-    }
-
-
-    @Data
-    public static abstract class PMSuperItem {
-        private String _postman_id;
-        private String name;
-    }
-
-    @Data
-    @Builder
-    @AllArgsConstructor
-    @NoArgsConstructor
-    public static class MappingMethod {
-
-        //url地址
-        private String url;
-
-        //方法
-        private Method method;
-
-    }
-
-    @SneakyThrows
-    private void setPMName(PMSuperItem item, final String url) {
-        //取出URL中的名称
-        final String name = PathUtil.getName(url, "/");
-        //读取配置文件的备注名
-        String nickName = postManConf.getUrlMappingRemark() != null ? postManConf.getUrlMappingRemark().getOrDefault(name, name) : name;
-
-        item.setName(nickName);
-        item.set_postman_id(uuid(url));
-    }
-
-
-    /**
-     * 转换为Uri的映射
-     *
-     * @param mappingMethods
-     */
-    private void toPMItems(PMItem pmRootItem, Set<MappingMethod> mappingMethods) {
-
-        //临时用于存储的项
-        List<PMItem> parentItemsList = new ArrayList<>();
-        parentItemsList.add(pmRootItem);
-
-        for (MappingMethod mappingMethod : mappingMethods) {
-            groupPMItem(parentItemsList, mappingMethod);
-        }
-
-    }
-
-
-    /**
-     * 分类
-     */
-    private void groupPMItem(List<PMItem> parentItemsList, MappingMethod mappingMethod) {
-        String parentUrl = PathUtil.getParent(mappingMethod.getUrl(), "/");
-
-        //取出父项目
-        PMItem parentItem = findParentItem(parentItemsList, parentUrl);
-
-        //将子集增加到付项的集合里
-        PMItem item = new PMItem();
-        //初始化项
-        item.initNode(parentItem, mappingMethod);
-
-    }
-
-
-    /**
-     * 查找到父类
-     *
-     * @param parentUrl
-     * @return
-     */
-    private PMItem findParentItem(List<PMItem> parentItemsList, String parentUrl) {
-        for (PMItem tempItem : parentItemsList) {
-            if (tempItem.getPath().equals(parentUrl)) {
-                return tempItem;
-            }
-        }
-
-        //没有则新创建一个
-        PMItem parentItem = new PMItem();
-        parentItem.initParent(parentUrl);
-        parentItemsList.add(parentItem);
-        parentItem.setPath(parentUrl);
-
-
-        //没有查找到则新创建一个对象
-        String[] uris = parentUrl.split("/");
-        //0 为空字符串 , 1 为根级
-        if (uris.length > 0) {
-            String parentParentUrl = PathUtil.getParent(parentUrl, "/");
-            PMItem parentParentItem = findParentItem(parentItemsList, parentParentUrl);
-            //存在父类则加到集合中
-            addChildren(parentParentItem, parentItem);
-        }
-        return parentItem;
-    }
-
-    /**
-     * 父项中添加子项
-     *
-     * @param parent
-     * @param child
-     */
-    private void addChildren(PMItem parent, PMItem child) {
-        if (parent.getItem() == null) {
-            parent.setItem(new ArrayList<>());
-        }
-        parent.getItem().add(child);
-    }
-
-
-    private static Map<String, PMItem> getItemMap(List<Map<String, PMItem>> tempItems, int index) {
-        if (tempItems.size() <= index) {
-            tempItems.add(index, new HashMap<>());
-        }
-        //取出所有的map
-        Map<String, PMItem> itemMap = tempItems.get(index);
-        if (itemMap == null) {
-            itemMap = new HashMap<>();
-            tempItems.add(index, itemMap);
-        }
-        return itemMap;
-    }
-
-
-    /**
-     * 构建UUID
-     *
-     * @param name
-     * @return
-     */
-    private static String uuid(String name) {
-        return UUID.nameUUIDFromBytes(DigestUtils.md5Digest(name.getBytes())).toString();
-    }
-
-
-    /**
-     * 获取 Mapping
-     *
-     * @param request
-     * @param mappings
-     */
-    private void getMapping(HttpServletRequest request, Set<MappingMethod> mappings) {
-        ServletContext servletContext = request.getSession().getServletContext();
-        if (servletContext == null) {
-            return;
-        }
-        WebApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(servletContext);
-        //获取所有的RequestMapping
-        Map<String, HandlerMapping> allRequestMappings = BeanFactoryUtils.beansOfTypeIncludingAncestors(appContext, HandlerMapping.class, true, false);
-        for (HandlerMapping handlerMapping : allRequestMappings.values()) {
-            if (!(handlerMapping instanceof RequestMappingHandlerMapping)) {
-                continue;
-            }
-            RequestMappingHandlerMapping mapping = (RequestMappingHandlerMapping) handlerMapping;
-            for (Map.Entry<RequestMappingInfo, HandlerMethod> requestMappingInfoHandlerMethodEntry : mapping.getHandlerMethods().entrySet()) {
-                RequestMappingInfo requestMappingInfo = requestMappingInfoHandlerMethodEntry.getKey();
-                HandlerMethod mappingInfoValue = requestMappingInfoHandlerMethodEntry.getValue();
-                PatternsRequestCondition patternsCondition = requestMappingInfo.getPatternsCondition();
-
-                for (String pattern : patternsCondition.getPatterns()) {
-                    mappings.add(MappingMethod.builder().url(pattern).method(mappingInfoValue.getMethod()).build());
-                }
-            }
-
-        }
-
-
-    }
-
-}

+ 0 - 479
super/PCore/src/main/java/com/github/microservice/core/helper/DiskCacheStoreHelper.java

@@ -1,479 +0,0 @@
-package com.github.microservice.core.helper;
-
-
-import lombok.AllArgsConstructor;
-import lombok.Cleanup;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-import org.apache.commons.codec.digest.DigestUtils;
-import org.springframework.util.StreamUtils;
-
-import java.io.*;
-import java.util.*;
-
-/**
- * 磁盘缓存存储
- */
-public abstract class DiskCacheStoreHelper {
-
-    //磁盘存储地址
-    private File storePath;
-
-    //最大的缓存长度
-    private long maxCacheSize;
-
-    //文件缓存
-    private FileCache fileCache = new FileCache();
-
-    protected DiskCacheStoreHelper(File storePath, long maxCacheSize) {
-        this.storePath = storePath;
-        this.maxCacheSize = maxCacheSize;
-    }
-
-    /**
-     * 创建缓存对象
-     *
-     * @return
-     */
-    public static DiskCacheStoreHelper build(File storePath, long maxCacheSize) {
-        if (!storePath.exists()) {
-            storePath.mkdirs();
-        }
-        DiskCacheStoreHelper diskCacheStore = new DiskCacheStoreHelper(storePath, maxCacheSize) {
-        };
-        diskCacheStore._initFileSize();
-        return diskCacheStore;
-    }
-
-
-    /**
-     * 默认的构建对象
-     *
-     * @return
-     */
-    public static DiskCacheStoreHelper build() {
-        return build(new File(System.getProperty("java.io.tmpdir") + "/_diskcache"), 1024 * 1024 * 100);
-    }
-
-
-    /**
-     * 获取总数量
-     *
-     * @return
-     */
-    public long getTotalSize() {
-        return this.fileCache.getTotalFileSize();
-    }
-
-
-    /**
-     * 获取所有的key
-     *
-     * @return
-     */
-    public Set<String> keySet() {
-        return this.fileCache.keySet();
-    }
-
-
-    /**
-     * 获取文件的长度
-     *
-     * @param key
-     * @return
-     */
-    public synchronized Long size(String key) {
-        String fileName = keyHash(key);
-        File targetFile = new File(this.storePath.getAbsolutePath() + "/" + fileName);
-        if (targetFile.exists()) {
-            return targetFile.length();
-        } else {
-            return null;
-        }
-    }
-
-
-    /**
-     * 根据key打开一个输出流,写完管道后并关闭
-     *
-     * @param key
-     * @return
-     */
-    public synchronized OutputStream store(String key) {
-        final String fileName = keyHash(key);
-        //保证目录一定存在
-        if (!this.storePath.exists()){
-            this.storePath.mkdirs();
-        }
-
-        final File tmpFile = new File(this.storePath.getAbsolutePath() + "/" + fileName + "_new");
-        //拷贝流
-        try {
-            FileOutputStream fileOutputStream = new FileOutputStream(tmpFile) {
-
-                //不允许多次关闭该对象
-                private boolean idClosed = false;
-
-                @Override
-                public synchronized void close() throws IOException {
-                    if (idClosed) {
-                        return;
-                    }
-                    try {
-                        super.close();
-                    } catch (Exception e) {
-                        e.printStackTrace();
-                    }
-                    _updateTmpFile(fileName, tmpFile);
-                    idClosed = true;
-                }
-            };
-            return fileOutputStream;
-        } catch (FileNotFoundException e) {
-            e.printStackTrace();
-        }
-        return null;
-    }
-
-
-    /**
-     * 存储对象
-     *
-     * @param key
-     * @param inputStream
-     * @return
-     */
-    public synchronized boolean store(String key, InputStream inputStream) {
-        try {
-            @Cleanup OutputStream outputStream = store(key);
-            StreamUtils.copy(inputStream, outputStream);
-            return true;
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        return false;
-    }
-
-
-    /**
-     * 更新文件
-     */
-    private void _updateTmpFile(String fileName, File tmpFile) {
-        //限制磁盘空间的大小
-        limitDiskSize(tmpFile.length());
-
-        //更新文件
-        File target = new File(storePath.getAbsolutePath() + "/" + fileName);
-        //存在删除旧文件
-        if (target.exists()) {
-            target.delete();
-        }
-        //新文件更新路径
-        if (tmpFile.renameTo(target)) {
-            updateCacheFileSize(fileName);
-        }
-        if (tmpFile.exists()) {
-            tmpFile.delete();
-        }
-    }
-
-
-    /**
-     * 查询文件
-     *
-     * @param key
-     * @param outputStream
-     */
-    public Long get(String key, OutputStream outputStream) {
-        InputStream inputStream = get(key);
-        if (inputStream == null) {
-            return null;
-        }
-        try {
-            Integer size = StreamUtils.copy(inputStream, outputStream);
-            inputStream.close();
-            return size + 0l;
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        return null;
-    }
-
-    public File getFile(String key) {
-        String fileName = keyHash(key);
-        File targetFile = new File(this.storePath.getAbsolutePath() + "/" + fileName);
-        return targetFile;
-    }
-
-
-    /**
-     * 请手动关闭流
-     *
-     * @param key
-     * @return
-     */
-    public InputStream get(String key) {
-        File targetFile = getFile(key);
-        if (!targetFile.exists()) {
-            return null;
-        }
-        try {
-            return new FileInputStream(targetFile);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        return null;
-    }
-
-
-    /**
-     * 删除磁盘及缓存
-     *
-     * @param key
-     */
-    public synchronized void remove(String key) {
-        _remove(keyHash(key));
-    }
-
-    public boolean exists(String key) {
-        String fileName = keyHash(key);
-        File file = new File(this.storePath.getAbsolutePath() + "/" + fileName);
-        return file.exists();
-    }
-
-
-    /**
-     * 删除
-     *
-     * @param fileName
-     */
-    private void _remove(String fileName) {
-
-        //从磁盘删除
-        removeDiskFile(fileName);
-
-        //删除缓存
-        this.fileCache.remove(fileName);
-
-    }
-
-
-    /**
-     * 限制磁盘空间的大小
-     */
-    private void limitDiskSize(long newDataSize) {
-        while (this.fileCache.getCount() > 0 && this.fileCache.getTotalFileSize() + newDataSize > this.maxCacheSize) {
-            FileInfo fileInfo = this.fileCache.removeBestOldFile();
-            if (fileInfo != null) {
-                removeDiskFile(fileInfo.getFileName());
-            }
-        }
-    }
-
-
-    /**
-     * 删除占用空间最小文件
-     */
-    private void removeDiskFile(String fileName) {
-        if (fileName != null) {
-            File file = new File(this.storePath.getAbsolutePath() + "/" + fileName);
-            if (file.exists()) {
-                file.delete();
-            }
-        }
-
-    }
-
-
-    /**
-     * 实例化的时候加载
-     */
-    private void _initFileSize() {
-        for (File file : this.storePath.listFiles()) {
-            updateCacheFileSize(file.getName());
-        }
-    }
-
-
-    /**
-     * 计算key的hash值
-     *
-     * @param key
-     * @return
-     */
-    public static String keyHash(String key) {
-        return DigestUtils.md5Hex(key);
-    }
-
-
-    /**
-     * 更新文件的缓存
-     *
-     * @param fileName
-     */
-    private void updateCacheFileSize(String fileName) {
-        File file = new File(this.storePath.getAbsolutePath() + "/" + fileName);
-        if (file.exists()) {
-            this.fileCache.addFile(file);
-        }
-    }
-
-
-    class FileCache {
-
-
-        //总文件大小
-        private long totalFileSize = 0;
-
-        //文件列表,按照创建时间排序
-        private List<FileInfo> fileInfos = new ArrayList<FileInfo>();
-
-        //文件名列表
-        private Map<String, FileInfo> fileNames = new HashMap<>();
-
-
-        /**
-         * 添加文件
-         */
-        public synchronized void addFile(File file) {
-            //非空
-            if (file == null || !file.exists()) {
-                return;
-            }
-
-            //文件名
-            String fileName = file.getName();
-
-            //存储对象
-            FileInfo fileInfo = new FileInfo(fileName, file.length(), file.lastModified());
-
-
-            int index = 0;
-            if (this.fileInfos.size() > 0 && fileInfo.getCreateTime() >= this.fileInfos.get(this.fileInfos.size() - 1).getCreateTime()) {
-                index = this.fileInfos.size();
-            } else {
-                //倒叙插入,理论上插入的都是新文件,从最后一个按时间的创建顺序排序效率最高
-                for (int i = 0; i < this.fileInfos.size(); i++) {
-                    index = i;
-                    if (fileInfo.getCreateTime() <= this.fileInfos.get(index).getCreateTime()) {
-                        break;
-                    }
-                }
-            }
-
-
-            //插入数据
-            this.fileInfos.add(index, fileInfo);
-
-            //更新文件总量
-            this.totalFileSize += fileInfo.getFileSize();
-
-            //更新文件名hash
-            this.fileNames.put(fileName, fileInfo);
-        }
-
-
-        /**
-         * 通过文件名删除
-         *
-         * @param fileName
-         * @return
-         */
-        public synchronized FileInfo remove(String fileName) {
-            FileInfo fileInfo = this.fileNames.get(fileName);
-            if (fileInfo == null) {
-                return null;
-            }
-            _remove(fileInfo);
-
-            return fileInfo;
-
-        }
-
-
-        /**
-         * 删除序号第一个元素
-         */
-        public synchronized FileInfo removeBestOldFile() {
-            if (this.fileInfos.size() <= 0) {
-                return null;
-            }
-            FileInfo fileInfo = this.fileInfos.remove(0);
-            if (fileInfo == null) {
-                return null;
-            }
-
-            _remove(fileInfo);
-
-            return fileInfo;
-        }
-
-
-        /**
-         * 获取文件缓存的总数量
-         *
-         * @return
-         */
-        public int getCount() {
-            return this.fileInfos.size();
-        }
-
-
-        private void _remove(FileInfo fileInfo) {
-
-            //删除缓存的文件名
-            this.fileNames.remove(fileInfo.getFileName());
-
-            //减少总记录
-            this.totalFileSize -= fileInfo.getFileSize();
-        }
-
-
-        /**
-         * 获取总文件大小
-         *
-         * @return
-         */
-        public long getTotalFileSize() {
-            return this.totalFileSize;
-        }
-
-
-        /**
-         * 获取所有的key
-         *
-         * @return
-         */
-        public Set<String> keySet() {
-            return this.fileNames.keySet();
-        }
-
-
-    }
-
-    @AllArgsConstructor
-    @NoArgsConstructor
-    @Data
-    class FileInfo {
-
-        /**
-         * 文件名
-         */
-        private String fileName;
-
-        /**
-         * 文件大小
-         */
-        private long fileSize;
-
-
-        /**
-         * 文件的创建时间
-         */
-        private long createTime;
-
-
-    }
-
-
-}

+ 0 - 44
super/PCore/src/main/java/com/github/microservice/core/util/ali/live/ALiLiveUtil.java

@@ -1,44 +0,0 @@
-package com.github.microservice.core.util.ali.live;
-
-import org.apache.commons.codec.digest.DigestUtils;
-
-import java.util.UUID;
-
-public class ALiLiveUtil {
-
-
-    private static String SourcesTemplate = "%s-%s-%s-%s-%s";
-    private static String OutputTemplate = "%s-%s-%s-%s";
-
-
-    /**
-     * 计算出直播流的 auth_key
-     *
-     * @param uri
-     * @param expiresSecond
-     * @param key
-     * @return
-     */
-    public static String getAuthkey(String uri, int expiresSecond, String key) {
-        long time = ((long) System.currentTimeMillis() / 1000) + expiresSecond;
-        String uid = "0";
-        String uuid = UUID.randomUUID().toString().replaceAll("-", "");
-        String source = String.format(SourcesTemplate, uri, time, uuid, uid, key);
-        String hash = DigestUtils.md5Hex(source);
-        return String.format(OutputTemplate, String.valueOf(time), uuid, uid, hash);
-    }
-
-//    public static void main(String[] args) {
-//        System.out.println("rtmp://live.meishuwa.cn/app/test1?auth_key=" + (getAuthkey("/app/test1", 60, "s3dp9vB8qy")));
-//        System.out.println("rtmp://pull.live.meishuwa.cn/app/test1?auth_key=" + (getAuthkey("/app/test1", 60, "WuCPsoegfD")));
-//    }
-
-
-//    public static void main(String[] args) {
-//        var serviceName = "/app/test1";
-//        System.out.println("rtmp://push.live.aiyilearning.com" + serviceName + "?auth_key=" + (getAuthkey(serviceName, 360, "***")));
-//        System.out.println("rtmp://pull.live.aiyilearning.com" + serviceName + "?auth_key=" + (getAuthkey(serviceName, 360, "***")));
-//    }
-
-
-}

+ 0 - 48
super/PCore/src/main/java/com/github/microservice/core/util/bean/BeanUtil.java

@@ -11,12 +11,10 @@ import org.springframework.beans.BeanWrapperImpl;
 import org.springframework.core.StandardReflectionParameterNameDiscoverer;
 import org.springframework.util.Assert;
 import org.springframework.util.StringUtils;
-import org.springframework.web.bind.annotation.RequestParam;
 
 import java.beans.BeanInfo;
 import java.beans.Introspector;
 import java.beans.PropertyDescriptor;
-import java.lang.annotation.Annotation;
 import java.lang.reflect.*;
 import java.math.BigDecimal;
 import java.util.*;
@@ -344,54 +342,8 @@ public class BeanUtil {
         return parameterNameDiscoverer.getParameterNames(method);
     }
 
-    /**
-     * 取方法名上的参数名,优先遵循是 RequestParam 注解
-     *
-     * @param method
-     * @param index
-     * @return
-     */
-    public static String getMethodParamName(Method method, final int index) {
-        String[] paramNames = getParameterNames(method);
-        //读取参数名,优先读取注解上的参数名
-        String paramName = null;
-        Annotation[] parameterAnnotations = method.getParameterAnnotations()[index];
-        for (Annotation parameterAnnotation : parameterAnnotations) {
-            if (parameterAnnotation instanceof RequestParam) {
-                RequestParam requestParam = (RequestParam) parameterAnnotation;
-                return requestParam.value();
-            }
-        }
-        if (paramName == null) {
-            paramName = paramNames[index];
-        }
-
-        return paramName;
-    }
 
 
-    /**
-     * 取出controller的方法的所有属性以及类型
-     *
-     * @param method
-     * @return
-     */
-    public static Map<String, BeanValueInfo> getControllerMethodParmaInfo(final Method method,
-                                                                          final int maxDepthCount) {
-        Map<String, String> fieldComment = new HashMap<>();
-        CodeCommentUtil.readMethodComment(method, fieldComment);
-        //当前深度
-        Map<String, BeanValueInfo> ret = new HashMap<>();
-        for (int i = 0; i < method.getParameterTypes().length; i++) {
-            String paramName = getMethodParamName(method, i);
-            Class paramType = method.getParameterTypes()[i];
-
-            //深度设置参数值
-            setDepthParmaInfo(ret, null, paramName, paramType, fieldComment.get(paramName), 0, maxDepthCount);
-        }
-        return ret;
-    }
-
 
     /**
      * 深度设置参数或bean的值

+ 25 - 20
super/PCore/src/main/java/com/github/microservice/core/util/net/apache/HttpClientUtil.java

@@ -4,19 +4,20 @@ import com.github.microservice.core.util.JsonUtil;
 import lombok.Cleanup;
 import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.http.Header;
-import org.apache.http.client.config.RequestConfig;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.client.methods.HttpRequestBase;
-import org.apache.http.conn.ssl.NoopHostnameVerifier;
-import org.apache.http.conn.ssl.TrustStrategy;
-import org.apache.http.entity.ContentType;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.ssl.SSLContexts;
+import org.apache.hc.client5.http.classic.methods.HttpGet;
+import org.apache.hc.client5.http.classic.methods.HttpPost;
+import org.apache.hc.client5.http.classic.methods.HttpUriRequestBase;
+import org.apache.hc.client5.http.config.RequestConfig;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.classic.HttpClients;
+import org.apache.hc.client5.http.routing.RoutingSupport;
+import org.apache.hc.core5.http.ContentType;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.io.entity.StringEntity;
+import org.apache.hc.core5.ssl.SSLContexts;
+import org.apache.hc.core5.ssl.TrustStrategy;
+import org.apache.hc.core5.util.Timeout;
 import org.springframework.cglib.beans.BeanMap;
 import org.springframework.util.StreamUtils;
 
@@ -28,6 +29,7 @@ import java.io.OutputStream;
 import java.security.cert.CertificateException;
 import java.security.cert.X509Certificate;
 import java.util.*;
+import java.util.concurrent.TimeUnit;
 
 @Slf4j
 public class HttpClientUtil {
@@ -75,7 +77,7 @@ public class HttpClientUtil {
         //构建超时参数
         RequestConfig.Builder builder = RequestConfig.custom();
         if (httpModel.getTimeOut() != null) {
-            builder.setSocketTimeout(httpModel.getTimeOut());
+            builder.setConnectionRequestTimeout(Timeout.of(httpModel.getTimeOut(), TimeUnit.MILLISECONDS));
         }
         RequestConfig requestConfig = builder.build();
 
@@ -86,14 +88,16 @@ public class HttpClientUtil {
                 return true;
             }
         }).build();
+
+
         CloseableHttpClient httpclient = HttpClients.custom()
                 .setDefaultRequestConfig(requestConfig)
-                .setSSLContext(sslContext)
-                .setSSLHostnameVerifier(new NoopHostnameVerifier())
+//                .setSSLContext(sslContext)
+//                .setSSLHostnameVerifier(new NoopHostnameVerifier())
                 .build();
 
 //        CloseableHttpClient httpclient = HttpClients.createDefault();
-        HttpRequestBase requestBase = null;
+        HttpUriRequestBase requestBase = null;
         String[] urls = httpModel.getUrl().split("://");
 
         String url = urls[0] + "://" + UrlEncodeUtil.encode(urls[1]);
@@ -116,10 +120,11 @@ public class HttpClientUtil {
 
 
         //开始请求
-        CloseableHttpResponse response = httpclient.execute(requestBase);
+        final HttpHost httpHost = RoutingSupport.determineHost(requestBase);
+        CloseableHttpResponse response = httpclient.execute(httpHost, requestBase);
 
         if (headers != null) {
-            for (Header header : response.getAllHeaders()) {
+            for (org.apache.hc.core5.http.Header header : response.getHeaders()) {
                 Set<Object> val = headers.get(header.getName());
                 if (val == null) {
                     val = new HashSet<>();
@@ -133,7 +138,7 @@ public class HttpClientUtil {
         @Cleanup InputStream inputStream = response.getEntity().getContent();
         int size = StreamUtils.copy(inputStream, outputStream);
         log.debug("requestUrl : " + httpModel.getUrl() + " , responseSize : " + size);
-        return response.getStatusLine().getStatusCode();
+        return response.getCode();
     }
 
 

+ 2 - 1
super/PCore/src/main/java/com/github/microservice/core/util/result/ServiceResult.java

@@ -1,5 +1,6 @@
 package com.github.microservice.core.util.result;
 
+import com.github.microservice.core.util.bean.BeanUtil;
 import lombok.AllArgsConstructor;
 import lombok.Data;
 import lombok.NoArgsConstructor;
@@ -28,7 +29,7 @@ public abstract class ServiceResult {
      */
     public static <T> T build(Class<? extends T> cls, Object state) {
         try {
-            ServiceResult serviceResult = (ServiceResult) cls.newInstance();
+            ServiceResult serviceResult = (ServiceResult) BeanUtil.newClass(cls);
             serviceResult.setState(state);
             return (T) serviceResult;
         } catch (Exception e) {