Преглед на файлове

update

tags/Baseline_30082024_BACKEND_UAT
MSI\derek преди 1 година
родител
ревизия
74283017e3
променени са 3 файла, в които са добавени 16 реда и са изтрити 14 реда
  1. +0
    -3
      src/main/java/com/ffii/tsms/modules/data/service/StaffsService.kt
  2. +1
    -1
      src/main/java/com/ffii/tsms/modules/user/req/UpdateUserReq.java
  3. +15
    -10
      src/main/java/com/ffii/tsms/modules/user/web/UserController.java

+ 0
- 3
src/main/java/com/ffii/tsms/modules/data/service/StaffsService.kt Целия файл

@@ -107,7 +107,6 @@ open class StaffsService(
val grade = if (req.gradeId != null && req.gradeId > 0L) gradeRepository.findById(req.gradeId).orElseThrow() else null val grade = if (req.gradeId != null && req.gradeId > 0L) gradeRepository.findById(req.gradeId).orElseThrow() else null
val team = if (req.teamId != null && req.teamId > 0L) teamRepository.findById(req.teamId).orElseThrow() else null val team = if (req.teamId != null && req.teamId > 0L) teamRepository.findById(req.teamId).orElseThrow() else null
val salary = salaryRepository.findBySalaryPoint(req.salaryId).orElseThrow() val salary = salaryRepository.findBySalaryPoint(req.salaryId).orElseThrow()
// val salaryEffective = salaryEffectiveRepository.findById(req.salaryEffId).orElseThrow()
val department = departmentRepository.findById(req.departmentId).orElseThrow() val department = departmentRepository.findById(req.departmentId).orElseThrow()


val user = userRepository.saveAndFlush( val user = userRepository.saveAndFlush(
@@ -116,7 +115,6 @@ open class StaffsService(
password = passwordEncoder.encode("mms1234") password = passwordEncoder.encode("mms1234")
name = req.name name = req.name
phone1 = req.phone1 phone1 = req.phone1
// phone2 = req.phone2 ?: null
email = req.email ?: null email = req.email ?: null
} }
) )
@@ -141,7 +139,6 @@ open class StaffsService(
this.company = company this.company = company
this.grade = grade this.grade = grade
this.team = team this.team = team
// this.skill = skill
this.salary = salary this.salary = salary
this.department = department this.department = department
} }


+ 1
- 1
src/main/java/com/ffii/tsms/modules/user/req/UpdateUserReq.java Целия файл

@@ -24,7 +24,7 @@ public class UpdateUserReq {
private String locale; private String locale;
private String remarks; private String remarks;


@NotBlank
// @NotBlank
@Email @Email
private String email; private String email;
// @NotBlank // @NotBlank


+ 15
- 10
src/main/java/com/ffii/tsms/modules/user/web/UserController.java Целия файл

@@ -153,19 +153,10 @@ public class UserController{
@PatchMapping("/admin-change-password") @PatchMapping("/admin-change-password")
@ResponseStatus(HttpStatus.NO_CONTENT) @ResponseStatus(HttpStatus.NO_CONTENT)
@PreAuthorize("hasAuthority('MAINTAIN_USER')") @PreAuthorize("hasAuthority('MAINTAIN_USER')")
public void adminChangePassword(@RequestBody @Valid ChangePwdReq req) {
public void adminChangePassword(@RequestBody @Valid AdminChangePwdReq req) {
long id = req.getId(); long id = req.getId();
User instance = userService.find(id).orElseThrow(NotFoundException::new); User instance = userService.find(id).orElseThrow(NotFoundException::new);


logger.info("TEST req: "+req.getPassword());
logger.info("TEST instance: "+instance.getPassword());
// if (!passwordEncoder.matches(req.getPassword(), instance.getPassword())) {
// throw new BadRequestException();
// }
PasswordRule rule = new PasswordRule(settingsService);
if (!PasswordUtils.checkPwd(req.getNewPassword(), rule)) {
throw new UnprocessableEntityException(ErrorCodes.USER_WRONG_NEW_PWD);
}
instance.setPassword(passwordEncoder.encode(req.getNewPassword())); instance.setPassword(passwordEncoder.encode(req.getNewPassword()));
userService.save(instance); userService.save(instance);
} }
@@ -188,6 +179,20 @@ public class UserController{
return new PasswordRule(settingsService); return new PasswordRule(settingsService);
} }


public static class AdminChangePwdReq {
private Long id;
@NotBlank
private String newPassword;

public Long getId() { return id; }
public Long setId(Long id) { return this.id = id; }
public String getNewPassword() {
return newPassword;
}
public void setNewPassword(String newPassword) {
this.newPassword = newPassword;
}
}
public static class ChangePwdReq { public static class ChangePwdReq {
private Long id; private Long id;
@NotBlank @NotBlank


Зареждане…
Отказ
Запис