增加构建通知

This commit is contained in:
dengqichen 2025-11-20 14:46:09 +08:00
parent bbcc11b511
commit 0991fb487f
3 changed files with 11 additions and 3 deletions

View File

@ -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);

View File

@ -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();
}

View File

@ -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())