|
@@ -2,11 +2,20 @@ package com.coffee.admin.controller.system;
|
|
|
|
|
|
|
|
import cn.dev33.satoken.stp.StpUtil;
|
|
import cn.dev33.satoken.stp.StpUtil;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
|
|
+import com.coffee.admin.controller.system.vo.UserPassVo;
|
|
|
import com.coffee.common.annotation.Log;
|
|
import com.coffee.common.annotation.Log;
|
|
|
import com.coffee.common.dto.LoginDTO;
|
|
import com.coffee.common.dto.LoginDTO;
|
|
|
|
|
+import com.coffee.common.exception.CustomException;
|
|
|
import com.coffee.common.result.R;
|
|
import com.coffee.common.result.R;
|
|
|
|
|
+import com.coffee.common.util.SecurityUtil;
|
|
|
import com.coffee.framework.web.service.IUserService;
|
|
import com.coffee.framework.web.service.IUserService;
|
|
|
import com.coffee.system.common.vo.AccountInfoVO;
|
|
import com.coffee.system.common.vo.AccountInfoVO;
|
|
|
|
|
+import com.coffee.system.entity.SysUser;
|
|
|
|
|
+import com.coffee.system.service.ISysUserService;
|
|
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
@@ -28,6 +37,8 @@ public class SysLoginController {
|
|
|
@Resource
|
|
@Resource
|
|
|
IUserService userService;
|
|
IUserService userService;
|
|
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ ISysUserService sysUserService;
|
|
|
@Log(title = "登录")
|
|
@Log(title = "登录")
|
|
|
@PostMapping("/login")
|
|
@PostMapping("/login")
|
|
|
public R login(@Validated @RequestBody LoginDTO req) {
|
|
public R login(@Validated @RequestBody LoginDTO req) {
|
|
@@ -37,6 +48,22 @@ public class SysLoginController {
|
|
|
return R.success(result);
|
|
return R.success(result);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @ApiOperation("修改密码")
|
|
|
|
|
+ @PostMapping(value = "/updatePass")
|
|
|
|
|
+ public ResponseEntity<Object> updatePass(@RequestBody @Validated UserPassVo passVo) throws Exception {
|
|
|
|
|
+ // 密码解密
|
|
|
|
|
+ Long userId = SecurityUtil.getSysUser().getId();
|
|
|
|
|
+ SysUser sysUser = sysUserService.getById(userId);
|
|
|
|
|
+ if (!SecurityUtil.matchesPassword(passVo.getOldPass(), sysUser.getPassword())) {
|
|
|
|
|
+ throw new CustomException("旧密码不正确");
|
|
|
|
|
+ }
|
|
|
|
|
+ String encryptPassword = SecurityUtil.encryptPassword(sysUser.getPassword());
|
|
|
|
|
+ sysUserService
|
|
|
|
|
+ .update(new UpdateWrapper<SysUser>()
|
|
|
|
|
+ .lambda().eq(SysUser::getId,userId)
|
|
|
|
|
+ .set(SysUser::getPassword,encryptPassword));
|
|
|
|
|
+ return new ResponseEntity<>(HttpStatus.OK);
|
|
|
|
|
+ }
|
|
|
@Log(title = "获取用户信息")
|
|
@Log(title = "获取用户信息")
|
|
|
@GetMapping("/getUserInfo")
|
|
@GetMapping("/getUserInfo")
|
|
|
public R getUserInfo() {
|
|
public R getUserInfo() {
|