增加创建部门ID入库逻辑

This commit is contained in:
smallchill 2024-03-10 16:53:39 +08:00
parent 823bdca0b4
commit 945efc8fbf
2 changed files with 28 additions and 0 deletions

View File

@ -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<M extends BaseMapper<T>, 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();

View File

@ -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<Long> longs = toLongList(split, str);
if (isEmpty(longs)) {
return null;
} else {
return longs.get(0);
}
}
/**
* 转换为String数组<br>
*