mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-10-31 10:18:42 +08:00 
			
		
		
		
	!446 配合周建进行测试所提bug的后端修改
Merge pull request !446 from clockdotnet/master_pr
This commit is contained in:
		| @@ -78,8 +78,8 @@ public class TenantSecurityWebFilter extends ApiRequestFilter { | ||||
|             // 2. 如果请求未带租户的编号,不允许访问。 | ||||
|             if (tenantId == null) { | ||||
|                 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; | ||||
|             } | ||||
|             // 3. 校验租户是合法,例如说被禁用、到期 | ||||
|   | ||||
| @@ -1,9 +1,7 @@ | ||||
| package cn.iocoder.yudao.framework.mybatis.core.query; | ||||
|  | ||||
| import cn.hutool.core.lang.Assert; | ||||
| import cn.hutool.core.util.ArrayUtil; | ||||
| 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.toolkit.CollectionUtils; | ||||
| import com.baomidou.mybatisplus.core.toolkit.support.SFunction; | ||||
| @@ -13,7 +11,7 @@ import java.util.Collection; | ||||
|  | ||||
| /** | ||||
|  * 拓展 MyBatis Plus QueryWrapper 类,主要增加如下功能: | ||||
|  * | ||||
|  * <p> | ||||
|  * 1. 拼接条件的方法,增加 xxxIfPresent 方法,用于判断值不存在的时候,不要拼接到条件中。 | ||||
|  * | ||||
|  * @param <T> 数据类型 | ||||
| @@ -42,14 +40,14 @@ public class LambdaQueryWrapperX<T> extends LambdaQueryWrapper<T> { | ||||
|     } | ||||
|  | ||||
|     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 this; | ||||
|     } | ||||
|  | ||||
|     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 this; | ||||
|   | ||||
| @@ -23,6 +23,9 @@ public class CodegenTablePageReqVO extends PageParam { | ||||
|     @Schema(description = "表描述,模糊匹配", example = "芋道") | ||||
|     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]") | ||||
|     @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||||
|     private LocalDateTime[] createTime; | ||||
|   | ||||
| @@ -29,8 +29,8 @@ public class ConfigBaseVO { | ||||
|     @Size(max = 500, message = "参数键值长度不能超过500个字符") | ||||
|     private String value; | ||||
|  | ||||
|     @Schema(description = "是否敏感", required = true, example = "true") | ||||
|     @NotNull(message = "是否敏感不能为空") | ||||
|     @Schema(description = "是否可见", required = true, example = "true") | ||||
|     @NotNull(message = "是否可见不能为空") | ||||
|     private Boolean visible; | ||||
|  | ||||
|     @Schema(description = "备注", example = "备注一下很帅气!") | ||||
|   | ||||
| @@ -18,10 +18,10 @@ public class ConfigExcelVO { | ||||
|     private Long id; | ||||
|  | ||||
|     @ExcelProperty("参数键名") | ||||
|     private String key; | ||||
|     private String configKey; | ||||
|  | ||||
|     @ExcelProperty("参数分组") | ||||
|     private String group; | ||||
|     @ExcelProperty("参数分类") | ||||
|     private String category; | ||||
|  | ||||
|     @ExcelProperty("参数名称") | ||||
|     private String name; | ||||
| @@ -33,9 +33,9 @@ public class ConfigExcelVO { | ||||
|     @DictFormat(DictTypeConstants.CONFIG_TYPE) | ||||
|     private Integer type; | ||||
|  | ||||
|     @ExcelProperty(value = "是否敏感", converter = DictConvert.class) | ||||
|     @ExcelProperty(value = "是否可见", converter = DictConvert.class) | ||||
|     @DictFormat(DictTypeConstants.BOOLEAN_STRING) | ||||
|     private Boolean sensitive; | ||||
|     private Boolean visible; | ||||
|  | ||||
|     @ExcelProperty("备注") | ||||
|     private String remark; | ||||
|   | ||||
| @@ -21,6 +21,7 @@ public interface CodegenTableMapper extends BaseMapperX<CodegenTableDO> { | ||||
|         return selectPage(pageReqVO, new LambdaQueryWrapperX<CodegenTableDO>() | ||||
|                 .likeIfPresent(CodegenTableDO::getTableName, pageReqVO.getTableName()) | ||||
|                 .likeIfPresent(CodegenTableDO::getTableComment, pageReqVO.getTableComment()) | ||||
|                 .likeIfPresent(CodegenTableDO::getClassName, pageReqVO.getClassName()) | ||||
|                 .betweenIfPresent(CodegenTableDO::getCreateTime, pageReqVO.getCreateTime())); | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -103,6 +103,7 @@ public interface ErrorCodeConstants { | ||||
|     ErrorCode TENANT_DISABLE = new ErrorCode(1002015001, "名字为【{}】的租户已被禁用"); | ||||
|     ErrorCode TENANT_EXPIRE = new ErrorCode(1002015002, "名字为【{}】的租户已过期"); | ||||
|     ErrorCode TENANT_CAN_NOT_UPDATE_SYSTEM = new ErrorCode(1002015003, "系统租户不能进行修改、删除等操作!"); | ||||
|     ErrorCode TENANT_NAME_DUPLICATE = new ErrorCode(1002015004, "已经存在该名称的租户"); | ||||
|  | ||||
|     // ========== 租户套餐 1002016000 ========== | ||||
|     ErrorCode TENANT_PACKAGE_NOT_EXISTS = new ErrorCode(1002016000, "租户套餐不存在"); | ||||
|   | ||||
| @@ -38,6 +38,12 @@ public interface TenantMapper extends BaseMapperX<TenantDO> { | ||||
|                 .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) { | ||||
|         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.TenantMenuHandler; | ||||
| import cn.iocoder.yudao.module.system.service.user.AdminUserService; | ||||
| import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | ||||
| import lombok.extern.slf4j.Slf4j; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.context.annotation.Lazy; | ||||
| @@ -97,6 +98,9 @@ public class TenantServiceImpl implements TenantService { | ||||
|     @Override | ||||
|     @Transactional(rollbackFor = Exception.class) | ||||
|     public Long createTenant(TenantCreateReqVO createReqVO) { | ||||
|         // 校验租户名称是否重复 | ||||
|         validTenantName(createReqVO.getName(), null); | ||||
|  | ||||
|         // 校验套餐被禁用 | ||||
|         TenantPackageDO tenantPackage = tenantPackageService.validTenantPackage(createReqVO.getPackageId()); | ||||
|  | ||||
| @@ -139,6 +143,10 @@ public class TenantServiceImpl implements TenantService { | ||||
|     public void updateTenant(TenantUpdateReqVO updateReqVO) { | ||||
|         // 校验存在 | ||||
|         TenantDO tenant = validateUpdateTenant(updateReqVO.getId()); | ||||
|  | ||||
|         // 校验租户名称是否重复 | ||||
|         validTenantName(updateReqVO.getName(), updateReqVO.getId()); | ||||
|  | ||||
|         // 校验套餐被禁用 | ||||
|         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 | ||||
|     @Transactional(rollbackFor = Exception.class) | ||||
|     public void updateTenantRoleMenu(Long tenantId, Set<Long> menuIds) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 芋道源码
					芋道源码