Explorar el Código

系统资源配置

wanxing hace 2 meses
padre
commit
f30e6efa05

+ 0 - 64
src/main/java/com/singularity/config/RedisLettuceConfig.java

@@ -1,64 +0,0 @@
-package com.singularity.config;
-
-import org.springframework.cache.CacheManager;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.data.redis.cache.RedisCacheConfiguration;
-import org.springframework.data.redis.cache.RedisCacheManager;
-import org.springframework.data.redis.connection.RedisConnectionFactory;
-import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
-import org.springframework.data.redis.serializer.RedisSerializationContext;
-import org.springframework.data.redis.serializer.StringRedisSerializer;
-
-import java.time.Duration;
-
-/**
- * Redis 配置类
- */
-@Configuration
-public class RedisLettuceConfig {
-
-    /**
-     * 配置缓存管理器
-     * springboot版本为2.7.* 会有 Could not autowire. No beans of 'RedisConnectionFactory' type found 警告
-     *
-     * @param factory Redis 线程安全连接工厂
-     * @return 缓存管理器
-     */
-    @Bean
-    public CacheManager cacheManager(RedisConnectionFactory factory) {
-        // 通过 Config 对象即可对缓存进行自定义配置
-        RedisCacheConfiguration cacheConfig = RedisCacheConfiguration.defaultCacheConfig()
-                // 设置过期时间 10 分钟
-                .entryTtl(Duration.ofMinutes(10))
-                // 禁止缓存 null 值
-                .disableCachingNullValues()
-                // 设置 key 序列化
-                .serializeKeysWith(keyPair())
-                // 设置 value 序列化
-                .serializeValuesWith(valuePair());
-                //value hashmap序列化
-
-        // 返回 Redis 缓存管理器
-        return RedisCacheManager.builder(factory)
-                .withCacheConfiguration("user", cacheConfig)
-                .build();
-    }
-
-    /**
-     * 配置键序列化
-     * @return StringRedisSerializer
-     */
-    private RedisSerializationContext.SerializationPair<String> keyPair() {
-        return RedisSerializationContext.SerializationPair.fromSerializer(new StringRedisSerializer());
-    }
-
-    /**
-     * 配置值序列化,使用 GenericJackson2JsonRedisSerializer 替换默认序列化
-     * @return GenericJackson2JsonRedisSerializer
-     */
-    private RedisSerializationContext.SerializationPair<Object> valuePair() {
-        return RedisSerializationContext.SerializationPair.fromSerializer(new GenericJackson2JsonRedisSerializer());
-    }
-
-}

+ 11 - 14
src/main/java/com/singularity/config/WebConfig.java

@@ -1,8 +1,11 @@
 package com.singularity.config;
 
 import cn.dev33.satoken.config.SaTokenConfig;
+import cn.dev33.satoken.interceptor.SaInterceptor;
 import cn.dev33.satoken.jwt.StpLogicJwtForSimple;
+import cn.dev33.satoken.router.SaRouter;
 import cn.dev33.satoken.stp.StpLogic;
