commit
aa16b8279f
|
@ -1,51 +1,51 @@
|
||||||
######################################################################
|
######################################################################
|
||||||
# Build Tools
|
# Build Tools
|
||||||
|
|
||||||
.gradle
|
.gradle
|
||||||
/build/
|
/build/
|
||||||
!gradle/wrapper/gradle-wrapper.jar
|
!gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
target/
|
target/
|
||||||
!.mvn/wrapper/maven-wrapper.jar
|
!.mvn/wrapper/maven-wrapper.jar
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
# IDE
|
# IDE
|
||||||
|
|
||||||
### STS ###
|
### STS ###
|
||||||
.apt_generated
|
.apt_generated
|
||||||
.classpath
|
.classpath
|
||||||
.factorypath
|
.factorypath
|
||||||
.project
|
.project
|
||||||
.settings
|
.settings
|
||||||
.springBeans
|
.springBeans
|
||||||
|
|
||||||
### IntelliJ IDEA ###
|
### IntelliJ IDEA ###
|
||||||
.idea
|
.idea
|
||||||
*.iws
|
*.iws
|
||||||
*.iml
|
*.iml
|
||||||
*.ipr
|
*.ipr
|
||||||
|
|
||||||
### NetBeans ###
|
### NetBeans ###
|
||||||
nbproject/private/
|
nbproject/private/
|
||||||
build/*
|
build/*
|
||||||
nbbuild/
|
nbbuild/
|
||||||
dist/
|
dist/
|
||||||
nbdist/
|
nbdist/
|
||||||
.nb-gradle/
|
.nb-gradle/
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
# Others
|
# Others
|
||||||
*.log
|
*.log
|
||||||
*.xml.versionsBackup
|
*.xml.versionsBackup
|
||||||
*.swp
|
*.swp
|
||||||
|
|
||||||
!*/build/*.java
|
!*/build/*.java
|
||||||
!*/build/*.html
|
!*/build/*.html
|
||||||
!*/build/*.xml
|
!*/build/*.xml
|
||||||
|
|
||||||
### JRebel ###
|
### JRebel ###
|
||||||
rebel.xml
|
rebel.xml
|
||||||
|
|
||||||
application-my.yaml
|
application-my.yaml
|
||||||
|
|
||||||
/yudao-ui-app/unpackage/
|
/yudao-ui-app/unpackage/
|
||||||
|
|
|
@ -78,8 +78,8 @@ public class TenantSecurityWebFilter extends ApiRequestFilter {
|
||||||
// 2. 如果请求未带租户的编号,不允许访问。
|
// 2. 如果请求未带租户的编号,不允许访问。
|
||||||
if (tenantId == null) {
|
if (tenantId == null) {
|
||||||
log.error("[doFilterInternal][URL({}/{}) 未传递租户编号]", request.getRequestURI(), request.getMethod());
|
log.error("[doFilterInternal][URL({}/{}) 未传递租户编号]", request.getRequestURI(), request.getMethod());
|
||||||
ServletUtils.writeJSON(response, CommonResult.error(GlobalErrorCodeConstants.BAD_REQUEST.getCode(),
|
String msg = "请求的租户标识未传递,请进行排查";
|
||||||
"租户的请求未传递,请进行排查"));
|
ServletUtils.writeJSON(response, CommonResult.error(GlobalErrorCodeConstants.BAD_REQUEST.getCode(), msg));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 3. 校验租户是合法,例如说被禁用、到期
|
// 3. 校验租户是合法,例如说被禁用、到期
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
package cn.iocoder.yudao.framework.mybatis.core.query;
|
package cn.iocoder.yudao.framework.mybatis.core.query;
|
||||||
|
|
||||||
import cn.hutool.core.lang.Assert;
|
|
||||||
import cn.hutool.core.util.ArrayUtil;
|
import cn.hutool.core.util.ArrayUtil;
|
||||||
import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils;
|
import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.enums.SqlConstants;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
||||||
|
@ -13,7 +11,7 @@ import java.util.Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 拓展 MyBatis Plus QueryWrapper 类,主要增加如下功能:
|
* 拓展 MyBatis Plus QueryWrapper 类,主要增加如下功能:
|
||||||
*
|
* <p>
|
||||||
* 1. 拼接条件的方法,增加 xxxIfPresent 方法,用于判断值不存在的时候,不要拼接到条件中。
|
* 1. 拼接条件的方法,增加 xxxIfPresent 方法,用于判断值不存在的时候,不要拼接到条件中。
|
||||||
*
|
*
|
||||||
* @param <T> 数据类型
|
* @param <T> 数据类型
|
||||||
|
@ -42,14 +40,14 @@ public class LambdaQueryWrapperX<T> extends LambdaQueryWrapper<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public LambdaQueryWrapperX<T> eqIfPresent(SFunction<T, ?> column, Object val) {
|
public LambdaQueryWrapperX<T> eqIfPresent(SFunction<T, ?> column, Object val) {
|
||||||
if (val != null) {
|
if (val instanceof String && StringUtils.hasText((String) val) || !(val instanceof String) && val != null) {
|
||||||
return (LambdaQueryWrapperX<T>) super.eq(column, val);
|
return (LambdaQueryWrapperX<T>) super.eq(column, val);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LambdaQueryWrapperX<T> neIfPresent(SFunction<T, ?> column, Object val) {
|
public LambdaQueryWrapperX<T> neIfPresent(SFunction<T, ?> column, Object val) {
|
||||||
if (val != null) {
|
if (val instanceof String && StringUtils.hasText((String) val) || !(val instanceof String) && val != null) {
|
||||||
return (LambdaQueryWrapperX<T>) super.ne(column, val);
|
return (LambdaQueryWrapperX<T>) super.ne(column, val);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
|
|
|
@ -23,6 +23,9 @@ public class CodegenTablePageReqVO extends PageParam {
|
||||||
@Schema(description = "表描述,模糊匹配", example = "芋道")
|
@Schema(description = "表描述,模糊匹配", example = "芋道")
|
||||||
private String tableComment;
|
private String tableComment;
|
||||||
|
|
||||||
|
@Schema(description = "实体,模糊匹配", example = "Yudao")
|
||||||
|
private String className;
|
||||||
|
|
||||||
@Schema(description = "创建时间", example = "[2022-07-01 00:00:00,2022-07-01 23:59:59]")
|
@Schema(description = "创建时间", example = "[2022-07-01 00:00:00,2022-07-01 23:59:59]")
|
||||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||||
private LocalDateTime[] createTime;
|
private LocalDateTime[] createTime;
|
||||||
|
|
|
@ -29,8 +29,8 @@ public class ConfigBaseVO {
|
||||||
@Size(max = 500, message = "参数键值长度不能超过500个字符")
|
@Size(max = 500, message = "参数键值长度不能超过500个字符")
|
||||||
private String value;
|
private String value;
|
||||||
|
|
||||||
@Schema(description = "是否敏感", required = true, example = "true")
|
@Schema(description = "是否可见", required = true, example = "true")
|
||||||
@NotNull(message = "是否敏感不能为空")
|
@NotNull(message = "是否可见不能为空")
|
||||||
private Boolean visible;
|
private Boolean visible;
|
||||||
|
|
||||||
@Schema(description = "备注", example = "备注一下很帅气!")
|
@Schema(description = "备注", example = "备注一下很帅气!")
|
||||||
|
|
|
@ -18,10 +18,10 @@ public class ConfigExcelVO {
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@ExcelProperty("参数键名")
|
@ExcelProperty("参数键名")
|
||||||
private String key;
|
private String configKey;
|
||||||
|
|
||||||
@ExcelProperty("参数分组")
|
@ExcelProperty("参数分类")
|
||||||
private String group;
|
private String category;
|
||||||
|
|
||||||
@ExcelProperty("参数名称")
|
@ExcelProperty("参数名称")
|
||||||
private String name;
|
private String name;
|
||||||
|
@ -33,9 +33,9 @@ public class ConfigExcelVO {
|
||||||
@DictFormat(DictTypeConstants.CONFIG_TYPE)
|
@DictFormat(DictTypeConstants.CONFIG_TYPE)
|
||||||
private Integer type;
|
private Integer type;
|
||||||
|
|
||||||
@ExcelProperty(value = "是否敏感", converter = DictConvert.class)
|
@ExcelProperty(value = "是否可见", converter = DictConvert.class)
|
||||||
@DictFormat(DictTypeConstants.BOOLEAN_STRING)
|
@DictFormat(DictTypeConstants.BOOLEAN_STRING)
|
||||||
private Boolean sensitive;
|
private Boolean visible;
|
||||||
|
|
||||||
@ExcelProperty("备注")
|
@ExcelProperty("备注")
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
|
@ -21,6 +21,7 @@ public interface CodegenTableMapper extends BaseMapperX<CodegenTableDO> {
|
||||||
return selectPage(pageReqVO, new LambdaQueryWrapperX<CodegenTableDO>()
|
return selectPage(pageReqVO, new LambdaQueryWrapperX<CodegenTableDO>()
|
||||||
.likeIfPresent(CodegenTableDO::getTableName, pageReqVO.getTableName())
|
.likeIfPresent(CodegenTableDO::getTableName, pageReqVO.getTableName())
|
||||||
.likeIfPresent(CodegenTableDO::getTableComment, pageReqVO.getTableComment())
|
.likeIfPresent(CodegenTableDO::getTableComment, pageReqVO.getTableComment())
|
||||||
|
.likeIfPresent(CodegenTableDO::getClassName, pageReqVO.getClassName())
|
||||||
.betweenIfPresent(CodegenTableDO::getCreateTime, pageReqVO.getCreateTime()));
|
.betweenIfPresent(CodegenTableDO::getCreateTime, pageReqVO.getCreateTime()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -103,6 +103,7 @@ public interface ErrorCodeConstants {
|
||||||
ErrorCode TENANT_DISABLE = new ErrorCode(1002015001, "名字为【{}】的租户已被禁用");
|
ErrorCode TENANT_DISABLE = new ErrorCode(1002015001, "名字为【{}】的租户已被禁用");
|
||||||
ErrorCode TENANT_EXPIRE = new ErrorCode(1002015002, "名字为【{}】的租户已过期");
|
ErrorCode TENANT_EXPIRE = new ErrorCode(1002015002, "名字为【{}】的租户已过期");
|
||||||
ErrorCode TENANT_CAN_NOT_UPDATE_SYSTEM = new ErrorCode(1002015003, "系统租户不能进行修改、删除等操作!");
|
ErrorCode TENANT_CAN_NOT_UPDATE_SYSTEM = new ErrorCode(1002015003, "系统租户不能进行修改、删除等操作!");
|
||||||
|
ErrorCode TENANT_NAME_DUPLICATE = new ErrorCode(1002015004, "已经存在该名称的租户");
|
||||||
|
|
||||||
// ========== 租户套餐 1002016000 ==========
|
// ========== 租户套餐 1002016000 ==========
|
||||||
ErrorCode TENANT_PACKAGE_NOT_EXISTS = new ErrorCode(1002016000, "租户套餐不存在");
|
ErrorCode TENANT_PACKAGE_NOT_EXISTS = new ErrorCode(1002016000, "租户套餐不存在");
|
||||||
|
|
|
@ -38,6 +38,12 @@ public interface TenantMapper extends BaseMapperX<TenantDO> {
|
||||||
.orderByDesc(TenantDO::getId));
|
.orderByDesc(TenantDO::getId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default Long selectCountByName(String name, Long id) {
|
||||||
|
return selectCount(new LambdaQueryWrapperX<TenantDO>()
|
||||||
|
.eqIfPresent(TenantDO::getName, name)
|
||||||
|
.neIfPresent(TenantDO::getId, id));
|
||||||
|
}
|
||||||
|
|
||||||
default TenantDO selectByName(String name) {
|
default TenantDO selectByName(String name) {
|
||||||
return selectOne(TenantDO::getName, name);
|
return selectOne(TenantDO::getName, name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ import cn.iocoder.yudao.module.system.service.permission.RoleService;
|
||||||
import cn.iocoder.yudao.module.system.service.tenant.handler.TenantInfoHandler;
|
import cn.iocoder.yudao.module.system.service.tenant.handler.TenantInfoHandler;
|
||||||
import cn.iocoder.yudao.module.system.service.tenant.handler.TenantMenuHandler;
|
import cn.iocoder.yudao.module.system.service.tenant.handler.TenantMenuHandler;
|
||||||
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
|
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
|
@ -97,6 +98,9 @@ public class TenantServiceImpl implements TenantService {
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Long createTenant(TenantCreateReqVO createReqVO) {
|
public Long createTenant(TenantCreateReqVO createReqVO) {
|
||||||
|
// 校验租户名称是否重复
|
||||||
|
validTenantName(createReqVO.getName(), null);
|
||||||
|
|
||||||
// 校验套餐被禁用
|
// 校验套餐被禁用
|
||||||
TenantPackageDO tenantPackage = tenantPackageService.validTenantPackage(createReqVO.getPackageId());
|
TenantPackageDO tenantPackage = tenantPackageService.validTenantPackage(createReqVO.getPackageId());
|
||||||
|
|
||||||
|
@ -139,6 +143,10 @@ public class TenantServiceImpl implements TenantService {
|
||||||
public void updateTenant(TenantUpdateReqVO updateReqVO) {
|
public void updateTenant(TenantUpdateReqVO updateReqVO) {
|
||||||
// 校验存在
|
// 校验存在
|
||||||
TenantDO tenant = validateUpdateTenant(updateReqVO.getId());
|
TenantDO tenant = validateUpdateTenant(updateReqVO.getId());
|
||||||
|
|
||||||
|
// 校验租户名称是否重复
|
||||||
|
validTenantName(updateReqVO.getName(), updateReqVO.getId());
|
||||||
|
|
||||||
// 校验套餐被禁用
|
// 校验套餐被禁用
|
||||||
TenantPackageDO tenantPackage = tenantPackageService.validTenantPackage(updateReqVO.getPackageId());
|
TenantPackageDO tenantPackage = tenantPackageService.validTenantPackage(updateReqVO.getPackageId());
|
||||||
|
|
||||||
|
@ -151,6 +159,12 @@ public class TenantServiceImpl implements TenantService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void validTenantName(String tenantName, Long id) {
|
||||||
|
if (tenantMapper.selectCountByName(tenantName, id) > 0) {
|
||||||
|
throw exception(TENANT_NAME_DUPLICATE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void updateTenantRoleMenu(Long tenantId, Set<Long> menuIds) {
|
public void updateTenantRoleMenu(Long tenantId, Set<Long> menuIds) {
|
||||||
|
|
Loading…
Reference in New Issue