|
@@ -6,6 +6,7 @@ import com.yunzhi.nanyang.entity.SysLogin;
|
6
|
6
|
import com.yunzhi.nanyang.entity.SysUser;
|
7
|
7
|
import com.yunzhi.nanyang.service.ISysLoginService;
|
8
|
8
|
import com.yunzhi.nanyang.service.ISysUserService;
|
|
9
|
+import com.yunzhi.nanyang.vo.ChangePassword;
|
9
|
10
|
import com.yunzhi.nanyang.vo.LoginParam;
|
10
|
11
|
import io.swagger.annotations.Api;
|
11
|
12
|
import io.swagger.annotations.ApiOperation;
|
|
@@ -89,25 +90,25 @@ public class LoginController extends BaseController {
|
89
|
90
|
return ResponseBean.error(msg, ResponseBean.ERROR_AUTH_FAIL);
|
90
|
91
|
}
|
91
|
92
|
|
92
|
|
-// @PutMapping("/admin/change-password")
|
93
|
|
-// @ApiOperation(value="修改密码", notes = "修改密码", httpMethod = "PUT", response = ResponseBean.class)
|
94
|
|
-// public ResponseBean changePassword(@ApiParam("修改密码参数") @RequestBody ChangePassword param) throws Exception {
|
95
|
|
-// if (StringUtils.isEmpty(param.getOriginPassword()) || StringUtils.isEmpty(param.getNewPassword())) {
|
96
|
|
-// return ResponseBean.error("原始密码或新密码不能为空", ResponseBean.ERROR_ILLEGAL_PARAMS);
|
97
|
|
-// }
|
98
|
|
-//
|
99
|
|
-// SysUser currentUser = getCurrentUser();
|
100
|
|
-// SysLogin sysLogin = iSysLoginService.getByUser(currentUser.getUserId());
|
101
|
|
-//
|
102
|
|
-// if (!checkPassword(param.getOriginPassword(), sysLogin.getPassword(), currentUser.getUserId())) {
|
103
|
|
-// return ResponseBean.error("原始密码不正确", ResponseBean.ERROR_ILLEGAL_PARAMS);
|
104
|
|
-// }
|
105
|
|
-//
|
106
|
|
-// sysLogin.setPassword(EncryptUtils.md5(param.getNewPassword(), currentUser.getUserId()));
|
107
|
|
-// iSysLoginService.updateById(sysLogin);
|
108
|
|
-//
|
109
|
|
-// return ResponseBean.success("密码修改成功");
|
110
|
|
-// }
|
|
93
|
+ @PutMapping("/admin/change-password")
|
|
94
|
+ @ApiOperation(value="修改密码", notes = "修改密码", httpMethod = "PUT", response = ResponseBean.class)
|
|
95
|
+ public ResponseBean changePassword(@ApiParam("修改密码参数") @RequestBody ChangePassword param) throws Exception {
|
|
96
|
+ if (StringUtils.isEmpty(param.getOriginPassword()) || StringUtils.isEmpty(param.getNewPassword())) {
|
|
97
|
+ return ResponseBean.error("原始密码或新密码不能为空", ResponseBean.ERROR_ILLEGAL_PARAMS);
|
|
98
|
+ }
|
|
99
|
+
|
|
100
|
+ SysUser currentUser = currentUser();
|
|
101
|
+ SysLogin sysLogin = iSysLoginService.getExistBy("user_id", currentUser.getUserId(), false, true);
|
|
102
|
+
|
|
103
|
+ if (!checkPassword(param.getOriginPassword(), sysLogin.getPassword(), currentUser.getUserId())) {
|
|
104
|
+ return ResponseBean.error("原始密码不正确", ResponseBean.ERROR_ILLEGAL_PARAMS);
|
|
105
|
+ }
|
|
106
|
+
|
|
107
|
+ sysLogin.setPassword(EncryptUtils.md5(param.getNewPassword(), currentUser.getUserId()));
|
|
108
|
+ iSysLoginService.updateById(sysLogin);
|
|
109
|
+
|
|
110
|
+ return ResponseBean.success("密码修改成功");
|
|
111
|
+ }
|
111
|
112
|
|
112
|
113
|
|
113
|
114
|
private boolean checkPassword(String src, String targ, String salt) {
|