style: 应用 Spotless 代码格式化
- 对所有 Java 源文件应用统一的代码格式化 - 统一缩进为 4 个空格 - 清理尾随空白字符和文件末尾换行 - 优化导入语句组织 - 总计格式化 654 个 Java 文件 有问题可以回滚或者找我聊
This commit is contained in:
@@ -1,40 +1,38 @@
|
||||
package com.starry.generator;
|
||||
|
||||
import com.starry.generator.core.CodeGenerator;
|
||||
import com.starry.generator.config.GeneratorConfig;
|
||||
import com.starry.generator.core.CodeGenerator;
|
||||
|
||||
/**
|
||||
* 代码生成器主类
|
||||
* 通过main方法直接运行生成代码
|
||||
*
|
||||
* 代码生成器主类 通过main方法直接运行生成代码
|
||||
*
|
||||
* @author admin
|
||||
* @since 2024-01-01
|
||||
*/
|
||||
public class MainGenerator {
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
// 数据库配置
|
||||
GeneratorConfig config = new GeneratorConfig();
|
||||
config.setUrl("jdbc:mysql://122.51.20.105:3306/play-with?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai");
|
||||
config.setUrl(
|
||||
"jdbc:mysql://122.51.20.105:3306/play-with?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai");
|
||||
config.setDriverName("com.mysql.cj.jdbc.Driver");
|
||||
config.setUsername("root");
|
||||
config.setPassword("KdaKRZ2trpdhNePa");
|
||||
|
||||
|
||||
// 生成配置
|
||||
config.setAuthor("huchuansai");
|
||||
config.setPackageName("com.starry.admin");
|
||||
config.setOutputDir("./generated-code");
|
||||
config.setAutoRemovePre(false);
|
||||
config.setTablePrefix("sys_");
|
||||
|
||||
|
||||
// 要生成的表名(可以配置多个)
|
||||
String[] tableNames = {
|
||||
"sys_role",
|
||||
};
|
||||
|
||||
String[] tableNames = {"sys_role",};
|
||||
|
||||
// 创建代码生成器并执行生成
|
||||
CodeGenerator generator = new CodeGenerator(config);
|
||||
|
||||
|
||||
try {
|
||||
System.out.println("开始生成代码...");
|
||||
generator.generateCode(tableNames);
|
||||
@@ -44,4 +42,4 @@ public class MainGenerator {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,26 +1,24 @@
|
||||
package com.starry.generator;
|
||||
|
||||
import com.starry.generator.core.CodeGenerator;
|
||||
import com.starry.generator.config.GeneratorConfig;
|
||||
|
||||
import com.starry.generator.core.CodeGenerator;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* 代码生成器主类 - 支持配置文件版本
|
||||
* 通过读取 config.properties 配置文件来生成代码
|
||||
*
|
||||
* 代码生成器主类 - 支持配置文件版本 通过读取 config.properties 配置文件来生成代码
|
||||
*
|
||||
* @author admin
|
||||
* @since 2024-01-01
|
||||
*/
|
||||
public class MainGeneratorWithConfig {
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
// 读取配置文件
|
||||
GeneratorConfig config = loadConfig();
|
||||
|
||||
|
||||
// 获取要生成的表名
|
||||
String tableNamesStr = getProperty("gen.tableNames", "");
|
||||
if (tableNamesStr.isEmpty()) {
|
||||
@@ -28,15 +26,15 @@ public class MainGeneratorWithConfig {
|
||||
return;
|
||||
}
|
||||
String[] tableNames = tableNamesStr.split(",");
|
||||
|
||||
|
||||
// 清理表名(去除前后空格)
|
||||
for (int i = 0; i < tableNames.length; i++) {
|
||||
tableNames[i] = tableNames[i].trim();
|
||||
}
|
||||
|
||||
|
||||
// 创建代码生成器并执行生成
|
||||
CodeGenerator generator = new CodeGenerator(config);
|
||||
|
||||
|
||||
System.out.println("=== 代码生成器配置信息 ===");
|
||||
System.out.println("数据库地址: " + config.getUrl());
|
||||
System.out.println("包名: " + config.getPackageName());
|
||||
@@ -45,20 +43,20 @@ public class MainGeneratorWithConfig {
|
||||
System.out.println("要生成的表: " + String.join(", ", tableNames));
|
||||
System.out.println("========================");
|
||||
System.out.println();
|
||||
|
||||
|
||||
System.out.println("开始生成代码...");
|
||||
generator.generateCode(tableNames);
|
||||
System.out.println();
|
||||
System.out.println("代码生成完成!输出目录:" + config.getOutputDir());
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
System.err.println("代码生成失败:" + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static Properties properties;
|
||||
|
||||
|
||||
private static GeneratorConfig loadConfig() throws IOException {
|
||||
// 加载配置文件
|
||||
properties = new Properties();
|
||||
@@ -69,17 +67,17 @@ public class MainGeneratorWithConfig {
|
||||
}
|
||||
properties.load(input);
|
||||
}
|
||||
|
||||
|
||||
// 创建配置对象
|
||||
GeneratorConfig config = new GeneratorConfig();
|
||||
|
||||
|
||||
// 数据库配置
|
||||
config.setUrl(getProperty("db.url", ""));
|
||||
config.setDatabaseName(getProperty("db.name", ""));
|
||||
config.setDriverName(getProperty("db.driver", "com.mysql.cj.jdbc.Driver"));
|
||||
config.setUsername(getProperty("db.username", ""));
|
||||
config.setPassword(getProperty("db.password", ""));
|
||||
|
||||
|
||||
// 生成配置
|
||||
config.setAuthor(getProperty("gen.author", "admin"));
|
||||
config.setPackageName(getProperty("gen.packageName", "com.starry.play"));
|
||||
@@ -87,7 +85,7 @@ public class MainGeneratorWithConfig {
|
||||
config.setAutoRemovePre(Boolean.parseBoolean(getProperty("gen.autoRemovePre", "false")));
|
||||
config.setTablePrefix(getProperty("gen.tablePrefix", "sys_"));
|
||||
config.setTplCategory(getProperty("gen.tplCategory", "crud"));
|
||||
|
||||
|
||||
// 验证必需的配置
|
||||
if (config.getUrl().isEmpty()) {
|
||||
throw new IllegalArgumentException("数据库连接地址不能为空,请配置 db.url");
|
||||
@@ -95,11 +93,11 @@ public class MainGeneratorWithConfig {
|
||||
if (config.getUsername().isEmpty()) {
|
||||
throw new IllegalArgumentException("数据库用户名不能为空,请配置 db.username");
|
||||
}
|
||||
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
|
||||
private static String getProperty(String key, String defaultValue) {
|
||||
return properties.getProperty(key, defaultValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,8 +6,7 @@ import org.springframework.context.annotation.PropertySource;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
* 读取代码生成相关配置
|
||||
* @author admin 读取代码生成相关配置
|
||||
* @since 2022/7/15
|
||||
*/
|
||||
@Component
|
||||
|
||||
@@ -3,41 +3,40 @@ package com.starry.generator.config;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 代码生成器配置类
|
||||
* 用于配置数据库连接和生成参数
|
||||
*
|
||||
* 代码生成器配置类 用于配置数据库连接和生成参数
|
||||
*
|
||||
* @author admin
|
||||
* @since 2024-01-01
|
||||
*/
|
||||
@Data
|
||||
public class GeneratorConfig {
|
||||
|
||||
|
||||
// 数据库连接配置
|
||||
private String url;
|
||||
private String driverName;
|
||||
private String username;
|
||||
private String password;
|
||||
private String databaseName;
|
||||
|
||||
|
||||
// 代码生成配置
|
||||
private String author;
|
||||
private String packageName;
|
||||
private String outputDir;
|
||||
private boolean autoRemovePre;
|
||||
private String tablePrefix;
|
||||
|
||||
|
||||
// 模板类型 (crud, tree, sub)
|
||||
private String tplCategory = "crud";
|
||||
|
||||
|
||||
// 功能名称
|
||||
private String functionName;
|
||||
|
||||
|
||||
// 模块名
|
||||
private String moduleName;
|
||||
|
||||
|
||||
// 业务名
|
||||
private String businessName;
|
||||
|
||||
|
||||
public GeneratorConfig() {
|
||||
// 设置默认值
|
||||
this.author = "admin";
|
||||
@@ -47,7 +46,7 @@ public class GeneratorConfig {
|
||||
this.tablePrefix = "sys_";
|
||||
this.tplCategory = "crud";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 从URL中获取数据库名
|
||||
*/
|
||||
@@ -55,7 +54,7 @@ public class GeneratorConfig {
|
||||
if (databaseName != null && !databaseName.isEmpty()) {
|
||||
return databaseName;
|
||||
}
|
||||
|
||||
|
||||
// 如果没有手动设置数据库名,从URL中解析
|
||||
if (url != null) {
|
||||
String dbName = url.substring(url.lastIndexOf("/") + 1);
|
||||
@@ -66,4 +65,4 @@ public class GeneratorConfig {
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
package com.starry.generator.constant;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
* 代码生成通用常量
|
||||
* @author admin 代码生成通用常量
|
||||
*/
|
||||
public class GenConstants {
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.starry.generator.controller;
|
||||
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.starry.common.annotation.Log;
|
||||
@@ -10,15 +9,13 @@ import com.starry.generator.entity.GenTableEntity;
|
||||
import com.starry.generator.entity.vo.GenTableVo;
|
||||
import com.starry.generator.service.GenTableService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
|
||||
@@ -1,16 +1,11 @@
|
||||
package com.starry.generator.core;
|
||||
|
||||
import com.starry.generator.config.GeneratorConfig;
|
||||
import com.starry.generator.entity.GenTableEntity;
|
||||
import com.starry.generator.entity.GenTableColumnEntity;
|
||||
import com.starry.generator.entity.GenTableEntity;
|
||||
import com.starry.generator.utils.GenUtils;
|
||||
import com.starry.generator.utils.VelocityInitializer;
|
||||
import com.starry.generator.utils.VelocityUtils;
|
||||
import org.apache.velocity.Template;
|
||||
import org.apache.velocity.VelocityContext;
|
||||
import org.apache.velocity.app.Velocity;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
@@ -18,45 +13,51 @@ import java.io.StringWriter;
|
||||
import java.sql.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.velocity.Template;
|
||||
import org.apache.velocity.VelocityContext;
|
||||
import org.apache.velocity.app.Velocity;
|
||||
|
||||
/**
|
||||
* 核心代码生成器
|
||||
*
|
||||
*
|
||||
* @author admin
|
||||
* @since 2024-01-01
|
||||
*/
|
||||
@Slf4j
|
||||
public class CodeGenerator {
|
||||
|
||||
|
||||
private final GeneratorConfig config;
|
||||
|
||||
|
||||
public CodeGenerator(GeneratorConfig config) {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 生成代码
|
||||
*
|
||||
* @param tableNames 表名数组
|
||||
*
|
||||
* @param tableNames
|
||||
* 表名数组
|
||||
*/
|
||||
public void generateCode(String[] tableNames) throws Exception {
|
||||
// 初始化 Velocity
|
||||
VelocityInitializer.initVelocity();
|
||||
|
||||
|
||||
// 创建输出目录
|
||||
createOutputDirectory();
|
||||
|
||||
|
||||
for (String tableName : tableNames) {
|
||||
log.info("开始生成表 {} 的代码", tableName);
|
||||
generateTableCode(tableName);
|
||||
log.info("表 {} 代码生成完成", tableName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 生成单个表的代码
|
||||
*
|
||||
* @param tableName 表名
|
||||
*
|
||||
* @param tableName
|
||||
* 表名
|
||||
*/
|
||||
private void generateTableCode(String tableName) throws Exception {
|
||||
// 获取表信息
|
||||
@@ -65,53 +66,52 @@ public class CodeGenerator {
|
||||
log.warn("表 {} 不存在,跳过生成", tableName);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// 获取表字段信息
|
||||
List<GenTableColumnEntity> columns = getTableColumns(tableName);
|
||||
table.setColumns(columns);
|
||||
|
||||
|
||||
// 初始化表信息
|
||||
initTableInfo(table);
|
||||
|
||||
|
||||
// 初始化字段信息
|
||||
initColumnInfo(table);
|
||||
|
||||
|
||||
// 设置主键列信息
|
||||
setPkColumn(table);
|
||||
|
||||
|
||||
// 设置模板变量信息
|
||||
VelocityContext context = VelocityUtils.prepareContext(table);
|
||||
|
||||
|
||||
// 获取模版列表
|
||||
List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory());
|
||||
|
||||
|
||||
for (String template : templates) {
|
||||
// 渲染模板
|
||||
StringWriter sw = new StringWriter();
|
||||
Template tpl = Velocity.getTemplate(template, "UTF-8");
|
||||
tpl.merge(context, sw);
|
||||
|
||||
|
||||
// 写入文件
|
||||
writeToFile(template, table, sw.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取表信息
|
||||
*/
|
||||
private GenTableEntity getTableInfo(String tableName) throws Exception {
|
||||
String sql = "SELECT table_name, table_comment FROM information_schema.tables " +
|
||||
"WHERE table_schema = ? AND table_name = ?";
|
||||
|
||||
try (Connection conn = getConnection();
|
||||
PreparedStatement stmt = conn.prepareStatement(sql)) {
|
||||
|
||||
String sql = "SELECT table_name, table_comment FROM information_schema.tables "
|
||||
+ "WHERE table_schema = ? AND table_name = ?";
|
||||
|
||||
try (Connection conn = getConnection(); PreparedStatement stmt = conn.prepareStatement(sql)) {
|
||||
|
||||
String dbName = getDatabaseName();
|
||||
log.info("查询表信息 - 数据库名: {}, 表名: {}", dbName, tableName);
|
||||
|
||||
|
||||
stmt.setString(1, dbName);
|
||||
stmt.setString(2, tableName);
|
||||
|
||||
|
||||
try (ResultSet rs = stmt.executeQuery()) {
|
||||
if (rs.next()) {
|
||||
GenTableEntity table = new GenTableEntity();
|
||||
@@ -128,7 +128,7 @@ public class CodeGenerator {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 显示数据库中的所有表(用于调试)
|
||||
*/
|
||||
@@ -149,24 +149,23 @@ public class CodeGenerator {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取表字段信息
|
||||
*/
|
||||
private List<GenTableColumnEntity> getTableColumns(String tableName) throws Exception {
|
||||
List<GenTableColumnEntity> columns = new ArrayList<>();
|
||||
|
||||
String sql = "SELECT column_name, data_type, column_comment, is_nullable, " +
|
||||
"column_key, column_default, extra FROM information_schema.columns " +
|
||||
"WHERE table_schema = ? AND table_name = ? ORDER BY ordinal_position";
|
||||
|
||||
try (Connection conn = getConnection();
|
||||
PreparedStatement stmt = conn.prepareStatement(sql)) {
|
||||
|
||||
|
||||
String sql = "SELECT column_name, data_type, column_comment, is_nullable, "
|
||||
+ "column_key, column_default, extra FROM information_schema.columns "
|
||||
+ "WHERE table_schema = ? AND table_name = ? ORDER BY ordinal_position";
|
||||
|
||||
try (Connection conn = getConnection(); PreparedStatement stmt = conn.prepareStatement(sql)) {
|
||||
|
||||
String dbName = getDatabaseName();
|
||||
stmt.setString(1, dbName);
|
||||
stmt.setString(2, tableName);
|
||||
|
||||
|
||||
try (ResultSet rs = stmt.executeQuery()) {
|
||||
while (rs.next()) {
|
||||
GenTableColumnEntity column = new GenTableColumnEntity();
|
||||
@@ -176,15 +175,15 @@ public class CodeGenerator {
|
||||
column.setIsRequired("NO".equals(rs.getString("is_nullable")) ? "1" : "0");
|
||||
column.setIsPk("PRI".equals(rs.getString("column_key")) ? "1" : "0");
|
||||
column.setIsIncrement("auto_increment".equals(rs.getString("extra")) ? "1" : "0");
|
||||
|
||||
|
||||
columns.add(column);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return columns;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 初始化表信息
|
||||
*/
|
||||
@@ -197,7 +196,7 @@ public class CodeGenerator {
|
||||
table.setFunctionAuthor(config.getAuthor());
|
||||
table.setTplCategory(config.getTplCategory());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 初始化字段信息
|
||||
*/
|
||||
@@ -208,7 +207,7 @@ public class CodeGenerator {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 设置主键列信息
|
||||
*/
|
||||
@@ -219,29 +218,29 @@ public class CodeGenerator {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (table.getPkColumn() == null) {
|
||||
table.setPkColumn(table.getColumns().get(0));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 写入文件
|
||||
*/
|
||||
private void writeToFile(String template, GenTableEntity table, String content) throws IOException {
|
||||
String fileName = getFileName(template, table);
|
||||
File file = new File(fileName);
|
||||
|
||||
|
||||
// 创建父目录
|
||||
file.getParentFile().mkdirs();
|
||||
|
||||
|
||||
try (FileWriter writer = new FileWriter(file)) {
|
||||
writer.write(content);
|
||||
}
|
||||
|
||||
|
||||
log.info("生成文件:{}", fileName);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取文件名
|
||||
*/
|
||||
@@ -251,10 +250,10 @@ public class CodeGenerator {
|
||||
String moduleName = table.getModuleName();
|
||||
String businessName = table.getBusinessName();
|
||||
String className = table.getClassName();
|
||||
|
||||
|
||||
String javaPath = outputDir + "/src/main/java/" + packageName.replace(".", "/");
|
||||
String resourcesPath = outputDir + "/src/main/resources";
|
||||
|
||||
|
||||
if (template.contains("entity.java.vm")) {
|
||||
return javaPath + "/entity/" + className + "Entity.java";
|
||||
} else if (template.contains("mapper.java.vm")) {
|
||||
@@ -278,10 +277,10 @@ public class CodeGenerator {
|
||||
} else if (template.contains("index.vue.vm")) {
|
||||
return outputDir + "/views/" + moduleName + "/" + businessName + "/index.vue";
|
||||
}
|
||||
|
||||
|
||||
return outputDir + "/" + template.replace(".vm", "");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取数据库连接
|
||||
*/
|
||||
@@ -289,14 +288,14 @@ public class CodeGenerator {
|
||||
Class.forName(config.getDriverName());
|
||||
return DriverManager.getConnection(config.getUrl(), config.getUsername(), config.getPassword());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 从URL中获取数据库名
|
||||
*/
|
||||
private String getDatabaseName() {
|
||||
return config.getDatabaseName();
|
||||
return config.getDatabaseName();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 创建输出目录
|
||||
*/
|
||||
@@ -306,4 +305,4 @@ public class CodeGenerator {
|
||||
outputDir.mkdirs();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.starry.generator.entity;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
@@ -8,15 +7,13 @@ import com.starry.common.domain.BaseEntity;
|
||||
import com.starry.common.utils.StringUtils;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import java.io.Serializable;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
* 代码生成业务字段表 gen_table_column
|
||||
* @author admin 代码生成业务字段表 gen_table_column
|
||||
* @since 2022/7/14
|
||||
*/
|
||||
@Getter
|
||||
|
||||
@@ -9,15 +9,13 @@ import com.starry.common.utils.StringUtils;
|
||||
import com.starry.generator.constant.GenConstants;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import java.util.List;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
* 业务表 gen_table
|
||||
* @author admin 业务表 gen_table
|
||||
* @since 2022/7/14
|
||||
*/
|
||||
@Getter
|
||||
@@ -156,7 +154,6 @@ public class GenTableEntity extends BaseEntity<GenTableEntity> {
|
||||
@TableField(exist = false)
|
||||
private String parentMenuName;
|
||||
|
||||
|
||||
public static boolean isCrud(String tplCategory) {
|
||||
return tplCategory != null && StringUtils.equals(GenConstants.TPL_CRUD, tplCategory);
|
||||
}
|
||||
|
||||
@@ -6,15 +6,13 @@ import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.starry.common.domain.BasePageEntity;
|
||||
import com.starry.generator.entity.GenTableColumnEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import java.util.List;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
* 业务表 gen_table
|
||||
* @author admin 业务表 gen_table
|
||||
* @since 2022/7/14
|
||||
*/
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.starry.generator.mapper;
|
||||
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.starry.generator.entity.GenTableColumnEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -19,7 +18,8 @@ public interface GenTableColumnMapper extends BaseMapper<GenTableColumnEntity> {
|
||||
/**
|
||||
* 根据表名称查询列信息
|
||||
*
|
||||
* @param tableName 表名称
|
||||
* @param tableName
|
||||
* 表名称
|
||||
* @return 列信息
|
||||
*/
|
||||
@InterceptorIgnore(tenantLine = "1")
|
||||
|
||||
@@ -6,13 +6,11 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.starry.generator.entity.GenTableEntity;
|
||||
import com.starry.generator.entity.vo.GenTableVo;
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
* 业务 数据层
|
||||
* @author admin 业务 数据层
|
||||
* @since 2022/7/14
|
||||
*/
|
||||
public interface GenTableMapper extends BaseMapper<GenTableEntity> {
|
||||
@@ -20,12 +18,13 @@ public interface GenTableMapper extends BaseMapper<GenTableEntity> {
|
||||
/**
|
||||
* 查询业务列表
|
||||
*
|
||||
* @param genTableEntity 业务信息
|
||||
* @param genTableEntity
|
||||
* 业务信息
|
||||
* @return 业务集合
|
||||
*/
|
||||
|
||||
IPage<GenTableEntity> selectGenTableList(Page<GenTableEntity> page, @Param(value = "genTableEntity") GenTableVo genTableEntity);
|
||||
|
||||
IPage<GenTableEntity> selectGenTableList(Page<GenTableEntity> page,
|
||||
@Param(value = "genTableEntity") GenTableVo genTableEntity);
|
||||
|
||||
@InterceptorIgnore(tenantLine = "1")
|
||||
IPage<GenTableEntity> selectDbTableList(Page page, @Param("genTableEntity") GenTableEntity genTableEntity);
|
||||
@@ -33,7 +32,8 @@ public interface GenTableMapper extends BaseMapper<GenTableEntity> {
|
||||
/**
|
||||
* 查询数据库列表
|
||||
*
|
||||
* @param tableNames 表名称组
|
||||
* @param tableNames
|
||||
* 表名称组
|
||||
* @return 数据库表集合
|
||||
*/
|
||||
@InterceptorIgnore(tenantLine = "1")
|
||||
@@ -49,7 +49,8 @@ public interface GenTableMapper extends BaseMapper<GenTableEntity> {
|
||||
/**
|
||||
* 查询表ID业务信息
|
||||
*
|
||||
* @param id 业务ID
|
||||
* @param id
|
||||
* 业务ID
|
||||
* @return 业务信息
|
||||
*/
|
||||
GenTableEntity selectGenTableById(Long id);
|
||||
@@ -57,7 +58,8 @@ public interface GenTableMapper extends BaseMapper<GenTableEntity> {
|
||||
/**
|
||||
* 查询表名称业务信息
|
||||
*
|
||||
* @param tableName 表名称
|
||||
* @param tableName
|
||||
* 表名称
|
||||
* @return 业务信息
|
||||
*/
|
||||
GenTableEntity selectGenTableByName(String tableName);
|
||||
|
||||
@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.starry.generator.entity.GenTableEntity;
|
||||
import com.starry.generator.entity.vo.GenTableVo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -17,17 +16,19 @@ public interface GenTableService extends IService<GenTableEntity> {
|
||||
/**
|
||||
* 查询数据库列表
|
||||
*
|
||||
* @param genTableEntity 业务信息
|
||||
* @param genTableEntity
|
||||
* 业务信息
|
||||
* @return 数据库表集合
|
||||
*/
|
||||
/*List<GenTableEntity> selectDbTableList(GenTableEntity genTableEntity);*/
|
||||
/* List<GenTableEntity> selectDbTableList(GenTableEntity genTableEntity); */
|
||||
|
||||
IPage<GenTableEntity> selectDbTableList(GenTableEntity genTableEntity);
|
||||
|
||||
/**
|
||||
* 查询据库列表
|
||||
*
|
||||
* @param tableNames 表名称组
|
||||
* @param tableNames
|
||||
* 表名称组
|
||||
* @return 数据库表集合
|
||||
*/
|
||||
List<GenTableEntity> selectDbTableListByNames(String[] tableNames);
|
||||
@@ -35,14 +36,16 @@ public interface GenTableService extends IService<GenTableEntity> {
|
||||
/**
|
||||
* 导入表结构
|
||||
*
|
||||
* @param tableList 导入表列表
|
||||
* @param tableList
|
||||
* 导入表列表
|
||||
*/
|
||||
void importGenTable(List<GenTableEntity> tableList);
|
||||
|
||||
/**
|
||||
* 查询业务列表
|
||||
*
|
||||
* @param genTableEntity 业务信息
|
||||
* @param genTableEntity
|
||||
* 业务信息
|
||||
* @return 业务集合
|
||||
*/
|
||||
IPage<GenTableEntity> selectGenTableList(GenTableVo genTableEntity);
|
||||
@@ -50,7 +53,8 @@ public interface GenTableService extends IService<GenTableEntity> {
|
||||
/**
|
||||
* 预览代码
|
||||
*
|
||||
* @param tableId 表编号
|
||||
* @param tableId
|
||||
* 表编号
|
||||
* @return 预览数据列表
|
||||
*/
|
||||
Map<String, String> previewCode(Long tableId);
|
||||
@@ -58,7 +62,8 @@ public interface GenTableService extends IService<GenTableEntity> {
|
||||
/**
|
||||
* 生成代码(下载方式)
|
||||
*
|
||||
* @param tableName 表名称
|
||||
* @param tableName
|
||||
* 表名称
|
||||
* @return 数据
|
||||
*/
|
||||
byte[] downloadCode(String tableName);
|
||||
@@ -66,7 +71,8 @@ public interface GenTableService extends IService<GenTableEntity> {
|
||||
/**
|
||||
* 批量生成代码(下载方式)
|
||||
*
|
||||
* @param tableNames 表数组
|
||||
* @param tableNames
|
||||
* 表数组
|
||||
* @return 数据
|
||||
*/
|
||||
byte[] downloadCode(String[] tableNames);
|
||||
@@ -74,7 +80,8 @@ public interface GenTableService extends IService<GenTableEntity> {
|
||||
/**
|
||||
* 删除业务信息
|
||||
*
|
||||
* @param tableIds 需要删除的表数据ID
|
||||
* @param tableIds
|
||||
* 需要删除的表数据ID
|
||||
*/
|
||||
void deleteGenTableByIds(Long[] tableIds);
|
||||
}
|
||||
|
||||
@@ -17,15 +17,6 @@ import com.starry.generator.mapper.GenTableMapper;
|
||||
import com.starry.generator.utils.GenUtils;
|
||||
import com.starry.generator.utils.VelocityInitializer;
|
||||
import com.starry.generator.utils.VelocityUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.velocity.Template;
|
||||
import org.apache.velocity.VelocityContext;
|
||||
import org.apache.velocity.app.Velocity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
@@ -35,6 +26,14 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
import javax.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.velocity.Template;
|
||||
import org.apache.velocity.VelocityContext;
|
||||
import org.apache.velocity.app.Velocity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
@@ -47,13 +46,14 @@ public class GenTableServiceImpl extends ServiceImpl<GenTableMapper, GenTableEnt
|
||||
@Resource
|
||||
private GenTableColumnMapper genTableColumnMapper;
|
||||
|
||||
/*@Override
|
||||
public List<GenTableEntity> selectDbTableList(GenTableEntity genTableEntity) {
|
||||
return baseMapper.selectDbTableList(genTableEntity);
|
||||
}*/
|
||||
/*
|
||||
* @Override public List<GenTableEntity> selectDbTableList(GenTableEntity
|
||||
* genTableEntity) { return baseMapper.selectDbTableList(genTableEntity); }
|
||||
*/
|
||||
@Override
|
||||
public IPage<GenTableEntity> selectDbTableList(GenTableEntity genTableEntity) {
|
||||
Page mpPage = new Page(Convert.toLong(ServletUtils.getParameterToInt("pageNum"), 1L), Convert.toLong(ServletUtils.getParameterToInt("pageSize"), 10L));
|
||||
Page mpPage = new Page(Convert.toLong(ServletUtils.getParameterToInt("pageNum"), 1L),
|
||||
Convert.toLong(ServletUtils.getParameterToInt("pageSize"), 10L));
|
||||
return baseMapper.selectDbTableList(mpPage, genTableEntity);
|
||||
}
|
||||
|
||||
@@ -73,7 +73,8 @@ public class GenTableServiceImpl extends ServiceImpl<GenTableMapper, GenTableEnt
|
||||
int row = baseMapper.insert(table);
|
||||
if (row > 0) {
|
||||
// 查询数据库表列信息
|
||||
List<GenTableColumnEntity> genTableColumnEntities = genTableColumnMapper.selectDbTableColumnsByName(tableName);
|
||||
List<GenTableColumnEntity> genTableColumnEntities = genTableColumnMapper
|
||||
.selectDbTableColumnsByName(tableName);
|
||||
if (CollectionUtil.isNotEmpty(genTableColumnEntities)) {
|
||||
for (GenTableColumnEntity column : genTableColumnEntities) {
|
||||
GenUtils.initColumnField(column, table);
|
||||
@@ -100,7 +101,7 @@ public class GenTableServiceImpl extends ServiceImpl<GenTableMapper, GenTableEnt
|
||||
setSubTable(table);
|
||||
// 设置主键列信息
|
||||
setPkColumn(table);
|
||||
// 初始化
|
||||
// 初始化
|
||||
VelocityInitializer.initVelocity();
|
||||
// 设置模板变量信息
|
||||
VelocityContext context = VelocityUtils.prepareContext(table);
|
||||
@@ -140,7 +141,9 @@ public class GenTableServiceImpl extends ServiceImpl<GenTableMapper, GenTableEnt
|
||||
@Override
|
||||
public void deleteGenTableByIds(Long[] tableIds) {
|
||||
baseMapper.deleteBatchIds(Arrays.asList(tableIds));
|
||||
List<GenTableColumnEntity> genTableColumnEntities = genTableColumnMapper.selectList(new LambdaQueryWrapper<GenTableColumnEntity>().in(GenTableColumnEntity::getTableId, Arrays.asList(tableIds)));
|
||||
List<GenTableColumnEntity> genTableColumnEntities = genTableColumnMapper
|
||||
.selectList(new LambdaQueryWrapper<GenTableColumnEntity>().in(GenTableColumnEntity::getTableId,
|
||||
Arrays.asList(tableIds)));
|
||||
genTableColumnMapper.deleteBatchIds(genTableColumnEntities);
|
||||
}
|
||||
|
||||
@@ -151,7 +154,7 @@ public class GenTableServiceImpl extends ServiceImpl<GenTableMapper, GenTableEnt
|
||||
setSubTable(table);
|
||||
// 设置主键列信息
|
||||
setPkColumn(table);
|
||||
// 初始化
|
||||
// 初始化
|
||||
VelocityInitializer.initVelocity();
|
||||
// 设置模板变量信息
|
||||
VelocityContext context = VelocityUtils.prepareContext(table);
|
||||
@@ -185,7 +188,8 @@ public class GenTableServiceImpl extends ServiceImpl<GenTableMapper, GenTableEnt
|
||||
/**
|
||||
* 设置主键列信息
|
||||
*
|
||||
* @param table 业务表信息
|
||||
* @param table
|
||||
* 业务表信息
|
||||
*/
|
||||
public void setPkColumn(GenTableEntity table) {
|
||||
for (GenTableColumnEntity column : table.getColumns()) {
|
||||
|
||||
@@ -4,13 +4,11 @@ import com.starry.generator.config.GenConfig;
|
||||
import com.starry.generator.constant.GenConstants;
|
||||
import com.starry.generator.entity.GenTableColumnEntity;
|
||||
import com.starry.generator.entity.GenTableEntity;
|
||||
import java.util.Arrays;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
* 代码生成器 工具类
|
||||
* @author admin 代码生成器 工具类
|
||||
* @since 2022/7/15
|
||||
*/
|
||||
public class GenUtils {
|
||||
@@ -30,7 +28,8 @@ public class GenUtils {
|
||||
/**
|
||||
* 表名转换成Java类名
|
||||
*
|
||||
* @param tableName 表名称
|
||||
* @param tableName
|
||||
* 表名称
|
||||
* @return 类名
|
||||
*/
|
||||
public static String convertClassName(String tableName) {
|
||||
@@ -48,8 +47,10 @@ public class GenUtils {
|
||||
/**
|
||||
* 批量替换前缀
|
||||
*
|
||||
* @param replacement 替换值
|
||||
* @param searchList 替换列表
|
||||
* @param replacement
|
||||
* 替换值
|
||||
* @param searchList
|
||||
* 替换列表
|
||||
* @return
|
||||
*/
|
||||
public static String replaceFirst(String replacement, String[] searchList) {
|
||||
@@ -64,10 +65,11 @@ public class GenUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* 将下划线大写方式命名的字符串转换为驼峰式。如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。
|
||||
* 例如:HELLO_WORLD -> HelloWorld
|
||||
* 将下划线大写方式命名的字符串转换为驼峰式。如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。 例如:HELLO_WORLD ->
|
||||
* HelloWorld
|
||||
*
|
||||
* @param name 转换前的下划线大写方式命名的字符串
|
||||
* @param name
|
||||
* 转换前的下划线大写方式命名的字符串
|
||||
* @return 转换后的驼峰式命名的字符串
|
||||
*/
|
||||
public static String convertToCamelCase(String name) {
|
||||
@@ -94,7 +96,8 @@ public class GenUtils {
|
||||
/**
|
||||
* 获取模块名
|
||||
*
|
||||
* @param packageName 包名
|
||||
* @param packageName
|
||||
* 包名
|
||||
* @return 模块名
|
||||
*/
|
||||
public static String getModuleName(String packageName) {
|
||||
@@ -106,7 +109,8 @@ public class GenUtils {
|
||||
/**
|
||||
* 获取业务名
|
||||
*
|
||||
* @param tableName 表名
|
||||
* @param tableName
|
||||
* 表名
|
||||
* @return 业务名
|
||||
*/
|
||||
public static String getBusinessName(String tableName) {
|
||||
@@ -128,10 +132,13 @@ public class GenUtils {
|
||||
column.setJavaType(GenConstants.TYPE_STRING);
|
||||
column.setQueryType(GenConstants.QUERY_EQ);
|
||||
|
||||
if (arraysContains(GenConstants.COLUMN_TYPE_STR, dataType) || arraysContains(GenConstants.COLUMN_TYPE_TEXT, dataType)) {
|
||||
if (arraysContains(GenConstants.COLUMN_TYPE_STR, dataType)
|
||||
|| arraysContains(GenConstants.COLUMN_TYPE_TEXT, dataType)) {
|
||||
// 字符串长度超过500设置为文本域
|
||||
Integer columnLength = getColumnLength(column.getColumnType());
|
||||
String htmlType = columnLength >= 500 || arraysContains(GenConstants.COLUMN_TYPE_TEXT, dataType) ? GenConstants.HTML_TEXTAREA : GenConstants.HTML_INPUT;
|
||||
String htmlType = columnLength >= 500 || arraysContains(GenConstants.COLUMN_TYPE_TEXT, dataType)
|
||||
? GenConstants.HTML_TEXTAREA
|
||||
: GenConstants.HTML_INPUT;
|
||||
column.setHtmlType(htmlType);
|
||||
} else if (arraysContains(GenConstants.COLUMN_TYPE_TIME, dataType)) {
|
||||
// 时间类型
|
||||
@@ -197,10 +204,10 @@ public class GenUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据库类型字段
|
||||
* 例如: bigint 、varchar(64)
|
||||
* 获取数据库类型字段 例如: bigint 、varchar(64)
|
||||
*
|
||||
* @param columnType 列类型
|
||||
* @param columnType
|
||||
* 列类型
|
||||
* @return 截取后的列类型
|
||||
*/
|
||||
public static String getDbType(String columnType) {
|
||||
@@ -214,7 +221,8 @@ public class GenUtils {
|
||||
/**
|
||||
* 获取字段长度
|
||||
*
|
||||
* @param columnType 列类型
|
||||
* @param columnType
|
||||
* 列类型
|
||||
* @return 截取后的列类型
|
||||
*/
|
||||
public static Integer getColumnLength(String columnType) {
|
||||
@@ -255,8 +263,10 @@ public class GenUtils {
|
||||
/**
|
||||
* 校验数组是否包含指定值
|
||||
*
|
||||
* @param arr 数组
|
||||
* @param targetValue 值
|
||||
* @param arr
|
||||
* 数组
|
||||
* @param targetValue
|
||||
* 值
|
||||
* @return 是否包含
|
||||
*/
|
||||
public static boolean arraysContains(String[] arr, String targetValue) {
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
package com.starry.generator.utils;
|
||||
|
||||
import org.apache.velocity.app.Velocity;
|
||||
|
||||
import java.util.Properties;
|
||||
import org.apache.velocity.app.Velocity;
|
||||
|
||||
/**
|
||||
* @author VelocityEngine工厂
|
||||
@@ -13,7 +12,8 @@ public class VelocityInitializer {
|
||||
public static void initVelocity() {
|
||||
Properties p = new Properties();
|
||||
// 加载classpath目录下的vm文件
|
||||
p.setProperty("resource.loader.file.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
|
||||
p.setProperty("resource.loader.file.class",
|
||||
"org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
|
||||
// 定义字符集
|
||||
p.setProperty(Velocity.INPUT_ENCODING, "UTF-8");
|
||||
// 初始化Velocity引擎,指定配置Properties
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.starry.generator.utils;
|
||||
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
@@ -9,13 +8,11 @@ import com.starry.common.utils.StringUtils;
|
||||
import com.starry.generator.constant.GenConstants;
|
||||
import com.starry.generator.entity.GenTableColumnEntity;
|
||||
import com.starry.generator.entity.GenTableEntity;
|
||||
import java.util.*;
|
||||
import org.apache.velocity.VelocityContext;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
* 模板处理工具类
|
||||
* @author admin 模板处理工具类
|
||||
* @since 2022/7/19
|
||||
*/
|
||||
public class VelocityUtils {
|
||||
@@ -80,7 +77,8 @@ public class VelocityUtils {
|
||||
/**
|
||||
* 获取包前缀
|
||||
*
|
||||
* @param packageName 包名称
|
||||
* @param packageName
|
||||
* 包名称
|
||||
* @return 包前缀名称
|
||||
*/
|
||||
public static String getPackagePrefix(String packageName) {
|
||||
@@ -91,7 +89,8 @@ public class VelocityUtils {
|
||||
/**
|
||||
* 根据列类型获取导入包
|
||||
*
|
||||
* @param genTableEntity 业务表对象
|
||||
* @param genTableEntity
|
||||
* 业务表对象
|
||||
* @return 返回需要导入的包列表
|
||||
*/
|
||||
public static HashSet<String> getImportList(GenTableEntity genTableEntity) {
|
||||
@@ -116,8 +115,10 @@ public class VelocityUtils {
|
||||
/**
|
||||
* 获取权限前缀
|
||||
*
|
||||
* @param moduleName 模块名称
|
||||
* @param businessName 业务名称
|
||||
* @param moduleName
|
||||
* 模块名称
|
||||
* @param businessName
|
||||
* 业务名称
|
||||
* @return 返回权限前缀
|
||||
*/
|
||||
public static String getPermissionPrefix(String moduleName, String businessName) {
|
||||
@@ -127,7 +128,8 @@ public class VelocityUtils {
|
||||
/**
|
||||
* 根据列类型获取字典组
|
||||
*
|
||||
* @param genTableEntity 业务表对象
|
||||
* @param genTableEntity
|
||||
* 业务表对象
|
||||
* @return 返回字典组
|
||||
*/
|
||||
public static String getDicts(GenTableEntity genTableEntity) {
|
||||
@@ -144,12 +146,16 @@ public class VelocityUtils {
|
||||
/**
|
||||
* 添加字典列表
|
||||
*
|
||||
* @param dicts 字典列表
|
||||
* @param columns 列集合
|
||||
* @param dicts
|
||||
* 字典列表
|
||||
* @param columns
|
||||
* 列集合
|
||||
*/
|
||||
public static void addDicts(Set<String> dicts, List<GenTableColumnEntity> columns) {
|
||||
for (GenTableColumnEntity column : columns) {
|
||||
if (!column.isSuperColumn() && StrUtil.isNotBlank(column.getDictType()) && StringUtils.equalsAny(column.getHtmlType(), new String[]{GenConstants.HTML_SELECT, GenConstants.HTML_RADIO, GenConstants.HTML_CHECKBOX})) {
|
||||
if (!column.isSuperColumn() && StrUtil.isNotBlank(column.getDictType()) && StringUtils.equalsAny(
|
||||
column.getHtmlType(),
|
||||
new String[]{GenConstants.HTML_SELECT, GenConstants.HTML_RADIO, GenConstants.HTML_CHECKBOX})) {
|
||||
dicts.add("'" + column.getDictType() + "'");
|
||||
}
|
||||
}
|
||||
@@ -201,11 +207,13 @@ public class VelocityUtils {
|
||||
/**
|
||||
* 获取上级菜单ID字段
|
||||
*
|
||||
* @param paramsObj 生成其他选项
|
||||
* @param paramsObj
|
||||
* 生成其他选项
|
||||
* @return 上级菜单ID字段
|
||||
*/
|
||||
public static String getParentMenuId(JSONObject paramsObj) {
|
||||
if (StringUtils.isNotEmpty(paramsObj) && paramsObj.containsKey(GenConstants.PARENT_MENU_ID) && StrUtil.isNotBlank(paramsObj.getString(GenConstants.PARENT_MENU_ID))) {
|
||||
if (StringUtils.isNotEmpty(paramsObj) && paramsObj.containsKey(GenConstants.PARENT_MENU_ID)
|
||||
&& StrUtil.isNotBlank(paramsObj.getString(GenConstants.PARENT_MENU_ID))) {
|
||||
return paramsObj.getString(GenConstants.PARENT_MENU_ID);
|
||||
}
|
||||
return DEFAULT_PARENT_MENU_ID;
|
||||
@@ -214,7 +222,8 @@ public class VelocityUtils {
|
||||
/**
|
||||
* 获取树编码
|
||||
*
|
||||
* @param paramsObj 生成其他选项
|
||||
* @param paramsObj
|
||||
* 生成其他选项
|
||||
* @return 树编码
|
||||
*/
|
||||
public static String getTreeCode(JSONObject paramsObj) {
|
||||
@@ -227,7 +236,8 @@ public class VelocityUtils {
|
||||
/**
|
||||
* 获取树父编码
|
||||
*
|
||||
* @param paramsObj 生成其他选项
|
||||
* @param paramsObj
|
||||
* 生成其他选项
|
||||
* @return 树父编码
|
||||
*/
|
||||
public static String getTreeParentCode(JSONObject paramsObj) {
|
||||
@@ -240,7 +250,8 @@ public class VelocityUtils {
|
||||
/**
|
||||
* 获取树名称
|
||||
*
|
||||
* @param paramsObj 生成其他选项
|
||||
* @param paramsObj
|
||||
* 生成其他选项
|
||||
* @return 树名称
|
||||
*/
|
||||
public static String getTreeName(JSONObject paramsObj) {
|
||||
@@ -319,7 +330,8 @@ public class VelocityUtils {
|
||||
|
||||
if (template.contains("entity.java.vm")) {
|
||||
fileName = StringUtils.format("{}/module/entity/{}Entity.java", javaPath, className);
|
||||
} else if (template.contains("sub-domain.java.vm") && StringUtils.equals(GenConstants.TPL_SUB, genTableEntity.getTplCategory())) {
|
||||
} else if (template.contains("sub-domain.java.vm")
|
||||
&& StringUtils.equals(GenConstants.TPL_SUB, genTableEntity.getTplCategory())) {
|
||||
fileName = StringUtils.format("{}/domain/{}.java", javaPath, genTableEntity.getSubTable().getClassName());
|
||||
} else if (template.contains("mapper.java.vm")) {
|
||||
fileName = StringUtils.format("{}/mapper/{}Mapper.java", javaPath, className);
|
||||
|
||||
Reference in New Issue
Block a user