| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.moral.api.entity.SysConfig; |
| | | import com.moral.api.entity.UserLog; |
| | | import com.moral.api.service.SysConfigService; |
| | | import com.moral.api.service.UserLogService; |
| | | import com.moral.api.service.UserService; |
| | | import com.moral.constant.Constants; |
| | | import com.moral.constant.ResponseCodeEnum; |
| | |
| | | import com.moral.pojo.VerificationCode; |
| | | import com.moral.util.KaptchaUtils; |
| | | import com.moral.util.TokenUtils; |
| | | import com.moral.util.WebUtils; |
| | | |
| | | @Slf4j |
| | | @Api(tags = {"登陆"}) |
| | |
| | | @Autowired |
| | | private SysConfigService sysConfigService; |
| | | |
| | | @Autowired |
| | | private UserLogService userLogService; |
| | | |
| | | @ApiOperation(value = "登陆", notes = "登陆") |
| | | @RequestMapping(value = "login", method = RequestMethod.POST) |
| | | public ResultMessage login(@RequestBody Map<String, Object> parameters) { |
| | | public ResultMessage login(@RequestBody Map<String, Object> parameters, HttpServletRequest request) { |
| | | if (!(parameters.containsKey("account") && parameters.containsKey("password"))) { |
| | | return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), |
| | | ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); |
| | |
| | | if (!result.containsKey("data")) { |
| | | return ResultMessage.fail((int) result.get("code"), (String) result.get("msg")); |
| | | } |
| | | return ResultMessage.ok(result.get("data")); |
| | | Map<String, Object> data = (Map<String, Object>) result.get("data"); |
| | | Map<String, Object> userInfo = (Map<String, Object>) data.get("user"); |
| | | UserLog userLog = new UserLog(); |
| | | String ip = WebUtils.getIpAddr(request); |
| | | userLog.setIp(ip); |
| | | userLog.setOperateId((Integer) userInfo.get("userId")); |
| | | Map<String, Object> organization = (Map<String, Object>) userInfo.get("organization"); |
| | | userLog.setOrganizationId((Integer) organization.get("id")); |
| | | userLog.setContent(userInfo.get("account") + "登陆了"); |
| | | userLogService.save(userLog); |
| | | return ResultMessage.ok(data); |
| | | } |
| | | |
| | | @ApiOperation(value = "退出", notes = "退出") |