|  |  | 
 |  |  | import com.doumee.core.model.LoginUserInfo; | 
 |  |  | import com.doumee.core.utils.Constants; | 
 |  |  | import com.doumee.dao.system.dto.LoginDTO; | 
 |  |  | import com.doumee.service.common.CaptchaService; | 
 |  |  | import com.doumee.service.system.SystemLoginService; | 
 |  |  | import com.doumee.service.system.SystemUserService; | 
 |  |  | import io.swagger.annotations.Api; | 
 |  |  | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private SystemLoginService systemLoginService; | 
 |  |  |     @Autowired | 
 |  |  |     private CaptchaService captchaService; | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * @author Eva.Caesar Liu | 
 |  |  |      * @date 2023/03/21 14:49 | 
 |  |  |      */ | 
 |  |  |     @ApiOperation("获取图片验证码") | 
 |  |  |     @GetMapping("/captcha") | 
 |  |  |     public ApiResponse<CaptchaService.Captcha> getCaptcha() { | 
 |  |  |         return ApiResponse.success(captchaService.genCaptcha()); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @PreventRepeat(limit = 10, lockTime = 10000) | 
 |  |  |     @ApiOperation("登录") | 
 |  |  | 
 |  |  |         }catch (BusinessException e){ | 
 |  |  |             return ApiResponse.failed(e.getCode(),e.getMessage()); | 
 |  |  |         }catch (Exception e){ | 
 |  |  |             e.printStackTrace(); | 
 |  |  |             return ApiResponse.failed(ResponseStatus.SERVER_ERROR); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     @PreventRepeat(limit = 10, lockTime = 10000) | 
 |  |  |     @ApiOperation("H5业务登录") | 
 |  |  |     @PostMapping("/loginH5") | 
 |  |  |     @LoginNoRequired | 
 |  |  |     public ApiResponse<String> loginH5 (@Validated @RequestBody LoginDTO dto, ServerWebExchange serverWebExchange) { | 
 |  |  |         try { | 
 |  |  |             ServerHttpRequest request = serverWebExchange.getRequest(); | 
 |  |  |             dto.setCheckCode(false); | 
 |  |  |             LoginUserInfo user = systemLoginService.loginByPasswordNew(dto,request); | 
 |  |  |             String token = jwtTokenUtil.generateToken(user); | 
 |  |  |             return ApiResponse.success(token); | 
 |  |  |         }catch (BusinessException e){ | 
 |  |  |             return ApiResponse.failed(e.getCode(),e.getMessage()); | 
 |  |  |         }catch (Exception e){ | 
 |  |  |             e.printStackTrace(); | 
 |  |  |             return ApiResponse.failed(ResponseStatus.SERVER_ERROR); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  | 
 |  |  |      */ | 
 |  |  |     @PostMapping("/refreshtoken") | 
 |  |  |     @ApiOperation("刷新token") | 
 |  |  |     public ApiResponse<String> refreshtoken(@RequestHeader("userToken") String oldToken){ | 
 |  |  |     public ApiResponse<String> refreshtoken(@RequestHeader(Constants.HEADER_USER_TOKEN) String oldToken){ | 
 |  |  |         try { | 
 |  |  |             if(!jwtTokenUtil.isTokenExpired(oldToken)){ | 
 |  |  |                 return ApiResponse.success(jwtTokenUtil.refreshToken(oldToken)); | 
 |  |  | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |     } | 
 |  |  |     /** | 
 |  |  |      * 刷新JWT令牌,用旧的令牌换新的令牌 | 
 |  |  |      */ | 
 |  |  |     @PostMapping("/logout") | 
 |  |  |     @ApiOperation("退出登陆") | 
 |  |  |     public ApiResponse<String> logout(@RequestHeader(Constants.HEADER_USER_TOKEN) String oldToken){ | 
 |  |  |         try { | 
 |  |  |              jwtTokenUtil.logout(oldToken); | 
 |  |  |         }catch (BusinessException e){ | 
 |  |  |             return ApiResponse.failed(e.getCode(),e.getMessage()); | 
 |  |  |         }catch (Exception e){ | 
 |  |  |             return ApiResponse.failed(ResponseStatus.SERVER_ERROR); | 
 |  |  |         } | 
 |  |  |         return ApiResponse.success(null); | 
 |  |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 刷新JWT令牌,用旧的令牌换新的令牌 |