Commit aa16b8279fbe676bc2feab8b7ba080b0394dd4f5
Committed by
Gitee
!446 配合周建进行测试所提bug的后端修改
Merge pull request !446 from clockdotnet/master_pr
Showing
10 changed files
with
88 additions
and
65 deletions
.gitignore
| 1 | -###################################################################### | ||
| 2 | -# Build Tools | ||
| 3 | - | ||
| 4 | -.gradle | ||
| 5 | -/build/ | ||
| 6 | -!gradle/wrapper/gradle-wrapper.jar | ||
| 7 | - | ||
| 8 | -target/ | ||
| 9 | -!.mvn/wrapper/maven-wrapper.jar | ||
| 10 | - | ||
| 11 | -###################################################################### | ||
| 12 | -# IDE | ||
| 13 | - | ||
| 14 | -### STS ### | ||
| 15 | -.apt_generated | ||
| 16 | -.classpath | ||
| 17 | -.factorypath | ||
| 18 | -.project | ||
| 19 | -.settings | ||
| 20 | -.springBeans | ||
| 21 | - | ||
| 22 | -### IntelliJ IDEA ### | ||
| 23 | -.idea | ||
| 24 | -*.iws | ||
| 25 | -*.iml | ||
| 26 | -*.ipr | ||
| 27 | - | ||
| 28 | -### NetBeans ### | ||
| 29 | -nbproject/private/ | ||
| 30 | -build/* | ||
| 31 | -nbbuild/ | ||
| 32 | -dist/ | ||
| 33 | -nbdist/ | ||
| 34 | -.nb-gradle/ | ||
| 35 | - | ||
| 36 | -###################################################################### | ||
| 37 | -# Others | ||
| 38 | -*.log | ||
| 39 | -*.xml.versionsBackup | ||
| 40 | -*.swp | ||
| 41 | - | ||
| 42 | -!*/build/*.java | ||
| 43 | -!*/build/*.html | ||
| 44 | -!*/build/*.xml | ||
| 45 | - | ||
| 46 | -### JRebel ### | ||
| 47 | -rebel.xml | ||
| 48 | - | ||
| 49 | -application-my.yaml | ||
| 50 | - | ||
| 51 | -/yudao-ui-app/unpackage/ | 1 | +###################################################################### |
| 2 | +# Build Tools | ||
| 3 | + | ||
| 4 | +.gradle | ||
| 5 | +/build/ | ||
| 6 | +!gradle/wrapper/gradle-wrapper.jar | ||
| 7 | + | ||
| 8 | +target/ | ||
| 9 | +!.mvn/wrapper/maven-wrapper.jar | ||
| 10 | + | ||
| 11 | +###################################################################### | ||
| 12 | +# IDE | ||
| 13 | + | ||
| 14 | +### STS ### | ||
| 15 | +.apt_generated | ||
| 16 | +.classpath | ||
| 17 | +.factorypath | ||
| 18 | +.project | ||
| 19 | +.settings | ||
| 20 | +.springBeans | ||
| 21 | + | ||
| 22 | +### IntelliJ IDEA ### | ||
| 23 | +.idea | ||
| 24 | +*.iws | ||
| 25 | +*.iml | ||
| 26 | +*.ipr | ||
| 27 | + | ||
| 28 | +### NetBeans ### | ||
| 29 | +nbproject/private/ | ||
| 30 | +build/* | ||
| 31 | +nbbuild/ | ||
| 32 | +dist/ | ||
| 33 | +nbdist/ | ||
| 34 | +.nb-gradle/ | ||
| 35 | + | ||
| 36 | +###################################################################### | ||
| 37 | +# Others | ||
| 38 | +*.log | ||
| 39 | +*.xml.versionsBackup | ||
| 40 | +*.swp | ||
| 41 | + | ||
| 42 | +!*/build/*.java | ||
| 43 | +!*/build/*.html | ||
| 44 | +!*/build/*.xml | ||
| 45 | + | ||
| 46 | +### JRebel ### | ||
| 47 | +rebel.xml | ||
| 48 | + | ||
| 49 | +application-my.yaml | ||
| 50 | + | ||
| 51 | +/yudao-ui-app/unpackage/ |
yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/core/security/TenantSecurityWebFilter.java
| @@ -78,8 +78,8 @@ public class TenantSecurityWebFilter extends ApiRequestFilter { | @@ -78,8 +78,8 @@ public class TenantSecurityWebFilter extends ApiRequestFilter { | ||
| 78 | // 2. 如果请求未带租户的编号,不允许访问。 | 78 | // 2. 如果请求未带租户的编号,不允许访问。 |
| 79 | if (tenantId == null) { | 79 | if (tenantId == null) { |
| 80 | log.error("[doFilterInternal][URL({}/{}) 未传递租户编号]", request.getRequestURI(), request.getMethod()); | 80 | log.error("[doFilterInternal][URL({}/{}) 未传递租户编号]", request.getRequestURI(), request.getMethod()); |
| 81 | - ServletUtils.writeJSON(response, CommonResult.error(GlobalErrorCodeConstants.BAD_REQUEST.getCode(), | ||
| 82 | - "租户的请求未传递,请进行排查")); | 81 | + String msg = "请求的租户标识未传递,请进行排查"; |
| 82 | + ServletUtils.writeJSON(response, CommonResult.error(GlobalErrorCodeConstants.BAD_REQUEST.getCode(), msg)); | ||
| 83 | return; | 83 | return; |
| 84 | } | 84 | } |
| 85 | // 3. 校验租户是合法,例如说被禁用、到期 | 85 | // 3. 校验租户是合法,例如说被禁用、到期 |
yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/query/LambdaQueryWrapperX.java
| 1 | package cn.iocoder.yudao.framework.mybatis.core.query; | 1 | package cn.iocoder.yudao.framework.mybatis.core.query; |
| 2 | 2 | ||
| 3 | -import cn.hutool.core.lang.Assert; | ||
| 4 | import cn.hutool.core.util.ArrayUtil; | 3 | import cn.hutool.core.util.ArrayUtil; |
| 5 | import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils; | 4 | import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils; |
| 6 | -import cn.iocoder.yudao.framework.mybatis.core.enums.SqlConstants; | ||
| 7 | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | 5 | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| 8 | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; | 6 | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| 9 | import com.baomidou.mybatisplus.core.toolkit.support.SFunction; | 7 | import com.baomidou.mybatisplus.core.toolkit.support.SFunction; |
| @@ -13,7 +11,7 @@ import java.util.Collection; | @@ -13,7 +11,7 @@ import java.util.Collection; | ||
| 13 | 11 | ||
| 14 | /** | 12 | /** |
| 15 | * 拓展 MyBatis Plus QueryWrapper 类,主要增加如下功能: | 13 | * 拓展 MyBatis Plus QueryWrapper 类,主要增加如下功能: |
| 16 | - * | 14 | + * <p> |
| 17 | * 1. 拼接条件的方法,增加 xxxIfPresent 方法,用于判断值不存在的时候,不要拼接到条件中。 | 15 | * 1. 拼接条件的方法,增加 xxxIfPresent 方法,用于判断值不存在的时候,不要拼接到条件中。 |
| 18 | * | 16 | * |
| 19 | * @param <T> 数据类型 | 17 | * @param <T> 数据类型 |
| @@ -42,14 +40,14 @@ public class LambdaQueryWrapperX<T> extends LambdaQueryWrapper<T> { | @@ -42,14 +40,14 @@ public class LambdaQueryWrapperX<T> extends LambdaQueryWrapper<T> { | ||
| 42 | } | 40 | } |
| 43 | 41 | ||
| 44 | public LambdaQueryWrapperX<T> eqIfPresent(SFunction<T, ?> column, Object val) { | 42 | public LambdaQueryWrapperX<T> eqIfPresent(SFunction<T, ?> column, Object val) { |
| 45 | - if (val != null) { | 43 | + if (val instanceof String && StringUtils.hasText((String) val) || !(val instanceof String) && val != null) { |
| 46 | return (LambdaQueryWrapperX<T>) super.eq(column, val); | 44 | return (LambdaQueryWrapperX<T>) super.eq(column, val); |
| 47 | } | 45 | } |
| 48 | return this; | 46 | return this; |
| 49 | } | 47 | } |
| 50 | 48 | ||
| 51 | public LambdaQueryWrapperX<T> neIfPresent(SFunction<T, ?> column, Object val) { | 49 | public LambdaQueryWrapperX<T> neIfPresent(SFunction<T, ?> column, Object val) { |
| 52 | - if (val != null) { | 50 | + if (val instanceof String && StringUtils.hasText((String) val) || !(val instanceof String) && val != null) { |
| 53 | return (LambdaQueryWrapperX<T>) super.ne(column, val); | 51 | return (LambdaQueryWrapperX<T>) super.ne(column, val); |
| 54 | } | 52 | } |
| 55 | return this; | 53 | return this; |
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/codegen/vo/table/CodegenTablePageReqVO.java
| @@ -23,6 +23,9 @@ public class CodegenTablePageReqVO extends PageParam { | @@ -23,6 +23,9 @@ public class CodegenTablePageReqVO extends PageParam { | ||
| 23 | @Schema(description = "表描述,模糊匹配", example = "芋道") | 23 | @Schema(description = "表描述,模糊匹配", example = "芋道") |
| 24 | private String tableComment; | 24 | private String tableComment; |
| 25 | 25 | ||
| 26 | + @Schema(description = "实体,模糊匹配", example = "Yudao") | ||
| 27 | + private String className; | ||
| 28 | + | ||
| 26 | @Schema(description = "创建时间", example = "[2022-07-01 00:00:00,2022-07-01 23:59:59]") | 29 | @Schema(description = "创建时间", example = "[2022-07-01 00:00:00,2022-07-01 23:59:59]") |
| 27 | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | 30 | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
| 28 | private LocalDateTime[] createTime; | 31 | private LocalDateTime[] createTime; |
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/config/vo/ConfigBaseVO.java
| @@ -29,8 +29,8 @@ public class ConfigBaseVO { | @@ -29,8 +29,8 @@ public class ConfigBaseVO { | ||
| 29 | @Size(max = 500, message = "参数键值长度不能超过500个字符") | 29 | @Size(max = 500, message = "参数键值长度不能超过500个字符") |
| 30 | private String value; | 30 | private String value; |
| 31 | 31 | ||
| 32 | - @Schema(description = "是否敏感", required = true, example = "true") | ||
| 33 | - @NotNull(message = "是否敏感不能为空") | 32 | + @Schema(description = "是否可见", required = true, example = "true") |
| 33 | + @NotNull(message = "是否可见不能为空") | ||
| 34 | private Boolean visible; | 34 | private Boolean visible; |
| 35 | 35 | ||
| 36 | @Schema(description = "备注", example = "备注一下很帅气!") | 36 | @Schema(description = "备注", example = "备注一下很帅气!") |
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/config/vo/ConfigExcelVO.java
| @@ -18,10 +18,10 @@ public class ConfigExcelVO { | @@ -18,10 +18,10 @@ public class ConfigExcelVO { | ||
| 18 | private Long id; | 18 | private Long id; |
| 19 | 19 | ||
| 20 | @ExcelProperty("参数键名") | 20 | @ExcelProperty("参数键名") |
| 21 | - private String key; | 21 | + private String configKey; |
| 22 | 22 | ||
| 23 | - @ExcelProperty("参数分组") | ||
| 24 | - private String group; | 23 | + @ExcelProperty("参数分类") |
| 24 | + private String category; | ||
| 25 | 25 | ||
| 26 | @ExcelProperty("参数名称") | 26 | @ExcelProperty("参数名称") |
| 27 | private String name; | 27 | private String name; |
| @@ -33,9 +33,9 @@ public class ConfigExcelVO { | @@ -33,9 +33,9 @@ public class ConfigExcelVO { | ||
| 33 | @DictFormat(DictTypeConstants.CONFIG_TYPE) | 33 | @DictFormat(DictTypeConstants.CONFIG_TYPE) |
| 34 | private Integer type; | 34 | private Integer type; |
| 35 | 35 | ||
| 36 | - @ExcelProperty(value = "是否敏感", converter = DictConvert.class) | 36 | + @ExcelProperty(value = "是否可见", converter = DictConvert.class) |
| 37 | @DictFormat(DictTypeConstants.BOOLEAN_STRING) | 37 | @DictFormat(DictTypeConstants.BOOLEAN_STRING) |
| 38 | - private Boolean sensitive; | 38 | + private Boolean visible; |
| 39 | 39 | ||
| 40 | @ExcelProperty("备注") | 40 | @ExcelProperty("备注") |
| 41 | private String remark; | 41 | private String remark; |
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/codegen/CodegenTableMapper.java
| @@ -21,6 +21,7 @@ public interface CodegenTableMapper extends BaseMapperX<CodegenTableDO> { | @@ -21,6 +21,7 @@ public interface CodegenTableMapper extends BaseMapperX<CodegenTableDO> { | ||
| 21 | return selectPage(pageReqVO, new LambdaQueryWrapperX<CodegenTableDO>() | 21 | return selectPage(pageReqVO, new LambdaQueryWrapperX<CodegenTableDO>() |
| 22 | .likeIfPresent(CodegenTableDO::getTableName, pageReqVO.getTableName()) | 22 | .likeIfPresent(CodegenTableDO::getTableName, pageReqVO.getTableName()) |
| 23 | .likeIfPresent(CodegenTableDO::getTableComment, pageReqVO.getTableComment()) | 23 | .likeIfPresent(CodegenTableDO::getTableComment, pageReqVO.getTableComment()) |
| 24 | + .likeIfPresent(CodegenTableDO::getClassName, pageReqVO.getClassName()) | ||
| 24 | .betweenIfPresent(CodegenTableDO::getCreateTime, pageReqVO.getCreateTime())); | 25 | .betweenIfPresent(CodegenTableDO::getCreateTime, pageReqVO.getCreateTime())); |
| 25 | } | 26 | } |
| 26 | 27 |
yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java
| @@ -103,6 +103,7 @@ public interface ErrorCodeConstants { | @@ -103,6 +103,7 @@ public interface ErrorCodeConstants { | ||
| 103 | ErrorCode TENANT_DISABLE = new ErrorCode(1002015001, "名字为【{}】的租户已被禁用"); | 103 | ErrorCode TENANT_DISABLE = new ErrorCode(1002015001, "名字为【{}】的租户已被禁用"); |
| 104 | ErrorCode TENANT_EXPIRE = new ErrorCode(1002015002, "名字为【{}】的租户已过期"); | 104 | ErrorCode TENANT_EXPIRE = new ErrorCode(1002015002, "名字为【{}】的租户已过期"); |
| 105 | ErrorCode TENANT_CAN_NOT_UPDATE_SYSTEM = new ErrorCode(1002015003, "系统租户不能进行修改、删除等操作!"); | 105 | ErrorCode TENANT_CAN_NOT_UPDATE_SYSTEM = new ErrorCode(1002015003, "系统租户不能进行修改、删除等操作!"); |
| 106 | + ErrorCode TENANT_NAME_DUPLICATE = new ErrorCode(1002015004, "已经存在该名称的租户"); | ||
| 106 | 107 | ||
| 107 | // ========== 租户套餐 1002016000 ========== | 108 | // ========== 租户套餐 1002016000 ========== |
| 108 | ErrorCode TENANT_PACKAGE_NOT_EXISTS = new ErrorCode(1002016000, "租户套餐不存在"); | 109 | ErrorCode TENANT_PACKAGE_NOT_EXISTS = new ErrorCode(1002016000, "租户套餐不存在"); |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/tenant/TenantMapper.java
| @@ -38,6 +38,12 @@ public interface TenantMapper extends BaseMapperX<TenantDO> { | @@ -38,6 +38,12 @@ public interface TenantMapper extends BaseMapperX<TenantDO> { | ||
| 38 | .orderByDesc(TenantDO::getId)); | 38 | .orderByDesc(TenantDO::getId)); |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | + default Long selectCountByName(String name, Long id) { | ||
| 42 | + return selectCount(new LambdaQueryWrapperX<TenantDO>() | ||
| 43 | + .eqIfPresent(TenantDO::getName, name) | ||
| 44 | + .neIfPresent(TenantDO::getId, id)); | ||
| 45 | + } | ||
| 46 | + | ||
| 41 | default TenantDO selectByName(String name) { | 47 | default TenantDO selectByName(String name) { |
| 42 | return selectOne(TenantDO::getName, name); | 48 | return selectOne(TenantDO::getName, name); |
| 43 | } | 49 | } |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/tenant/TenantServiceImpl.java
| @@ -29,6 +29,7 @@ import cn.iocoder.yudao.module.system.service.permission.RoleService; | @@ -29,6 +29,7 @@ import cn.iocoder.yudao.module.system.service.permission.RoleService; | ||
| 29 | import cn.iocoder.yudao.module.system.service.tenant.handler.TenantInfoHandler; | 29 | import cn.iocoder.yudao.module.system.service.tenant.handler.TenantInfoHandler; |
| 30 | import cn.iocoder.yudao.module.system.service.tenant.handler.TenantMenuHandler; | 30 | import cn.iocoder.yudao.module.system.service.tenant.handler.TenantMenuHandler; |
| 31 | import cn.iocoder.yudao.module.system.service.user.AdminUserService; | 31 | import cn.iocoder.yudao.module.system.service.user.AdminUserService; |
| 32 | +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | ||
| 32 | import lombok.extern.slf4j.Slf4j; | 33 | import lombok.extern.slf4j.Slf4j; |
| 33 | import org.springframework.beans.factory.annotation.Autowired; | 34 | import org.springframework.beans.factory.annotation.Autowired; |
| 34 | import org.springframework.context.annotation.Lazy; | 35 | import org.springframework.context.annotation.Lazy; |
| @@ -97,6 +98,9 @@ public class TenantServiceImpl implements TenantService { | @@ -97,6 +98,9 @@ public class TenantServiceImpl implements TenantService { | ||
| 97 | @Override | 98 | @Override |
| 98 | @Transactional(rollbackFor = Exception.class) | 99 | @Transactional(rollbackFor = Exception.class) |
| 99 | public Long createTenant(TenantCreateReqVO createReqVO) { | 100 | public Long createTenant(TenantCreateReqVO createReqVO) { |
| 101 | + // 校验租户名称是否重复 | ||
| 102 | + validTenantName(createReqVO.getName(), null); | ||
| 103 | + | ||
| 100 | // 校验套餐被禁用 | 104 | // 校验套餐被禁用 |
| 101 | TenantPackageDO tenantPackage = tenantPackageService.validTenantPackage(createReqVO.getPackageId()); | 105 | TenantPackageDO tenantPackage = tenantPackageService.validTenantPackage(createReqVO.getPackageId()); |
| 102 | 106 | ||
| @@ -139,6 +143,10 @@ public class TenantServiceImpl implements TenantService { | @@ -139,6 +143,10 @@ public class TenantServiceImpl implements TenantService { | ||
| 139 | public void updateTenant(TenantUpdateReqVO updateReqVO) { | 143 | public void updateTenant(TenantUpdateReqVO updateReqVO) { |
| 140 | // 校验存在 | 144 | // 校验存在 |
| 141 | TenantDO tenant = validateUpdateTenant(updateReqVO.getId()); | 145 | TenantDO tenant = validateUpdateTenant(updateReqVO.getId()); |
| 146 | + | ||
| 147 | + // 校验租户名称是否重复 | ||
| 148 | + validTenantName(updateReqVO.getName(), updateReqVO.getId()); | ||
| 149 | + | ||
| 142 | // 校验套餐被禁用 | 150 | // 校验套餐被禁用 |
| 143 | TenantPackageDO tenantPackage = tenantPackageService.validTenantPackage(updateReqVO.getPackageId()); | 151 | TenantPackageDO tenantPackage = tenantPackageService.validTenantPackage(updateReqVO.getPackageId()); |
| 144 | 152 | ||
| @@ -151,6 +159,12 @@ public class TenantServiceImpl implements TenantService { | @@ -151,6 +159,12 @@ public class TenantServiceImpl implements TenantService { | ||
| 151 | } | 159 | } |
| 152 | } | 160 | } |
| 153 | 161 | ||
| 162 | + protected void validTenantName(String tenantName, Long id) { | ||
| 163 | + if (tenantMapper.selectCountByName(tenantName, id) > 0) { | ||
| 164 | + throw exception(TENANT_NAME_DUPLICATE); | ||
| 165 | + } | ||
| 166 | + } | ||
| 167 | + | ||
| 154 | @Override | 168 | @Override |
| 155 | @Transactional(rollbackFor = Exception.class) | 169 | @Transactional(rollbackFor = Exception.class) |
| 156 | public void updateTenantRoleMenu(Long tenantId, Set<Long> menuIds) { | 170 | public void updateTenantRoleMenu(Long tenantId, Set<Long> menuIds) { |