|
|
|
@@ -79,6 +79,7 @@ import javax.annotation.Resource; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import java.io.IOException; |
|
|
|
import java.util.*; |
|
|
|
import java.util.concurrent.TimeUnit; |
|
|
|
import java.util.regex.Matcher; |
|
|
|
import java.util.regex.Pattern; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
@@ -108,6 +109,10 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us |
|
|
|
@Value("${user.config.gpu-limit}") |
|
|
|
private Integer gpuLimit; |
|
|
|
|
|
|
|
@Value("${spring.mail.count-limit:6}") |
|
|
|
private Integer mailCountLimit; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
private UserMapper userMapper; |
|
|
|
|
|
|
|
@@ -885,17 +890,17 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us |
|
|
|
*/ |
|
|
|
private void limitSendEmail(final String receiverMailAddress) { |
|
|
|
double count = redisUtils.hincr(UserConstant.USER_EMAIL_LIMIT_COUNT.concat(receiverMailAddress), receiverMailAddress, 1); |
|
|
|
if (count > UserConstant.COUNT_SENT_EMAIL) { |
|
|
|
LogUtil.error(LogEnum.SYS_ERR, "Email verification code cannot exceed three times , error:{}", UserConstant.COUNT_SENT_EMAIL); |
|
|
|
if (count > mailCountLimit) { |
|
|
|
LogUtil.error(LogEnum.SYS_ERR, "Email verification code cannot exceed three times , error:{}", mailCountLimit); |
|
|
|
throw new BusinessException(BaseErrorCodeEnum.SYSTEM_USER_EMAIL_CODE_CANNOT_EXCEED_TIMES.getCode(), |
|
|
|
BaseErrorCodeEnum.SYSTEM_USER_EMAIL_CODE_CANNOT_EXCEED_TIMES.getMsg()); |
|
|
|
String.format(BaseErrorCodeEnum.SYSTEM_USER_EMAIL_CODE_CANNOT_EXCEED_TIMES.getMsg(), mailCountLimit)); |
|
|
|
} else { |
|
|
|
// 验证码次数凌晨清除 |
|
|
|
String concat = UserConstant.USER_EMAIL_LIMIT_COUNT.concat(receiverMailAddress); |
|
|
|
|
|
|
|
Long secondsNextEarlyMorning = DateUtil.getSecondTime(); |
|
|
|
|
|
|
|
redisUtils.expire(concat, secondsNextEarlyMorning); |
|
|
|
redisUtils.expire(concat, TimeUnit.MILLISECONDS.toSeconds(secondsNextEarlyMorning)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|