From ba9c4bca1bdf36f827ab258222d92c885ff890db Mon Sep 17 00:00:00 2001 From: jinpengyong <jpy123456> Date: Tue, 05 Sep 2023 08:43:01 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/wb' into qa --- screen-api/src/main/java/com/moral/api/controller/LoginController.java | 72 +++++++++++++++++++----------------- 1 files changed, 38 insertions(+), 34 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 faf1d3b..b93a263 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 @@ -10,25 +10,27 @@ import java.util.Map; import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.ObjectUtils; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.moral.api.entity.SysConfig; import com.moral.api.service.SysConfigService; import com.moral.api.service.UserService; +import com.moral.constant.Constants; import com.moral.constant.ResponseCodeEnum; import com.moral.constant.ResultMessage; import com.moral.pojo.VerificationCode; import com.moral.util.KaptchaUtils; import com.moral.util.TokenUtils; -import com.moral.util.WebUtils; @Slf4j @Api(tags = {"������"}) @RestController +@CrossOrigin(origins = "*", maxAge = 3600) public class LoginController { @Autowired @@ -37,53 +39,55 @@ @Autowired private SysConfigService sysConfigService; - @ApiOperation(value = "������", notes = "������") - @ApiImplicitParams({ - @ApiImplicitParam(name = "account", value = "������", required = true, paramType = "query", dataType = "String"), - @ApiImplicitParam(name = "password", value = "������", required = true, paramType = "query", dataType = "String") - }) + @ApiOperation(value = "������������", notes = "������������") @RequestMapping(value = "login", method = RequestMethod.POST) - public ResultMessage login(HttpServletRequest request) { - Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null); + public ResultMessage login(@RequestBody Map<String, Object> parameters) { if (!(parameters.containsKey("account") && parameters.containsKey("password"))) { - return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); + return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), + ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); } Map<String, Object> result = userService.login(parameters); - if (!result.containsKey("data")) { + if (!result.containsKey("token")) { return ResultMessage.fail((int) result.get("code"), (String) result.get("msg")); } - return ResultMessage.ok(result.get("data")); + return ResultMessage.ok(result); } - @ApiOperation(value = "������", notes = "������") - @RequestMapping(value = "logout", method = RequestMethod.POST) + @ApiOperation(value = "������������������", notes = "������������������") @ApiImplicitParams({ - @ApiImplicitParam(name = "uid", value = "������", required = false, paramType = "query", dataType = "String"), @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String") }) - public ResultMessage logout(HttpServletRequest request) { - Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null); - if (!parameters.containsKey("uid")) { - return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); + @RequestMapping(value = "getUserInfo", method = RequestMethod.POST) + public ResultMessage getUserInfo() { + Map<String, Object> result = userService.getCurrentUserInfo(); + return ResultMessage.ok(result); + } + + @ApiOperation(value = "������", notes = "������") + @RequestMapping(value = "logout", method = RequestMethod.GET) + @ApiImplicitParams({ + @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String") + }) + public ResultMessage logout(Integer userId, HttpServletRequest request) { + if (userId == null) { + return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), + ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); } - String userId = parameters.get("uid").toString(); String token = request.getHeader("token"); - TokenUtils.destoryToken(userId, token); + TokenUtils.destoryToken(userId.toString(), token); return ResultMessage.ok(); } - /** - * @Description: ��������������������������� - * @Param: [] - * @return: com.moral.constant.ResultMessage - * @Author: ��������� - * @Date: 2021/3/18 - */ - @ApiOperation(value = "���������������������������", notes = "���������������������������") - @RequestMapping(value = "verificationCodeConfig", method = RequestMethod.GET) - public ResultMessage verifyConfig() { - return null; + @RequestMapping(value = "verificationCode/config", method = RequestMethod.GET) + public ResultMessage verifyConfig(HttpServletResponse response) { + QueryWrapper<SysConfig> queryWrapper = new QueryWrapper<>(); + queryWrapper.eq(Constants.FRONT_VERIFICATIONCODE_COLUMN, Constants.FRONT_ERIFICATIONCODE_VALUE); + SysConfig sysConfig = sysConfigService.getOne(queryWrapper); + if (Constants.VERFICATIONCODE_OPEN.equals(sysConfig.getCode())) { + return new ResultMessage(ResponseCodeEnum.VERIFICATION_OPEN, null); + } + return new ResultMessage(ResponseCodeEnum.VERIFICATION_CLOSE, null); } @ApiOperation(value = "���������������", notes = "���������������") -- Gitblit v1.8.0