代码生成模块重构
This commit is contained in:
parent
751545f4be
commit
5a72eb7f49
@ -34,7 +34,7 @@ mybatis-flex:
|
|||||||
|
|
||||||
datasource:
|
datasource:
|
||||||
# 数据源-1
|
# 数据源-1
|
||||||
PrimaryDS:
|
ds1:
|
||||||
# 指定为HikariDataSource
|
# 指定为HikariDataSource
|
||||||
type: com.zaxxer.hikari.HikariDataSource
|
type: com.zaxxer.hikari.HikariDataSource
|
||||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
@ -44,7 +44,7 @@ mybatis-flex:
|
|||||||
|
|
||||||
hikari:
|
hikari:
|
||||||
#连接池名
|
#连接池名
|
||||||
pool-name: HikariCP-PrimaryDS
|
pool-name: HikariCP-ds1
|
||||||
#最小空闲连接数
|
#最小空闲连接数
|
||||||
minimum-idle: 5
|
minimum-idle: 5
|
||||||
# 空闲连接存活最大时间,默认10分钟
|
# 空闲连接存活最大时间,默认10分钟
|
||||||
|
@ -35,26 +35,32 @@ public class GenConstants
|
|||||||
public static final String[] COLUMNTYPE_STR = { "char", "varchar", "nvarchar", "varchar2" };
|
public static final String[] COLUMNTYPE_STR = { "char", "varchar", "nvarchar", "varchar2" };
|
||||||
|
|
||||||
/** 数据库文本类型 */
|
/** 数据库文本类型 */
|
||||||
public static final String[] COLUMNTYPE_TEXT = { "tinytext", "text", "mediumtext", "longtext" };
|
public static final String[] COLUMNTYPE_TEXT = { "tinytext", "text", "mediumtext", "longtext", "binary", "varbinary", "blob",
|
||||||
|
"ntext", "image", "bytea" };
|
||||||
|
|
||||||
/** 数据库时间类型 */
|
/** 数据库时间类型 */
|
||||||
public static final String[] COLUMNTYPE_TIME = { "datetime", "time", "date", "timestamp" };
|
public static final String[] COLUMNTYPE_TIME = { "datetime", "time", "date", "timestamp", "year", "interval",
|
||||||
|
"smalldatetime", "datetime2", "datetimeoffset" };
|
||||||
|
|
||||||
/** 数据库数字类型 */
|
/** 数据库数字类型 */
|
||||||
public static final String[] COLUMNTYPE_NUMBER = { "tinyint", "smallint", "mediumint", "int", "number", "integer",
|
public static final String[] COLUMNTYPE_NUMBER = { "tinyint", "smallint", "mediumint", "int", "number", "integer",
|
||||||
"bit", "bigint", "float", "double", "decimal" };
|
"bit", "bigint", "float", "double", "decimal", "numeric", "real", "double precision",
|
||||||
|
"smallserial", "serial", "bigserial", "money", "smallmoney" };
|
||||||
|
|
||||||
/** 页面不需要编辑字段 */
|
/**
|
||||||
public static final String[] COLUMNNAME_NOT_EDIT = { "id", "create_by", "create_time", "update_by",
|
* BO对象 不需要添加字段
|
||||||
"update_time","del_flag" };
|
*/
|
||||||
|
public static final String[] COLUMNNAME_NOT_ADD = {"create_by", "create_time", "update_by", "update_time" };
|
||||||
|
|
||||||
/** 页面不需要显示的列表字段 */
|
/** BO对象 不需要编辑字段 */
|
||||||
public static final String[] COLUMNNAME_NOT_LIST = { "id", "create_by", "create_time", "del_flag", "update_by",
|
public static final String[] COLUMNNAME_NOT_EDIT = { "create_by", "create_time", "update_by", "update_time" };
|
||||||
"update_time" };
|
|
||||||
|
|
||||||
/** 页面不需要查询字段 */
|
/** VO对象 不需要显示的列表字段 */
|
||||||
public static final String[] COLUMNNAME_NOT_QUERY = { "id", "create_by", "create_time", "del_flag", "update_by",
|
public static final String[] COLUMNNAME_NOT_LIST = { "create_by", "create_time", "update_by", "update_time" };
|
||||||
"update_time", "remark" };
|
|
||||||
|
/** BO对象 不需要查询字段 */
|
||||||
|
public static final String[] COLUMNNAME_NOT_QUERY = { "create_by", "create_time", "update_by",
|
||||||
|
"update_time", "del_flag", "remark", "version" };
|
||||||
|
|
||||||
/** Entity基类字段 */
|
/** Entity基类字段 */
|
||||||
public static final String[] BASE_ENTITY = { "createBy", "createTime", "updateBy", "updateTime"};
|
public static final String[] BASE_ENTITY = { "createBy", "createTime", "updateBy", "updateTime"};
|
||||||
|
@ -31,7 +31,9 @@ import com.ruoyi.generator.service.IGenTableService;
|
|||||||
* 代码生成 操作处理
|
* 代码生成 操作处理
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
|
* @author 数据小王子
|
||||||
*/
|
*/
|
||||||
|
@Validated
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/tool/gen")
|
@RequestMapping("/tool/gen")
|
||||||
public class GenController extends BaseController
|
public class GenController extends BaseController
|
||||||
@ -47,11 +49,9 @@ public class GenController extends BaseController
|
|||||||
*/
|
*/
|
||||||
@SaCheckPermission("tool:gen:list")
|
@SaCheckPermission("tool:gen:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo genList(GenTable genTable)
|
public TableDataInfo<GenTable> genList(GenTable genTable)
|
||||||
{
|
{
|
||||||
startPage();
|
return genTableService.selectPage(genTable);
|
||||||
List<GenTable> list = genTableService.selectGenTableList(genTable);
|
|
||||||
return getDataTable(list);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -198,7 +198,7 @@ public class GenController extends BaseController
|
|||||||
response.reset();
|
response.reset();
|
||||||
response.addHeader("Access-Control-Allow-Origin", "*");
|
response.addHeader("Access-Control-Allow-Origin", "*");
|
||||||
response.addHeader("Access-Control-Expose-Headers", "Content-Disposition");
|
response.addHeader("Access-Control-Expose-Headers", "Content-Disposition");
|
||||||
response.setHeader("Content-Disposition", "attachment; filename=\"ruoyi.zip\"");
|
response.setHeader("Content-Disposition", "attachment; filename=\"ruoyi-flex.zip\"");
|
||||||
response.addHeader("Content-Length", "" + data.length);
|
response.addHeader("Content-Length", "" + data.length);
|
||||||
response.setContentType("application/octet-stream; charset=UTF-8");
|
response.setContentType("application/octet-stream; charset=UTF-8");
|
||||||
IOUtils.write(data, response.getOutputStream());
|
IOUtils.write(data, response.getOutputStream());
|
||||||
|
@ -2,8 +2,14 @@ package com.ruoyi.generator.domain;
|
|||||||
|
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.mybatisflex.annotation.Column;
|
||||||
|
import com.mybatisflex.annotation.Id;
|
||||||
|
import com.mybatisflex.annotation.Table;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
import jakarta.validation.constraints.NotBlank;
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
import com.ruoyi.common.core.constant.GenConstants;
|
import com.ruoyi.common.core.constant.GenConstants;
|
||||||
import com.ruoyi.common.orm.core.domain.BaseEntity;
|
import com.ruoyi.common.orm.core.domain.BaseEntity;
|
||||||
@ -13,13 +19,18 @@ import com.ruoyi.common.core.utils.StringUtils;
|
|||||||
* 业务表 gen_table
|
* 业务表 gen_table
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
|
* @author 数据小王子
|
||||||
*/
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Table(value = "gen_table")
|
||||||
public class GenTable extends BaseEntity
|
public class GenTable extends BaseEntity
|
||||||
{
|
{
|
||||||
@Serial
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/** 编号 */
|
/** 编号 */
|
||||||
|
@Id
|
||||||
private Long tableId;
|
private Long tableId;
|
||||||
|
|
||||||
/** 表名称 */
|
/** 表名称 */
|
||||||
@ -70,6 +81,7 @@ public class GenTable extends BaseEntity
|
|||||||
private String genPath;
|
private String genPath;
|
||||||
|
|
||||||
/** 主键信息 */
|
/** 主键信息 */
|
||||||
|
@Column(ignore = true)
|
||||||
private GenTableColumn pkColumn;
|
private GenTableColumn pkColumn;
|
||||||
|
|
||||||
/** 子表信息 */
|
/** 子表信息 */
|
||||||
@ -83,12 +95,15 @@ public class GenTable extends BaseEntity
|
|||||||
private String options;
|
private String options;
|
||||||
|
|
||||||
/** 树编码字段 */
|
/** 树编码字段 */
|
||||||
|
@Column(ignore = true)
|
||||||
private String treeCode;
|
private String treeCode;
|
||||||
|
|
||||||
/** 树父编码字段 */
|
/** 树父编码字段 */
|
||||||
|
@Column(ignore = true)
|
||||||
private String treeParentCode;
|
private String treeParentCode;
|
||||||
|
|
||||||
/** 树名称字段 */
|
/** 树名称字段 */
|
||||||
|
@Column(ignore = true)
|
||||||
private String treeName;
|
private String treeName;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -97,252 +112,16 @@ public class GenTable extends BaseEntity
|
|||||||
private List<Long> menuIds;
|
private List<Long> menuIds;
|
||||||
|
|
||||||
/** 上级菜单ID字段 */
|
/** 上级菜单ID字段 */
|
||||||
|
@Column(ignore = true)
|
||||||
private String parentMenuId;
|
private String parentMenuId;
|
||||||
|
|
||||||
/** 上级菜单名称字段 */
|
/** 上级菜单名称字段 */
|
||||||
|
@Column(ignore = true)
|
||||||
private String parentMenuName;
|
private String parentMenuName;
|
||||||
|
|
||||||
/** 备注 */
|
/** 备注 */
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
public Long getTableId()
|
|
||||||
{
|
|
||||||
return tableId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTableId(Long tableId)
|
|
||||||
{
|
|
||||||
this.tableId = tableId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTableName()
|
|
||||||
{
|
|
||||||
return tableName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTableName(String tableName)
|
|
||||||
{
|
|
||||||
this.tableName = tableName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTableComment()
|
|
||||||
{
|
|
||||||
return tableComment;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTableComment(String tableComment)
|
|
||||||
{
|
|
||||||
this.tableComment = tableComment;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSubTableName()
|
|
||||||
{
|
|
||||||
return subTableName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSubTableName(String subTableName)
|
|
||||||
{
|
|
||||||
this.subTableName = subTableName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSubTableFkName()
|
|
||||||
{
|
|
||||||
return subTableFkName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSubTableFkName(String subTableFkName)
|
|
||||||
{
|
|
||||||
this.subTableFkName = subTableFkName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getClassName()
|
|
||||||
{
|
|
||||||
return className;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setClassName(String className)
|
|
||||||
{
|
|
||||||
this.className = className;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTplCategory()
|
|
||||||
{
|
|
||||||
return tplCategory;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTplCategory(String tplCategory)
|
|
||||||
{
|
|
||||||
this.tplCategory = tplCategory;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPackageName()
|
|
||||||
{
|
|
||||||
return packageName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPackageName(String packageName)
|
|
||||||
{
|
|
||||||
this.packageName = packageName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getModuleName()
|
|
||||||
{
|
|
||||||
return moduleName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setModuleName(String moduleName)
|
|
||||||
{
|
|
||||||
this.moduleName = moduleName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getBusinessName()
|
|
||||||
{
|
|
||||||
return businessName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBusinessName(String businessName)
|
|
||||||
{
|
|
||||||
this.businessName = businessName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFunctionName()
|
|
||||||
{
|
|
||||||
return functionName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFunctionName(String functionName)
|
|
||||||
{
|
|
||||||
this.functionName = functionName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFunctionAuthor()
|
|
||||||
{
|
|
||||||
return functionAuthor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFunctionAuthor(String functionAuthor)
|
|
||||||
{
|
|
||||||
this.functionAuthor = functionAuthor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getGenType()
|
|
||||||
{
|
|
||||||
return genType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setGenType(String genType)
|
|
||||||
{
|
|
||||||
this.genType = genType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getGenPath()
|
|
||||||
{
|
|
||||||
return genPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setGenPath(String genPath)
|
|
||||||
{
|
|
||||||
this.genPath = genPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GenTableColumn getPkColumn()
|
|
||||||
{
|
|
||||||
return pkColumn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPkColumn(GenTableColumn pkColumn)
|
|
||||||
{
|
|
||||||
this.pkColumn = pkColumn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GenTable getSubTable()
|
|
||||||
{
|
|
||||||
return subTable;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSubTable(GenTable subTable)
|
|
||||||
{
|
|
||||||
this.subTable = subTable;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<GenTableColumn> getColumns()
|
|
||||||
{
|
|
||||||
return columns;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setColumns(List<GenTableColumn> columns)
|
|
||||||
{
|
|
||||||
this.columns = columns;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getOptions()
|
|
||||||
{
|
|
||||||
return options;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOptions(String options)
|
|
||||||
{
|
|
||||||
this.options = options;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTreeCode()
|
|
||||||
{
|
|
||||||
return treeCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTreeCode(String treeCode)
|
|
||||||
{
|
|
||||||
this.treeCode = treeCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTreeParentCode()
|
|
||||||
{
|
|
||||||
return treeParentCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTreeParentCode(String treeParentCode)
|
|
||||||
{
|
|
||||||
this.treeParentCode = treeParentCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTreeName()
|
|
||||||
{
|
|
||||||
return treeName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTreeName(String treeName)
|
|
||||||
{
|
|
||||||
this.treeName = treeName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Long> getMenuIds() {
|
|
||||||
return menuIds;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMenuIds(List<Long> menuIds) {
|
|
||||||
this.menuIds = menuIds;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getParentMenuId()
|
|
||||||
{
|
|
||||||
return parentMenuId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setParentMenuId(String parentMenuId)
|
|
||||||
{
|
|
||||||
this.parentMenuId = parentMenuId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getParentMenuName()
|
|
||||||
{
|
|
||||||
return parentMenuName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setParentMenuName(String parentMenuName)
|
|
||||||
{
|
|
||||||
this.parentMenuName = parentMenuName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSub()
|
public boolean isSub()
|
||||||
{
|
{
|
||||||
return isSub(this.tplCategory);
|
return isSub(this.tplCategory);
|
||||||
@ -388,11 +167,4 @@ public class GenTable extends BaseEntity
|
|||||||
return StringUtils.equalsAnyIgnoreCase(javaField, GenConstants.BASE_ENTITY);
|
return StringUtils.equalsAnyIgnoreCase(javaField, GenConstants.BASE_ENTITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRemark() {
|
|
||||||
return remark;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRemark(String remark) {
|
|
||||||
this.remark = remark;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,12 @@
|
|||||||
package com.ruoyi.generator.domain;
|
package com.ruoyi.generator.domain;
|
||||||
|
|
||||||
|
import com.mybatisflex.annotation.Id;
|
||||||
|
import com.mybatisflex.annotation.Table;
|
||||||
import jakarta.validation.constraints.NotBlank;
|
import jakarta.validation.constraints.NotBlank;
|
||||||
import com.ruoyi.common.orm.core.domain.BaseEntity;
|
import com.ruoyi.common.orm.core.domain.BaseEntity;
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
|
|
||||||
@ -10,13 +14,18 @@ import java.io.Serial;
|
|||||||
* 代码生成业务字段表 gen_table_column
|
* 代码生成业务字段表 gen_table_column
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
|
* @author 数据小王子
|
||||||
*/
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Table(value = "gen_table_column")
|
||||||
public class GenTableColumn extends BaseEntity
|
public class GenTableColumn extends BaseEntity
|
||||||
{
|
{
|
||||||
@Serial
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/** 编号 */
|
/** 编号 */
|
||||||
|
@Id
|
||||||
private Long columnId;
|
private Long columnId;
|
||||||
|
|
||||||
/** 归属表编号 */
|
/** 归属表编号 */
|
||||||
@ -71,91 +80,11 @@ public class GenTableColumn extends BaseEntity
|
|||||||
/** 排序 */
|
/** 排序 */
|
||||||
private Integer sort;
|
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 String getCapJavaField()
|
public String getCapJavaField()
|
||||||
{
|
{
|
||||||
return StringUtils.capitalize(javaField);
|
return StringUtils.capitalize(javaField);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIsPk(String isPk)
|
|
||||||
{
|
|
||||||
this.isPk = isPk;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getIsPk()
|
|
||||||
{
|
|
||||||
return isPk;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isPk()
|
public boolean isPk()
|
||||||
{
|
{
|
||||||
return isPk(this.isPk);
|
return isPk(this.isPk);
|
||||||
@ -166,16 +95,6 @@ public class GenTableColumn extends BaseEntity
|
|||||||
return isPk != null && StringUtils.equals("1", isPk);
|
return isPk != null && StringUtils.equals("1", isPk);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIsIncrement()
|
|
||||||
{
|
|
||||||
return isIncrement;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIsIncrement(String isIncrement)
|
|
||||||
{
|
|
||||||
this.isIncrement = isIncrement;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isIncrement()
|
public boolean isIncrement()
|
||||||
{
|
{
|
||||||
return isIncrement(this.isIncrement);
|
return isIncrement(this.isIncrement);
|
||||||
@ -186,16 +105,6 @@ public class GenTableColumn extends BaseEntity
|
|||||||
return isIncrement != null && StringUtils.equals("1", isIncrement);
|
return isIncrement != null && StringUtils.equals("1", isIncrement);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIsRequired(String isRequired)
|
|
||||||
{
|
|
||||||
this.isRequired = isRequired;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getIsRequired()
|
|
||||||
{
|
|
||||||
return isRequired;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isRequired()
|
public boolean isRequired()
|
||||||
{
|
{
|
||||||
return isRequired(this.isRequired);
|
return isRequired(this.isRequired);
|
||||||
@ -206,16 +115,6 @@ public class GenTableColumn extends BaseEntity
|
|||||||
return isRequired != null && StringUtils.equals("1", isRequired);
|
return isRequired != null && StringUtils.equals("1", isRequired);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIsInsert(String isInsert)
|
|
||||||
{
|
|
||||||
this.isInsert = isInsert;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getIsInsert()
|
|
||||||
{
|
|
||||||
return isInsert;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isInsert()
|
public boolean isInsert()
|
||||||
{
|
{
|
||||||
return isInsert(this.isInsert);
|
return isInsert(this.isInsert);
|
||||||
@ -226,16 +125,6 @@ public class GenTableColumn extends BaseEntity
|
|||||||
return isInsert != null && StringUtils.equals("1", isInsert);
|
return isInsert != null && StringUtils.equals("1", isInsert);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIsEdit(String isEdit)
|
|
||||||
{
|
|
||||||
this.isEdit = isEdit;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getIsEdit()
|
|
||||||
{
|
|
||||||
return isEdit;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isEdit()
|
public boolean isEdit()
|
||||||
{
|
{
|
||||||
return isInsert(this.isEdit);
|
return isInsert(this.isEdit);
|
||||||
@ -245,17 +134,6 @@ public class GenTableColumn extends BaseEntity
|
|||||||
{
|
{
|
||||||
return isEdit != null && StringUtils.equals("1", isEdit);
|
return isEdit != null && StringUtils.equals("1", isEdit);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIsList(String isList)
|
|
||||||
{
|
|
||||||
this.isList = isList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getIsList()
|
|
||||||
{
|
|
||||||
return isList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isList()
|
public boolean isList()
|
||||||
{
|
{
|
||||||
return isList(this.isList);
|
return isList(this.isList);
|
||||||
@ -266,16 +144,6 @@ public class GenTableColumn extends BaseEntity
|
|||||||
return isList != null && StringUtils.equals("1", isList);
|
return isList != null && StringUtils.equals("1", isList);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIsQuery(String isQuery)
|
|
||||||
{
|
|
||||||
this.isQuery = isQuery;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getIsQuery()
|
|
||||||
{
|
|
||||||
return isQuery;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isQuery()
|
public boolean isQuery()
|
||||||
{
|
{
|
||||||
return isQuery(this.isQuery);
|
return isQuery(this.isQuery);
|
||||||
@ -286,46 +154,6 @@ public class GenTableColumn extends BaseEntity
|
|||||||
return isQuery != null && StringUtils.equals("1", isQuery);
|
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()
|
public boolean isSuperColumn()
|
||||||
{
|
{
|
||||||
return isSuperColumn(this.javaField);
|
return isSuperColumn(this.javaField);
|
||||||
|
@ -1,60 +1,41 @@
|
|||||||
package com.ruoyi.generator.mapper;
|
package com.ruoyi.generator.mapper;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.mybatisflex.core.BaseMapper;
|
||||||
import com.ruoyi.generator.domain.GenTableColumn;
|
import com.ruoyi.generator.domain.GenTableColumn;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 业务字段 数据层
|
* 业务字段 数据层
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
|
* @author 数据小王子
|
||||||
*/
|
*/
|
||||||
public interface GenTableColumnMapper
|
@Mapper
|
||||||
|
public interface GenTableColumnMapper extends BaseMapper<GenTableColumn>
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* 根据表名称查询列信息
|
* 根据表名称查询列信息
|
||||||
*
|
*
|
||||||
* @param tableName 表名称
|
* @param tableName 表名称
|
||||||
* @return 列信息
|
* @return 列信息
|
||||||
*/
|
*/
|
||||||
public List<GenTableColumn> selectDbTableColumnsByName(String tableName);
|
List<GenTableColumn> selectDbTableColumnsByName(String tableName);
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询业务字段列表
|
|
||||||
*
|
|
||||||
* @param tableId 业务字段编号
|
|
||||||
* @return 业务字段集合
|
|
||||||
*/
|
|
||||||
public List<GenTableColumn> selectGenTableColumnListByTableId(Long tableId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增业务字段
|
|
||||||
*
|
|
||||||
* @param genTableColumn 业务字段信息
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public int insertGenTableColumn(GenTableColumn genTableColumn);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改业务字段
|
|
||||||
*
|
|
||||||
* @param genTableColumn 业务字段信息
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public int updateGenTableColumn(GenTableColumn genTableColumn);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除业务字段
|
* 删除业务字段
|
||||||
*
|
*
|
||||||
* @param genTableColumns 列数据
|
* @param genTableColumns 列数据
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int deleteGenTableColumns(List<GenTableColumn> genTableColumns);
|
int deleteGenTableColumns(List<GenTableColumn> genTableColumns);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除业务字段
|
* 批量删除业务字段
|
||||||
*
|
*
|
||||||
* @param ids 需要删除的数据ID
|
* @param ids 需要删除的数据ID
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int deleteGenTableColumnByIds(Long[] ids);
|
int deleteGenTableColumnByIds(Long[] ids);
|
||||||
}
|
}
|
||||||
|
@ -1,83 +1,44 @@
|
|||||||
package com.ruoyi.generator.mapper;
|
package com.ruoyi.generator.mapper;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.mybatisflex.core.BaseMapper;
|
||||||
import com.ruoyi.generator.domain.GenTable;
|
import com.ruoyi.generator.domain.GenTable;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 业务 数据层
|
* 业务 数据层
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
|
* @author 数据小王子
|
||||||
*/
|
*/
|
||||||
public interface GenTableMapper
|
@Mapper
|
||||||
|
public interface GenTableMapper extends BaseMapper<GenTable>
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* 查询业务列表
|
|
||||||
*
|
|
||||||
* @param genTable 业务信息
|
|
||||||
* @return 业务集合
|
|
||||||
*/
|
|
||||||
public List<GenTable> selectGenTableList(GenTable genTable);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询据库列表
|
* 查询据库列表
|
||||||
*
|
*
|
||||||
* @param genTable 业务信息
|
* @param genTable 业务信息
|
||||||
* @return 数据库表集合
|
* @return 数据库表集合
|
||||||
*/
|
*/
|
||||||
public List<GenTable> selectDbTableList(GenTable genTable);
|
List<GenTable> selectDbTableList(GenTable genTable);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询据库列表
|
* 查询据库列表
|
||||||
*
|
*
|
||||||
* @param tableNames 表名称组
|
* @param tableNames 表名称组
|
||||||
* @return 数据库表集合
|
* @return 数据库表集合
|
||||||
*/
|
*/
|
||||||
public List<GenTable> selectDbTableListByNames(String[] tableNames);
|
List<GenTable> selectDbTableListByNames(String[] tableNames);
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询所有表信息
|
|
||||||
*
|
|
||||||
* @return 表信息集合
|
|
||||||
*/
|
|
||||||
public List<GenTable> selectGenTableAll();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询表ID业务信息
|
|
||||||
*
|
|
||||||
* @param id 业务ID
|
|
||||||
* @return 业务信息
|
|
||||||
*/
|
|
||||||
public GenTable selectGenTableById(Long id);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询表名称业务信息
|
* 查询表名称业务信息
|
||||||
*
|
*
|
||||||
* @param tableName 表名称
|
* @param tableName 表名称
|
||||||
* @return 业务信息
|
* @return 业务信息
|
||||||
*/
|
*/
|
||||||
public GenTable selectGenTableByName(String tableName);
|
GenTable selectGenTableByName(String tableName);
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增业务
|
|
||||||
*
|
|
||||||
* @param genTable 业务信息
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public int insertGenTable(GenTable genTable);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改业务
|
|
||||||
*
|
|
||||||
* @param genTable 业务信息
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public int updateGenTable(GenTable genTable);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除业务
|
|
||||||
*
|
|
||||||
* @param ids 需要删除的数据ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public int deleteGenTableByIds(Long[] ids);
|
|
||||||
}
|
}
|
||||||
|
@ -2,23 +2,33 @@ package com.ruoyi.generator.service;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.mybatisflex.core.query.QueryWrapper;
|
||||||
|
import com.ruoyi.common.orm.core.service.impl.BaseServiceImpl;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import com.ruoyi.common.core.core.text.Convert;
|
import com.ruoyi.common.core.core.text.Convert;
|
||||||
import com.ruoyi.generator.domain.GenTableColumn;
|
import com.ruoyi.generator.domain.GenTableColumn;
|
||||||
import com.ruoyi.generator.mapper.GenTableColumnMapper;
|
import com.ruoyi.generator.mapper.GenTableColumnMapper;
|
||||||
|
|
||||||
|
import static com.ruoyi.generator.domain.table.GenTableColumnTableDef.GEN_TABLE_COLUMN;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 业务字段 服务层实现
|
* 业务字段 服务层实现
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
|
* @author 数据小王子
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class GenTableColumnServiceImpl implements IGenTableColumnService
|
public class GenTableColumnServiceImpl extends BaseServiceImpl<GenTableColumnMapper, GenTableColumn> implements IGenTableColumnService
|
||||||
{
|
{
|
||||||
@Resource
|
@Resource
|
||||||
private GenTableColumnMapper genTableColumnMapper;
|
private GenTableColumnMapper genTableColumnMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public QueryWrapper query() {
|
||||||
|
return super.query().from(GEN_TABLE_COLUMN);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询业务字段列表
|
* 查询业务字段列表
|
||||||
*
|
*
|
||||||
@ -28,7 +38,11 @@ public class GenTableColumnServiceImpl implements IGenTableColumnService
|
|||||||
@Override
|
@Override
|
||||||
public List<GenTableColumn> selectGenTableColumnListByTableId(Long tableId)
|
public List<GenTableColumn> selectGenTableColumnListByTableId(Long tableId)
|
||||||
{
|
{
|
||||||
return genTableColumnMapper.selectGenTableColumnListByTableId(tableId);
|
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||||
|
.from(GEN_TABLE_COLUMN)
|
||||||
|
.where(GEN_TABLE_COLUMN.TABLE_ID.eq(tableId))
|
||||||
|
.orderBy(GEN_TABLE_COLUMN.SORT.asc());
|
||||||
|
return this.list(queryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -40,7 +54,8 @@ public class GenTableColumnServiceImpl implements IGenTableColumnService
|
|||||||
@Override
|
@Override
|
||||||
public int insertGenTableColumn(GenTableColumn genTableColumn)
|
public int insertGenTableColumn(GenTableColumn genTableColumn)
|
||||||
{
|
{
|
||||||
return genTableColumnMapper.insertGenTableColumn(genTableColumn);
|
//return genTableColumnMapper.insertGenTableColumn(genTableColumn);
|
||||||
|
return genTableColumnMapper.insertSelective(genTableColumn);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -52,7 +67,7 @@ public class GenTableColumnServiceImpl implements IGenTableColumnService
|
|||||||
@Override
|
@Override
|
||||||
public int updateGenTableColumn(GenTableColumn genTableColumn)
|
public int updateGenTableColumn(GenTableColumn genTableColumn)
|
||||||
{
|
{
|
||||||
return genTableColumnMapper.updateGenTableColumn(genTableColumn);
|
return genTableColumnMapper.update(genTableColumn);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,24 +1,26 @@
|
|||||||
package com.ruoyi.generator.service;
|
package com.ruoyi.generator.service;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipOutputStream;
|
import java.util.zip.ZipOutputStream;
|
||||||
|
|
||||||
|
import com.mybatisflex.core.paginate.Page;
|
||||||
|
import com.mybatisflex.core.query.QueryMethods;
|
||||||
|
import com.mybatisflex.core.query.QueryWrapper;
|
||||||
import com.ruoyi.common.core.utils.DateUtils;
|
import com.ruoyi.common.core.utils.DateUtils;
|
||||||
|
import com.ruoyi.common.orm.core.page.PageQuery;
|
||||||
|
import com.ruoyi.common.orm.core.page.TableDataInfo;
|
||||||
|
import com.ruoyi.common.orm.core.service.impl.BaseServiceImpl;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.velocity.Template;
|
import org.apache.velocity.Template;
|
||||||
import org.apache.velocity.VelocityContext;
|
import org.apache.velocity.VelocityContext;
|
||||||
import org.apache.velocity.app.Velocity;
|
import org.apache.velocity.app.Velocity;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
@ -36,23 +38,44 @@ import com.ruoyi.generator.util.GenUtils;
|
|||||||
import com.ruoyi.generator.util.VelocityInitializer;
|
import com.ruoyi.generator.util.VelocityInitializer;
|
||||||
import com.ruoyi.generator.util.VelocityUtils;
|
import com.ruoyi.generator.util.VelocityUtils;
|
||||||
|
|
||||||
|
import static com.ruoyi.generator.domain.table.GenTableColumnTableDef.GEN_TABLE_COLUMN;
|
||||||
|
import static com.ruoyi.generator.domain.table.GenTableTableDef.GEN_TABLE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 业务 服务层实现
|
* 业务 服务层实现
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class GenTableServiceImpl implements IGenTableService
|
public class GenTableServiceImpl extends BaseServiceImpl<GenTableMapper, GenTable> implements IGenTableService
|
||||||
{
|
{
|
||||||
@Serial
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(GenTableServiceImpl.class);
|
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private GenTableMapper genTableMapper;
|
private GenTableMapper genTableMapper;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private GenTableColumnMapper genTableColumnMapper;
|
private GenTableColumnMapper genTableColumnMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public QueryWrapper query() {
|
||||||
|
return super.query().from(GEN_TABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
private QueryWrapper buildQueryWrapper(GenTable genTable) {
|
||||||
|
QueryWrapper queryWrapper = super.buildBaseQueryWrapper();
|
||||||
|
if (StringUtils.isNotBlank(genTable.getTableName())) {
|
||||||
|
queryWrapper.and(QueryMethods.lower(GEN_TABLE.TABLE_NAME).like(genTable.getTableName().toLowerCase()));
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(genTable.getTableComment())) {
|
||||||
|
queryWrapper.and(QueryMethods.lower(GEN_TABLE.TABLE_COMMENT).like(genTable.getTableComment().toLowerCase()));
|
||||||
|
}
|
||||||
|
Map<String, Object> params = genTable.getParams();
|
||||||
|
if (params.get("beginTime") != null && params.get("endTime") != null) {
|
||||||
|
queryWrapper.and(GEN_TABLE.CREATE_TIME.between(params.get("beginTime"), params.get("endTime")));
|
||||||
|
}
|
||||||
|
return queryWrapper;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询业务信息
|
* 查询业务信息
|
||||||
*
|
*
|
||||||
@ -62,21 +85,34 @@ public class GenTableServiceImpl implements IGenTableService
|
|||||||
@Override
|
@Override
|
||||||
public GenTable selectGenTableById(Long id)
|
public GenTable selectGenTableById(Long id)
|
||||||
{
|
{
|
||||||
GenTable genTable = genTableMapper.selectGenTableById(id);
|
/*SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark,
|
||||||
|
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
|
||||||
|
FROM gen_table t
|
||||||
|
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
|
||||||
|
where t.table_id = #{tableId} order by c.sort*/
|
||||||
|
|
||||||
|
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||||
|
.from(GEN_TABLE)
|
||||||
|
.leftJoin(GEN_TABLE_COLUMN).on(GEN_TABLE_COLUMN.TABLE_ID.eq(GEN_TABLE.TABLE_ID))
|
||||||
|
.where(GEN_TABLE.TABLE_ID.eq(id))
|
||||||
|
.orderBy(GEN_TABLE_COLUMN.SORT.asc());
|
||||||
|
GenTable genTable = this.getOne(queryWrapper);
|
||||||
setTableFromOptions(genTable);
|
setTableFromOptions(genTable);
|
||||||
return genTable;
|
return genTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询业务列表
|
* 分页查询业务列表
|
||||||
*
|
*
|
||||||
* @param genTable 业务信息
|
* @param genTable 业务信息
|
||||||
* @return 业务集合
|
* @return 分页集合
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<GenTable> selectGenTableList(GenTable genTable)
|
public TableDataInfo<GenTable> selectPage(GenTable genTable)
|
||||||
{
|
{
|
||||||
return genTableMapper.selectGenTableList(genTable);
|
QueryWrapper queryWrapper = buildQueryWrapper(genTable);
|
||||||
|
Page<GenTable> page = this.pageAs(PageQuery.build(), queryWrapper, GenTable.class);
|
||||||
|
return TableDataInfo.build(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -111,7 +147,11 @@ public class GenTableServiceImpl implements IGenTableService
|
|||||||
@Override
|
@Override
|
||||||
public List<GenTable> selectGenTableAll()
|
public List<GenTable> selectGenTableAll()
|
||||||
{
|
{
|
||||||
return genTableMapper.selectGenTableAll();
|
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||||
|
.from(GEN_TABLE)
|
||||||
|
.leftJoin(GEN_TABLE_COLUMN).on(GEN_TABLE_COLUMN.TABLE_ID.eq(GEN_TABLE.TABLE_ID))
|
||||||
|
.orderBy(GEN_TABLE_COLUMN.SORT.asc());
|
||||||
|
return this.list(queryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -126,12 +166,12 @@ public class GenTableServiceImpl implements IGenTableService
|
|||||||
{
|
{
|
||||||
String options = JSON.toJSONString(genTable.getParams());
|
String options = JSON.toJSONString(genTable.getParams());
|
||||||
genTable.setOptions(options);
|
genTable.setOptions(options);
|
||||||
int row = genTableMapper.updateGenTable(genTable);
|
boolean updated = this.updateById(genTable);
|
||||||
if (row > 0)
|
if (updated)
|
||||||
{
|
{
|
||||||
for (GenTableColumn cenTableColumn : genTable.getColumns())
|
for (GenTableColumn genTableColumn : genTable.getColumns())
|
||||||
{
|
{
|
||||||
genTableColumnMapper.updateGenTableColumn(cenTableColumn);
|
genTableColumnMapper.update(genTableColumn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -146,7 +186,7 @@ public class GenTableServiceImpl implements IGenTableService
|
|||||||
@Transactional
|
@Transactional
|
||||||
public void deleteGenTableByIds(Long[] tableIds)
|
public void deleteGenTableByIds(Long[] tableIds)
|
||||||
{
|
{
|
||||||
genTableMapper.deleteGenTableByIds(tableIds);
|
genTableMapper.deleteBatchByIds(Arrays.asList(tableIds));
|
||||||
genTableColumnMapper.deleteGenTableColumnByIds(tableIds);
|
genTableColumnMapper.deleteGenTableColumnByIds(tableIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,15 +205,16 @@ public class GenTableServiceImpl implements IGenTableService
|
|||||||
{
|
{
|
||||||
String tableName = table.getTableName();
|
String tableName = table.getTableName();
|
||||||
GenUtils.initTable(table);
|
GenUtils.initTable(table);
|
||||||
int row = genTableMapper.insertGenTable(table);
|
//int row = genTableMapper.insertGenTable(table);
|
||||||
if (row > 0)
|
boolean saved = this.save(table);
|
||||||
|
if (saved)
|
||||||
{
|
{
|
||||||
// 保存列信息
|
// 保存列信息
|
||||||
List<GenTableColumn> genTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName);
|
List<GenTableColumn> genTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName);
|
||||||
for (GenTableColumn column : genTableColumns)
|
for (GenTableColumn column : genTableColumns)
|
||||||
{
|
{
|
||||||
GenUtils.initColumnField(column, table);
|
GenUtils.initColumnField(column, table);
|
||||||
genTableColumnMapper.insertGenTableColumn(column);
|
genTableColumnMapper.insertSelective(column);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -195,7 +236,7 @@ public class GenTableServiceImpl implements IGenTableService
|
|||||||
{
|
{
|
||||||
Map<String, String> dataMap = new LinkedHashMap<>();
|
Map<String, String> dataMap = new LinkedHashMap<>();
|
||||||
// 查询表信息
|
// 查询表信息
|
||||||
GenTable table = genTableMapper.selectGenTableById(tableId);
|
GenTable table = selectGenTableById(tableId);
|
||||||
//设置生成的sys_menu6条记录的主键值
|
//设置生成的sys_menu6条记录的主键值
|
||||||
setMenuIds(table);
|
setMenuIds(table);
|
||||||
// 设置主子表信息
|
// 设置主子表信息
|
||||||
@ -319,11 +360,11 @@ public class GenTableServiceImpl implements IGenTableService
|
|||||||
column.setIsRequired(prevColumn.getIsRequired());
|
column.setIsRequired(prevColumn.getIsRequired());
|
||||||
column.setHtmlType(prevColumn.getHtmlType());
|
column.setHtmlType(prevColumn.getHtmlType());
|
||||||
}
|
}
|
||||||
genTableColumnMapper.updateGenTableColumn(column);
|
genTableColumnMapper.update(column);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
genTableColumnMapper.insertGenTableColumn(column);
|
genTableColumnMapper.insertSelective(column);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -362,6 +403,8 @@ public class GenTableServiceImpl implements IGenTableService
|
|||||||
GenTable table = genTableMapper.selectGenTableByName(tableName);
|
GenTable table = genTableMapper.selectGenTableByName(tableName);
|
||||||
// 设置主子表信息
|
// 设置主子表信息
|
||||||
setSubTable(table);
|
setSubTable(table);
|
||||||
|
//设置生成的sys_menu6条记录的主键值
|
||||||
|
setMenuIds(table);
|
||||||
// 设置主键列信息
|
// 设置主键列信息
|
||||||
setPkColumn(table);
|
setPkColumn(table);
|
||||||
|
|
||||||
|
@ -5,40 +5,41 @@ import com.ruoyi.generator.domain.GenTableColumn;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 业务字段 服务层
|
* 业务字段 服务层
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
|
* @author 数据小王子
|
||||||
*/
|
*/
|
||||||
public interface IGenTableColumnService
|
public interface IGenTableColumnService
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* 查询业务字段列表
|
* 查询业务字段列表
|
||||||
*
|
*
|
||||||
* @param tableId 业务字段编号
|
* @param tableId 业务字段编号
|
||||||
* @return 业务字段集合
|
* @return 业务字段集合
|
||||||
*/
|
*/
|
||||||
public List<GenTableColumn> selectGenTableColumnListByTableId(Long tableId);
|
List<GenTableColumn> selectGenTableColumnListByTableId(Long tableId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增业务字段
|
* 新增业务字段
|
||||||
*
|
*
|
||||||
* @param genTableColumn 业务字段信息
|
* @param genTableColumn 业务字段信息
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int insertGenTableColumn(GenTableColumn genTableColumn);
|
int insertGenTableColumn(GenTableColumn genTableColumn);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改业务字段
|
* 修改业务字段
|
||||||
*
|
*
|
||||||
* @param genTableColumn 业务字段信息
|
* @param genTableColumn 业务字段信息
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int updateGenTableColumn(GenTableColumn genTableColumn);
|
int updateGenTableColumn(GenTableColumn genTableColumn);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除业务字段信息
|
* 删除业务字段信息
|
||||||
*
|
*
|
||||||
* @param ids 需要删除的数据ID
|
* @param ids 需要删除的数据ID
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int deleteGenTableColumnByIds(String ids);
|
int deleteGenTableColumnByIds(String ids);
|
||||||
}
|
}
|
||||||
|
@ -2,34 +2,38 @@ package com.ruoyi.generator.service;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.ruoyi.common.orm.core.page.TableDataInfo;
|
||||||
|
import com.ruoyi.common.orm.core.service.IBaseService;
|
||||||
import com.ruoyi.generator.domain.GenTable;
|
import com.ruoyi.generator.domain.GenTable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 业务 服务层
|
* 业务 服务层
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
|
* @author 数据小王子
|
||||||
*/
|
*/
|
||||||
public interface IGenTableService
|
public interface IGenTableService extends IBaseService<GenTable>
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* 查询业务列表
|
|
||||||
*
|
|
||||||
* @param genTable 业务信息
|
|
||||||
* @return 业务集合
|
|
||||||
*/
|
|
||||||
public List<GenTable> selectGenTableList(GenTable genTable);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询据库列表
|
* 查询据库列表
|
||||||
*
|
*
|
||||||
* @param genTable 业务信息
|
* @param genTable 业务信息
|
||||||
* @return 数据库表集合
|
* @return 数据库表集合
|
||||||
*/
|
*/
|
||||||
public List<GenTable> selectDbTableList(GenTable genTable);
|
public List<GenTable> selectDbTableList(GenTable genTable);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询业务列表
|
||||||
|
*
|
||||||
|
* @param genTable 业务信息
|
||||||
|
* @return 分页集合
|
||||||
|
*/
|
||||||
|
TableDataInfo<GenTable> selectPage(GenTable genTable);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询据库列表
|
* 查询据库列表
|
||||||
*
|
*
|
||||||
* @param tableNames 表名称组
|
* @param tableNames 表名称组
|
||||||
* @return 数据库表集合
|
* @return 数据库表集合
|
||||||
*/
|
*/
|
||||||
@ -37,14 +41,14 @@ public interface IGenTableService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询所有表信息
|
* 查询所有表信息
|
||||||
*
|
*
|
||||||
* @return 表信息集合
|
* @return 表信息集合
|
||||||
*/
|
*/
|
||||||
public List<GenTable> selectGenTableAll();
|
public List<GenTable> selectGenTableAll();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询业务信息
|
* 查询业务信息
|
||||||
*
|
*
|
||||||
* @param id 业务ID
|
* @param id 业务ID
|
||||||
* @return 业务信息
|
* @return 业务信息
|
||||||
*/
|
*/
|
||||||
@ -52,7 +56,7 @@ public interface IGenTableService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改业务
|
* 修改业务
|
||||||
*
|
*
|
||||||
* @param genTable 业务信息
|
* @param genTable 业务信息
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@ -60,7 +64,7 @@ public interface IGenTableService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除业务信息
|
* 删除业务信息
|
||||||
*
|
*
|
||||||
* @param tableIds 需要删除的表数据ID
|
* @param tableIds 需要删除的表数据ID
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@ -68,14 +72,14 @@ public interface IGenTableService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 导入表结构
|
* 导入表结构
|
||||||
*
|
*
|
||||||
* @param tableList 导入表列表
|
* @param tableList 导入表列表
|
||||||
*/
|
*/
|
||||||
public void importGenTable(List<GenTable> tableList);
|
public void importGenTable(List<GenTable> tableList);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 预览代码
|
* 预览代码
|
||||||
*
|
*
|
||||||
* @param tableId 表编号
|
* @param tableId 表编号
|
||||||
* @return 预览数据列表
|
* @return 预览数据列表
|
||||||
*/
|
*/
|
||||||
@ -83,7 +87,7 @@ public interface IGenTableService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成代码(下载方式)
|
* 生成代码(下载方式)
|
||||||
*
|
*
|
||||||
* @param tableName 表名称
|
* @param tableName 表名称
|
||||||
* @return 数据
|
* @return 数据
|
||||||
*/
|
*/
|
||||||
@ -91,7 +95,7 @@ public interface IGenTableService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成代码(自定义路径)
|
* 生成代码(自定义路径)
|
||||||
*
|
*
|
||||||
* @param tableName 表名称
|
* @param tableName 表名称
|
||||||
* @return 数据
|
* @return 数据
|
||||||
*/
|
*/
|
||||||
@ -99,14 +103,14 @@ public interface IGenTableService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 同步数据库
|
* 同步数据库
|
||||||
*
|
*
|
||||||
* @param tableName 表名称
|
* @param tableName 表名称
|
||||||
*/
|
*/
|
||||||
public void synchDb(String tableName);
|
public void synchDb(String tableName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量生成代码(下载方式)
|
* 批量生成代码(下载方式)
|
||||||
*
|
*
|
||||||
* @param tableNames 表数组
|
* @param tableNames 表数组
|
||||||
* @return 数据
|
* @return 数据
|
||||||
*/
|
*/
|
||||||
@ -114,7 +118,7 @@ public interface IGenTableService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改保存参数校验
|
* 修改保存参数校验
|
||||||
*
|
*
|
||||||
* @param genTable 业务信息
|
* @param genTable 业务信息
|
||||||
*/
|
*/
|
||||||
public void validateEdit(GenTable genTable);
|
public void validateEdit(GenTable genTable);
|
||||||
|
@ -14,6 +14,7 @@ import com.ruoyi.generator.domain.GenTableColumn;
|
|||||||
* 代码生成器 工具类
|
* 代码生成器 工具类
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
|
* @author 数据小王子
|
||||||
*/
|
*/
|
||||||
public class GenUtils
|
public class GenUtils
|
||||||
{
|
{
|
||||||
@ -80,25 +81,26 @@ public class GenUtils
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 插入字段
|
// BO对象 默认插入勾选
|
||||||
if (!arraysContains(GenConstants.COLUMNNAME_NOT_EDIT, columnName) && !column.isPk())
|
if (!arraysContains(GenConstants.COLUMNNAME_NOT_ADD, columnName) && !column.isPk()) {
|
||||||
{
|
|
||||||
column.setIsInsert(GenConstants.REQUIRE);
|
column.setIsInsert(GenConstants.REQUIRE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 编辑字段
|
// BO对象 默认编辑勾选
|
||||||
if (!arraysContains(GenConstants.COLUMNNAME_NOT_EDIT, columnName))
|
if (!arraysContains(GenConstants.COLUMNNAME_NOT_EDIT, columnName)) {
|
||||||
{
|
|
||||||
column.setIsEdit(GenConstants.REQUIRE);
|
column.setIsEdit(GenConstants.REQUIRE);
|
||||||
}
|
}
|
||||||
// 列表字段
|
// BO对象 默认是否必填勾选
|
||||||
if (!arraysContains(GenConstants.COLUMNNAME_NOT_LIST, columnName) && !column.isPk())
|
if (!arraysContains(GenConstants.COLUMNNAME_NOT_EDIT, columnName)) {
|
||||||
{
|
column.setIsRequired(GenConstants.REQUIRE);
|
||||||
|
}
|
||||||
|
|
||||||
|
// VO对象 默认返回勾选
|
||||||
|
if (!arraysContains(GenConstants.COLUMNNAME_NOT_LIST, columnName)) {
|
||||||
column.setIsList(GenConstants.REQUIRE);
|
column.setIsList(GenConstants.REQUIRE);
|
||||||
}
|
}
|
||||||
// 查询字段
|
// BO对象 默认查询勾选
|
||||||
if (!arraysContains(GenConstants.COLUMNNAME_NOT_QUERY, columnName) && !column.isPk())
|
if (!arraysContains(GenConstants.COLUMNNAME_NOT_QUERY, columnName) && !column.isPk()) {
|
||||||
{
|
|
||||||
column.setIsQuery(GenConstants.REQUIRE);
|
column.setIsQuery(GenConstants.REQUIRE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,9 +170,11 @@ public class GenUtils
|
|||||||
*/
|
*/
|
||||||
public static String getBusinessName(String tableName)
|
public static String getBusinessName(String tableName)
|
||||||
{
|
{
|
||||||
int lastIndex = tableName.lastIndexOf("_");
|
int firstIndex = tableName.indexOf("_");
|
||||||
int nameLength = tableName.length();
|
int nameLength = tableName.length();
|
||||||
return StringUtils.substring(tableName, lastIndex + 1, nameLength);
|
String businessName = StringUtils.substring(tableName, firstIndex + 1, nameLength);
|
||||||
|
businessName = StringUtils.toCamelCase(businessName);
|
||||||
|
return businessName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4,6 +4,10 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import com.mybatisflex.core.datasource.FlexDataSource;
|
||||||
|
import com.mybatisflex.core.dialect.DbTypeUtil;
|
||||||
import org.apache.velocity.VelocityContext;
|
import org.apache.velocity.VelocityContext;
|
||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
@ -17,6 +21,7 @@ import com.ruoyi.generator.domain.GenTableColumn;
|
|||||||
* 模板处理工具类
|
* 模板处理工具类
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
|
* @author 数据小王子
|
||||||
*/
|
*/
|
||||||
public class VelocityUtils
|
public class VelocityUtils
|
||||||
{
|
{
|
||||||
@ -140,6 +145,7 @@ public class VelocityUtils
|
|||||||
templates.add("vm/java/serviceImpl.java.vm");
|
templates.add("vm/java/serviceImpl.java.vm");
|
||||||
templates.add("vm/java/controller.java.vm");
|
templates.add("vm/java/controller.java.vm");
|
||||||
templates.add("vm/xml/mapper.xml.vm");
|
templates.add("vm/xml/mapper.xml.vm");
|
||||||
|
|
||||||
templates.add("vm/sql/sql.vm");
|
templates.add("vm/sql/sql.vm");
|
||||||
templates.add("vm/js/api.js.vm");
|
templates.add("vm/js/api.js.vm");
|
||||||
if (GenConstants.TPL_CRUD.equals(tplCategory))
|
if (GenConstants.TPL_CRUD.equals(tplCategory))
|
||||||
@ -334,7 +340,7 @@ public class VelocityUtils
|
|||||||
*/
|
*/
|
||||||
public static String getTreeParentCode(JSONObject paramsObj)
|
public static String getTreeParentCode(JSONObject paramsObj)
|
||||||
{
|
{
|
||||||
if (paramsObj.containsKey(GenConstants.TREE_PARENT_CODE))
|
if (CollUtil.isNotEmpty(paramsObj) && paramsObj.containsKey(GenConstants.TREE_PARENT_CODE))
|
||||||
{
|
{
|
||||||
return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_PARENT_CODE));
|
return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_PARENT_CODE));
|
||||||
}
|
}
|
||||||
@ -349,7 +355,7 @@ public class VelocityUtils
|
|||||||
*/
|
*/
|
||||||
public static String getTreeName(JSONObject paramsObj)
|
public static String getTreeName(JSONObject paramsObj)
|
||||||
{
|
{
|
||||||
if (paramsObj.containsKey(GenConstants.TREE_NAME))
|
if (CollUtil.isNotEmpty(paramsObj) && paramsObj.containsKey(GenConstants.TREE_NAME))
|
||||||
{
|
{
|
||||||
return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_NAME));
|
return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_NAME));
|
||||||
}
|
}
|
||||||
|
@ -33,83 +33,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
select column_id, table_id, column_name, column_comment, column_type, java_type, java_field, is_pk, is_increment, is_required, is_insert, is_edit, is_list, is_query, query_type, html_type, dict_type, sort, create_by, create_time, update_by, update_time from gen_table_column
|
select column_id, table_id, column_name, column_comment, column_type, java_type, java_field, is_pk, is_increment, is_required, is_insert, is_edit, is_list, is_query, query_type, html_type, dict_type, sort, create_by, create_time, update_by, update_time from gen_table_column
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectGenTableColumnListByTableId" parameterType="Long" resultMap="GenTableColumnResult">
|
|
||||||
<include refid="selectGenTableColumnVo"/>
|
|
||||||
where table_id = #{tableId}
|
|
||||||
order by sort
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="selectDbTableColumnsByName" parameterType="String" resultMap="GenTableColumnResult">
|
<select id="selectDbTableColumnsByName" parameterType="String" resultMap="GenTableColumnResult">
|
||||||
select column_name, (case when (is_nullable = 'no' <![CDATA[ && ]]> column_key != 'PRI') then '1' else '0' end) as is_required, (case when column_key = 'PRI' then '1' else '0' end) as is_pk, ordinal_position as sort, column_comment, (case when extra = 'auto_increment' then '1' else '0' end) as is_increment, column_type
|
select column_name, (case when (is_nullable = 'no' <![CDATA[ && ]]> column_key != 'PRI') then '1' else '0' end) as is_required, (case when column_key = 'PRI' then '1' else '0' end) as is_pk, ordinal_position as sort, column_comment, (case when extra = 'auto_increment' then '1' else '0' end) as is_increment, column_type
|
||||||
from information_schema.columns where table_schema = (select database()) and table_name = (#{tableName})
|
from information_schema.columns where table_schema = (select database()) and table_name = (#{tableName})
|
||||||
order by ordinal_position
|
order by ordinal_position
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<insert id="insertGenTableColumn" parameterType="GenTableColumn" useGeneratedKeys="true" keyProperty="columnId">
|
|
||||||
insert into gen_table_column (
|
|
||||||
<if test="tableId != null and tableId != ''">table_id,</if>
|
|
||||||
<if test="columnName != null and columnName != ''">column_name,</if>
|
|
||||||
<if test="columnComment != null and columnComment != ''">column_comment,</if>
|
|
||||||
<if test="columnType != null and columnType != ''">column_type,</if>
|
|
||||||
<if test="javaType != null and javaType != ''">java_type,</if>
|
|
||||||
<if test="javaField != null and javaField != ''">java_field,</if>
|
|
||||||
<if test="isPk != null and isPk != ''">is_pk,</if>
|
|
||||||
<if test="isIncrement != null and isIncrement != ''">is_increment,</if>
|
|
||||||
<if test="isRequired != null and isRequired != ''">is_required,</if>
|
|
||||||
<if test="isInsert != null and isInsert != ''">is_insert,</if>
|
|
||||||
<if test="isEdit != null and isEdit != ''">is_edit,</if>
|
|
||||||
<if test="isList != null and isList != ''">is_list,</if>
|
|
||||||
<if test="isQuery != null and isQuery != ''">is_query,</if>
|
|
||||||
<if test="queryType != null and queryType != ''">query_type,</if>
|
|
||||||
<if test="htmlType != null and htmlType != ''">html_type,</if>
|
|
||||||
<if test="dictType != null and dictType != ''">dict_type,</if>
|
|
||||||
<if test="sort != null">sort,</if>
|
|
||||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
|
||||||
create_time
|
|
||||||
)values(
|
|
||||||
<if test="tableId != null and tableId != ''">#{tableId},</if>
|
|
||||||
<if test="columnName != null and columnName != ''">#{columnName},</if>
|
|
||||||
<if test="columnComment != null and columnComment != ''">#{columnComment},</if>
|
|
||||||
<if test="columnType != null and columnType != ''">#{columnType},</if>
|
|
||||||
<if test="javaType != null and javaType != ''">#{javaType},</if>
|
|
||||||
<if test="javaField != null and javaField != ''">#{javaField},</if>
|
|
||||||
<if test="isPk != null and isPk != ''">#{isPk},</if>
|
|
||||||
<if test="isIncrement != null and isIncrement != ''">#{isIncrement},</if>
|
|
||||||
<if test="isRequired != null and isRequired != ''">#{isRequired},</if>
|
|
||||||
<if test="isInsert != null and isInsert != ''">#{isInsert},</if>
|
|
||||||
<if test="isEdit != null and isEdit != ''">#{isEdit},</if>
|
|
||||||
<if test="isList != null and isList != ''">#{isList},</if>
|
|
||||||
<if test="isQuery != null and isQuery != ''">#{isQuery},</if>
|
|
||||||
<if test="queryType != null and queryType != ''">#{queryType},</if>
|
|
||||||
<if test="htmlType != null and htmlType != ''">#{htmlType},</if>
|
|
||||||
<if test="dictType != null and dictType != ''">#{dictType},</if>
|
|
||||||
<if test="sort != null">#{sort},</if>
|
|
||||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
|
||||||
sysdate()
|
|
||||||
)
|
|
||||||
</insert>
|
|
||||||
|
|
||||||
<update id="updateGenTableColumn" parameterType="GenTableColumn">
|
|
||||||
update gen_table_column
|
|
||||||
<set>
|
|
||||||
<if test="columnComment != null">column_comment = #{columnComment},</if>
|
|
||||||
<if test="javaType != null">java_type = #{javaType},</if>
|
|
||||||
<if test="javaField != null">java_field = #{javaField},</if>
|
|
||||||
<if test="isInsert != null">is_insert = #{isInsert},</if>
|
|
||||||
<if test="isEdit != null">is_edit = #{isEdit},</if>
|
|
||||||
<if test="isList != null">is_list = #{isList},</if>
|
|
||||||
<if test="isQuery != null">is_query = #{isQuery},</if>
|
|
||||||
<if test="isRequired != null">is_required = #{isRequired},</if>
|
|
||||||
<if test="queryType != null">query_type = #{queryType},</if>
|
|
||||||
<if test="htmlType != null">html_type = #{htmlType},</if>
|
|
||||||
<if test="dictType != null">dict_type = #{dictType},</if>
|
|
||||||
<if test="sort != null">sort = #{sort},</if>
|
|
||||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
|
||||||
update_time = sysdate()
|
|
||||||
</set>
|
|
||||||
where column_id = #{columnId}
|
|
||||||
</update>
|
|
||||||
|
|
||||||
<delete id="deleteGenTableColumnByIds" parameterType="Long">
|
<delete id="deleteGenTableColumnByIds" parameterType="Long">
|
||||||
delete from gen_table_column where table_id in
|
delete from gen_table_column where table_id in
|
||||||
<foreach collection="array" item="tableId" open="(" separator="," close=")">
|
<foreach collection="array" item="tableId" open="(" separator="," close=")">
|
||||||
|
@ -27,7 +27,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<result property="remark" column="remark" />
|
<result property="remark" column="remark" />
|
||||||
<collection property="columns" javaType="java.util.List" resultMap="GenTableColumnResult" />
|
<collection property="columns" javaType="java.util.List" resultMap="GenTableColumnResult" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<resultMap type="GenTableColumn" id="GenTableColumnResult">
|
<resultMap type="GenTableColumn" id="GenTableColumnResult">
|
||||||
<id property="columnId" column="column_id" />
|
<id property="columnId" column="column_id" />
|
||||||
<result property="tableId" column="table_id" />
|
<result property="tableId" column="table_id" />
|
||||||
@ -52,33 +52,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<result property="updateBy" column="update_by" />
|
<result property="updateBy" column="update_by" />
|
||||||
<result property="updateTime" column="update_time" />
|
<result property="updateTime" column="update_time" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectGenTableVo">
|
<sql id="selectGenTableVo">
|
||||||
select table_id, table_name, table_comment, sub_table_name, sub_table_fk_name, class_name, tpl_category, package_name, module_name, business_name, function_name, function_author, gen_type, gen_path, options, create_by, create_time, update_by, update_time, remark from gen_table
|
select table_id, table_name, table_comment, sub_table_name, sub_table_fk_name, class_name, tpl_category, package_name, module_name, business_name, function_name, function_author, gen_type, gen_path, options, create_by, create_time, update_by, update_time, remark from gen_table
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectGenTableList" parameterType="GenTable" resultMap="GenTableResult">
|
|
||||||
<include refid="selectGenTableVo"/>
|
|
||||||
<where>
|
|
||||||
<if test="tableName != null and tableName != ''">
|
|
||||||
AND lower(table_name) like lower(concat('%', #{tableName}, '%'))
|
|
||||||
</if>
|
|
||||||
<if test="tableComment != null and tableComment != ''">
|
|
||||||
AND lower(table_comment) like lower(concat('%', #{tableComment}, '%'))
|
|
||||||
</if>
|
|
||||||
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
|
|
||||||
AND date_format(create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
|
|
||||||
</if>
|
|
||||||
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
|
|
||||||
AND date_format(create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
|
|
||||||
</if>
|
|
||||||
</where>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="selectDbTableList" parameterType="GenTable" resultMap="GenTableResult">
|
<select id="selectDbTableList" parameterType="GenTable" resultMap="GenTableResult">
|
||||||
select table_name, table_comment, create_time, update_time from information_schema.tables
|
select table_name, table_comment, create_time, update_time from information_schema.tables
|
||||||
where table_schema = (select database())
|
where table_schema = (select database())
|
||||||
AND table_name NOT LIKE 'qrtz_%' AND table_name NOT LIKE 'gen_%'
|
AND table_name NOT LIKE 'pj_%' AND table_name NOT LIKE 'gen_%'
|
||||||
AND table_name NOT IN (select table_name from gen_table)
|
AND table_name NOT IN (select table_name from gen_table)
|
||||||
<if test="tableName != null and tableName != ''">
|
<if test="tableName != null and tableName != ''">
|
||||||
AND lower(table_name) like lower(concat('%', #{tableName}, '%'))
|
AND lower(table_name) like lower(concat('%', #{tableName}, '%'))
|
||||||
@ -94,30 +76,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</if>
|
</if>
|
||||||
order by create_time desc
|
order by create_time desc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectDbTableListByNames" resultMap="GenTableResult">
|
<select id="selectDbTableListByNames" resultMap="GenTableResult">
|
||||||
select table_name, table_comment, create_time, update_time from information_schema.tables
|
select table_name, table_comment, create_time, update_time from information_schema.tables
|
||||||
where table_name NOT LIKE 'qrtz_%' and table_name NOT LIKE 'gen_%' and table_schema = (select database())
|
where table_name NOT LIKE 'pj_%' and table_name NOT LIKE 'gen_%' and table_schema = (select database())
|
||||||
and table_name in
|
and table_name in
|
||||||
<foreach collection="array" item="name" open="(" separator="," close=")">
|
<foreach collection="array" item="name" open="(" separator="," close=")">
|
||||||
#{name}
|
#{name}
|
||||||
</foreach>
|
</foreach>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectTableByName" parameterType="String" resultMap="GenTableResult">
|
<select id="selectTableByName" parameterType="String" resultMap="GenTableResult">
|
||||||
select table_name, table_comment, create_time, update_time from information_schema.tables
|
select table_name, table_comment, create_time, update_time from information_schema.tables
|
||||||
where table_comment <![CDATA[ <> ]]> '' and table_schema = (select database())
|
where table_comment <![CDATA[ <> ]]> '' and table_schema = (select database())
|
||||||
and table_name = #{tableName}
|
and table_name = #{tableName}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectGenTableById" parameterType="Long" resultMap="GenTableResult">
|
|
||||||
SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark,
|
|
||||||
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
|
|
||||||
FROM gen_table t
|
|
||||||
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
|
|
||||||
where t.table_id = #{tableId} order by c.sort
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="selectGenTableByName" parameterType="String" resultMap="GenTableResult">
|
<select id="selectGenTableByName" parameterType="String" resultMap="GenTableResult">
|
||||||
SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark,
|
SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark,
|
||||||
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
|
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
|
||||||
@ -125,78 +99,5 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
|
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
|
||||||
where t.table_name = #{tableName} order by c.sort
|
where t.table_name = #{tableName} order by c.sort
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectGenTableAll" parameterType="String" resultMap="GenTableResult">
|
|
||||||
SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.options, t.remark,
|
|
||||||
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
|
|
||||||
FROM gen_table t
|
|
||||||
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
|
|
||||||
order by c.sort
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<insert id="insertGenTable" parameterType="GenTable" useGeneratedKeys="true" keyProperty="tableId">
|
|
||||||
insert into gen_table (
|
|
||||||
<if test="tableName != null">table_name,</if>
|
|
||||||
<if test="tableComment != null and tableComment != ''">table_comment,</if>
|
|
||||||
<if test="className != null and className != ''">class_name,</if>
|
|
||||||
<if test="tplCategory != null and tplCategory != ''">tpl_category,</if>
|
|
||||||
<if test="packageName != null and packageName != ''">package_name,</if>
|
|
||||||
<if test="moduleName != null and moduleName != ''">module_name,</if>
|
|
||||||
<if test="businessName != null and businessName != ''">business_name,</if>
|
|
||||||
<if test="functionName != null and functionName != ''">function_name,</if>
|
|
||||||
<if test="functionAuthor != null and functionAuthor != ''">function_author,</if>
|
|
||||||
<if test="genType != null and genType != ''">gen_type,</if>
|
|
||||||
<if test="genPath != null and genPath != ''">gen_path,</if>
|
|
||||||
<if test="remark != null and remark != ''">remark,</if>
|
|
||||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
|
||||||
create_time
|
|
||||||
)values(
|
|
||||||
<if test="tableName != null">#{tableName},</if>
|
|
||||||
<if test="tableComment != null and tableComment != ''">#{tableComment},</if>
|
|
||||||
<if test="className != null and className != ''">#{className},</if>
|
|
||||||
<if test="tplCategory != null and tplCategory != ''">#{tplCategory},</if>
|
|
||||||
<if test="packageName != null and packageName != ''">#{packageName},</if>
|
|
||||||
<if test="moduleName != null and moduleName != ''">#{moduleName},</if>
|
|
||||||
<if test="businessName != null and businessName != ''">#{businessName},</if>
|
|
||||||
<if test="functionName != null and functionName != ''">#{functionName},</if>
|
|
||||||
<if test="functionAuthor != null and functionAuthor != ''">#{functionAuthor},</if>
|
|
||||||
<if test="genType != null and genType != ''">#{genType},</if>
|
|
||||||
<if test="genPath != null and genPath != ''">#{genPath},</if>
|
|
||||||
<if test="remark != null and remark != ''">#{remark},</if>
|
|
||||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
|
||||||
sysdate()
|
|
||||||
)
|
|
||||||
</insert>
|
|
||||||
|
|
||||||
<update id="updateGenTable" parameterType="GenTable">
|
|
||||||
update gen_table
|
|
||||||
<set>
|
|
||||||
<if test="tableName != null">table_name = #{tableName},</if>
|
|
||||||
<if test="tableComment != null and tableComment != ''">table_comment = #{tableComment},</if>
|
|
||||||
<if test="subTableName != null">sub_table_name = #{subTableName},</if>
|
|
||||||
<if test="subTableFkName != null">sub_table_fk_name = #{subTableFkName},</if>
|
|
||||||
<if test="className != null and className != ''">class_name = #{className},</if>
|
|
||||||
<if test="functionAuthor != null and functionAuthor != ''">function_author = #{functionAuthor},</if>
|
|
||||||
<if test="genType != null and genType != ''">gen_type = #{genType},</if>
|
|
||||||
<if test="genPath != null and genPath != ''">gen_path = #{genPath},</if>
|
|
||||||
<if test="tplCategory != null and tplCategory != ''">tpl_category = #{tplCategory},</if>
|
|
||||||
<if test="packageName != null and packageName != ''">package_name = #{packageName},</if>
|
|
||||||
<if test="moduleName != null and moduleName != ''">module_name = #{moduleName},</if>
|
|
||||||
<if test="businessName != null and businessName != ''">business_name = #{businessName},</if>
|
|
||||||
<if test="functionName != null and functionName != ''">function_name = #{functionName},</if>
|
|
||||||
<if test="options != null and options != ''">options = #{options},</if>
|
|
||||||
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
|
||||||
<if test="remark != null">remark = #{remark},</if>
|
|
||||||
update_time = sysdate()
|
|
||||||
</set>
|
|
||||||
where table_id = #{tableId}
|
|
||||||
</update>
|
|
||||||
|
|
||||||
<delete id="deleteGenTableByIds" parameterType="Long">
|
|
||||||
delete from gen_table where table_id in
|
|
||||||
<foreach collection="array" item="tableId" open="(" separator="," close=")">
|
|
||||||
#{tableId}
|
|
||||||
</foreach>
|
|
||||||
</delete>
|
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
@ -82,11 +82,6 @@ public class SysRole extends BaseEntity {
|
|||||||
@Column(ignore = true)
|
@Column(ignore = true)
|
||||||
private Long[] menuIds;
|
private Long[] menuIds;
|
||||||
|
|
||||||
@RelationManyToMany(
|
|
||||||
selfField = "roleId", targetField = "menuId",
|
|
||||||
joinTable = "sys_role_menu",
|
|
||||||
joinSelfColumn = "role_id", joinTargetColumn = "menu_id"
|
|
||||||
)
|
|
||||||
private List<SysMenu> menuList;
|
private List<SysMenu> menuList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -95,18 +90,8 @@ public class SysRole extends BaseEntity {
|
|||||||
@Column(ignore = true)
|
@Column(ignore = true)
|
||||||
private Long[] deptIds;
|
private Long[] deptIds;
|
||||||
|
|
||||||
@RelationManyToMany(
|
|
||||||
selfField = "roleId", targetField = "deptId",
|
|
||||||
joinTable = "sys_role_dept",
|
|
||||||
joinSelfColumn = "role_id", joinTargetColumn = "dept_id"
|
|
||||||
)
|
|
||||||
private List<SysDept> deptList;
|
private List<SysDept> deptList;
|
||||||
|
|
||||||
@RelationManyToMany(
|
|
||||||
selfField = "roleId", targetField = "userId",
|
|
||||||
joinTable = "sys_user_role",
|
|
||||||
joinSelfColumn = "role_id", joinTargetColumn = "user_id"
|
|
||||||
)
|
|
||||||
private List<SysUser> userList;
|
private List<SysUser> userList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user