mirror of
https://github.com/FatttSnake/Pinnacle-OA.git
synced 2026-04-05 23:11:24 +08:00
Added modify passwd
This commit is contained in:
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.cfive.pinnacle.entity.permission.User;
|
||||
import com.cfive.pinnacle.entity.common.ResponseCode;
|
||||
import com.cfive.pinnacle.entity.common.ResponseResult;
|
||||
import com.cfive.pinnacle.exception.DataValidationFailedException;
|
||||
import com.cfive.pinnacle.service.permission.IUserService;
|
||||
import com.cfive.pinnacle.utils.WebUtil;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
@@ -41,6 +42,23 @@ public class UserController {
|
||||
return ResponseResult.databaseSelectSuccess(userService.getInfo());
|
||||
}
|
||||
|
||||
@PutMapping("/passwd")
|
||||
@Operation(summary = "修改密码")
|
||||
public ResponseResult<?> modifyPasswd(String password) {
|
||||
if (password == null) {
|
||||
throw new DataValidationFailedException();
|
||||
}
|
||||
password = password.trim();
|
||||
if (password.isBlank() || password.length() < 8 || password.length() > 64) {
|
||||
throw new DataValidationFailedException();
|
||||
}
|
||||
if (userService.modifyPasswd(password)) {
|
||||
return ResponseResult.databaseUpdateSuccess(null);
|
||||
} else {
|
||||
return ResponseResult.build(ResponseCode.DATABASE_UPDATE_ERROR, "error", null);
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/affair")
|
||||
@PreAuthorize("hasAnyAuthority('affair:self:add')")
|
||||
@Operation(summary = "获取拥有审批权限的用户")
|
||||
|
||||
@@ -18,6 +18,8 @@ public interface IUserService extends IService<User> {
|
||||
|
||||
User getInfo();
|
||||
|
||||
boolean modifyPasswd(String passwd);
|
||||
|
||||
List<User> getAffairUser();
|
||||
|
||||
List<User> getDepartmentUser();
|
||||
|
||||
@@ -75,6 +75,13 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
||||
return WebUtil.getLoginUser().getUser();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean modifyPasswd(String passwd) {
|
||||
String encryptedPassword = passwordEncoder.encode(passwd);
|
||||
User user = new User().setId(WebUtil.getLoginUser().getUser().getId()).setPasswd(encryptedPassword);
|
||||
return userMapper.updateById(user) == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<User> getAffairUser() {
|
||||
return userMapper.getAllAffairUser();
|
||||
|
||||
Reference in New Issue
Block a user