1. 系统新增用户标记为外部用户;e 办同步用户标记为系统用户

2. 业务表新增基础业务字段,创建人与更新人名称

(cherry picked from commit 9ee1100b29)
This commit is contained in:
chenbowen
2025-09-16 16:09:10 +08:00
committed by chenbowen
parent cdbe341555
commit 93b62dc175
19 changed files with 195 additions and 53 deletions

View File

@@ -45,4 +45,15 @@ public class ServiceErrorCodeRange {
// 模块 ai 错误码区间 [1-022-000-000 ~ 1-023-000-000)
// 模块 databus 错误码区间 [1-023-000-000 ~ 1-024-000-000)
// 模块 rule 错误码区间 [1-024-000-000 ~ 1-025-000-000)
// 模块 gateway 错误码区间 [1-025-000-000 ~ 1-026-000-000)
// 模块 convert 错误码区间 [1-026-000-000 ~ 1-027-000-000)
// 模块 base 错误码区间 [1-027-000-000 ~ 1-028-000-000)
// 模块 manage 错误码区间 [1-028-000-000 ~ 1-029-000-000)
// 模块 supply 错误码区间 [1-029-000-000 ~ 1-030-000-000)
// 模块 mes 错误码区间 [1-030-000-000 ~ 1-031-000-000)
// 模块 logistics 错误码区间 [1-031-000-000 ~ 1-032-000-000)
// 模块 qms 错误码区间 [1-032-000-000 ~ 1-033-000-000)
}

View File

@@ -34,6 +34,12 @@ public class BusinessBaseDO extends BaseDO {
* 多租户编号
*/
private Long tenantId;
/** 创建人名称 */
@TableField(fill = FieldFill.INSERT, jdbcType = JdbcType.VARCHAR)
private String creatorName;
/** 更新人名称 */
@TableField(fill = FieldFill.INSERT_UPDATE, jdbcType = JdbcType.VARCHAR)
private String updaterName;
@TableField(exist = false)
private List<String> inputStrs;
@@ -49,6 +55,8 @@ public class BusinessBaseDO extends BaseDO {
this.deptId = null;
this.deptName = null;
this.postId = null;
this.creatorName = null;
this.updaterName = null;
}
}

View File

@@ -7,6 +7,7 @@ import cn.iocoder.yudao.framework.mybatis.core.annotation.BusinessCode;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BusinessBaseDO;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils;
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import jakarta.annotation.Resource;
@@ -51,6 +52,7 @@ public class DefaultDBFieldHandler implements MetaObjectHandler {
}
Long userId = WebFrameworkUtils.getLoginUserId();
String userNickname = SecurityFrameworkUtils.getLoginUserNickname();
// 当前登录用户不为空,创建人为空,则当前登录用户为创建人
if (Objects.nonNull(userId) && Objects.isNull(baseDO.getCreator())) {
baseDO.setCreator(userId.toString());
@@ -65,6 +67,9 @@ public class DefaultDBFieldHandler implements MetaObjectHandler {
// 需要在业务层手动设置
autoFillDeptInfo(businessBaseDO);
// 自动填充用户名称字段
autoFillUserNames(businessBaseDO);
// 自动填充带 @BusinessCode 注解的字段序列
autoFillBusinessCode(businessBaseDO);
}
@@ -81,9 +86,32 @@ public class DefaultDBFieldHandler implements MetaObjectHandler {
// 当前登录用户不为空,更新人为空,则当前登录用户为更新人
Object modifier = getFieldValByName("updater", metaObject);
Long userId = WebFrameworkUtils.getLoginUserId();
String userNickname = SecurityFrameworkUtils.getLoginUserNickname();
if (Objects.nonNull(userId) && Objects.isNull(modifier)) {
setFieldValByName("updater", userId.toString(), metaObject);
}
// 对于 BusinessBaseDO自动填充更新人名称
if (Objects.nonNull(metaObject) && metaObject.getOriginalObject() instanceof BusinessBaseDO) {
Object updaterNameVal = getFieldValByName("updaterName", metaObject);
if (Objects.nonNull(userNickname) && Objects.isNull(updaterNameVal)) {
setFieldValByName("updaterName", userNickname, metaObject);
}
}
}
private void autoFillUserNames(BusinessBaseDO businessBaseDO) {
String userNickname = SecurityFrameworkUtils.getLoginUserNickname();
if (Objects.nonNull(userNickname)) {
// 创建人名称为空,则填充当前用户昵称
if (Objects.isNull(businessBaseDO.getCreatorName())) {
businessBaseDO.setCreatorName(userNickname);
}
// 更新人名称为空,则填充当前用户昵称
if (Objects.isNull(businessBaseDO.getUpdaterName())) {
businessBaseDO.setUpdaterName(userNickname);
}
}
}
private void autoFillBusinessCode(BusinessBaseDO businessBaseDO) {

View File

@@ -50,8 +50,8 @@ spring:
# Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优
data:
redis:
host: 172.16.46.63:30379 # 地址
port: 6379 # 端口
host: 172.16.46.63 # 地址
port: 30379 # 端口
database: 1 # 数据库索引
# password: 123456 # 密码,建议生产环境开启

View File

@@ -50,8 +50,8 @@ spring:
# Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优
data:
redis:
host: 172.16.46.63:30379 # 地址
port: 6379 # 端口
host: 172.16.46.63 # 地址
port: 30379 # 端口
database: 1 # 数据库索引
# password: 123456 # 密码,建议生产环境开启

View File

@@ -50,8 +50,8 @@ spring:
# Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优
data:
redis:
host: 172.16.46.63:30379 # 地址
port: 6379 # 端口
host: 172.16.46.63 # 地址
port: 30379 # 端口
database: 1 # 数据库索引
# password: 123456 # 密码,建议生产环境开启

View File

@@ -0,0 +1,27 @@
package cn.iocoder.yudao.module.system.enums.dept;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 部门来源枚举
*
* @author ZT
*/
@AllArgsConstructor
@Getter
public enum DeptSourceEnum {
EXTERNAL(1, "外部部门"), // 系统创建的部门
SYNC(2, "同步部门"); // 通过 OrgSyncService 同步的部门
/**
* 类型
*/
private final Integer source;
/**
* 名字
*/
private final String name;
}

View File

@@ -0,0 +1,27 @@
package cn.iocoder.yudao.module.system.enums.user;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 用户来源枚举
*
* @author ZT
*/
@AllArgsConstructor
@Getter
public enum UserSourceEnum {
EXTERNAL(1, "外部用户"), // 系统创建、注册等方式产生的用户
SYNC(2, "同步用户"); // 通过 UserSyncService 同步的用户
/**
* 类型
*/
private final Integer source;
/**
* 名字
*/
private final String name;
}

View File

@@ -56,4 +56,7 @@ public class DeptSaveReqVO {
@Schema(description = "是否集团", example = "false")
private Boolean isGroup;
@Schema(description = "部门来源类型", example = "1")
private Integer deptSource;
}

View File

@@ -70,6 +70,9 @@ public class UserSaveReqVO {
@DiffLogField(name = "用户头像")
private String avatar;
@Schema(description = "用户来源类型", example = "1")
private Integer userSource;
// ========== 仅【创建】时,需要传递的字段 ==========
@Schema(description = "密码", requiredMode = Schema.RequiredMode.REQUIRED, example = "123456")

Some files were not shown because too many files have changed in this diff Show More