|
@@ -2,9 +2,11 @@ package com.fdkankan.fusion.controller;
|
|
|
|
|
|
import cn.hutool.captcha.CaptchaUtil;
|
|
|
import cn.hutool.captcha.LineCaptcha;
|
|
|
+import com.fdkankan.fusion.common.ResultCode;
|
|
|
import com.fdkankan.fusion.common.ResultData;
|
|
|
import com.fdkankan.fusion.common.util.RedisKeyUtil;
|
|
|
import com.fdkankan.fusion.common.util.StringUtils;
|
|
|
+import com.fdkankan.fusion.exception.BusinessException;
|
|
|
import com.fdkankan.fusion.response.UserAddRequest;
|
|
|
import com.fdkankan.fusion.service.ITmUserService;
|
|
|
import com.fdkankan.redis.util.RedisUtil;
|
|
@@ -12,6 +14,7 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
@RestController
|
|
@@ -25,9 +28,22 @@ public class NoLoginController {
|
|
|
ITmUserService tmUserService;
|
|
|
|
|
|
@GetMapping("/getLoginAuthCode")
|
|
|
- public void getLoginCode(HttpServletResponse response){
|
|
|
+ public void getLoginCode(HttpServletRequest request, HttpServletResponse response){
|
|
|
response.setHeader("Cache-Control", "no-store, no-cache");
|
|
|
response.setContentType("image/jpeg");
|
|
|
+ String sessionId = request.getSession().getId();
|
|
|
+
|
|
|
+ log.info("request--sessionId:{}",sessionId);
|
|
|
+ if(redisUtil.hasKey(sessionId)){
|
|
|
+ String value = redisUtil.get(sessionId);
|
|
|
+ String newValue = value +"1";
|
|
|
+ if(newValue.equals("11111")){
|
|
|
+ throw new BusinessException(ResultCode.LOGIN_AUTH_ERROR);
|
|
|
+ }
|
|
|
+ redisUtil.set(sessionId,value +"1",60);
|
|
|
+ }else {
|
|
|
+ redisUtil.set(sessionId, "1",60);
|
|
|
+ }
|
|
|
|
|
|
try {
|
|
|
LineCaptcha lineCaptcha = CaptchaUtil.createLineCaptcha(200, 100,4,60);
|