浏览代码

update properties

deason 1 年之前
父节点
当前提交
a4eabe181f

+ 6 - 4
src/main/java/com/qmth/exam/reserve/config/WxProperty.java → src/main/java/com/qmth/exam/reserve/config/SysProperty.java

@@ -1,15 +1,14 @@
 package com.qmth.exam.reserve.config;
 
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Component;
-
 import lombok.Getter;
 import lombok.Setter;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
 
 @Getter
 @Setter
 @Component
-public class WxProperty {
+public class SysProperty {
 
     @Value("${wx.app_id}")
     private String appId;
@@ -23,4 +22,7 @@ public class WxProperty {
     @Value("${com.qmth.fss.server}")
     private String server;
 
+    @Value("${com.qmth.api_limit_expression:}")
+    private String apiLimitExpression;
+
 }

+ 3 - 3
src/main/java/com/qmth/exam/reserve/controller/student/StudentController.java

@@ -6,7 +6,7 @@ import com.qmth.boot.core.exception.StatusException;
 import com.qmth.exam.reserve.bean.Constants;
 import com.qmth.exam.reserve.bean.student.StudentInfo;
 import com.qmth.exam.reserve.bean.student.WechatBindReq;
-import com.qmth.exam.reserve.config.WxProperty;
+import com.qmth.exam.reserve.config.SysProperty;
 import com.qmth.exam.reserve.controller.BaseController;
 import com.qmth.exam.reserve.service.StudentService;
 import com.qmth.exam.reserve.weixin.OauthAccessTokenRequest;
@@ -31,7 +31,7 @@ public class StudentController extends BaseController {
     private StudentService studentService;
 
     @Autowired
-    private WxProperty wxProperty;
+    private SysProperty sysProperty;
 
     @ApiOperation(value = "考生账号与微信号绑定")
     @PostMapping(value = "/wechat/binding")
@@ -56,7 +56,7 @@ public class StudentController extends BaseController {
     @ApiOperation(value = "获取微信用户的openid")
     @PostMapping(value = "/wechat/get/openid")
     public String getOpenid(@ApiParam("微信用户code") @RequestParam String code) {
-        OauthAccessTokenRequest tokenRequest = new OauthAccessTokenRequest(code, wxProperty.getAppId(), wxProperty.getAppSecret());
+        OauthAccessTokenRequest tokenRequest = new OauthAccessTokenRequest(code, sysProperty.getAppId(), sysProperty.getAppSecret());
         OauthAccessTokenResponseJson response = tokenRequest.request();
         if (response.getErrcode() != 0) {
             log.warn("获取微信用户的openid失败!code:{}", code);

+ 4 - 5
src/main/java/com/qmth/exam/reserve/service/impl/FileUploadServiceImpl.java

@@ -2,7 +2,6 @@ package com.qmth.exam.reserve.service.impl;
 
 import java.io.ByteArrayInputStream;
 import java.io.File;
-import java.io.FileInputStream;
 import java.nio.file.Files;
 import java.time.Duration;
 
@@ -13,7 +12,7 @@ import org.springframework.stereotype.Service;
 
 import com.qmth.boot.core.fss.store.impl.OssStore;
 import com.qmth.boot.tools.models.ByteArray;
-import com.qmth.exam.reserve.config.WxProperty;
+import com.qmth.exam.reserve.config.SysProperty;
 import com.qmth.exam.reserve.service.FileUploadService;
 
 @Service
@@ -22,12 +21,12 @@ public class FileUploadServiceImpl implements FileUploadService {
     private final static Logger log = LoggerFactory.getLogger(FileUploadServiceImpl.class);
 
     @Autowired
-    private WxProperty property;
+    private SysProperty sysProperty;
 
     @Override
     public String uploadFile(String dirName, File file) {
         try {
-            OssStore store = new OssStore(property.getServer(), property.getConfig());
+            OssStore store = new OssStore(sysProperty.getServer(), sysProperty.getConfig());
             String filePath = dirName + "/" + file.getName();
             store.write(filePath, Files.newInputStream(file.toPath()), ByteArray.md5(file).toHexString());
             String url = store.getPresignedUrl(filePath, Duration.ofMinutes(5));
@@ -42,7 +41,7 @@ public class FileUploadServiceImpl implements FileUploadService {
     @Override
     public String uploadByText(String dirName, String text, String fileName) {
         try {
-            OssStore store = new OssStore(property.getServer(), property.getConfig());
+            OssStore store = new OssStore(sysProperty.getServer(), sysProperty.getConfig());
             String filePath = dirName + "/" + fileName;
             ByteArray data = ByteArray.fromString(text);
             store.write(filePath, new ByteArrayInputStream(data.value()), ByteArray.md5(data.value()).toHexString());

+ 58 - 0
src/main/resources/application-dev.properties

@@ -0,0 +1,58 @@
+#
+# ********** server config **********
+#
+server.port=8080
+server.servlet.context-path=/
+server.servlet.session.timeout=PT2H
+spring.servlet.multipart.max-request-size=100MB
+spring.servlet.multipart.max-file-size=100MB
+spring.main.allow-bean-definition-overriding=true
+spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
+spring.jackson.time-zone=GMT+8
+server.tomcat.threads.max=800
+server.tomcat.max-connections=20000
+server.tomcat.connection-timeout=60000
+#
+# ********** mysql config **********
+#
+db.host=192.168.10.30
+db.port=3306
+db.database=exam_reserve_db
+com.qmth.datasource.username=exam_reserve_dev
+com.qmth.datasource.password=exam_reserve_dev
+com.qmth.datasource.url=jdbc:mysql://${db.host}:${db.port}/${db.database}?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=GMT%2b8&rewriteBatchedStatements=true
+com.qmth.datasource.max-pool-size=200
+com.qmth.datasource.min-idle=10
+#
+# ********** redis config **********
+#
+com.qmth.redis.host=192.168.10.130
+com.qmth.redis.password=examcloud
+com.qmth.redis.port=6379
+com.qmth.redis.db=15
+#
+# ********** file config **********
+#
+com.qmth.fss.config=/home/admin/project/exam-reserve/static
+com.qmth.fss.server=http://192.168.10.41:8300/file
+#
+# ********** sys config **********
+#
+com.qmth.mybatis.block-attack=false
+com.qmth.mybatis.log-level=info
+com.qmth.logging.root-level=info
+com.qmth.logging.file-path=logs/exam-reserve.log
+#
+# ********** auth config **********
+#
+com.qmth.auth.time-max-delay=10m
+com.qmth.auth.time-max-ahead=10m
+#
+# ********** api rate limit config **********
+#
+com.qmth.api_limit_expression=200/1s
+#
+# ********** wx config **********
+#
+wx.app_id=wx90d496f6838bcff7
+wx.app_secret=7802a1c8ff50344977fa0c18b4d147a8

+ 0 - 0
src/main/resources/application-prod.properties


+ 5 - 2
src/main/resources/application-test.properties

@@ -11,7 +11,7 @@ spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
 spring.jackson.time-zone=GMT+8
 server.tomcat.threads.max=800
 server.tomcat.max-connections=20000
-server.tomcat.connection-timeout=90000
+server.tomcat.connection-timeout=60000
 #
 # ********** mysql config **********
 #
@@ -48,8 +48,11 @@ com.qmth.logging.file-path=logs/exam-reserve.log
 com.qmth.auth.time-max-delay=10m
 com.qmth.auth.time-max-ahead=10m
 #
+# ********** api rate limit config **********
+#
+com.qmth.api_limit_expression=200/1s
+#
 # ********** wx config **********
 #
 wx.app_id=wx90d496f6838bcff7
 wx.app_secret=7802a1c8ff50344977fa0c18b4d147a8
-

+ 1 - 55
src/main/resources/application.properties

@@ -1,55 +1 @@
-#
-# ********** server config **********
-#
-server.port=8080
-server.servlet.context-path=/
-server.servlet.session.timeout=PT2H
-spring.servlet.multipart.max-request-size=100MB
-spring.servlet.multipart.max-file-size=100MB
-spring.main.allow-bean-definition-overriding=true
-spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
-spring.jackson.time-zone=GMT+8
-server.tomcat.threads.max=800
-server.tomcat.max-connections=20000
-server.tomcat.connection-timeout=90000
-#
-# ********** mysql config **********
-#
-db.host=192.168.10.30
-db.port=3306
-db.database=exam_reserve_db
-com.qmth.datasource.username=exam_reserve_dev
-com.qmth.datasource.password=exam_reserve_dev
-com.qmth.datasource.url=jdbc:mysql://${db.host}:${db.port}/${db.database}?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=GMT%2b8&rewriteBatchedStatements=true
-com.qmth.datasource.max-pool-size=200
-com.qmth.datasource.min-idle=10
-#
-# ********** redis config **********
-#
-com.qmth.redis.host=192.168.10.130
-com.qmth.redis.password=examcloud
-com.qmth.redis.port=6379
-com.qmth.redis.db=15
-#
-# ********** file config **********
-#
-com.qmth.fss.config=/home/admin/project/exam-reserve/static
-com.qmth.fss.server=http://192.168.10.41:8300/file
-#
-# ********** sys config **********
-#
-com.qmth.mybatis.block-attack=false
-com.qmth.mybatis.log-level=info
-com.qmth.logging.root-level=info
-com.qmth.logging.file-path=logs/exam-reserve.log
-#
-# ********** auth config **********
-#
-com.qmth.auth.time-max-delay=10m
-com.qmth.auth.time-max-ahead=10m
-#
-# ********** wx config **********
-#
-wx.app_id=wx90d496f6838bcff7
-wx.app_secret=7802a1c8ff50344977fa0c18b4d147a8
-
+spring.profiles.active=dev