初始化

This commit is contained in:
2026-02-22 18:56:10 +08:00
commit 26677972a6
3112 changed files with 255972 additions and 0 deletions

View File

@@ -0,0 +1,69 @@
package tech.easyflow.codegen;
import com.mybatisflex.codegen.Generator;
import com.mybatisflex.codegen.config.ColumnConfig;
import com.mybatisflex.codegen.config.GlobalConfig;
import com.mybatisflex.codegen.dialect.JdbcTypeMapping;
import com.mybatisflex.core.handler.CommaSplitTypeHandler;
import com.zaxxer.hikari.HikariDataSource;
public class AIModuleGen {
public static void main(String[] args) {
//配置数据源
HikariDataSource dataSource = new HikariDataSource();
//注意url 需添加上 useInformationSchema=true 才能正常获取表的注释
dataSource.setJdbcUrl("jdbc:mysql://192.168.2.10:3306/easyflow-v2?useInformationSchema=true&characterEncoding=utf-8");
dataSource.setUsername("root");
dataSource.setPassword("123456");
// 设置时间类型为 Date
JdbcTypeMapping.registerDateTypes();
//生成 framework-modules/easyflow-module-ai 下的代码
GlobalConfig globalConfig = createGlobalConfig();
Generator moduleGenerator = new Generator(dataSource, globalConfig);
moduleGenerator.generate();
}
public static GlobalConfig createGlobalConfig() {
String optionsColumns = "options,vector_store_options,model_options";
//创建配置内容
GlobalConfig globalConfig = Util.createBaseConfig(optionsColumns);
globalConfig.setBasePackage("tech.easyflow.ai");
globalConfig.setGenerateTable("tb_bot"
, "tb_bot_api_key", "tb_bot_category"
, "tb_bot_conversation", "tb_bot_document_collection", "tb_bot_message"
, "tb_bot_model", "tb_bot_plugin", "tb_bot_recently_used", "tb_bot_workflow"
, "tb_document", "tb_document_chunk", "tb_document_collection", "tb_document_collection_category", "tb_document_history"
, "tb_model", "tb_model_provider"
, "tb_plugin", "tb_plugin_category", "tb_plugin_category_mapping", "tb_plugin_item"
, "tb_resource", "tb_resource_category"
, "tb_workflow", "tb_workflow_category", "tb_workflow_exec_result", "tb_workflow_exec_step", "tb_mcp", "tb_bot_mcp"
);
String sourceDir = System.getProperty("user.dir") + "/easyflow-modules/easyflow-module-ai/src/main/java";
globalConfig.setSourceDir(sourceDir);
ColumnConfig tablesColumnConfig = new ColumnConfig();
tablesColumnConfig.setPropertyType("java.util.List<String>");
tablesColumnConfig.setTypeHandler(CommaSplitTypeHandler.class);
tablesColumnConfig.setColumnName("tables");
globalConfig.setColumnConfig("tb_dev_module", tablesColumnConfig);
ColumnConfig validRolesColumnConfig = new ColumnConfig();
validRolesColumnConfig.setPropertyType("java.util.List<String>");
validRolesColumnConfig.setTypeHandler(CommaSplitTypeHandler.class);
validRolesColumnConfig.setColumnName("valid_roles");
globalConfig.setColumnConfig("tb_dev_table_field", validRolesColumnConfig);
return globalConfig;
}
}

View File

@@ -0,0 +1,11 @@
package tech.easyflow.codegen;
public class AllModuleGen {
public static void main(String[] args) {
AIModuleGen.main(args);
DatacenterModuleGen.main(args);
JobModuleGen.main(args);
SystemModuleGen.main(args);
}
}

View File

