Commit 0758472d by 李小龙

factoryId->tenantId

parent b036ac30
Showing with 136 additions and 134 deletions
......@@ -16,10 +16,10 @@ import java.io.Serializable;
@AllArgsConstructor
@NoArgsConstructor
//@Builder
public class BaseFactoryDTO extends BaseIdDTO implements Serializable {
public class BaseTenantIdDTO extends BaseIdDTO implements Serializable {
@ExcelIgnore
@ApiModelProperty(value = "厂别id", required = true)
private String factoryId;
private String tenantId;
}
......@@ -12,7 +12,7 @@ import lombok.experimental.FieldNameConstants;
public class BaseBusEntity extends BaseEntity {
@TableField(fill = FieldFill.INSERT)
@ApiModelProperty("厂别id")
private String factoryId;
@ApiModelProperty("tenantId")
private String tenantId;
}
package com.makeit.config.global.swagger.model;
import com.makeit.enums.id.IdConst;
import com.makeit.global.aspect.tenant.FactoryIdUtil;
import com.makeit.global.aspect.tenant.TenantIdUtil;
import com.makeit.global.validator.Config;
import com.makeit.utils.data.excel.easyexcel.ConfigFormat;
import org.springframework.stereotype.Component;
......@@ -21,7 +21,7 @@ public class ConfigPlugin implements ModelPropertyBuilderPlugin {
private <T> void fill(String categoryCode, ModelPropertyContext context) {
FactoryIdUtil.execute(IdConst.DEFAULT_FACTORY_ID, () -> {
TenantIdUtil.execute(IdConst.DEFAULT_FACTORY_ID, () -> {
// String s = "配置 分类code:" + categoryCode + " " +
// TntConfigUtil.viewListByCategoryCode(categoryCode).stream().map(e -> e.getCode() + "-" + e.getValue() + "-" + e.getName()).collect(Collectors.joining(","));
......
......@@ -9,7 +9,7 @@ import com.makeit.config.global.thread.wrapper.log.LogRunnableWrapper;
import com.makeit.config.global.thread.wrapper.log.RequestIdCallableWrapper;
import com.makeit.config.global.thread.wrapper.log.RequestIdRunnableWrapper;
import com.makeit.config.global.thread.wrapper.request.RequestAsyncRunnableWrapper2;
import com.makeit.config.global.thread.wrapper.tenant.FactoryIdRunnableWrapper;
import com.makeit.config.global.thread.wrapper.tenant.TenantIdRunnableWrapper;
import java.util.concurrent.Callable;
......@@ -23,7 +23,7 @@ public class RunnableWrapperUtil {
return TtlRunnable.get(new UserRunnerWrapper(
/*new RequestAsyncRunnableWrapper(*/
new RequestAsyncRunnableWrapper2(
new FactoryIdRunnableWrapper(
new TenantIdRunnableWrapper(
new RequestIdRunnableWrapper(
new LogRunnableWrapper(runnable)
......
package com.makeit.config.global.thread.wrapper.ignore;
import com.makeit.config.global.thread.wrapper.BizCallable;
import com.makeit.global.aspect.tenant.FactoryIdIgnoreUtil;
import com.makeit.global.aspect.tenant.TenantIdIgnoreUtil;
import java.util.concurrent.Callable;
......@@ -15,7 +15,7 @@ public class FactoryIgnoreCallableWrapper<V> implements BizCallable<V> {
@Override
public V call() throws Exception {
return FactoryIdIgnoreUtil.executeCallable(task);
return TenantIdIgnoreUtil.executeCallable(task);
}
}
\ No newline at end of file
package com.makeit.config.global.thread.wrapper.ignore;
import com.makeit.config.global.thread.wrapper.BizRunnable;
import com.makeit.global.aspect.tenant.FactoryIdIgnoreUtil;
import com.makeit.global.aspect.tenant.TenantIdIgnoreUtil;
public class FactoryIgnoreRunnableWrapper implements BizRunnable {
private Runnable task;
......@@ -13,6 +13,6 @@ public class FactoryIgnoreRunnableWrapper implements BizRunnable {
@Override
public void run() {
FactoryIdIgnoreUtil.execute(task);
TenantIdIgnoreUtil.execute(task);
}
}
\ No newline at end of file
package com.makeit.config.global.thread.wrapper.tenant;
import com.makeit.config.global.thread.wrapper.BizCallable;
import com.makeit.global.aspect.tenant.FactoryIdUtil;
import com.makeit.global.aspect.tenant.TenantIdUtil;
import com.makeit.utils.old.StringUtils;
import java.util.concurrent.Callable;
public class FactoryIdCallableWrapper<V> implements BizCallable<V> {
public class TenantIdCallableWrapper<V> implements BizCallable<V> {
private Callable<V> task;
private String factoryId;
public FactoryIdCallableWrapper(Callable<V> task) {
public TenantIdCallableWrapper(Callable<V> task) {
super();
this.task = task;
factoryId = FactoryIdUtil.getFromThreadLocal();
factoryId = TenantIdUtil.getFromThreadLocal();
}
@Override
public V call() throws Exception {
if (StringUtils.isNotBlank(factoryId)) {
FactoryIdUtil.setThreadLocal(factoryId);
TenantIdUtil.setThreadLocal(factoryId);
try {
return task.call();
} finally {
FactoryIdUtil.removeThreadLocal();
TenantIdUtil.removeThreadLocal();
}
} else {
return task.call();
......
package com.makeit.config.global.thread.wrapper.tenant;
import com.makeit.config.global.thread.wrapper.BizRunnable;
import com.makeit.global.aspect.tenant.FactoryIdUtil;
import com.makeit.global.aspect.tenant.TenantIdUtil;
import com.makeit.utils.old.StringUtils;
public class FactoryIdRunnableWrapper implements BizRunnable {
public class TenantIdRunnableWrapper implements BizRunnable {
private Runnable task;
private String factoryId;
public FactoryIdRunnableWrapper(Runnable task) {
public TenantIdRunnableWrapper(Runnable task) {
super();
this.task = task;
this.factoryId = FactoryIdUtil.getFromThreadLocal();
this.factoryId = TenantIdUtil.getFromThreadLocal();
}
@Override
public void run() {
if (StringUtils.isNotBlank(factoryId)) {
FactoryIdUtil.setThreadLocal(factoryId);
TenantIdUtil.setThreadLocal(factoryId);
try {
task.run();
} finally {
FactoryIdUtil.removeThreadLocal();
TenantIdUtil.removeThreadLocal();
}
}else{
task.run();
......
......@@ -5,14 +5,14 @@ import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInt
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.TenantLineInnerInterceptor;
import com.makeit.config.mybatis.interceptor.EmptyListInterceptor;
import com.makeit.config.mybatis.tenant.FactoryIdHandler;
import com.makeit.config.mybatis.tenant.FactoryIdInterceptor;
import com.makeit.config.mybatis.tenant.TenantIdHandler;
import com.makeit.config.mybatis.tenant.TenantIdInterceptor;
import com.makeit.config.mybatis.tenant.FactoryTableProperties;
import com.makeit.enums.CodeMessageEnum;
import com.makeit.enums.Const;
import com.makeit.exception.BusinessException;
import com.makeit.global.aspect.tenant.FactoryIdIgnoreUtil;
import com.makeit.global.aspect.tenant.FactoryIdUtil;
import com.makeit.global.aspect.tenant.TenantIdIgnoreUtil;
import com.makeit.global.aspect.tenant.TenantIdUtil;
import com.makeit.utils.data.convert.StreamUtil;
import net.sf.jsqlparser.expression.Expression;
import net.sf.jsqlparser.expression.StringValue;
......@@ -55,12 +55,12 @@ public class MybatisPlusConfig {
}
@Bean
public FactoryIdHandler tenantLineHandler() {
return new FactoryIdHandler() {
public TenantIdHandler tenantLineHandler() {
return new TenantIdHandler() {
@Override
public String getTenantIdNoWrapper() {
String s = FactoryIdUtil.getFactoryId();
String s = TenantIdUtil.getTenantId();
if (StringUtils.isBlank(s)) {
throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR_FACTORY_ID_NOT_BLANK);
}
......@@ -75,7 +75,7 @@ public class MybatisPlusConfig {
@Override
public String getTenantIdColumn() {
return Const.FACTORY_ID_DB;
return Const.TENANT_ID_DB;
}
@Override
......@@ -86,7 +86,7 @@ public class MybatisPlusConfig {
// List<TableFieldInfo> fieldInfoList = TableInfoHelper.getTableInfo(tableName).getFieldList();
// logger.info("{} has factoryId:{}", tableName, StreamUtil.anyMatch(fieldInfoList, e -> Const.FACTORY_ID_DB.equals(e.getColumn())));
if (Boolean.TRUE.equals(FactoryIdIgnoreUtil.get())) {
if (Boolean.TRUE.equals(TenantIdIgnoreUtil.get())) {
return true;
}
......@@ -104,7 +104,7 @@ public class MybatisPlusConfig {
@Bean
public TenantLineInnerInterceptor tenantLineInnerInterceptor() {
return new FactoryIdInterceptor(tenantLineHandler());
return new TenantIdInterceptor(tenantLineHandler());
}
}
......@@ -3,7 +3,7 @@ package com.makeit.config.mybatis.objecthandler;
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
import com.makeit.common.entity.BaseBusEntity;
import com.makeit.config.mybatis.tenant.FactoryIdHandler;
import com.makeit.config.mybatis.tenant.TenantIdHandler;
import com.makeit.utils.old.StringUtils;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -12,21 +12,21 @@ import org.springframework.stereotype.Component;
@Order(40)
@Component
public class FactoryIdObjectHandler implements MetaObjectHandlerInternal {
public class TenantIdObjectHandler implements MetaObjectHandlerInternal {
@Autowired
private FactoryIdHandler factoryIdHandler;
private TenantIdHandler tenantIdHandler;
@Override
public boolean support(MetaObject metaObject, MetaObjectHandler handler) {
return !factoryIdHandler.ignoreTable(SqlHelper.table(metaObject.getOriginalObject().getClass()).getTableName());
return !tenantIdHandler.ignoreTable(SqlHelper.table(metaObject.getOriginalObject().getClass()).getTableName());
}
@Override
public void insertFill(MetaObject metaObject, MetaObjectHandler handler) {
String oldValue = (String)handler.getFieldValByName(BaseBusEntity.Fields.factoryId, metaObject);
String oldValue = (String)handler.getFieldValByName(BaseBusEntity.Fields.tenantId, metaObject);
if(StringUtils.isBlank(oldValue)) {
handler.setFieldValByName(BaseBusEntity.Fields.factoryId, factoryIdHandler.getTenantIdNoWrapper(), metaObject);
handler.setFieldValByName(BaseBusEntity.Fields.tenantId, tenantIdHandler.getTenantIdNoWrapper(), metaObject);
}
}
......
......@@ -2,6 +2,6 @@ package com.makeit.config.mybatis.tenant;
import com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler;
public interface FactoryIdHandler extends TenantLineHandler {
public interface TenantIdHandler extends TenantLineHandler {
String getTenantIdNoWrapper();
}
......@@ -14,9 +14,9 @@ import org.apache.ibatis.session.RowBounds;
import java.sql.SQLException;
public class FactoryIdInterceptor extends TenantLineInnerInterceptor {
public class TenantIdInterceptor extends TenantLineInnerInterceptor {
public FactoryIdInterceptor(TenantLineHandler tenantLineHandler) {
public TenantIdInterceptor(TenantLineHandler tenantLineHandler) {
super(tenantLineHandler);
}
......
......@@ -12,8 +12,8 @@ public class Const {
//上面三个MDC用
public static final String FACTORY_ID = "factoryId";
public static final String FACTORY_ID_DB = "factory_id";
public static final String TENANT_ID = "tenantId";
public static final String TENANT_ID_DB = "tenant_id";
public static final String CHN = "中国";
public static final String CHN_ENG = "China";
......
......@@ -2,7 +2,7 @@ package com.makeit.enums;
public class HeaderConst {
public static final String FACTORY_ID = Const.FACTORY_ID;
public static final String TENANT_ID = Const.TENANT_ID;
//public static final String PLATFORM_TOKEN = "platformToken";
......
......@@ -6,5 +6,5 @@ import java.lang.annotation.*;
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface FactoryIdIgnore {
public @interface TenantIdIgnore {
}
......@@ -11,9 +11,9 @@ import java.lang.reflect.Method;
@Component
@Aspect
public class FactoryIdIgnoreAspect {
public class TenantIdIgnoreAspect {
@Pointcut("@annotation(com.makeit.global.aspect.tenant.FactoryIdIgnore)")
@Pointcut("@annotation(com.makeit.global.aspect.tenant.TenantIdIgnore)")
public void handle() {
}
......@@ -22,9 +22,9 @@ public class FactoryIdIgnoreAspect {
MethodSignature signature = (MethodSignature) pjp.getSignature();
Method method = signature.getMethod();
FactoryIdIgnore annotation = method.getAnnotation(FactoryIdIgnore.class);
TenantIdIgnore annotation = method.getAnnotation(TenantIdIgnore.class);
return FactoryIdIgnoreUtil.executeException(annotation != null, pjp::proceed);
return TenantIdIgnoreUtil.executeException(annotation != null, pjp::proceed);
}
......
......@@ -6,7 +6,7 @@ import com.makeit.utils.request.Scope;
import java.util.concurrent.Callable;
import java.util.function.Supplier;
public class FactoryIdIgnoreUtil {
public class TenantIdIgnoreUtil {
private static final Scope<Boolean> THREAD_LOCAL = new Scope<>();//不用scope变量 就要在 请求拦截的完成那边 清除掉threadlocal
......
......@@ -18,7 +18,7 @@ import java.util.function.Supplier;
import java.util.stream.Collectors;
@Component
public class FactoryIdUtil {
public class TenantIdUtil {
private static SysFactoryService sysFactoryService;
......@@ -39,14 +39,14 @@ public class FactoryIdUtil {
}
public static String getFromHeader() {
return RequestUtil.getFactoryIdHeader();
return RequestUtil.getTenantIdHeader();
}
public static String getFactoryId() {
public static String getTenantId() {
List<Supplier<String>> supplierList = Arrays.asList(
FactoryIdUtil::getFromThreadLocal,
FactoryIdUtil::getFromHeader//,
TenantIdUtil::getFromThreadLocal,
TenantIdUtil::getFromHeader//,
);
for (Supplier<String> supplier : supplierList) {
......@@ -60,7 +60,7 @@ public class FactoryIdUtil {
}
public static List<String> deptIdList() {
return deptIdList(getFactoryId());
return deptIdList(getTenantId());
}
public static List<String> deptIdList(String factoryId) {
......@@ -93,11 +93,11 @@ public class FactoryIdUtil {
@Autowired
public void setSysDeptService(SysDeptService sysDeptService) {
FactoryIdUtil.sysDeptService = sysDeptService;
TenantIdUtil.sysDeptService = sysDeptService;
}
@Autowired
public void setSysFactoryService(SysFactoryService sysFactoryService) {
FactoryIdUtil.sysFactoryService = sysFactoryService;
TenantIdUtil.sysFactoryService = sysFactoryService;
}
}
package com.makeit.module.admin.dto;
import com.makeit.common.dto.BaseFactoryDTO;
import com.makeit.common.dto.BaseTenantIdDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ApiModel("部门 查询")
@Data
public class SysDeptQueryDTO extends BaseFactoryDTO {
public class SysDeptQueryDTO extends BaseTenantIdDTO {
@ApiModelProperty(value = "名称")
private String name;
......
package com.makeit.module.admin.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.makeit.common.dto.BaseFactoryDTO;
import com.makeit.common.dto.BaseTenantIdDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......@@ -15,7 +15,7 @@ import java.util.List;
@ApiModel("角色 列表 新增 编辑 详情")
@Data
public class SysRoleDTOVO extends BaseFactoryDTO implements Serializable {
public class SysRoleDTOVO extends BaseTenantIdDTO implements Serializable {
@NotBlank(message = "名称不能为空")
@Size(max = 64, message = "名称最长为64字符")
......
package com.makeit.module.admin.dto;
import com.makeit.common.dto.BaseFactoryDTO;
import com.makeit.common.dto.BaseTenantIdDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......@@ -11,7 +11,7 @@ import java.util.List;
@ApiModel("角色分配菜单")
@Data
public class SysRoleMenuDTO extends BaseFactoryDTO implements Serializable {
public class SysRoleMenuDTO extends BaseTenantIdDTO implements Serializable {
// @ApiModelProperty(value = "菜单id")
// private String menuId;
......
package com.makeit.module.admin.dto;
import com.makeit.common.dto.BaseFactoryDTO;
import com.makeit.common.dto.BaseTenantIdDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......@@ -9,7 +9,7 @@ import java.io.Serializable;
@ApiModel("角色分配用户")
@Data
public class SysUserRoleDTO extends BaseFactoryDTO implements Serializable {
public class SysUserRoleDTO extends BaseTenantIdDTO implements Serializable {
@ApiModelProperty(value = "用户id")
private String userId;
......
......@@ -11,7 +11,7 @@ import com.makeit.enums.CodeMessageEnum;
import com.makeit.enums.CommonEnum;
import com.makeit.enums.id.IdConst;
import com.makeit.exception.BusinessException;
import com.makeit.global.aspect.tenant.FactoryIdUtil;
import com.makeit.global.aspect.tenant.TenantIdUtil;
import com.makeit.module.admin.dto.SysRoleDTOVO;
import com.makeit.module.admin.dto.SysRoleFactoryDTO;
import com.makeit.module.admin.dto.SysRoleMenuDTO;
......@@ -73,7 +73,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
LambdaQueryWrapper<SysRole> lambdaQueryWrapper = new QueryWrapper<SysRole>().lambda()
.eq(SysRole::getFactoryId, FactoryIdUtil.getFactoryId())
.eq(SysRole::getTenantId, TenantIdUtil.getTenantId())
.like(StringUtils.isNotBlank(dto.getName()), SysRole::getName, dto.getName())
.like(StringUtils.isNotBlank(dto.getCode()), SysRole::getCode, dto.getCode())
......@@ -154,14 +154,14 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
SysRole old = WrapperUtil.getOne(this, new QueryWrapper<SysRole>().lambda()
.eq(SysRole::getFactoryId, FactoryIdUtil.getFactoryId())
.eq(SysRole::getTenantId, TenantIdUtil.getTenantId())
.eq(SysRole::getName, dto.getName()));
if (old != null && !old.getId().equals(dto.getId())) {
throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR_NAME_DUPLICATE);
}
old = WrapperUtil.getOne(this, new QueryWrapper<SysRole>().lambda()
.eq(SysRole::getFactoryId, FactoryIdUtil.getFactoryId())
.eq(SysRole::getTenantId, TenantIdUtil.getTenantId())
.eq(SysRole::getCode, dto.getCode()));
if (old != null && !old.getId().equals(dto.getId())) {
throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR_CODE_DUPLICATE);
......@@ -184,7 +184,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
check(dto);
SysRole sysRole = BeanDtoVoUtils.convert(dto, SysRole.class);
sysRole.setFactoryId(FactoryIdUtil.getFactoryId());
sysRole.setTenantId(TenantIdUtil.getTenantId());
save(sysRole);
dto.setId(sysRole.getId());
......@@ -201,7 +201,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
SysRole role = BeanDtoVoUtils.convert(dto, SysRole.class);
role.setFactoryId(old.getFactoryId());
role.setTenantId(old.getTenantId());
updateById(role);
......@@ -255,7 +255,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
List<SysUserRole> userRoleList = BeanDtoVoUtils.listVo(userRoleDTOList, SysUserRole.class);
userRoleDTOList.forEach(e -> {
e.setFactoryId(FactoryIdUtil.getFactoryId());
e.setTenantId(TenantIdUtil.getTenantId());
});
sysUserRoleService.saveBatch(userRoleList);
......@@ -331,7 +331,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
SysRoleWechatMenu tntRoleMenu = new SysRoleWechatMenu();
tntRoleMenu.setRoleId(roleMenuDTO.getRoleId());
tntRoleMenu.setMenuId(e);
tntRoleMenu.setFactoryId(roleMenuDTO.getFactoryId());
tntRoleMenu.setTenantId(roleMenuDTO.getTenantId());
return tntRoleMenu;
});
......@@ -377,7 +377,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
public String factoryInit(String factoryId) {
SysRole role = new SysRole();
role.setFactoryId(factoryId);
role.setTenantId(factoryId);
role.setName(IdConst.ROLE_COMMON_USER_NAME);
role.setStatus(CommonEnum.YES.getValue());
role.setCode(IdConst.ROLE_COMMON_USER_CODE);
......
......@@ -18,8 +18,8 @@ import com.makeit.enums.biz.auth.SysUserEnum;
import com.makeit.enums.biz.sys.SysDictCategoryConst;
import com.makeit.enums.id.IdConst;
import com.makeit.exception.BusinessException;
import com.makeit.global.aspect.tenant.FactoryIdIgnore;
import com.makeit.global.aspect.tenant.FactoryIdUtil;
import com.makeit.global.aspect.tenant.TenantIdIgnore;
import com.makeit.global.aspect.tenant.TenantIdUtil;
import com.makeit.module.admin.dto.*;
import com.makeit.module.admin.entity.*;
import com.makeit.module.admin.mapper.SysUserMapper;
......@@ -826,7 +826,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
LambdaQueryWrapper<SysUser> lambdaQueryWrapper = defaultUserWrapper();
List<String> deptIdList = FactoryIdUtil.deptIdList(factoryId);
List<String> deptIdList = TenantIdUtil.deptIdList(factoryId);
findInSet(lambdaQueryWrapper, deptIdList);
......@@ -837,7 +837,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
sysUserRole.setUserId(e.getId());
sysUserRole.setRoleId(roleId);
sysUserRole.setFactoryId(factoryId);
sysUserRole.setTenantId(factoryId);
return sysUserRole;
});
......@@ -867,7 +867,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
}
@FactoryIdIgnore
@TenantIdIgnore
@Override
public List<SysUserVO> listByRoleAndMenuCode(SysRoleAndMenuCodeDTO codeDTO) {
......
package com.makeit.module.system.dto;
import com.makeit.common.dto.BaseFactoryDTO;
import com.makeit.common.dto.BaseTenantIdDTO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class SysConfigCategoryDTOVO extends BaseFactoryDTO {
public class SysConfigCategoryDTOVO extends BaseTenantIdDTO {
@ApiModelProperty("编码")
private String code;
......
......@@ -6,7 +6,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.makeit.enums.CodeMessageEnum;
import com.makeit.enums.redis.RedisConst;
import com.makeit.exception.BusinessException;
import com.makeit.global.aspect.tenant.FactoryIdUtil;
import com.makeit.global.aspect.tenant.TenantIdUtil;
import com.makeit.module.system.dto.SysConfigCategoryDTOVO;
import com.makeit.module.system.entity.SysConfig;
import com.makeit.module.system.entity.SysConfigCategory;
......@@ -34,7 +34,7 @@ public class SysConfigCategoryServiceImpl extends ServiceImpl<SysConfigCategoryM
List<SysConfigCategory> configCategoryList = list(new QueryWrapper<SysConfigCategory>().lambda()
.like(StringUtils.isNotBlank(tntConfigCategory.getName()), SysConfigCategory::getName, tntConfigCategory.getName())
.like(StringUtils.isNotBlank(tntConfigCategory.getCode()), SysConfigCategory::getCode, tntConfigCategory.getCode())
.eq(SysConfigCategory::getFactoryId, tntConfigCategory.getFactoryId())
.eq(SysConfigCategory::getTenantId, tntConfigCategory.getTenantId())
.orderByAsc(SysConfigCategory::getCreatedAt)
);
return BeanDtoVoUtils.listVo(configCategoryList, SysConfigCategoryDTOVO.class);
......@@ -42,14 +42,14 @@ public class SysConfigCategoryServiceImpl extends ServiceImpl<SysConfigCategoryM
private void checkPlatform(SysConfigCategoryDTOVO tntConfigCategory) {
SysConfigCategory old = getOne(new QueryWrapper<SysConfigCategory>().lambda()
.eq(SysConfigCategory::getFactoryId, tntConfigCategory.getFactoryId())
.eq(SysConfigCategory::getTenantId, tntConfigCategory.getTenantId())
.eq(SysConfigCategory::getName, tntConfigCategory.getName()));
if (old != null && !old.getId().equals(tntConfigCategory.getId())) {
throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR_NAME_DUPLICATE);
}
old = getOne(new QueryWrapper<SysConfigCategory>().lambda()
.eq(SysConfigCategory::getFactoryId, tntConfigCategory.getFactoryId())
.eq(SysConfigCategory::getTenantId, tntConfigCategory.getTenantId())
.eq(SysConfigCategory::getCode, tntConfigCategory.getCode()));
if (old != null && !old.getId().equals(tntConfigCategory.getId())) {
throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR_CODE_DUPLICATE);
......@@ -58,9 +58,9 @@ public class SysConfigCategoryServiceImpl extends ServiceImpl<SysConfigCategoryM
}
private void removeConfigList(SysConfigCategoryDTOVO tntConfigCategory, List<SysConfig> configList) {
RedisCacheUtil.del(RedisConst.CACHE_TNT_CONFIG_CATEGORY_CODE_PREFIX + FactoryIdUtil.getFactoryId() + ":" + tntConfigCategory.getCode());
RedisCacheUtil.del(RedisConst.CACHE_TNT_CONFIG_CATEGORY_CODE_PREFIX + TenantIdUtil.getTenantId() + ":" + tntConfigCategory.getCode());
configList.forEach(e -> {
RedisCacheUtil.del(RedisConst.CACHE_TNT_CONFIG_CODE_PREFIX + FactoryIdUtil.getFactoryId() + ":" + e.getCode());
RedisCacheUtil.del(RedisConst.CACHE_TNT_CONFIG_CODE_PREFIX + TenantIdUtil.getTenantId() + ":" + e.getCode());
});
}
......@@ -116,7 +116,7 @@ public class SysConfigCategoryServiceImpl extends ServiceImpl<SysConfigCategoryM
@Override
public SysConfigCategoryDTOVO viewByCode(String tenantId, String code) {
SysConfigCategory configCategory = getOne(new QueryWrapper<SysConfigCategory>().lambda()
.eq(StringUtils.isNotBlank(tenantId), SysConfigCategory::getFactoryId, tenantId)
.eq(StringUtils.isNotBlank(tenantId), SysConfigCategory::getTenantId, tenantId)
.eq(SysConfigCategory::getCode, code));
;
return BeanDtoVoUtils.convert(configCategory, SysConfigCategoryDTOVO.class);
......
package com.makeit.utils;
import com.makeit.global.aspect.tenant.FactoryIdUtil;
import com.makeit.global.aspect.tenant.TenantIdUtil;
import com.makeit.module.admin.service.SysDeptService;
import com.makeit.utils.user.tenant.SysUserUtil;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -14,7 +14,7 @@ public class DeptIdUtil {
private static SysDeptService sysDeptService;
public static List<String> deptIdListFromHeader() {
return FactoryIdUtil.deptIdList();
return TenantIdUtil.deptIdList();
}
public static List<String> deptIdListFromUser() {
......
......@@ -95,8 +95,8 @@ public class RequestUtil {
return getHeader(HeaderConst.DUPLICATE_REQUEST_ID);
}
public static String getFactoryIdHeader() {
return getHeader(HeaderConst.FACTORY_ID);
public static String getTenantIdHeader() {
return getHeader(HeaderConst.TENANT_ID);
}
//
......
......@@ -4,9 +4,9 @@ import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
import com.baomidou.mybatisplus.extension.service.IService;
import com.makeit.common.dto.BaseFactoryDTO;
import com.makeit.common.dto.BaseTenantIdDTO;
import com.makeit.common.entity.BaseBusEntity;
import com.makeit.global.aspect.tenant.FactoryIdUtil;
import com.makeit.global.aspect.tenant.TenantIdUtil;
import java.util.List;
......@@ -18,21 +18,21 @@ import java.util.List;
*/
public class WrapperUtil {
public static <T extends BaseBusEntity> LambdaQueryWrapper<T> withFactoryId(Class<T> clazz) {
public static <T extends BaseBusEntity> LambdaQueryWrapper<T> withTenantId(Class<T> clazz) {
LambdaQueryWrapper<T> lambdaQueryWrapper = new LambdaQueryWrapper<>(clazz);
lambdaQueryWrapper.eq(BaseBusEntity::getFactoryId, FactoryIdUtil.getFactoryId());
lambdaQueryWrapper.eq(BaseBusEntity::getTenantId, TenantIdUtil.getTenantId());
return lambdaQueryWrapper;
}
public static <T extends BaseBusEntity> LambdaQueryWrapper<T> withFactoryId(String tenantId, Class<T> clazz) {
public static <T extends BaseBusEntity> LambdaQueryWrapper<T> withTenantId(String tenantId, Class<T> clazz) {
LambdaQueryWrapper<T> lambdaQueryWrapper = new LambdaQueryWrapper<>(clazz);
lambdaQueryWrapper.eq(BaseBusEntity::getFactoryId, tenantId);
lambdaQueryWrapper.eq(BaseBusEntity::getTenantId, tenantId);
return lambdaQueryWrapper;
}
public static <T extends BaseBusEntity> LambdaQueryWrapper<T> withFactoryId(BaseFactoryDTO baseFactoryDTO, Class<T> clazz) {
public static <T extends BaseBusEntity> LambdaQueryWrapper<T> withTenantId(BaseTenantIdDTO baseFactoryDTO, Class<T> clazz) {
LambdaQueryWrapper<T> lambdaQueryWrapper = new LambdaQueryWrapper<>(clazz);
lambdaQueryWrapper.eq(BaseBusEntity::getFactoryId, baseFactoryDTO.getFactoryId());
lambdaQueryWrapper.eq(BaseBusEntity::getTenantId, baseFactoryDTO.getTenantId());
return lambdaQueryWrapper;
}
......
......@@ -3,7 +3,7 @@ package com.makeit.utils.sys;
import com.makeit.enums.CodeMessageEnum;
import com.makeit.enums.redis.RedisConst;
import com.makeit.exception.BusinessException;
import com.makeit.global.aspect.tenant.FactoryIdUtil;
import com.makeit.global.aspect.tenant.TenantIdUtil;
import com.makeit.module.system.dto.CategoryCodeDTO;
import com.makeit.module.system.dto.CodeDTO;
import com.makeit.module.system.service.SysConfigService;
......@@ -87,8 +87,8 @@ public class SysConfigUtil {
//还有二级缓存 防止循环读redis
List<SysConfigVO> configList =
LocalCacheUtil.get(RedisConst.CACHE_TNT_CONFIG_CATEGORY_CODE_PREFIX + FactoryIdUtil.getFactoryId() + ":" + categoryCode,
() -> RedisCacheUtil.get(RedisConst.CACHE_TNT_CONFIG_CATEGORY_CODE_PREFIX + FactoryIdUtil.getFactoryId() + ":" + categoryCode,
LocalCacheUtil.get(RedisConst.CACHE_TNT_CONFIG_CATEGORY_CODE_PREFIX + TenantIdUtil.getTenantId() + ":" + categoryCode,
() -> RedisCacheUtil.get(RedisConst.CACHE_TNT_CONFIG_CATEGORY_CODE_PREFIX + TenantIdUtil.getTenantId() + ":" + categoryCode,
() -> sysConfigService.viewListByCategoryCodeCanNull(categoryCode), 5),
1);
configList.forEach(SysConfigUtil::convertMessage);
......@@ -101,8 +101,8 @@ public class SysConfigUtil {
//有redis 缓存
//还有二级缓存 防止循环读redis
SysConfigVO configVO = LocalCacheUtil.get(RedisConst.CACHE_TNT_CONFIG_CODE_PREFIX + FactoryIdUtil.getFactoryId() + ":" + code, () ->
RedisCacheUtil.get(RedisConst.CACHE_TNT_CONFIG_CODE_PREFIX + FactoryIdUtil.getFactoryId() + ":" + code, () -> {
SysConfigVO configVO = LocalCacheUtil.get(RedisConst.CACHE_TNT_CONFIG_CODE_PREFIX + TenantIdUtil.getTenantId() + ":" + code, () ->
RedisCacheUtil.get(RedisConst.CACHE_TNT_CONFIG_CODE_PREFIX + TenantIdUtil.getTenantId() + ":" + code, () -> {
CodeDTO codeDTO = new CodeDTO();
codeDTO.setCode(code);
return sysConfigService.viewByCode(code);
......
package com.makeit.utils.user.tenant;
import com.makeit.common.dto.BaseFactoryDTO;
import com.makeit.common.dto.BaseTenantIdDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ApiModel("厂别用户vo")
@Data
public class SysUserVO extends BaseFactoryDTO {
public class SysUserVO extends BaseTenantIdDTO {
@ApiModelProperty(value = "姓名")
private String name;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment