deason 1 tahun lalu
induk
melakukan
12abd80b97

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

@@ -66,6 +66,11 @@ public class StudentApplyController extends BaseController {
     @ApiOperation(value = "获取考生预约结果列表(个人中心)")
     @PostMapping(value = "/apply/list")
     public List<ApplyVO> list(@ApiParam("是否已取消预约") @RequestParam(required = false) Boolean cancel) {
+        RateLimitRule limitRule = RateLimitRule.parse(Constants.API_LIMIT_EXPRESSION);
+        if (!rateLimitService.getRateLimiter("apply_list", null, limitRule).acquire()) {
+            throw DefaultExceptionEnum.RATE_LIMITED.exception(Constants.REQUEST_API_BUSY);
+        }
+
         return examReserveService.getStudentApplyList(curLoginStudent(), cancel);
     }
 
@@ -109,6 +114,11 @@ public class StudentApplyController extends BaseController {
     @PostMapping(value = "/apply/time/period/list")
     public ApplyTimePeriodResult timePeriodList(@ApiParam("考点ID") @RequestParam Long examSiteId,
                                                 @ApiParam("预约日期:yyyyMMdd") @RequestParam String date) {
+        RateLimitRule limitRule = RateLimitRule.parse(Constants.API_LIMIT_EXPRESSION);
+        if (!rateLimitService.getRateLimiter("apply_time_list", null, limitRule).acquire()) {
+            throw DefaultExceptionEnum.RATE_LIMITED.exception(Constants.REQUEST_API_BUSY);
+        }
+
         return examReserveService.getApplyTimePeriodList(curLoginStudent(), examSiteId, date);
     }