From 1ec0374d08be45c6c6854705211dbd6c067dfab7 Mon Sep 17 00:00:00 2001 From: kaiyu <404897439@qq.com> Date: Thu, 18 Mar 2021 17:23:20 +0800 Subject: [PATCH] Merge branch 'dev' of http://blit.7drlb.com:8888/r/moral into dev --- screen-api/src/main/java/com/moral/api/controller/LoginController.java | 40 +++++----------------------------------- 1 files changed, 5 insertions(+), 35 deletions(-) diff --git a/screen-api/src/main/java/com/moral/api/controller/LoginController.java b/screen-api/src/main/java/com/moral/api/controller/LoginController.java index a6cef12..6b1a304 100644 --- a/screen-api/src/main/java/com/moral/api/controller/LoginController.java +++ b/screen-api/src/main/java/com/moral/api/controller/LoginController.java @@ -1,6 +1,5 @@ package com.moral.api.controller; -import com.moral.constant.Constants; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; @@ -12,19 +11,15 @@ import javax.servlet.http.HttpServletRequest; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import com.moral.api.entity.Group; -import com.moral.api.entity.User; import com.moral.api.service.GroupService; import com.moral.api.service.UserService; import com.moral.constant.ResponseCodeEnum; import com.moral.constant.ResultMessage; -import com.moral.util.AESUtils; -import com.moral.util.MD5Utils; import com.moral.util.TokenUtils; import com.moral.util.WebUtils; @@ -39,9 +34,6 @@ @Autowired private GroupService groupService; - @Value("${AES.KEY}") - private String AESKey; - @ApiOperation(value = "������", notes = "������") @ApiImplicitParams({ @ApiImplicitParam(name = "account", value = "������", required = false, paramType = "query", dataType = "String"), @@ -53,33 +45,11 @@ if (!(parameters.containsKey("account") && parameters.containsKey("password"))) { return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); } - //������������ - String password = parameters.get("password").toString(); - //������������ - password = AESUtils.decrypt(password, AESKey); - - User user = userService.selectUserInfo(parameters); - //������������ - if (user == null) { - return ResultMessage.fail(ResponseCodeEnum.ACCOUNT_NOT_EXIST.getCode(), ResponseCodeEnum.ACCOUNT_NOT_EXIST.getMsg()); + Map<String, Object> result = userService.login(parameters); + if (!result.containsKey("data")) { + return ResultMessage.fail(Integer.parseInt(result.get("code").toString()), result.get("msg").toString()); } - //������������ - if (!MD5Utils.saltMD5Verify(password, user.getPassword())) { - return ResultMessage.fail(ResponseCodeEnum.PASSWORD_INVALID.getCode(), ResponseCodeEnum.PASSWORD_INVALID.getMsg()); - } - //������������������ - if (Constants.DELETE.equals(user.getIsDelete())) { - return ResultMessage.fail(ResponseCodeEnum.ACCOUNT_IS_DELETE.getCode(), ResponseCodeEnum.ACCOUNT_IS_DELETE.getMsg()); - } - //������������������ - if (user.getExpireTime() != null && user.getExpireTime().getTime() < System.currentTimeMillis()) { - return ResultMessage.fail(ResponseCodeEnum.ACCOUNT_IS_EXPIRE.getCode(), ResponseCodeEnum.ACCOUNT_IS_EXPIRE.getMsg()); - } - Map<String, Object> result = userService.login(user); - if (!result.containsKey("token")) { - return ResultMessage.fail(ResponseCodeEnum.TOKEN_CREATE_ERROR.getCode(), ResponseCodeEnum.TOKEN_CREATE_ERROR.getMsg()); - } - return ResultMessage.ok(); + return ResultMessage.ok(result.get("data")); } @ApiOperation(value = "������", notes = "������") @@ -89,7 +59,7 @@ if (!parameters.containsKey("uid")) { return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); } - String userId = request.getParameter("uid"); + String userId = parameters.get("uid").toString(); String token = request.getHeader("token"); TokenUtils.destoryToken(userId, token); return ResultMessage.ok(); -- Gitblit v1.8.0