| | |
| | | package com.moral.api.controller; |
| | | |
| | | import com.moral.api.pojo.dto.LoginDTO; |
| | | import com.moral.api.service.ManageAccountService; |
| | | import com.moral.constant.Constants; |
| | | import com.moral.constant.ResultMessage; |
| | | import com.moral.util.ObjectUtils; |
| | | import io.swagger.annotations.*; |
| | |
| | | |
| | | |
| | | @PostMapping("login") |
| | | public ResultMessage login(@RequestBody Map<String, Object> paramters) { |
| | | if (!ObjectUtils.checkParamAndMap(paramters, "account", "password")) |
| | | return ResultMessage.fail("参数不完整"); |
| | | public ResultMessage login(@RequestBody Map<String, Object> parameters) { |
| | | if (!ObjectUtils.isNotAllEmpty(parameters, "account", "password")) |
| | | return ResultMessage.fail(Constants.CODE_PARAMETER_IS_MISSING,Constants.MSG_PARAMETER_IS_MISSING); |
| | | String AESAccount = (String) parameters.get("account"); |
| | | String AESPassword = (String) parameters.get("password"); |
| | | |
| | | Map<String, Object> result = accountService.login(paramters); |
| | | LoginDTO loginDTO = accountService.login(AESAccount,AESPassword); |
| | | |
| | | if ((int) result.get("accountId") < 0) |
| | | return ResultMessage.fail(result); |
| | | return ResultMessage.ok(result); |
| | | if(loginDTO.getCode().equals(LoginDTO.SUCCESS)) |
| | | return ResultMessage.ok(loginDTO); |
| | | return ResultMessage.fail(loginDTO); |
| | | } |
| | | |
| | | |
| | | @PostMapping("logout") |
| | | public ResultMessage logout(@RequestBody Map<String, Object> paramters, HttpServletRequest request) { |
| | | public ResultMessage logout(@RequestBody Map<String, Object> parameters, HttpServletRequest request) { |
| | | if(!ObjectUtils.isNotAllEmpty(parameters,"accountId")) |
| | | return ResultMessage.fail(Constants.CODE_PARAMETER_IS_MISSING,Constants.MSG_PARAMETER_IS_MISSING); |
| | | String token = request.getHeader("token"); |
| | | |
| | | return null; |
| | | if(accountService.logout(String.valueOf(parameters.get("accountId")),token)) |
| | | return ResultMessage.ok("注销成功"); |
| | | return ResultMessage.fail("注销异常"); |
| | | |
| | | } |
| | | |
| | | |