开始开发代码生成器,完成数据库 information_schema 的读取

This commit is contained in:
YunaiV
2021-01-30 20:38:27 +08:00
parent 753c7678ee
commit 67c3a62dcf
25 changed files with 514 additions and 237 deletions

View File

@@ -3,6 +3,7 @@ package com.ruoyi.generator.domain;
import java.util.List;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import org.apache.commons.lang3.ArrayUtils;
import com.ruoyi.common.constant.GenConstants;
import com.ruoyi.common.core.domain.BaseEntity;
@@ -13,108 +14,87 @@ import com.ruoyi.common.utils.StringUtils;
*
* @author ruoyi
*/
public class GenTable extends BaseEntity
{
private static final long serialVersionUID = 1L;
public class GenTable extends BaseEntity {
/** 编号 */
private Long tableId;
/** 表名称 */
@NotBlank(message = "表名称不能为空")
private String tableName;
/** 表描述 */
@NotBlank(message = "表描述不能为空")
private String tableComment;
/** 实体类名称(首字母大写) */
@NotBlank(message = "实体类名称不能为空")
private String className;
/** 使用的模板crud单表操作 tree树表操作 */
private String tplCategory;
/** 生成包路径 */
/**
* 生成包路径
*/
@NotBlank(message = "生成包路径不能为空")
private String packageName;
/** 生成模块名 */
@NotBlank(message = "生成模块名不能为空")
private String moduleName;
/** 生成业务名 */
@NotBlank(message = "生成业务名不能为空")
private String businessName;
/** 生成功能名 */
@NotBlank(message = "生成功能名不能为空")
private String functionName;
/** 生成作者 */
@NotBlank(message = "作者不能为空")
private String functionAuthor;
/** 生成代码方式0zip压缩包 1自定义路径 */
/**
* 生成代码方式0zip压缩包 1自定义路径
*/
private String genType;
/** 生成路径(不填默认项目路径) */
/**
* 生成路径(不填默认项目路径)
*/
private String genPath;
/** 主键信息 */
/**
* 主键信息
*/
private GenTableColumn pkColumn;
/** 表列信息 */
/**
* 表列信息
*/
@Valid
private List<GenTableColumn> columns;
/** 其它生成选项 */
/**
* 其它生成选项
*/
private String options;
/** 树编码字段 */
/**
* 树编码字段
*/
private String treeCode;
/** 树父编码字段 */
/**
* 树父编码字段
*/
private String treeParentCode;
/** 树名称字段 */
/**
* 树名称字段
*/
private String treeName;
/** 上级菜单ID字段 */
/**
* 上级菜单ID字段
*/
private String parentMenuId;
/** 上级菜单名称字段 */
/**
* 上级菜单名称字段
*/
private String parentMenuName;
public boolean isTree()
{
public boolean isTree() {
return isTree(this.tplCategory);
}
public static boolean isTree(String tplCategory)
{
public static boolean isTree(String tplCategory) {
return tplCategory != null && StringUtils.equals(GenConstants.TPL_TREE, tplCategory);
}
public boolean isCrud()
{
public boolean isCrud() {
return isCrud(this.tplCategory);
}
public static boolean isCrud(String tplCategory)
{
public static boolean isCrud(String tplCategory) {
return tplCategory != null && StringUtils.equals(GenConstants.TPL_CRUD, tplCategory);
}
public boolean isSuperColumn(String javaField)
{
public boolean isSuperColumn(String javaField) {
return isSuperColumn(this.tplCategory, javaField);
}
public static boolean isSuperColumn(String tplCategory, String javaField)
{
if (isTree(tplCategory))
{
public static boolean isSuperColumn(String tplCategory, String javaField) {
if (isTree(tplCategory)) {
return StringUtils.equalsAnyIgnoreCase(javaField,
ArrayUtils.addAll(GenConstants.TREE_ENTITY, GenConstants.BASE_ENTITY));
}

View File

@@ -6,7 +6,7 @@ import com.ruoyi.common.utils.StringUtils;
/**
* 代码生成业务字段表 gen_table_column
*
*
* @author ruoyi
*/
public class GenTableColumn extends BaseEntity
@@ -68,86 +68,6 @@ public class GenTableColumn extends BaseEntity
/** 排序 */
private Integer sort;
public void setColumnId(Long columnId)
{
this.columnId = columnId;
}
public Long getColumnId()
{
return columnId;
}
public void setTableId(Long tableId)
{
this.tableId = tableId;
}
public Long getTableId()
{
return tableId;
}
public void setColumnName(String columnName)
{
this.columnName = columnName;
}
public String getColumnName()
{
return columnName;
}
public void setColumnComment(String columnComment)
{
this.columnComment = columnComment;
}
public String getColumnComment()
{
return columnComment;
}
public void setColumnType(String columnType)
{
this.columnType = columnType;
}
public String getColumnType()
{
return columnType;
}
public void setJavaType(String javaType)
{
this.javaType = javaType;
}
public String getJavaType()
{
return javaType;
}
public void setJavaField(String javaField)
{
this.javaField = javaField;
}
public String getJavaField()
{
return javaField;
}
public void setIsPk(String isPk)
{
this.isPk = isPk;
}
public String getIsPk()
{
return isPk;
}
public boolean isPk()
{
return isPk(this.isPk);
@@ -278,46 +198,6 @@ public class GenTableColumn extends BaseEntity
return isQuery != null && StringUtils.equals("1", isQuery);
}
public void setQueryType(String queryType)
{
this.queryType = queryType;
}
public String getQueryType()
{
return queryType;
}
public String getHtmlType()
{
return htmlType;
}
public void setHtmlType(String htmlType)
{
this.htmlType = htmlType;
}
public void setDictType(String dictType)
{
this.dictType = dictType;
}
public String getDictType()
{
return dictType;
}
public void setSort(Integer sort)
{
this.sort = sort;
}
public Integer getSort()
{
return sort;
}
public boolean isSuperColumn()
{
return isSuperColumn(this.javaField);