From 398543d37bb342e0d7b65dcde1f7433b6450b6a7 Mon Sep 17 00:00:00 2001 From: zichun Date: Wed, 6 May 2026 21:32:24 +0800 Subject: [PATCH] feat(common): USR_NOT_FOUND + iStaffId IGNORED REQ-USR-002 --- backend/src/main/java/com/xly/erp/common/response/ErrorCode.java | 1 + backend/src/main/java/com/xly/erp/module/usr/entity/UserEntity.java | 5 ++++- backend/src/test/java/com/xly/erp/common/response/ApiResponseTest.java | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/backend/src/main/java/com/xly/erp/common/response/ErrorCode.java b/backend/src/main/java/com/xly/erp/common/response/ErrorCode.java index 2c1fb65..5ef5226 100644 --- a/backend/src/main/java/com/xly/erp/common/response/ErrorCode.java +++ b/backend/src/main/java/com/xly/erp/common/response/ErrorCode.java @@ -10,6 +10,7 @@ public enum ErrorCode { MOD_NOT_FOUND(40421, "模块不存在或已删除"), STAFF_NOT_FOUND(40421, "职员不存在或已删除"), PERM_CATEGORY_NOT_FOUND(40422, "权限分类不存在或已删除"), + USR_NOT_FOUND(40431, "用户不存在或已删除"), MOD_PROC_NAME_DUP(40911, "存储过程名称已存在"), MOD_HAS_REFERENCES(40912, "存在子模块或外部业务引用,禁止删除"), MOD_PARENT_LOOP(40921, "iParentId 不能等于自身或后代"), diff --git a/backend/src/main/java/com/xly/erp/module/usr/entity/UserEntity.java b/backend/src/main/java/com/xly/erp/module/usr/entity/UserEntity.java index 2e5a092..610b536 100644 --- a/backend/src/main/java/com/xly/erp/module/usr/entity/UserEntity.java +++ b/backend/src/main/java/com/xly/erp/module/usr/entity/UserEntity.java @@ -1,5 +1,6 @@ package com.xly.erp.module.usr.entity; +import com.baomidou.mybatisplus.annotation.FieldStrategy; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; @@ -34,7 +35,9 @@ public class UserEntity { @TableField("sUserName") private String sUserName; - @TableField("iStaffId") + /** REQ-USR-002 允许更新为 null(清空员工关联),用 IGNORED 让 MP updateById 把 NULL 写入 SQL。 + * 注意:此策略意味着任何 updateById 都会写 iStaffId;调用方必须 selectById 后再 updateById(load-then-modify)。 */ + @TableField(value = "iStaffId", updateStrategy = FieldStrategy.IGNORED) private Integer iStaffId; @TableField("sUserType") diff --git a/backend/src/test/java/com/xly/erp/common/response/ApiResponseTest.java b/backend/src/test/java/com/xly/erp/common/response/ApiResponseTest.java index 7740aa7..f2fa1c3 100644 --- a/backend/src/test/java/com/xly/erp/common/response/ApiResponseTest.java +++ b/backend/src/test/java/com/xly/erp/common/response/ApiResponseTest.java @@ -54,5 +54,6 @@ class ApiResponseTest { assertThat(ErrorCode.STAFF_NOT_FOUND.getCode()).isEqualTo(40421); assertThat(ErrorCode.PERM_CATEGORY_NOT_FOUND.getCode()).isEqualTo(40422); assertThat(ErrorCode.USR_USER_NAME_OR_NO_DUP.getCode()).isEqualTo(40921); + assertThat(ErrorCode.USR_NOT_FOUND.getCode()).isEqualTo(40431); } } -- libgit2 0.22.2