瀏覽代碼

update logs

deason 1 年之前
父節點
當前提交
ac27eeb3cc

+ 3 - 1
src/main/java/com/qmth/exam/reserve/bean/Constants.java

@@ -5,7 +5,9 @@ package com.qmth.exam.reserve.bean;
  */
  */
 public interface Constants {
 public interface Constants {
 
 
-    String SYSTEM_BUSY = "当前请求繁忙,请稍后再试!";
+    String SYSTEM_BUSY = "当前系统繁忙,请稍后再试!";
+
+    String REQUEST_API_BUSY = "当前请求繁忙,请稍后再试!";
 
 
     /**
     /**
      * 接口限流规则:N次/N秒
      * 接口限流规则:N次/N秒

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

@@ -45,7 +45,7 @@ public class StudentApplyController extends BaseController {
                      @ApiParam("预约时段ID") @RequestParam Long timePeriodId) {
                      @ApiParam("预约时段ID") @RequestParam Long timePeriodId) {
         RateLimitRule limitRule = RateLimitRule.parse(Constants.API_LIMIT_EXPRESSION);
         RateLimitRule limitRule = RateLimitRule.parse(Constants.API_LIMIT_EXPRESSION);
         if (!rateLimitService.getRateLimiter("apply_save", null, limitRule).acquire()) {
         if (!rateLimitService.getRateLimiter("apply_save", null, limitRule).acquire()) {
-            throw DefaultExceptionEnum.RATE_LIMITED.exception(Constants.SYSTEM_BUSY);
+            throw DefaultExceptionEnum.RATE_LIMITED.exception(Constants.REQUEST_API_BUSY);
         }
         }
 
 
         examReserveService.saveStudentApply(curLoginStudent(), examSiteId, timePeriodId);
         examReserveService.saveStudentApply(curLoginStudent(), examSiteId, timePeriodId);
@@ -57,7 +57,7 @@ public class StudentApplyController extends BaseController {
                        @ApiParam("预约时段ID") @RequestParam Long timePeriodId) {
                        @ApiParam("预约时段ID") @RequestParam Long timePeriodId) {
         RateLimitRule limitRule = RateLimitRule.parse(Constants.API_LIMIT_EXPRESSION);
         RateLimitRule limitRule = RateLimitRule.parse(Constants.API_LIMIT_EXPRESSION);
         if (!rateLimitService.getRateLimiter("apply_cancel", null, limitRule).acquire()) {
         if (!rateLimitService.getRateLimiter("apply_cancel", null, limitRule).acquire()) {
-            throw DefaultExceptionEnum.RATE_LIMITED.exception(Constants.SYSTEM_BUSY);
+            throw DefaultExceptionEnum.RATE_LIMITED.exception(Constants.REQUEST_API_BUSY);
         }
         }
 
 
         examReserveService.cancelStudentApply(curLoginStudent(), examSiteId, timePeriodId);
         examReserveService.cancelStudentApply(curLoginStudent(), examSiteId, timePeriodId);
@@ -74,7 +74,7 @@ public class StudentApplyController extends BaseController {
     public List<ApplyVO> listForCurrent() {
     public List<ApplyVO> listForCurrent() {
         RateLimitRule limitRule = RateLimitRule.parse(Constants.API_LIMIT_EXPRESSION);
         RateLimitRule limitRule = RateLimitRule.parse(Constants.API_LIMIT_EXPRESSION);
         if (!rateLimitService.getRateLimiter("apply_list", null, limitRule).acquire()) {
         if (!rateLimitService.getRateLimiter("apply_list", null, limitRule).acquire()) {
-            throw DefaultExceptionEnum.RATE_LIMITED.exception(Constants.SYSTEM_BUSY);
+            throw DefaultExceptionEnum.RATE_LIMITED.exception(Constants.REQUEST_API_BUSY);
         }
         }
 
 
         return examReserveService.getStudentApplyListForCurrent(curLoginStudent());
         return examReserveService.getStudentApplyListForCurrent(curLoginStudent());

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

@@ -1,14 +1,5 @@
 package com.qmth.exam.reserve.controller.student;
 package com.qmth.exam.reserve.controller.student;
 
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-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.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-
 import com.qmth.boot.api.annotation.Aac;
 import com.qmth.boot.api.annotation.Aac;
 import com.qmth.boot.api.constant.ApiConstant;
 import com.qmth.boot.api.constant.ApiConstant;
 import com.qmth.boot.core.exception.StatusException;
 import com.qmth.boot.core.exception.StatusException;
@@ -20,10 +11,13 @@ import com.qmth.exam.reserve.controller.BaseController;
 import com.qmth.exam.reserve.service.StudentService;
 import com.qmth.exam.reserve.service.StudentService;
 import com.qmth.exam.reserve.weixin.OauthAccessTokenRequest;
 import com.qmth.exam.reserve.weixin.OauthAccessTokenRequest;
 import com.qmth.exam.reserve.weixin.response.OauthAccessTokenResponseJson;
 import com.qmth.exam.reserve.weixin.response.OauthAccessTokenResponseJson;
-
 import io.swagger.annotations.Api;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
 import io.swagger.annotations.ApiParam;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
 
 
 @RestController
 @RestController
 @Api(tags = "【考生端】考生相关接口")
 @Api(tags = "【考生端】考生相关接口")
@@ -59,17 +53,16 @@ public class StudentController extends BaseController {
     }
     }
 
 
     @Aac(strict = false, auth = false)
     @Aac(strict = false, auth = false)
-    @ApiOperation(value = "获取用户的openid")
+    @ApiOperation(value = "获取微信用户的openid")
     @PostMapping(value = "/wechat/get/openid")
     @PostMapping(value = "/wechat/get/openid")
-    public String getOpenid(@ApiParam("微信平台返回的用户code") @RequestParam String code) {
-        OauthAccessTokenRequest tokenRequest = new OauthAccessTokenRequest(code, wxProperty.getAppId(),
-                wxProperty.getAppSecret());
-        OauthAccessTokenResponseJson responseJson = tokenRequest.request();
-        if (responseJson.getErrcode() != 0) {
-            log.warn("openId获取失败:用户code:" + code);
-            throw new StatusException(Constants.SYSTEM_BUSY);
+    public String getOpenid(@ApiParam("微信用户code") @RequestParam String code) {
+        OauthAccessTokenRequest tokenRequest = new OauthAccessTokenRequest(code, wxProperty.getAppId(), wxProperty.getAppSecret());
+        OauthAccessTokenResponseJson response = tokenRequest.request();
+        if (response.getErrcode() != 0) {
+            log.warn("获取微信用户的openid失败!code:{}", code);
+            throw new StatusException(Constants.REQUEST_API_BUSY);
         }
         }
-        return responseJson.getOpenid();
+        return response.getOpenid();
     }
     }
 
 
 }
 }

+ 2 - 2
src/main/java/com/qmth/exam/reserve/controller/student/StudentLoginController.java

@@ -40,7 +40,7 @@ public class StudentLoginController extends BaseController {
     public LoginUser login(@RequestBody LoginReq req) {
     public LoginUser login(@RequestBody LoginReq req) {
         RateLimitRule limitRule = RateLimitRule.parse(Constants.API_LIMIT_EXPRESSION);
         RateLimitRule limitRule = RateLimitRule.parse(Constants.API_LIMIT_EXPRESSION);
         if (!rateLimitService.getRateLimiter("student_login", null, limitRule).acquire()) {
         if (!rateLimitService.getRateLimiter("student_login", null, limitRule).acquire()) {
-            throw DefaultExceptionEnum.RATE_LIMITED.exception(Constants.SYSTEM_BUSY);
+            throw DefaultExceptionEnum.RATE_LIMITED.exception(Constants.REQUEST_API_BUSY);
         }
         }
 
 
         return authService.studentLogin(req);
         return authService.studentLogin(req);
@@ -51,7 +51,7 @@ public class StudentLoginController extends BaseController {
     public LoginUser loginForWechat(@RequestBody WechatLoginReq req) {
     public LoginUser loginForWechat(@RequestBody WechatLoginReq req) {
         RateLimitRule limitRule = RateLimitRule.parse(Constants.API_LIMIT_EXPRESSION);
         RateLimitRule limitRule = RateLimitRule.parse(Constants.API_LIMIT_EXPRESSION);
         if (!rateLimitService.getRateLimiter("wechat_login", null, limitRule).acquire()) {
         if (!rateLimitService.getRateLimiter("wechat_login", null, limitRule).acquire()) {
-            throw DefaultExceptionEnum.RATE_LIMITED.exception(Constants.SYSTEM_BUSY);
+            throw DefaultExceptionEnum.RATE_LIMITED.exception(Constants.REQUEST_API_BUSY);
         }
         }
 
 
         return authService.wechatLogin(req);
         return authService.wechatLogin(req);