@@ -0,0 +1,50 @@
package tech.easyflow.codegen;
import com.mybatisflex.codegen.Generator;
import com.mybatisflex.codegen.config.GlobalConfig;
import com.mybatisflex.codegen.dialect.JdbcTypeMapping;
import com.zaxxer.hikari.HikariDataSource;
public class DatacenterModuleGen {
public static void main(String[] args) {
//配置数据源
HikariDataSource dataSource = new HikariDataSource();
//注意url 需添加上 useInformationSchema=true 才能正常获取表的注释
dataSource.setJdbcUrl("jdbc:mysql://192.168.2.10:3306/easyflow-v2?useInformationSchema=true&characterEncoding=utf-8");
dataSource.setUsername("root");
dataSource.setPassword("123456");
// 设置时间类型为 Date
JdbcTypeMapping.registerDateTypes();
//生成 framework-modules/easyflow-module-datacenter 下的代码
GlobalConfig globalConfig = createGlobalConfig();
Generator moduleGenerator = new Generator(dataSource, globalConfig);
moduleGenerator.generate();
}
public static GlobalConfig createGlobalConfig() {
String optionsColumns = "options,vector_store_options,llm_options";
//创建配置内容
GlobalConfig globalConfig = Util.createBaseConfig(optionsColumns);
globalConfig.setBasePackage("tech.easyflow.datacenter");
globalConfig.setGenerateTable("tb_datacenter_table", "tb_datacenter_table_field");
String sourceDir = System.getProperty("user.dir") + "/easyflow-modules/easyflow-module-datacenter/src/main/java";
globalConfig.setSourceDir(sourceDir);
return globalConfig;
}
}

View File

@@ -0,0 +1,50 @@
package tech.easyflow.codegen;
import com.mybatisflex.codegen.Generator;
import com.mybatisflex.codegen.config.GlobalConfig;
import com.mybatisflex.codegen.dialect.JdbcTypeMapping;
import com.zaxxer.hikari.HikariDataSource;
public class JobModuleGen {
public static void main(String[] args) {
//配置数据源
HikariDataSource dataSource = new HikariDataSource();
//注意url 需添加上 useInformationSchema=true 才能正常获取表的注释
dataSource.setJdbcUrl("jdbc:mysql://192.168.2.10:3306/easyflow-v2?useInformationSchema=true&characterEncoding=utf-8");
dataSource.setUsername("root");
dataSource.setPassword("123456");
// 设置时间类型为 Date
JdbcTypeMapping.registerDateTypes();
//生成 framework-modules/easyflow-module-job 下的代码
GlobalConfig globalConfig = createGlobalConfig();
Generator moduleGenerator = new Generator(dataSource, globalConfig);
moduleGenerator.generate();
}
public static GlobalConfig createGlobalConfig() {
String optionsColumns = "options,job_params";
//创建配置内容
GlobalConfig globalConfig = Util.createBaseConfig(optionsColumns);
globalConfig.setBasePackage("tech.easyflow.job");
globalConfig.setGenerateTable("tb_sys_job", "tb_sys_job_log");
String sourceDir = System.getProperty("user.dir") + "/easyflow-modules/easyflow-module-job/src/main/java";
globalConfig.setSourceDir(sourceDir);
return globalConfig;
}
}

View File

@@ -0,0 +1,17 @@
package tech.easyflow.codegen;
import tech.easyflow.common.util.HashUtil;
public class PasswordGen {
public static void main(String[] args) {
String password = "123456";
String salt = HashUtil.generateSalt(24);
String hashPassword = HashUtil.sha256(salt + password);
System.out.println("salt: " + salt);
System.out.println("password: " + password);
System.out.println("hashPassword: " + hashPassword);
}
}

View File

@@ -0,0 +1,53 @@
package tech.easyflow.codegen;
import com.mybatisflex.codegen.Generator;
import com.mybatisflex.codegen.config.GlobalConfig;
import com.mybatisflex.codegen.dialect.JdbcTypeMapping;
import com.zaxxer.hikari.HikariDataSource;
public class SystemModuleGen {
public static void main(String[] args) {
//配置数据源
HikariDataSource dataSource = new HikariDataSource();
//注意url 需添加上 useInformationSchema=true 才能正常获取表的注释
dataSource.setJdbcUrl("jdbc:mysql://192.168.2.10:3306/easyflow-v2?useInformationSchema=true&characterEncoding=utf-8");
dataSource.setUsername("root");
dataSource.setPassword("123456");
// 设置时间类型为 Date
JdbcTypeMapping.registerDateTypes();
//生成 framework-modules/easyflow-module-system 下的代码
GlobalConfig globalConfig = createGlobalConfig();
Generator moduleGenerator = new Generator(dataSource, globalConfig);
moduleGenerator.generate();
}
public static GlobalConfig createGlobalConfig() {
String optionsColumns = "options,vector_store_options,llm_options";
//创建配置内容
GlobalConfig globalConfig = Util.createBaseConfig(optionsColumns);
globalConfig.setBasePackage("tech.easyflow.system");
globalConfig.setGenerateTable("tb_sys_account", "tb_sys_account_position", "tb_sys_account_role"
, "tb_sys_api_key", "tb_sys_api_key_resource", "tb_sys_api_key_resource_mapping"
, "tb_sys_dept", "tb_sys_dict", "tb_sys_dict_item", "tb_sys_log", "tb_sys_menu", "tb_sys_option"
, "tb_sys_position", "tb_sys_role", "tb_sys_role_menu", "tb_sys_user_feedback"
);
String sourceDir = System.getProperty("user.dir") + "/easyflow-modules/easyflow-module-system/src/main/java";
globalConfig.setSourceDir(sourceDir);
return globalConfig;
}
}

