From 3ce81d9c75bd4b0d7a54f906d1cd94fcecf9aab7 Mon Sep 17 00:00:00 2001 From: macro Date: Sun, 10 Nov 2019 10:45:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BC=9A=E5=91=98=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/UmsMemberController.java | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/mall-portal/src/main/java/com/macro/mall/portal/controller/UmsMemberController.java b/mall-portal/src/main/java/com/macro/mall/portal/controller/UmsMemberController.java index 655b9f9..5fdb856 100644 --- a/mall-portal/src/main/java/com/macro/mall/portal/controller/UmsMemberController.java +++ b/mall-portal/src/main/java/com/macro/mall/portal/controller/UmsMemberController.java @@ -5,12 +5,16 @@ import com.macro.mall.portal.service.UmsMemberService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; +import java.util.HashMap; +import java.util.Map; + /** * 会员登录注册管理Controller * Created by macro on 2018/8/3. @@ -19,10 +23,12 @@ import org.springframework.web.bind.annotation.ResponseBody; @Api(tags = "UmsMemberController", description = "会员登录注册管理") @RequestMapping("/sso") public class UmsMemberController { + @Value("${jwt.tokenHead}") + private String tokenHead; @Autowired private UmsMemberService memberService; - @ApiOperation("注册") + @ApiOperation("会员注册") @RequestMapping(value = "/register", method = RequestMethod.POST) @ResponseBody public CommonResult register(@RequestParam String username, @@ -32,6 +38,21 @@ public class UmsMemberController { return memberService.register(username, password, telephone, authCode); } + @ApiOperation("会员登录") + @RequestMapping(value = "/login", method = RequestMethod.POST) + @ResponseBody + public CommonResult login(@RequestParam String username, + @RequestParam String password) { + String token = memberService.login(username, password); + if (token == null) { + return CommonResult.validateFailed("用户名或密码错误"); + } + Map tokenMap = new HashMap<>(); + tokenMap.put("token", token); + tokenMap.put("tokenHead", tokenHead); + return CommonResult.success(tokenMap); + } + @ApiOperation("获取验证码") @RequestMapping(value = "/getAuthCode", method = RequestMethod.GET) @ResponseBody