增加构建通知
This commit is contained in:
parent
bbcc11b511
commit
0991fb487f
@ -23,7 +23,7 @@ public class PasswordGenerator {
|
||||
* 生成示例密码(仅用于测试)
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
String rawPassword = "admin123";
|
||||
String rawPassword = "lianyu_123";
|
||||
String encodedPassword = encode(rawPassword);
|
||||
System.out.println("Raw password: " + rawPassword);
|
||||
System.out.println("Encoded password: " + encodedPassword);
|
||||
|
||||
@ -2,6 +2,7 @@ package com.qqchen.deploy.backend.system.api;
|
||||
|
||||
import com.qqchen.deploy.backend.system.model.query.UserQuery;
|
||||
import com.qqchen.deploy.backend.system.model.request.DepartmentAssignRequest;
|
||||
import com.qqchen.deploy.backend.system.model.request.ResetPasswordRequest;
|
||||
import com.qqchen.deploy.backend.framework.controller.BaseController;
|
||||
import com.qqchen.deploy.backend.framework.api.Response;
|
||||
import com.qqchen.deploy.backend.system.entity.User;
|
||||
@ -82,8 +83,8 @@ public class UserApiController extends BaseController<User, UserDTO, Long, UserQ
|
||||
|
||||
@Operation(summary = "重置用户密码")
|
||||
@PostMapping("/{id}/reset-password")
|
||||
public Response<Void> resetPassword(@PathVariable Long id, @RequestBody String newPassword) {
|
||||
userService.resetPassword(id, newPassword);
|
||||
public Response<Void> resetPassword(@PathVariable Long id, @Validated @RequestBody ResetPasswordRequest request) {
|
||||
userService.resetPassword(id, request.getNewPassword());
|
||||
return Response.success();
|
||||
}
|
||||
|
||||
|
||||
@ -276,6 +276,13 @@ public class UserServiceImpl extends BaseServiceImpl<User, UserDTO, UserQuery, L
|
||||
// 更新基本信息
|
||||
userConverter.updateEntity(user, dto);
|
||||
|
||||
// ✅ 如果提供了新密码,需要加密后更新(因为 updateEntity 忽略了 password 字段)
|
||||
if (dto.getPassword() != null && !dto.getPassword().isEmpty()) {
|
||||
String encodedPassword = PasswordGenerator.encode(dto.getPassword());
|
||||
user.setPassword(encodedPassword);
|
||||
log.info("用户 {} 的密码已更新", user.getUsername());
|
||||
}
|
||||
|
||||
// 如果指定了部门ID,更新用户部门
|
||||
if (dto.getDepartmentId() != null) {
|
||||
Department department = departmentRepository.findById(dto.getDepartmentId())
|
||||
|
||||
Loading…
Reference in New Issue
Block a user