|
|
@@ -11,6 +11,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.dromara.common.core.constant.CacheNames;
|
|
|
import org.dromara.common.core.constant.SystemConstants;
|
|
|
+import org.dromara.common.core.context.PlatformContext;
|
|
|
+import org.dromara.common.core.enums.SysPlatformCode;
|
|
|
import org.dromara.common.core.exception.ServiceException;
|
|
|
import org.dromara.common.core.utils.*;
|
|
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
|
|
@@ -252,6 +254,7 @@ public class SysDeptServiceImpl implements ISysDeptService {
|
|
|
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysDept>()
|
|
|
.eq(SysDept::getDeptName, dept.getDeptName())
|
|
|
.eq(SysDept::getParentId, dept.getParentId())
|
|
|
+ .eq(SysDept::getPlatformCode, dept.getPlatformCode())
|
|
|
.ne(ObjectUtil.isNotNull(dept.getDeptId()), SysDept::getDeptId, dept.getDeptId()));
|
|
|
return !exist;
|
|
|
}
|
|
|
@@ -290,7 +293,17 @@ public class SysDeptServiceImpl implements ISysDeptService {
|
|
|
}
|
|
|
SysDept dept = MapstructUtils.convert(bo, SysDept.class);
|
|
|
dept.setAncestors(info.getAncestors() + StringUtils.SEPARATOR + dept.getParentId());
|
|
|
- return baseMapper.insert(dept);
|
|
|
+ // 1. 校验当前是否为总控平台(main),否则不能指定 platformCode
|
|
|
+ String currentPlatform = PlatformContext.getPlatform();
|
|
|
+ String targetPlatform = currentPlatform;
|
|
|
+ if (SysPlatformCode.MAIN.getCode().equals(currentPlatform)) {
|
|
|
+ targetPlatform = dept.getPlatformCode();
|
|
|
+ }
|
|
|
+ //在 "main" 平台上下文中执行插入,并获取返回值
|
|
|
+ Integer rows = PlatformContextUtil.executeWithPlatform(targetPlatform, () -> {
|
|
|
+ return baseMapper.insert(dept);
|
|
|
+ });
|
|
|
+ return rows;
|
|
|
}
|
|
|
|
|
|
/**
|