添加密码修改的api
This commit is contained in:
@@ -93,6 +93,14 @@ public class UserController {
|
||||
return ResponseUtil.success(userService.reSetPwd(verifyId, email, pwd));
|
||||
}
|
||||
|
||||
@PostMapping("/user/setPwd")
|
||||
public Response setPwd(@RequestParam("pwd") String pwd,
|
||||
@RequestParam("newPwd") String newPwd,
|
||||
@RequestParam("confirmPwd") String confirmPwd) {
|
||||
return ResponseUtil.success(userService.setPwd(pwd,newPwd,confirmPwd));
|
||||
}
|
||||
|
||||
|
||||
@DeleteMapping("/admin/user/delete")
|
||||
public Response multipleDelete(@RequestBody Integer[] ids) {
|
||||
return ResponseUtil.success(userService.deleteUser(ids));
|
||||
|
||||
@@ -28,8 +28,10 @@ public enum ResponseEnum {
|
||||
USEREMAIL_NULL(3310, "未设置邮箱"),
|
||||
USEREMAIL_NOT_VERIFY(3320, "邮箱未验证"),
|
||||
LOGIN_LATER(3500, "错误次数已达5次,请稍后再试"),
|
||||
PWD_SAME(3600, "新密码与原密码相同"),
|
||||
PWD_SAME(3601, "新密码与原密码相同"),
|
||||
PWD_NOT_SAME(3602, "新密码与原密码不相同"),
|
||||
LOGIN_EXPIRED(3700, "登陆过期"),
|
||||
PWD_WRONG(3800, "密码不正确"),
|
||||
|
||||
JWT_EXPIRED(3810, "Token过期"),
|
||||
JWT_MALFORMED(3820, "Token格式不对"),
|
||||
|
||||
@@ -174,4 +174,13 @@ public interface UserService {
|
||||
* @return true:存在 false:不存在
|
||||
*/
|
||||
boolean getStatusOfEmail(String email);
|
||||
|
||||
/**
|
||||
* 设置密码
|
||||
* @param pwd
|
||||
* @param newPwd
|
||||
* @param confirmPwd
|
||||
* @return
|
||||
*/
|
||||
UserModel setPwd(String pwd, String newPwd, String confirmPwd);
|
||||
}
|
||||
|
||||
@@ -433,6 +433,20 @@ public class UserServiceImpl implements UserService {
|
||||
return userMapper.existsByEmail(email);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserModel setPwd(String pwd, String newPwd, String confirmPwd) {
|
||||
User user = redisUserUtil.get();
|
||||
String pwd1 = userMapper.getPwd(user.getEmail());
|
||||
if (!MD5Util.getMD5(pwd).equals(pwd1)) {
|
||||
throw new MyException(ResponseEnum.PWD_WRONG);
|
||||
}
|
||||
if (!newPwd.equals(confirmPwd)) {
|
||||
throw new MyException(ResponseEnum.PWD_NOT_SAME);
|
||||
}
|
||||
userMapper.updatePwd(user.getEmail(), MD5Util.getMD5(newPwd));
|
||||
return trans(userMapper.findByEmail(user.getEmail()));
|
||||
}
|
||||
|
||||
private UserModel trans(User u) {
|
||||
UserModel user = new UserModel();
|
||||
user.setId(u.getId());
|
||||
|
||||
Reference in New Issue
Block a user