From 945efc8fbf58c6a9aa59f0a2250981754431f786 Mon Sep 17 00:00:00 2001 From: smallchill Date: Sun, 10 Mar 2024 16:53:39 +0800 Subject: [PATCH] =?UTF-8?q?:zap:=20=E5=A2=9E=E5=8A=A0=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E9=83=A8=E9=97=A8ID=E5=85=A5=E5=BA=93=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/mp/base/BaseServiceImpl.java | 2 ++ .../org/springblade/core/tool/utils/Func.java | 26 +++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/blade-core-mybatis/src/main/java/org/springblade/core/mp/base/BaseServiceImpl.java b/blade-core-mybatis/src/main/java/org/springblade/core/mp/base/BaseServiceImpl.java index e4e9f76..7c02db2 100644 --- a/blade-core-mybatis/src/main/java/org/springblade/core/mp/base/BaseServiceImpl.java +++ b/blade-core-mybatis/src/main/java/org/springblade/core/mp/base/BaseServiceImpl.java @@ -25,6 +25,7 @@ import org.springblade.core.secure.BladeUser; import org.springblade.core.secure.utils.SecureUtil; import org.springblade.core.tool.constant.BladeConstant; import org.springblade.core.tool.utils.DateUtil; +import org.springblade.core.tool.utils.Func; import org.springframework.validation.annotation.Validated; import javax.validation.constraints.NotEmpty; @@ -86,6 +87,7 @@ public class BaseServiceImpl, T extends BaseEntity> exte BladeUser user = SecureUtil.getUser(); if (user != null) { entity.setCreateUser(user.getUserId()); + entity.setCreateDept(Func.firstLong(user.getDeptId())); entity.setUpdateUser(user.getUserId()); } Date now = DateUtil.now(); diff --git a/blade-core-tool/src/main/java/org/springblade/core/tool/utils/Func.java b/blade-core-tool/src/main/java/org/springblade/core/tool/utils/Func.java index e4bd0be..9bdee2c 100644 --- a/blade-core-tool/src/main/java/org/springblade/core/tool/utils/Func.java +++ b/blade-core-tool/src/main/java/org/springblade/core/tool/utils/Func.java @@ -726,6 +726,32 @@ public class Func { return Arrays.asList(toLongArray(split, str)); } + /** + * 获取第一位Long数值 + * + * @param str 被转换的值 + * @return 结果 + */ + public static Long firstLong(String str) { + return firstLong(",", str); + } + + /** + * 获取第一位Long数值 + * + * @param split 分隔符 + * @param str 被转换的值 + * @return 结果 + */ + public static Long firstLong(String split, String str) { + List longs = toLongList(split, str); + if (isEmpty(longs)) { + return null; + } else { + return longs.get(0); + } + } + /** * 转换为String数组
*