|
@@ -1,5 +1,10 @@
|
|
|
package com.fs.tenant.dict.service.impl;
|
|
package com.fs.tenant.dict.service.impl;
|
|
|
|
|
|
|
|
|
|
+import com.fs.common.core.page.PageDomain;
|
|
|
|
|
+import com.fs.common.core.page.TableSupport;
|
|
|
|
|
+import com.fs.common.utils.StringUtils;
|
|
|
|
|
+import com.fs.common.utils.sql.SqlUtil;
|
|
|
|
|
+import com.github.pagehelper.PageHelper;
|
|
|
import com.fs.common.constant.UserConstants;
|
|
import com.fs.common.constant.UserConstants;
|
|
|
import com.fs.common.core.domain.entity.SysDictData;
|
|
import com.fs.common.core.domain.entity.SysDictData;
|
|
|
import com.fs.common.core.domain.entity.SysDictType;
|
|
import com.fs.common.core.domain.entity.SysDictType;
|
|
@@ -31,7 +36,10 @@ public class TenantDictManageServiceImpl implements TenantDictManageService {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public List<SysDictType> selectDictTypeList(Long tenantId, SysDictType query) {
|
|
public List<SysDictType> selectDictTypeList(Long tenantId, SysDictType query) {
|
|
|
- return contextHelper.executeInTenant(tenantId, () -> dictTypeService.selectDictTypeList(query));
|
|
|
|
|
|
|
+ return contextHelper.executeInTenant(tenantId, () -> {
|
|
|
|
|
+ startPage();
|
|
|
|
|
+ return dictTypeService.selectDictTypeList(query);
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -57,8 +65,8 @@ public class TenantDictManageServiceImpl implements TenantDictManageService {
|
|
|
if (existing == null) {
|
|
if (existing == null) {
|
|
|
throw new CustomException("字典类型不存在");
|
|
throw new CustomException("字典类型不存在");
|
|
|
}
|
|
}
|
|
|
- if (isPlatformLocked(existing) && !TenantDictConstants.SOURCE_PLATFORM.equals(dict.getDictSource())) {
|
|
|
|
|
- throw new CustomException("平台管控字典类型不可直接修改,请通过模板同步或先取消平台管控");
|
|
|
|
|
|
|
+ if (isPlatformLocked(existing)) {
|
|
|
|
|
+ throw new CustomException("平台管控字典类型不可直接修改,请通过模板同步更新");
|
|
|
}
|
|
}
|
|
|
if (UserConstants.NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict))) {
|
|
if (UserConstants.NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict))) {
|
|
|
throw new CustomException("字典类型已存在: " + dict.getDictType());
|
|
throw new CustomException("字典类型已存在: " + dict.getDictType());
|
|
@@ -88,7 +96,10 @@ public class TenantDictManageServiceImpl implements TenantDictManageService {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public List<SysDictData> selectDictDataList(Long tenantId, SysDictData query) {
|
|
public List<SysDictData> selectDictDataList(Long tenantId, SysDictData query) {
|
|
|
- return contextHelper.executeInTenant(tenantId, () -> dictDataService.selectDictDataList(query));
|
|
|
|
|
|
|
+ return contextHelper.executeInTenant(tenantId, () -> {
|
|
|
|
|
+ startPage();
|
|
|
|
|
+ return dictDataService.selectDictDataList(query);
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -170,12 +181,34 @@ public class TenantDictManageServiceImpl implements TenantDictManageService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private boolean isPlatformLocked(SysDictType type) {
|
|
private boolean isPlatformLocked(SysDictType type) {
|
|
|
- return TenantDictConstants.SOURCE_PLATFORM.equals(type.getDictSource())
|
|
|
|
|
- || (type.getIsPlatformManaged() != null && type.getIsPlatformManaged() == 1);
|
|
|
|
|
|
|
+ if (type == null) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (type.getIsPlatformManaged() != null) {
|
|
|
|
|
+ return type.getIsPlatformManaged() == 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ return TenantDictConstants.SOURCE_PLATFORM.equals(type.getDictSource());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private boolean isPlatformLocked(SysDictData data) {
|
|
private boolean isPlatformLocked(SysDictData data) {
|
|
|
- return TenantDictConstants.SOURCE_PLATFORM.equals(data.getDictSource())
|
|
|
|
|
- || (data.getIsPlatformManaged() != null && data.getIsPlatformManaged() == 1);
|
|
|
|
|
|
|
+ if (data == null) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (data.getIsPlatformManaged() != null) {
|
|
|
|
|
+ return data.getIsPlatformManaged() == 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ return TenantDictConstants.SOURCE_PLATFORM.equals(data.getDictSource());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /** 切库后再开启分页,避免 loadActiveTenant 查询消耗 PageHelper */
|
|
|
|
|
+ private void startPage() {
|
|
|
|
|
+ PageDomain pageDomain = TableSupport.buildPageRequest();
|
|
|
|
|
+ Integer pageNum = pageDomain.getPageNum();
|
|
|
|
|
+ Integer pageSize = pageDomain.getPageSize();
|
|
|
|
|
+ if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)) {
|
|
|
|
|
+ String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
|
|
|
|
|
+ Boolean reasonable = pageDomain.getReasonable();
|
|
|
|
|
+ PageHelper.startPage(pageNum, pageSize, orderBy).setReasonable(reasonable);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|