Jelajahi Sumber

修改配置分组加载模式,改为从fss读取

luoshi 2 tahun lalu
induk
melakukan
f2ba502702

+ 3 - 3
src/main/java/com/qmth/ops/api/controller/sms/SmsController.java

@@ -8,8 +8,8 @@ import com.qmth.boot.core.sms.model.SmsSendRequest;
 import com.qmth.boot.core.sms.model.SmsSendResponse;
 import com.qmth.boot.tools.signature.SignatureType;
 import org.springframework.validation.annotation.Validated;
+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.annotation.Resource;
@@ -21,8 +21,8 @@ public class SmsController {
     @Resource
     private SmsApiClient smsApiClient;
 
-    @RequestMapping(SmsConstants.API_PATH_SEND_SMS)
-    public SmsSendResponse sendSms(@RequestBody @Validated SmsSendRequest request) {
+    @PostMapping(SmsConstants.API_PATH_SEND_SMS)
+    public SmsSendResponse send(@RequestBody @Validated SmsSendRequest request) {
         return smsApiClient.sendSms(request);
     }
 

+ 8 - 6
src/main/java/com/qmth/ops/biz/service/PropertyGroupService.java

@@ -2,12 +2,12 @@ package com.qmth.ops.biz.service;
 
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.type.CollectionType;
+import com.qmth.boot.core.fss.store.FileStore;
 import com.qmth.ops.biz.domain.PropertyGroup;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Service;
 
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -20,18 +20,20 @@ public class PropertyGroupService {
 
     private List<PropertyGroup> propertyGroupList = new ArrayList<>();
 
-    public PropertyGroupService() throws IOException {
+    private FileStore fileStore;
+
+    public PropertyGroupService(FileStore fileStore) throws Exception {
+        this.fileStore = fileStore;
         loadGroupFile(propertyGroupList, FILE_PATH);
     }
 
-    private void loadGroupFile(List<PropertyGroup> propertyGroupList, String... path) throws IOException {
+    private void loadGroupFile(List<PropertyGroup> propertyGroupList, String... path) throws Exception {
         ObjectMapper mapper = new ObjectMapper();
         CollectionType collectionType = mapper.getTypeFactory()
                 .constructCollectionType(ArrayList.class, PropertyGroup.class);
         for (String filePath : path) {
-            List<PropertyGroup> list = mapper
-                    .readValue(this.getClass().getClassLoader().getResourceAsStream(filePath), collectionType);
-            log.info(filePath + " size=" + list.size());
+            List<PropertyGroup> list = mapper.readValue(fileStore.read(filePath), collectionType);
+            log.info("Load property group, file={}, size={}", filePath, list.size());
             propertyGroupList.addAll(list);
         }
     }

+ 0 - 468
src/main/resources/property/qmth-boot.json

@@ -1,468 +0,0 @@
-[
-  {
-    "name": "qmth-boot:starter-api",
-    "prefix": "com.qmth.api",
-    "available": [
-      {
-        "key": "com.qmth.api.uri-prefix",
-        "description": "API统一使用的uri前缀",
-        "type": "string",
-        "defaultValue": "/api",
-        "options": []
-      },
-      {
-        "key": "com.qmth.api.error-mapping",
-        "description": "是否启用/error映射处理",
-        "type": "boolean",
-        "defaultValue": true,
-        "options": []
-      },
-      {
-        "key": "com.qmth.api.global-strict",
-        "description": "是否全局默认严格模式",
-        "type": "boolean",
-        "defaultValue": false,
-        "options": []
-      },
-      {
-        "key": "com.qmth.api.global-auth",
-        "description": "全局默认鉴权",
-        "type": "boolean",
-        "defaultValue": false,
-        "options": []
-      },
-      {
-        "key": "com.qmth.api.global-rate-limit",
-        "description": "全局默认限流规则",
-        "type": "string",
-        "defaultValue": null,
-        "options": []
-      },
-      {
-        "key": "com.qmth.api.metrics-endpoint",
-        "description": "统计查询接口",
-        "type": "string",
-        "defaultValue": null,
-        "options": []
-      }
-    ]
-  },
-  {
-    "name": "qmth-boot:data-mybatis-plus@datasource",
-    "prefix": "com.qmth.datasource",
-    "available": [
-      {
-        "key": "com.qmth.datasource.driver-class-name",
-        "description": "MySQL不用额外填写",
-        "type": "string",
-        "defaultValue": "com.mysql.cj.jdbc.Driver",
-        "options": []
-      },
-      {
-        "key": "com.qmth.datasource.url",
-        "description": "数据库连接地址",
-        "type": "string",
-        "defaultValue": null,
-        "options": []
-      },
-      {
-        "key": "com.qmth.datasource.username",
-        "description": "数据库连接账号",
-        "type": "string",
-        "defaultValue": null,
-        "options": []
-      },
-      {
-        "key": "com.qmth.datasource.password",
-        "description": "数据库连接密码",
-        "type": "string",
-        "defaultValue": null,
-        "options": []
-      },
-      {
-        "key": "com.qmth.datasource.min-idle",
-        "description": "数据库连接池最小闲置",
-        "type": "number",
-        "defaultValue": 5,
-        "options": []
-      },
-      {
-        "key": "com.qmth.datasource.max-pool-size",
-        "description": "数据库连接池最大数量",
-        "type": "number",
-        "defaultValue": 10,
-        "options": []
-      },
-      {
-        "key": "com.qmth.datasource.idle-timeout",
-        "description": "数据库连接闲置超时时间",
-        "type": "duration",
-        "defaultValue": "10m",
-        "options": []
-      },
-      {
-        "key": "com.qmth.datasource.connection-timeout",
-        "description": "数据库连接超时时间",
-        "type": "duration",
-        "defaultValue": "30s",
-        "options": []
-      },
-      {
-        "key": "com.qmth.datasource.max-lifetime",
-        "description": "数据库连接超时时间",
-        "type": "duration",
-        "defaultValue": "7h",
-        "options": []
-      }
-    ]
-  },
-  {
-    "name": "qmth-boot:data-mybatis-plus@mybatis",
-    "prefix": "com.qmth.mybatis",
-    "available": [
-      {
-        "key": "com.qmth.mybatis.log-level",
-        "description": "mybatis日志级别",
-        "type": "string",
-        "defaultValue": "info",
-        "options": [
-          "trace",
-          "debug",
-          "info",
-          "warn",
-          "error",
-          "off"
-        ]
-      },
-      {
-        "key": "com.qmth.mybatis.block-attack",
-        "description": "mybatis开启防攻击插件,默认开启",
-        "type": "boolean",
-        "defaultValue": true,
-        "options": []
-      }
-    ]
-  },
-  {
-    "name": "qmth-boot:data-redis",
-    "prefix": "com.qmth.redis",
-    "available": [
-      {
-        "key": "com.qmth.redis.host",
-        "description": "redis主机",
-        "type": "string",
-        "defaultValue": null,
-        "options": []
-      },
-      {
-        "key": "com.qmth.redis.port",
-        "description": "redis端口",
-        "type": "number",
-        "defaultValue": 6379,
-        "options": []
-      },
-      {
-        "key": "com.qmth.redis.db",
-        "description": "redis库编号",
-        "type": "number",
-        "defaultValue": 0,
-        "options": []
-      },
-      {
-        "key": "com.qmth.redis.password",
-        "description": "redis连接密码",
-        "type": "string",
-        "defaultValue": null,
-        "options": []
-      },
-      {
-        "key": "com.qmth.redis.use-ssl",
-        "description": "是否使用SSL连接",
-        "type": "boolean",
-        "defaultValue": false,
-        "options": []
-      },
-      {
-        "key": "com.qmth.redis.timeout",
-        "description": "redis命令超时时间",
-        "type": "duration",
-        "defaultValue": "3s",
-        "options": []
-      }
-    ]
-  },
-  {
-    "name": "qmth-boot:core-security",
-    "prefix": "com.qmth.auth",
-    "available": [
-      {
-        "key": "com.qmth.auth.time-max-delay",
-        "description": "服务器时间晚于鉴权时间戳最大时长",
-        "type": "duration",
-        "defaultValue": "15s",
-        "options": []
-      },
-      {
-        "key": "com.qmth.auth.time-max-ahead",
-        "description": "服务器时间早于鉴权时间戳最大时长",
-        "type": "duration",
-        "defaultValue": "5s",
-        "options": []
-      }
-    ]
-  },
-  {
-    "name": "qmth-boot:core-uid",
-    "prefix": "com.qmth.uid",
-    "available": [
-      {
-        "key": "com.qmth.uid.datacenter-id",
-        "description": "数据中心编号,需要在0~7之间",
-        "type": "number",
-        "defaultValue": "0",
-        "options": [
-          0,
-          1,
-          2,
-          3,
-          4,
-          5,
-          6,
-          7
-        ]
-      }
-    ]
-  },
-  {
-    "name": "qmth-boot:core-cache",
-    "prefix": "com.qmth.cache",
-    "available": [
-      {
-        "key": "com.qmth.cache.allow-null-value",
-        "description": "是否允许空值缓存",
-        "type": "boolean",
-        "defaultValue": true,
-        "options": []
-      },
-      {
-        "key": "com.qmth.cache.expire-after-write",
-        "description": "缓存写入后的强制失效时长,大于0时才生效",
-        "type": "duration",
-        "defaultValue": "0s",
-        "options": []
-      }
-    ]
-  },
-  {
-    "name": "qmth-boot:core-fss",
-    "prefix": "com.qmth.fss",
-    "available": [
-      {
-        "key": "com.qmth.fss.*.config",
-        "description": "多存储模式bucket设置",
-        "type": "string",
-        "defaultValue": null,
-        "options": []
-      },
-      {
-        "key": "com.qmth.fss.*.server",
-        "description": "多存储模式bucket访问前缀",
-        "type": "string",
-        "defaultValue": null,
-        "options": []
-      },
-      {
-        "key": "com.qmth.fss.config",
-        "description": "单存储模式设置",
-        "type": "string",
-        "defaultValue": null,
-        "options": []
-      },
-      {
-        "key": "com.qmth.fss.server",
-        "description": "单存储模式访问前缀",
-        "type": "string",
-        "defaultValue": null,
-        "options": []
-      }
-    ]
-  },
-  {
-    "name": "qmth-boot:core-logging",
-    "prefix": "com.qmth.logging",
-    "available": [
-      {
-        "key": "com.qmth.logging.pattern",
-        "description": "日志格式,不建议修改",
-        "type": "string",
-        "defaultValue": "%d{yyyy-MM-dd HH:mm:ss.SSS} | %-5level | %X{TRACE_ID} | %X{CALLER} | %logger{39}:%L | %msg%n",
-        "options": []
-      },
-      {
-        "key": "com.qmth.logging.root-level",
-        "description": "root日志级别",
-        "type": "string",
-        "defaultValue": "info",
-        "options": [
-          "trace",
-          "debug",
-          "info",
-          "warn",
-          "error",
-          "off"
-        ]
-      },
-      {
-        "key": "com.qmth.logging.file-path",
-        "description": "基本日志文件全路径,不设置表示不启用日志文件",
-        "type": "string",
-        "defaultValue": null,
-        "options": []
-      },
-      {
-        "key": "com.qmth.logging.file-max-history",
-        "description": "日志文件最多保留天数",
-        "type": "number",
-        "defaultValue": 7,
-        "options": []
-      },
-      {
-        "key": "com.qmth.logging.file-max-size",
-        "description": "拆分单个日志文件最大容量",
-        "type": "datasize",
-        "defaultValue": "100MB",
-        "options": []
-      },
-      {
-        "key": "com.qmth.logging.file-total-size",
-        "description": "所有日志文件容量上限",
-        "type": "datasize",
-        "defaultValue": "20GB",
-        "options": []
-      }
-    ]
-  },
-  {
-    "name": "qmth-boot:core-retrofit",
-    "prefix": "com.qmth.retrofit",
-    "available": [
-      {
-        "key": "com.qmth.retrofit.connect-timeout",
-        "description": "连接超时",
-        "type": "duration",
-        "defaultValue": "10s",
-        "options": []
-      },
-      {
-        "key": "com.qmth.retrofit.read-timeout",
-        "description": "读取超时",
-        "type": "duration",
-        "defaultValue": "10s",
-        "options": []
-      },
-      {
-        "key": "com.qmth.retrofit.write-timeout",
-        "description": "写入超时",
-        "type": "duration",
-        "defaultValue": "10s",
-        "options": []
-      },
-      {
-        "key": "com.qmth.retrofit.pool.max-idle",
-        "description": "连接池最大空闲",
-        "type": "number",
-        "defaultValue": 1,
-        "options": []
-      },
-      {
-        "key": "com.qmth.retrofit.pool.keep-alive",
-        "description": "连接池空闲时间",
-        "type": "duration",
-        "defaultValue": "10m",
-        "options": []
-      },
-      {
-        "key": "com.qmth.retrofit.retry.count",
-        "description": "最多重试次数",
-        "type": "number",
-        "defaultValue": 3,
-        "options": []
-      },
-      {
-        "key": "com.qmth.retrofit.retry.interval",
-        "description": "重试间隔时间",
-        "type": "duration",
-        "defaultValue": "300ms",
-        "options": []
-      },
-      {
-        "key": "com.qmth.retrofit.retry.status-code",
-        "description": "可重试状态码",
-        "type": "string",
-        "defaultValue": "408,503,504",
-        "options": []
-      },
-      {
-        "key": "com.qmth.retrofit.log-level",
-        "description": "日志级别",
-        "type": "string",
-        "defaultValue": "off",
-        "options": [
-          "trace",
-          "debug",
-          "info",
-          "warn",
-          "error",
-          "off"
-        ]
-      }
-    ]
-  },
-  {
-    "name": "qmth-boot:core-solar",
-    "prefix": "com.qmth.solar",
-    "available": [
-      {
-        "key": "com.qmth.solar.server",
-        "description": "solar服务地址",
-        "type": "string",
-        "defaultValue": "https://solar.qmth.com.cn",
-        "options": []
-      },
-      {
-        "key": "com.qmth.solar.access-key",
-        "description": "在线模式访问key",
-        "type": "string",
-        "defaultValue": null,
-        "options": []
-      },
-      {
-        "key": "com.qmth.solar.access-secret",
-        "description": "在线模式访问secret",
-        "type": "string",
-        "defaultValue": null,
-        "options": []
-      },
-      {
-        "key": "com.qmth.solar.license",
-        "description": "离线模式授权文件路径",
-        "type": "string",
-        "defaultValue": null,
-        "options": []
-      }
-    ]
-  },
-  {
-    "name": "qmth-boot:core-sms",
-    "prefix": "com.qmth.sms",
-    "available": [
-      {
-        "key": "com.qmth.sms.server",
-        "description": "短信服务地址,云端模式不用修改",
-        "type": "string",
-        "defaultValue": "https://solar.qmth.com.cn",
-        "options": []
-      }
-    ]
-  }
-]

+ 0 - 27
src/main/resources/property/spring.json

@@ -1,27 +0,0 @@
-[
-  {
-    "name": "server配置",
-    "prefix": "server",
-    "available": []
-  },
-  {
-    "name": "spring配置",
-    "prefix": "spring",
-    "available": []
-  },
-  {
-    "name": "rocketmq配置",
-    "prefix": "rocketmq",
-    "available": []
-  },
-  {
-    "name": "mybatis-plus配置",
-    "prefix": "mybatis-plus",
-    "available": []
-  },
-  {
-    "name": "logging配置",
-    "prefix": "logging",
-    "available": []
-  }
-]