mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-10-31 18:28:43 +08:00 
			
		
		
		
	* 【新增】后端 yudao.tenant.enable 配置项,前端 VUE_APP_TENANT_ENABLE 配置项,用于开关租户功能
				
					
				
			* 【优化】调整默认所有表开启多租户的特性,可通过 `yudao.tenant.ignore-tables` 配置项进行忽略,替代原本默认不开启的策略 * 【新增】通过 `yudao.tenant.ignore-urls` 配置忽略多租户的请求,例如说 ,例如说短信回调、支付回调等 Open API
This commit is contained in:
		| @@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.tool.service.codegen.inner; | ||||
| import cn.hutool.core.map.MapUtil; | ||||
| import cn.hutool.core.util.ReflectUtil; | ||||
| import cn.hutool.core.util.StrUtil; | ||||
| import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; | ||||
| import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | ||||
| import cn.iocoder.yudao.module.tool.convert.codegen.CodegenConvert; | ||||
| import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.CodegenColumnDO; | ||||
| import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.CodegenTableDO; | ||||
| @@ -60,7 +60,7 @@ public class CodegenBuilder { | ||||
|      */ | ||||
|     public static final String TENANT_ID_FIELD = "tenant_id"; | ||||
|     /** | ||||
|      * {@link TenantBaseDO} 的字段 | ||||
|      * {@link cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO} 的字段 | ||||
|      */ | ||||
|     public static final Set<String> BASE_DO_FIELDS = new HashSet<>(); | ||||
|     /** | ||||
| @@ -96,7 +96,8 @@ public class CodegenBuilder { | ||||
|             .build(); | ||||
|  | ||||
|     static { | ||||
|         Arrays.stream(ReflectUtil.getFields(TenantBaseDO.class)).forEach(field -> BASE_DO_FIELDS.add(field.getName())); | ||||
|         Arrays.stream(ReflectUtil.getFields(BaseDO.class)).forEach(field -> BASE_DO_FIELDS.add(field.getName())); | ||||
|         BASE_DO_FIELDS.add(TENANT_ID_FIELD); | ||||
|         // 处理 OPERATION 相关的字段 | ||||
|         CREATE_OPERATION_EXCLUDE_COLUMN.addAll(BASE_DO_FIELDS); | ||||
|         UPDATE_OPERATION_EXCLUDE_COLUMN.addAll(BASE_DO_FIELDS); | ||||
|   | ||||
| @@ -1,8 +1,6 @@ | ||||
| package cn.iocoder.yudao.module.tool.service.codegen.inner; | ||||
|  | ||||
| import cn.hutool.core.collection.ListUtil; | ||||
| import cn.hutool.core.map.MapUtil; | ||||
| import cn.hutool.core.util.ArrayUtil; | ||||
| import cn.hutool.core.util.StrUtil; | ||||
| import cn.hutool.extra.template.TemplateConfig; | ||||
| import cn.hutool.extra.template.TemplateEngine; | ||||
| @@ -11,23 +9,21 @@ import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; | ||||
| import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
| import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | ||||
| import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; | ||||
| import cn.iocoder.yudao.module.tool.enums.codegen.CodegenSceneEnum; | ||||
| import cn.iocoder.yudao.module.tool.framework.codegen.config.CodegenProperties; | ||||
| import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | ||||
| import cn.iocoder.yudao.framework.common.util.date.DateUtils; | ||||
| import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; | ||||
| import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; | ||||
| import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; | ||||
| import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | ||||
| import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | ||||
| import cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum; | ||||
| import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | ||||
| import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | ||||
| import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; | ||||
| import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | ||||
| import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | ||||
| import cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum; | ||||
| import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.CodegenColumnDO; | ||||
| import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.CodegenTableDO; | ||||
| import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | ||||
| import cn.iocoder.yudao.framework.common.util.date.DateUtils; | ||||
| import cn.iocoder.yudao.module.tool.enums.codegen.CodegenSceneEnum; | ||||
| import cn.iocoder.yudao.module.tool.framework.codegen.config.CodegenProperties; | ||||
| import com.google.common.collect.Maps; | ||||
| import org.springframework.stereotype.Component; | ||||
|  | ||||
| @@ -115,7 +111,8 @@ public class CodegenEngine { | ||||
|     private void initGlobalBindingMap() { | ||||
|         // 全局配置 | ||||
|         globalBindingMap.put("basePackage", codegenProperties.getBasePackage()); | ||||
|         globalBindingMap.put("baseFrameworkPackage", codegenProperties.getBasePackage() + '.' + "framework"); // 用于后续获取测试类的 package 地址 | ||||
|         globalBindingMap.put("baseFrameworkPackage", codegenProperties.getBasePackage() | ||||
|                 + '.' + "framework"); // 用于后续获取测试类的 package 地址 | ||||
|         // 全局 Java Bean | ||||
|         globalBindingMap.put("CommonResultClassName", CommonResult.class.getName()); | ||||
|         globalBindingMap.put("PageResultClassName", PageResult.class.getName()); | ||||
| @@ -123,6 +120,7 @@ public class CodegenEngine { | ||||
|         globalBindingMap.put("PageParamClassName", PageParam.class.getName()); | ||||
|         globalBindingMap.put("DictFormatClassName", DictFormat.class.getName()); | ||||
|         // DO 类,独有字段 | ||||
|         globalBindingMap.put("BaseDOClassName", BaseDO.class.getName()); | ||||
|         globalBindingMap.put("baseDOFields", CodegenBuilder.BASE_DO_FIELDS); | ||||
|         globalBindingMap.put("QueryWrapperClassName", LambdaQueryWrapperX.class.getName()); | ||||
|         globalBindingMap.put("BaseMapperClassName", BaseMapperX.class.getName()); | ||||
| @@ -156,15 +154,6 @@ public class CodegenEngine { | ||||
|         // permission 前缀 | ||||
|         bindingMap.put("permissionPrefix", table.getModuleName() + ":" + simpleClassNameStrikeCase); | ||||
|  | ||||
|         // 如果多租户,则进行覆盖 DB 独有字段 | ||||
|         if (CollectionUtils.findFirst(columns, column -> column.getColumnName().equals(CodegenBuilder.TENANT_ID_FIELD)) != null) { | ||||
|             bindingMap.put("BaseDOClassName", TenantBaseDO.class.getName()); | ||||
|             bindingMap.put("BaseDOClassName_simple", TenantBaseDO.class.getSimpleName()); | ||||
|         } else { | ||||
|             bindingMap.put("BaseDOClassName", BaseDO.class.getName()); | ||||
|             bindingMap.put("BaseDOClassName_simple", BaseDO.class.getSimpleName()); | ||||
|         } | ||||
|  | ||||
|         // 执行生成 | ||||
|         final Map<String, String> result = Maps.newLinkedHashMapWithExpectedSize(TEMPLATES.size()); // 有序 | ||||
|         TEMPLATES.forEach((vmPath, filePath) -> { | ||||
|   | ||||
| @@ -17,7 +17,7 @@ import ${BaseDOClassName}; | ||||
| @Builder | ||||
| @NoArgsConstructor | ||||
| @AllArgsConstructor | ||||
| public class ${table.className}DO extends ${BaseDOClassName_simple} { | ||||
| public class ${table.className}DO extends BaseDO { | ||||
|  | ||||
| #foreach ($column in $columns) | ||||
| #if (!${baseDOFields.contains(${column.javaField})})##排除 BaseDO 的字段 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 YunaiV
					YunaiV