From 6be4ac7a62df26912f11b953217d2089d7af583e Mon Sep 17 00:00:00 2001 From: weihongyang <1075331873@qq.com> Date: Thu, 23 Jun 2022 13:57:30 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E9=AA=8C=E8=AF=81?= =?UTF-8?q?=E7=A0=81=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/controller/LoginController.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/ym-admin/src/main/java/com/cnbm/admin/controller/LoginController.java b/ym-admin/src/main/java/com/cnbm/admin/controller/LoginController.java index 66bc7a8..c3f622e 100644 --- a/ym-admin/src/main/java/com/cnbm/admin/controller/LoginController.java +++ b/ym-admin/src/main/java/com/cnbm/admin/controller/LoginController.java @@ -2,9 +2,13 @@ package com.cnbm.admin.controller; import com.cnbm.admin.handler.LogoutSuccessHandlerImpl; import com.cnbm.admin.params.LoginParam; +import com.cnbm.admin.service.CaptchaService; import com.cnbm.admin.service.LoginService; import com.cnbm.admin.utils.ResponseResult; +import com.cnbm.common.exception.ErrorCode; +import com.cnbm.common.validator.AssertUtils; import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiOperation; import lombok.extern.log4j.Log4j2; import org.springframework.beans.factory.annotation.Autowired; @@ -17,6 +21,7 @@ import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import java.io.IOException; /** * @Author weihongyang @@ -31,6 +36,20 @@ public class LoginController { @Autowired private LoginService loginService; + @Autowired + private CaptchaService captchaService; + + @GetMapping("/captcha") + @ApiOperation(value = "验证码", produces="application/octet-stream") + @ApiImplicitParam(paramType = "query", dataTypeClass=String.class, name = "uuid", required = true) + public void captcha(HttpServletResponse response, String uuid)throws IOException { + //uuid不能为空 + AssertUtils.isBlank(uuid, ErrorCode.IDENTIFIER_NOT_NULL); + + //生成验证码 + captchaService.create(response, uuid); + } + @PostMapping("/login") @ApiOperation(value = "登录") public ResponseResult login(HttpServletRequest request, @RequestBody LoginParam loginParam) {