修改创建人逻辑.

This commit is contained in:
lijiahang
2025-02-21 17:57:35 +08:00
parent 397bbb2657
commit 7017c7502b
5 changed files with 481 additions and 466 deletions

View File

@@ -50,6 +50,7 @@ public class DomainFillUtils {
*/
public static void fillInsert(BaseDO baseDO) {
Date now = new Date();
String username = securityHolder.getLoginUsername();
// 创建时间
if (Objects.isNull(baseDO.getCreateTime())) {
baseDO.setCreateTime(now);
@@ -58,15 +59,13 @@ public class DomainFillUtils {
if (Objects.isNull(baseDO.getUpdateTime())) {
baseDO.setUpdateTime(now);
}
Long userId = securityHolder.getLoginUserId();
// 创建人
if (Objects.nonNull(userId) && Objects.isNull(baseDO.getCreator())) {
baseDO.setCreator(userId.toString());
if (Objects.nonNull(username) && Objects.isNull(baseDO.getCreator())) {
baseDO.setCreator(username);
}
// 更新人
if (Objects.nonNull(userId) && Objects.isNull(baseDO.getUpdater())) {
baseDO.setUpdater(userId.toString());
if (Objects.nonNull(username) && Objects.isNull(baseDO.getUpdater())) {
baseDO.setUpdater(username);
}
// 逻辑删除字段
if (Objects.isNull(baseDO.getDeleted())) {
@@ -85,9 +84,9 @@ public class DomainFillUtils {
baseDO.setUpdateTime(new Date());
}
// 更新人
Long userId = securityHolder.getLoginUserId();
if (Objects.nonNull(userId) && Objects.isNull(baseDO.getUpdater())) {
baseDO.setUpdater(userId.toString());
String username = securityHolder.getLoginUsername();
if (Objects.nonNull(username) && Objects.isNull(baseDO.getUpdater())) {
baseDO.setUpdater(username);
}
}

View File

@@ -45,4 +45,9 @@ public class SecurityHolderDelegate implements SecurityHolder {
return SecurityUtils.getLoginUserId();
}
@Override
public String getLoginUsername() {
return SecurityUtils.getLoginUsername();
}
}

View File

@@ -71,6 +71,11 @@ public class OrionMockBeanTestConfiguration {
public Long getLoginUserId() {
return DEFAULT.getId();
}
@Override
public String getLoginUsername() {
return DEFAULT.getUsername();
}
};
}