File tree Expand file tree Collapse file tree
common/src/main/java/com/ligg/common
flow-client/src/main/java/com/ligg/flowclient/service/impl Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package com .ligg .common .exception ;
2+
3+ /**
4+ * 更新操作频率超过限制时抛出
5+ */
6+ public class UpdateRateLimitException extends RuntimeException {
7+
8+ public UpdateRateLimitException (String message ) {
9+ super (message );
10+ }
11+ }
Original file line number Diff line number Diff line change 66import com .ligg .common .exception .LoginExpiredException ;
77import com .ligg .common .exception .AuthenticationFailedException ;
88import com .ligg .common .exception .AuthorizationException ;
9+ import com .ligg .common .exception .UpdateRateLimitException ;
910import com .ligg .common .exception .RateLimitExceededException ;
1011import com .ligg .common .exception .VerificationCodeException ;
1112import com .ligg .common .response .Result ;
@@ -178,6 +179,15 @@ public ResponseEntity<Result<Void>> handleRateLimitExceeded(RateLimitExceededExc
178179 .body (Result .error (ResponseCode .TOO_MANY_REQUESTS , ResponseCode .TOO_MANY_REQUESTS .getMessage ()));
179180 }
180181
182+ /**
183+ * 更新操作频率限制(正常 200,携带业务错误码)
184+ */
185+ @ ExceptionHandler (UpdateRateLimitException .class )
186+ public Result <Void > handleUpdateRateLimit (UpdateRateLimitException e ) {
187+ log .warn ("更新操作频率限制: {}" , e .getMessage ());
188+ return Result .error (ResponseCode .TOO_MANY_REQUESTS , e .getMessage ());
189+ }
190+
181191 /**
182192 * 验证码过期
183193 */
Original file line number Diff line number Diff line change 99import com .ligg .common .entity .UserEntity ;
1010import com .ligg .common .exception .AuthenticationFailedException ;
1111import com .ligg .common .exception .LoginExpiredException ;
12+ import com .ligg .common .exception .UpdateRateLimitException ;
1213import com .ligg .common .exception .RateLimitExceededException ;
1314import com .ligg .common .response .FlowTokenVo ;
1415import com .ligg .common .storage .ObjectStorageService ;
@@ -267,7 +268,7 @@ private void checkUserInfoUpdateDailyLimit(Long userId) {
267268 if (ttl > 0 ) {
268269 long minutes = ttl / 60 ;
269270 long seconds = ttl % 60 ;
270- throw new IllegalArgumentException (
271+ throw new UpdateRateLimitException (
271272 "用户信息更新过于频繁,请 %d 分 %d 秒后再试" .formatted (minutes , seconds )
272273 );
273274 }
@@ -279,7 +280,7 @@ private void checkAvatarUploadLimit(Long userId) {
279280 if (ttl > 0 ) {
280281 long minutes = ttl / 60 ;
281282 long seconds = ttl % 60 ;
282- throw new IllegalArgumentException (
283+ throw new UpdateRateLimitException (
283284 "头像更新过于频繁,请 %d 分 %d 秒后再试" .formatted (minutes , seconds )
284285 );
285286 }
You can’t perform that action at this time.
0 commit comments