+import cn.dev33.satoken.stp.StpUtil;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
@@ -19,7 +22,7 @@ public class WebConfig implements WebMvcConfigurer {
 
     private static final String[] EXCLUDE_PATH_PATTERNS = {
             // Swagger
-            "**/swagger-ui.html",
+            "**/doc.html",
             "/swagger-resources/**",
             "/webjars/**",
             "/v2/**",
@@ -73,22 +76,16 @@ public class WebConfig implements WebMvcConfigurer {
         return config;
     }
 
-    /**
-     * 注册拦截器
-     * addInterceptor: 注册拦截器对象
-     * addPathPatterns: 拦截的请求
-     * excludePathPatgetPermissionListterns: 拦截白名单
-     */
     @Override
     public void addInterceptors(InterceptorRegistry registry) {
         // 注册 Sa-Token 拦截器,定义详细认证规则
-//        registry.addInterceptor(new SaInterceptor(handler -> {
-//            // 指定一条 match 规则
-//            SaRouter.match("/**")    // 拦截的 path 列表,可以写多个 */
-//                    .notMatch("/backstageLogin/password") // 排除掉的 path 列表,可以写多个
-//                    .notMatch(EXCLUDE_PATH_PATTERNS)
-//                    .check(r -> StpUtil.checkLogin());        // 要执行的校验动作,可以写完整的 lambda 表达式
-//        })).addPathPatterns("/**");
+        registry.addInterceptor(new SaInterceptor(handler -> {
+            // 指定一条 match 规则
+            SaRouter.match("/**")    // 拦截的 path 列表,可以写多个 */
+                    .notMatch("/backstageLogin/password")// 排除掉的 path 列表,可以写多个
+                    .notMatch(EXCLUDE_PATH_PATTERNS)
+                    .check(r -> StpUtil.checkLogin());        // 要执行的校验动作,可以写完整的 lambda 表达式
+        })).addPathPatterns("/**");
     }
 
     /**

+ 0 - 3
src/main/java/com/singularity/service/impl/LoginServiceImpl.java

@@ -38,9 +38,6 @@ public class LoginServiceImpl  implements LoginService{
     @Resource(name = "threadPool")
     private Executor executor;
 
-    @Resource
-    private LogsService logsService;
-
     @Override
     public UserInfoDTO loginByCaptcha(CaptchaLoginParam captchaLoginParam) {
         return null;

+ 5 - 5
src/main/java/com/singularity/util/OpenOfficeUtil.java

@@ -18,23 +18,23 @@ import java.util.UUID;
 @Component
 public class OpenOfficeUtil {
 
-    @Resource
-    private DocumentConverter documentConverter;
+//    @Resource
+//    private DocumentConverter documentConverter;
 
     @Value("${file.path}")
     private String filePath;
 
     public void wordToPDF(String srcPath, String destPath) throws OfficeException {
         File file = new File(destPath);
-        documentConverter.convert(new File(srcPath)).to(file).as(DefaultDocumentFormatRegistry.PDF).execute();
+//        documentConverter.convert(new File(srcPath)).to(file).as(DefaultDocumentFormatRegistry.PDF).execute();
     }
 
     public void wordToPDF(InputStream src,OutputStream tar) throws OfficeException {
-        documentConverter.convert(src).as(DefaultDocumentFormatRegistry.DOCX).to(tar).as(DefaultDocumentFormatRegistry.PDF).execute();
+//        documentConverter.convert(src).as(DefaultDocumentFormatRegistry.DOCX).to(tar).as(DefaultDocumentFormatRegistry.PDF).execute();
     }
 
     public void excelToPDF(InputStream src, OutputStream tar) throws OfficeException {
-        documentConverter.convert(src).as(DefaultDocumentFormatRegistry.XLSX).to(tar).as(DefaultDocumentFormatRegistry.PDF).execute();
+//        documentConverter.convert(src).as(DefaultDocumentFormatRegistry.XLSX).to(tar).as(DefaultDocumentFormatRegistry.PDF).execute();
     }
 
     /**

+ 85 - 0
src/main/resources/application-pro.yml

@@ -0,0 +1,85 @@
+spring:
+  datasource:
+    url: jdbc:mysql://localhost:3306/car_test?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true
+    username: root
+    password: Su28092015__
+    driver-class-name: com.mysql.cj.jdbc.Driver
+    hikari:
+      minimum-idle: 3
+      maximum-pool-size: 10
+      #不能小于30秒,否则默认回到1800秒
+      max-lifetime: 30000
+      idle-timeout: 10000
+      connection-test-query: SELECT 1
+  mvc:
+    path match:
+      matching-strategy: ANT_PATH_MATCHER
+  jackson:
+    time-zone: GMT+8
+    serialization:
+      write-dates-as-timestamps: true
+  servlet: #配置单次上传文件大小100MB以内,单次请求大小500MB以内
+    multipart:
+      max-file-size: 500MB
+      max-request-size: 1000MB
+  jmx:
+    enabled: true
+
+mybatis-plus:
+  mapper-locations: classpath:mapper/*.xml
+  configuration:
+    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+    map-underscore-to-camel-case: true
+
+swagger:
+  basic:
+    enabled: true
+
+pagehelper:
+  # pageSize=0时会传回所有数据
+  page-size-zero: true
+  # 指定数据库,不指定的话会默认自动检测数据库类型
+  helperDialect: mysql
+  #启用合理化,如果pageNum<1会查询第一页,如果pageNum>pages会查询最后一页
+  reasonable: true
+  #支持通过 Mapper 接口参数来传递分页参数,默认值false,分页插件会从查询方法的参数值中,自动根据上面 params 配置的字段中取值,查找到合适的值时就会自动分页
+  supportMethodsArguments: true
+
+token:
+  jwtSecretKey: N8mD8RlP4ammXRAZzOyWANuC0Dfo0XYGHiVqG5JnIL6lElUnML
+
+sa-token:
+  alone-redis:
+    port: 6379
+    database: 0
+    host: localhost
+    lettuce:
+      pool:
+        # 连接池最大连接数
+        max-active: 200
+        # 连接池最大阻塞等待时间(使用负值表示没有限制)
+        max-wait: -1ms
+        # 连接池中的最大空闲连接
+        max-idle: 200
+        # 连接池中的最小空闲连接
+        min-idle: 20
+        time-between-eviction-runs: 100
+
+file:
+  path: /home/temporary_file
+
+#jodconverter:
+#  local:
+#    enabled: true
+#    office-home: /opt/openoffice4
+#    max-tasks-per-process: 10
+#    port-numbers: 8100
+
+detection:
+  minio:
+    endpoint: http://localhost:9000
+    accessKey: admin
+    secretKey: 12345678
+    bucketName: car
+    pathPrefix: common
+    virtualUrl: http://localhost:9000

+ 101 - 0
src/main/resources/application-test.yml

@@ -0,0 +1,101 @@
+spring:
+  datasource:
+    url: jdbc:mysql://120.79.182.152:3230/car_test?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true
+    username: root
+    password: Su28092015__
+    driver-class-name: com.mysql.cj.jdbc.Driver
+    hikari:
+      minimum-idle: 3
+      maximum-pool-size: 10
+      #不能小于30秒,否则默认回到1800秒
+      max-lifetime: 30000
+      idle-timeout: 10000
+      connection-test-query: SELECT 1
+  mvc:
+    path match:
+      matching-strategy: ANT_PATH_MATCHER
+  jackson:
+    time-zone: GMT+8
+    serialization:
+      write-dates-as-timestamps: true
+  redis:
+    port: 6379
+    database: 1
+    host: localhost
+    timeout: 3s
+    lettuce:
+      pool:
+        # 连接池最大连接数
+        max-active: 20
+        # 连接池最大阻塞等待时间(使用负值表示没有限制)
+        max-wait: -1ms
+        # 连接池中的最大空闲连接
+        max-idle: 10
+        # 连接池中的最小空闲连接
+        min-idle: 3
+        time-between-eviction-runs: 100
+  servlet: #配置单次上传文件大小100MB以内,单次请求大小500MB以内
+    multipart:
+      max-file-size: 500MB
+      max-request-size: 1000MB
+  jmx:
+    enabled: true
+
+mybatis-plus:
+  mapper-locations: classpath:mapper/*.xml
+  configuration:
+    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+    map-underscore-to-camel-case: true
+
+swagger:
+  basic:
+    enabled: true
+
+pagehelper:
+  # pageSize=0时会传回所有数据
+  page-size-zero: true
+  # 指定数据库,不指定的话会默认自动检测数据库类型
+  helperDialect: mysql
+  #启用合理化,如果pageNum<1会查询第一页,如果pageNum>pages会查询最后一页
+  reasonable: true
+  #支持通过 Mapper 接口参数来传递分页参数,默认值false,分页插件会从查询方法的参数值中,自动根据上面 params 配置的字段中取值,查找到合适的值时就会自动分页
+  supportMethodsArguments: true
+
+token:
+  jwtSecretKey: N8mD8RlP4ammXRAZzOyWANuC0Dfo0XYGHiVqG5JnIL6lElUnML
+
+sa-token:
+  alone-redis:
+    port: 6379
+    database: 0
+    host: localhost
+    lettuce:
+      pool:
+        # 连接池最大连接数
+        max-active: 200
+        # 连接池最大阻塞等待时间(使用负值表示没有限制)
+        max-wait: -1ms
+        # 连接池中的最大空闲连接
+        max-idle: 200
+        # 连接池中的最小空闲连接
+        min-idle: 20
+        time-between-eviction-runs: 100
+
+file:
+  path: D:/model/
+
+jodconverter:
+  local:
+    enabled: true
+    office-home: D:/Program Files/openOffice
+    max-tasks-per-process: 10
+    port-numbers: 8100
+
+detection:
+  minio:
+    endpoint: http://localhost:9000
+    accessKey: admin
+    secretKey: 12345678
+    bucketName: car
+    pathPrefix: common
+    virtualUrl: http://localhost:9000

+ 1 - 101
src/main/resources/application.yml

@@ -3,106 +3,6 @@ server:
 
 spring:
   profiles:
-    active: test
+    active: pro
   application:
     name: car-server
-  datasource:
-    url: jdbc:mysql://120.79.182.152:3230/car_test?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true
-    username: root
-    password: Su28092015__
-    driver-class-name: com.mysql.cj.jdbc.Driver
-    hikari:
-      minimum-idle: 3
-      maximum-pool-size: 10
-      #不能小于30秒,否则默认回到1800秒
-      max-lifetime: 30000
-      idle-timeout: 10000
-      connection-test-query: SELECT 1
-  mvc:
-    path match:
-      matching-strategy: ANT_PATH_MATCHER
-  jackson:
-    time-zone: GMT+8
-    serialization:
-      write-dates-as-timestamps: true
-  redis:
-    port: 6379
-    database: 1
-    host: localhost
-    timeout: 3s
-    lettuce:
-      pool:
-        # 连接池最大连接数
-        max-active: 20
-        # 连接池最大阻塞等待时间(使用负值表示没有限制)
-        max-wait: -1ms
-        # 连接池中的最大空闲连接
-        max-idle: 10
-        # 连接池中的最小空闲连接
-        min-idle: 3
-        time-between-eviction-runs: 100
-  servlet: #配置单次上传文件大小100MB以内,单次请求大小500MB以内
-    multipart:
-      max-file-size: 500MB
-      max-request-size: 1000MB
-  jmx:
-    enabled: true
-
-mybatis-plus:
-  mapper-locations: classpath:mapper/*.xml
-  configuration:
-    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
-    map-underscore-to-camel-case: true
-
-swagger:
-  basic:
-    enabled: true
-
-pagehelper:
-  # pageSize=0时会传回所有数据
-  page-size-zero: true
-  # 指定数据库,不指定的话会默认自动检测数据库类型
-  helperDialect: mysql
-  #启用合理化,如果pageNum<1会查询第一页,如果pageNum>pages会查询最后一页
-  reasonable: true
-  #支持通过 Mapper 接口参数来传递分页参数,默认值false,分页插件会从查询方法的参数值中,自动根据上面 params 配置的字段中取值,查找到合适的值时就会自动分页
-  supportMethodsArguments: true
-
-token:
-  jwtSecretKey: N8mD8RlP4ammXRAZzOyWANuC0Dfo0XYGHiVqG5JnIL6lElUnML
-
-sa-token:
-  alone-redis:
-    port: 6379
-    database: 0
-    host: localhost
-    lettuce:
-      pool:
-        # 连接池最大连接数
-        max-active: 200
-        # 连接池最大阻塞等待时间(使用负值表示没有限制)
-        max-wait: -1ms
-        # 连接池中的最大空闲连接
-        max-idle: 200
-        # 连接池中的最小空闲连接
-        min-idle: 20
-        time-between-eviction-runs: 100
-
-file:
-  path: D:/model/
-
-jodconverter:
-  local:
-    enabled: true
-    office-home: D:/Program Files/openOffice
-    max-tasks-per-process: 10
-    port-numbers: 8100
-
-detection:
-  minio:
-    endpoint: http://localhost:9000
-    accessKey: admin
-    secretKey: 12345678
-    bucketName: car
-    pathPrefix: common
-    virtualUrl: http://localhost:9000