Commit 105b9039a79a913402ddded4a2b2d793df48fbec

Authored by zichun
1 parent 237a97e4

feat(common): error codes + PasswordConfig REQ-USR-001

backend/src/main/java/com/xly/erp/common/response/ErrorCode.java
@@ -8,9 +8,12 @@ public enum ErrorCode { @@ -8,9 +8,12 @@ public enum ErrorCode {
8 PARAM_INVALID(40010, "参数错误"), 8 PARAM_INVALID(40010, "参数错误"),
9 MOD_PARENT_NOT_FOUND(40411, "父模块不存在或已删除"), 9 MOD_PARENT_NOT_FOUND(40411, "父模块不存在或已删除"),
10 MOD_NOT_FOUND(40421, "模块不存在或已删除"), 10 MOD_NOT_FOUND(40421, "模块不存在或已删除"),
  11 + STAFF_NOT_FOUND(40421, "职员不存在或已删除"),
  12 + PERM_CATEGORY_NOT_FOUND(40422, "权限分类不存在或已删除"),
11 MOD_PROC_NAME_DUP(40911, "存储过程名称已存在"), 13 MOD_PROC_NAME_DUP(40911, "存储过程名称已存在"),
12 MOD_HAS_REFERENCES(40912, "存在子模块或外部业务引用,禁止删除"), 14 MOD_HAS_REFERENCES(40912, "存在子模块或外部业务引用,禁止删除"),
13 MOD_PARENT_LOOP(40921, "iParentId 不能等于自身或后代"), 15 MOD_PARENT_LOOP(40921, "iParentId 不能等于自身或后代"),
  16 + USR_USER_NAME_OR_NO_DUP(40921, "用户名或用户号已存在"),
14 INTERNAL_ERROR(50000, "服务器内部错误"); 17 INTERNAL_ERROR(50000, "服务器内部错误");
15 18
16 private final int code; 19 private final int code;
backend/src/main/java/com/xly/erp/config/PasswordConfig.java 0 → 100644
  1 +package com.xly.erp.config;
  2 +
  3 +import org.springframework.context.annotation.Bean;
  4 +import org.springframework.context.annotation.Configuration;
  5 +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
  6 +import org.springframework.security.crypto.password.PasswordEncoder;
  7 +
  8 +/**
  9 + * REQ-USR-001 引入:BCryptPasswordEncoder 注册为 Spring bean,
  10 + * 供 UserService.create / REQ-USR-004 登录校验复用。strength 用 BCrypt 默认(10)。
  11 + */
  12 +@Configuration
  13 +public class PasswordConfig {
  14 +
  15 + @Bean
  16 + public PasswordEncoder passwordEncoder() {
  17 + return new BCryptPasswordEncoder();
  18 + }
  19 +}
backend/src/test/java/com/xly/erp/common/response/ApiResponseTest.java
@@ -51,5 +51,8 @@ class ApiResponseTest { @@ -51,5 +51,8 @@ class ApiResponseTest {
51 assertThat(ErrorCode.MOD_NOT_FOUND.getCode()).isEqualTo(40421); 51 assertThat(ErrorCode.MOD_NOT_FOUND.getCode()).isEqualTo(40421);
52 assertThat(ErrorCode.MOD_PARENT_LOOP.getCode()).isEqualTo(40921); 52 assertThat(ErrorCode.MOD_PARENT_LOOP.getCode()).isEqualTo(40921);
53 assertThat(ErrorCode.MOD_HAS_REFERENCES.getCode()).isEqualTo(40912); 53 assertThat(ErrorCode.MOD_HAS_REFERENCES.getCode()).isEqualTo(40912);
  54 + assertThat(ErrorCode.STAFF_NOT_FOUND.getCode()).isEqualTo(40421);
  55 + assertThat(ErrorCode.PERM_CATEGORY_NOT_FOUND.getCode()).isEqualTo(40422);
  56 + assertThat(ErrorCode.USR_USER_NAME_OR_NO_DUP.getCode()).isEqualTo(40921);
54 } 57 }
55 } 58 }