View File

@@ -0,0 +1,102 @@
package tech.easyflow.codegen;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.codegen.config.ColumnConfig;
import com.mybatisflex.codegen.config.GlobalConfig;
import com.mybatisflex.core.handler.FastjsonTypeHandler;
import com.mybatisflex.core.keygen.KeyGenerators;
import tech.easyflow.common.entity.DateEntity;
import tech.easyflow.common.entity.DateTreeEntity;
import tech.easyflow.common.entity.TreeEntity;
import tech.easyflow.common.util.StringUtil;
public class Util {
public static GlobalConfig createBaseConfig() {
return createBaseConfig("options");
}
public static GlobalConfig createBaseConfig(String optionsColumns) {
//创建配置内容
GlobalConfig globalConfig = new GlobalConfig();
//设置表前缀和只生成哪些表
globalConfig.setTablePrefix("tb_");
//设置生成 entity
globalConfig.setEntityGenerateEnable(true);
globalConfig.getEntityConfig().setWithBaseClassEnable(true);
globalConfig.getEntityConfig().setBaseOverwriteEnable(true);
globalConfig.getEntityConfig().setColumnCommentEnable(true);
globalConfig.setMapperGenerateEnable(true);
globalConfig.setServiceGenerateEnable(true);
globalConfig.setServiceImplGenerateEnable(true);
// 设置 entity 父类
globalConfig.setEntitySuperClassFactory(table -> {
if (table.containsColumn("id", "pid") || table.containsColumn("id","parent_id")) {
if (table.containsColumn("created", "modified")) {
return DateTreeEntity.class;
} else {
return TreeEntity.class;
}
} else if (table.containsColumn("created", "modified")) {
return DateEntity.class;
}
return null;
});
// 不生成 Controller
globalConfig.setControllerGenerateEnable(false);
// globalConfig.setControllerOverwriteEnable(false);
// try {
// ClassPathResource cpr = new ClassPathResource("templates/controller.tpl");
// globalConfig.setControllerTemplatePath(cpr.getFile().getAbsolutePath());
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
ColumnConfig pkColumnConfig = new ColumnConfig();
pkColumnConfig.setPrimaryKey(true);
pkColumnConfig.setKeyType(KeyType.Generator);
pkColumnConfig.setKeyValue(KeyGenerators.snowFlakeId);
pkColumnConfig.setColumnName("id");
ColumnConfig tenantColumnConfig = new ColumnConfig();
tenantColumnConfig.setTenantId(true);
tenantColumnConfig.setColumnName("tenant_id");
ColumnConfig logicDeleteColumnConfig = new ColumnConfig();
logicDeleteColumnConfig.setLogicDelete(true);
logicDeleteColumnConfig.setColumnName("is_deleted");
globalConfig.setColumnConfig(pkColumnConfig);
globalConfig.setColumnConfig(tenantColumnConfig);
globalConfig.setColumnConfig(logicDeleteColumnConfig);
String[] optionsColumnArray = optionsColumns.split(",");
for (String optionsColumn : optionsColumnArray) {
if (StringUtil.hasText(optionsColumn)) {
ColumnConfig optionsColumnConfig = new ColumnConfig();
optionsColumnConfig.setPropertyType("java.util.Map<String, Object>");
optionsColumnConfig.setTypeHandler(FastjsonTypeHandler.class);
optionsColumnConfig.setColumnName(optionsColumn.trim());
globalConfig.setColumnConfig(optionsColumnConfig);
}
}
return globalConfig;
}
}