完成树表重构“代码生成”模块,支持mybatis-flex
This commit is contained in:
parent
faebcb7a6a
commit
630881c1d7
@ -2,7 +2,7 @@ package com.ruoyi.common.core.constant;
|
||||
|
||||
/**
|
||||
* 代码生成通用常量
|
||||
*
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class GenConstants
|
||||
@ -45,7 +45,8 @@ public class GenConstants
|
||||
"bit", "bigint", "float", "double", "decimal" };
|
||||
|
||||
/** 页面不需要编辑字段 */
|
||||
public static final String[] COLUMNNAME_NOT_EDIT = { "id", "create_by", "create_time", "del_flag" };
|
||||
public static final String[] COLUMNNAME_NOT_EDIT = { "id", "create_by", "create_time", "update_by",
|
||||
"update_time","del_flag" };
|
||||
|
||||
/** 页面不需要显示的列表字段 */
|
||||
public static final String[] COLUMNNAME_NOT_LIST = { "id", "create_by", "create_time", "del_flag", "update_by",
|
||||
@ -56,7 +57,7 @@ public class GenConstants
|
||||
"update_time", "remark" };
|
||||
|
||||
/** Entity基类字段 */
|
||||
public static final String[] BASE_ENTITY = { "createBy", "createTime", "updateBy", "updateTime", "remark" };
|
||||
public static final String[] BASE_ENTITY = { "createBy", "createTime", "updateBy", "updateTime"};
|
||||
|
||||
/** Tree基类字段 */
|
||||
public static final String[] TREE_ENTITY = { "parentName", "parentId", "orderNum", "ancestors", "children" };
|
||||
|
@ -2,6 +2,7 @@ package com.ruoyi.common.orm.core.domain;
|
||||
|
||||
import com.mybatisflex.annotation.Column;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -12,6 +13,7 @@ import java.util.List;
|
||||
*/
|
||||
public class TreeEntity extends BaseEntity
|
||||
{
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 父菜单名称 */
|
||||
@ -22,7 +24,6 @@ public class TreeEntity extends BaseEntity
|
||||
private Long parentId;
|
||||
|
||||
/** 显示顺序 */
|
||||
@Column(ignore = true)
|
||||
private Integer orderNum;
|
||||
|
||||
/** 祖级列表 */
|
||||
@ -31,7 +32,7 @@ public class TreeEntity extends BaseEntity
|
||||
|
||||
/** 子部门 */
|
||||
@Column(ignore = true)
|
||||
private List<?> children = new ArrayList<>();
|
||||
private List<Object> children = new ArrayList<>();
|
||||
|
||||
public String getParentName()
|
||||
{
|
||||
@ -73,12 +74,12 @@ public class TreeEntity extends BaseEntity
|
||||
this.ancestors = ancestors;
|
||||
}
|
||||
|
||||
public List<?> getChildren()
|
||||
public List<Object> getChildren()
|
||||
{
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<?> children)
|
||||
public void setChildren(List<Object> children)
|
||||
{
|
||||
this.children = children;
|
||||
}
|
||||
|
@ -335,7 +335,7 @@ public class GenTableColumn extends BaseEntity
|
||||
{
|
||||
return StringUtils.equalsAnyIgnoreCase(javaField,
|
||||
// BaseEntity
|
||||
"createBy", "createTime", "updateBy", "updateTime", "remark",
|
||||
"createBy", "createTime", "updateBy", "updateTime",
|
||||
// TreeEntity
|
||||
"parentName", "parentId", "orderNum", "ancestors");
|
||||
}
|
||||
@ -348,7 +348,7 @@ public class GenTableColumn extends BaseEntity
|
||||
public static boolean isUsableColumn(String javaField)
|
||||
{
|
||||
// isSuperColumn()中的名单用于避免生成多余Domain属性,若某些属性在生成页面时需要用到不能忽略,则放在此处白名单
|
||||
return StringUtils.equalsAnyIgnoreCase(javaField, "parentId", "orderNum", "remark");
|
||||
return StringUtils.equalsAnyIgnoreCase(javaField, "parentId", "orderNum");
|
||||
}
|
||||
|
||||
public String readConverterExp()
|
||||
|
@ -87,7 +87,7 @@ public class GenUtils
|
||||
}
|
||||
|
||||
// 编辑字段
|
||||
if (!arraysContains(GenConstants.COLUMNNAME_NOT_EDIT, columnName) && !column.isPk())
|
||||
if (!arraysContains(GenConstants.COLUMNNAME_NOT_EDIT, columnName))
|
||||
{
|
||||
column.setIsEdit(GenConstants.REQUIRE);
|
||||
}
|
||||
@ -114,7 +114,7 @@ public class GenUtils
|
||||
}
|
||||
// 类型&性别字段设置下拉框
|
||||
else if (StringUtils.endsWithIgnoreCase(columnName, "type")
|
||||
|| StringUtils.endsWithIgnoreCase(columnName, "sex"))
|
||||
|| StringUtils.endsWithIgnoreCase(columnName, "gender"))
|
||||
{
|
||||
column.setHtmlType(GenConstants.HTML_SELECT);
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package ${packageName}.domain.bo;
|
||||
|
||||
import ${packageName}.domain.${ClassName};
|
||||
import com.ruoyi.common.orm.core.domain.BaseEntity;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@ -9,6 +8,11 @@ import jakarta.validation.constraints.*;
|
||||
#foreach ($import in $importList)
|
||||
import ${import};
|
||||
#end
|
||||
#if($table.crud || $table.sub)
|
||||
import com.ruoyi.common.orm.core.domain.BaseEntity;
|
||||
#elseif($table.tree)
|
||||
import com.ruoyi.common.orm.core.domain.TreeEntity;
|
||||
#end
|
||||
|
||||
/**
|
||||
* ${functionName}业务对象 ${tableName}
|
||||
@ -16,10 +20,16 @@ import ${import};
|
||||
* @author ${author}
|
||||
* @date ${datetime}
|
||||
*/
|
||||
#if($table.crud || $table.sub)
|
||||
#set($Entity="BaseEntity")
|
||||
#elseif($table.tree)
|
||||
#set($Entity="TreeEntity")
|
||||
#end
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@AutoMapper(target = ${ClassName}.class, reverseConvertGenerate = false)
|
||||
public class ${ClassName}Bo extends BaseEntity {
|
||||
public class ${ClassName}Bo extends ${Entity}
|
||||
{
|
||||
|
||||
#foreach ($column in $columns)
|
||||
#if(!$table.isSuperColumn($column.javaField) && ($column.query || $column.insert || $column.edit))
|
||||
|
@ -10,6 +10,7 @@ import lombok.EqualsAndHashCode;
|
||||
#if($table.crud || $table.sub)
|
||||
import com.ruoyi.common.orm.core.domain.BaseEntity;
|
||||
#elseif($table.tree)
|
||||
import com.ruoyi.common.orm.core.domain.TreeEntity;
|
||||
#end
|
||||
|
||||
/**
|
||||
|
@ -10,6 +10,7 @@ import com.ruoyi.common.excel.annotation.ExcelDictFormat;
|
||||
import com.ruoyi.common.excel.convert.ExcelDictConvert;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
@ -17,19 +18,25 @@ import java.util.Date;
|
||||
#if($table.crud || $table.sub)
|
||||
import com.ruoyi.common.orm.core.domain.BaseEntity;
|
||||
#elseif($table.tree)
|
||||
import com.ruoyi.common.orm.core.domain.TreeEntity;
|
||||
#end
|
||||
|
||||
|
||||
/**
|
||||
* ${functionName}视图对象 ${tableName}
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${datetime}
|
||||
*/
|
||||
#if($table.crud || $table.sub)
|
||||
#set($Entity="BaseEntity")
|
||||
#elseif($table.tree)
|
||||
#set($Entity="TreeEntity")
|
||||
#end
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@AutoMapper(target = ${ClassName}.class)
|
||||
public class ${ClassName}Vo extends BaseEntity implements Serializable
|
||||
public class ${ClassName}Vo extends ${Entity} implements Serializable
|
||||
{
|
||||
|
||||
@Serial
|
||||
|
@ -84,6 +84,15 @@
|
||||
@click="toggleExpandAll"
|
||||
>展开/折叠</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="warning"
|
||||
plain
|
||||
icon="Download"
|
||||
@click="handleExport"
|
||||
v-hasPermi="['${moduleName}:${businessName}:export']"
|
||||
>导出</el-button>
|
||||
</el-col>
|
||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
@ -472,5 +481,12 @@ function handleDelete(row) {
|
||||
}).catch(() => {});
|
||||
}
|
||||
|
||||
/** 导出按钮操作 */
|
||||
function handleExport() {
|
||||
proxy.download('${moduleName}/${businessName}/export', {
|
||||
...queryParams.value
|
||||
}, `${businessName}_#[[${new Date().getTime()}]]#.xlsx`)
|
||||
}
|
||||
|
||||
getList();
|
||||
</script>
|
||||
|
@ -1,20 +1,13 @@
|
||||
package com.ruoyi.system.domain;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import jakarta.validation.constraints.Email;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.ruoyi.common.orm.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
@ -64,151 +57,5 @@ public class SysDept extends BaseEntity
|
||||
private String parentName;
|
||||
|
||||
/** 子部门 */
|
||||
private List<SysDept> children = new ArrayList<SysDept>();
|
||||
|
||||
// public Long getDeptId()
|
||||
// {
|
||||
// return deptId;
|
||||
// }
|
||||
//
|
||||
// public void setDeptId(Long deptId)
|
||||
// {
|
||||
// this.deptId = deptId;
|
||||
// }
|
||||
//
|
||||
// public Long getParentId()
|
||||
// {
|
||||
// return parentId;
|
||||
// }
|
||||
//
|
||||
// public void setParentId(Long parentId)
|
||||
// {
|
||||
// this.parentId = parentId;
|
||||
// }
|
||||
//
|
||||
// public String getAncestors()
|
||||
// {
|
||||
// return ancestors;
|
||||
// }
|
||||
//
|
||||
// public void setAncestors(String ancestors)
|
||||
// {
|
||||
// this.ancestors = ancestors;
|
||||
// }
|
||||
//
|
||||
// @NotBlank(message = "部门名称不能为空")
|
||||
// @Size(min = 0, max = 30, message = "部门名称长度不能超过30个字符")
|
||||
// public String getDeptName()
|
||||
// {
|
||||
// return deptName;
|
||||
// }
|
||||
//
|
||||
// public void setDeptName(String deptName)
|
||||
// {
|
||||
// this.deptName = deptName;
|
||||
// }
|
||||
//
|
||||
// @NotBlank(message = "显示顺序不能为空")
|
||||
// public String getOrderNum()
|
||||
// {
|
||||
// return orderNum;
|
||||
// }
|
||||
//
|
||||
// public void setOrderNum(String orderNum)
|
||||
// {
|
||||
// this.orderNum = orderNum;
|
||||
// }
|
||||
//
|
||||
// public String getLeader()
|
||||
// {
|
||||
// return leader;
|
||||
// }
|
||||
//
|
||||
// public void setLeader(String leader)
|
||||
// {
|
||||
// this.leader = leader;
|
||||
// }
|
||||
//
|
||||
// @Size(min = 0, max = 11, message = "联系电话长度不能超过11个字符")
|
||||
// public String getPhone()
|
||||
// {
|
||||
// return phone;
|
||||
// }
|
||||
//
|
||||
// public void setPhone(String phone)
|
||||
// {
|
||||
// this.phone = phone;
|
||||
// }
|
||||
//
|
||||
// @Email(message = "邮箱格式不正确")
|
||||
// @Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符")
|
||||
// public String getEmail()
|
||||
// {
|
||||
// return email;
|
||||
// }
|
||||
//
|
||||
// public void setEmail(String email)
|
||||
// {
|
||||
// this.email = email;
|
||||
// }
|
||||
//
|
||||
// public String getStatus()
|
||||
// {
|
||||
// return status;
|
||||
// }
|
||||
//
|
||||
// public void setStatus(String status)
|
||||
// {
|
||||
// this.status = status;
|
||||
// }
|
||||
//
|
||||
// public String getDelFlag()
|
||||
// {
|
||||
// return delFlag;
|
||||
// }
|
||||
//
|
||||
// public void setDelFlag(String delFlag)
|
||||
// {
|
||||
// this.delFlag = delFlag;
|
||||
// }
|
||||
//
|
||||
// public String getParentName()
|
||||
// {
|
||||
// return parentName;
|
||||
// }
|
||||
//
|
||||
// public void setParentName(String parentName)
|
||||
// {
|
||||
// this.parentName = parentName;
|
||||
// }
|
||||
//
|
||||
// public List<SysDept> getChildren()
|
||||
// {
|
||||
// return children;
|
||||
// }
|
||||
//
|
||||
// public void setChildren(List<SysDept> children)
|
||||
// {
|
||||
// this.children = children;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String toString() {
|
||||
// return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
// .append("deptId", getDeptId())
|
||||
// .append("parentId", getParentId())
|
||||
// .append("ancestors", getAncestors())
|
||||
// .append("deptName", getDeptName())
|
||||
// .append("orderNum", getOrderNum())
|
||||
// .append("leader", getLeader())
|
||||
// .append("phone", getPhone())
|
||||
// .append("email", getEmail())
|
||||
// .append("status", getStatus())
|
||||
// .append("delFlag", getDelFlag())
|
||||
// .append("createBy", getCreateBy())
|
||||
// .append("createTime", getCreateTime())
|
||||
// .append("updateBy", getUpdateBy())
|
||||
// .append("updateTime", getUpdateTime())
|
||||
// .toString();
|
||||
// }
|
||||
private List<SysDept> children = new ArrayList<>();
|
||||
}
|
||||
|
@ -1,77 +0,0 @@
|
||||
package com.ruoyi.system.domain;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
|
||||
/**
|
||||
* Treeselect树结构实体类
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class TreeSelect implements Serializable
|
||||
{
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 节点ID */
|
||||
private Long id;
|
||||
|
||||
/** 节点名称 */
|
||||
private String label;
|
||||
|
||||
/** 子节点 */
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
private List<TreeSelect> children;
|
||||
|
||||
public TreeSelect()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public TreeSelect(SysDept dept)
|
||||
{
|
||||
this.id = dept.getDeptId();
|
||||
this.label = dept.getDeptName();
|
||||
this.children = dept.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public TreeSelect(SysMenu menu)
|
||||
{
|
||||
this.id = menu.getMenuId();
|
||||
this.label = menu.getMenuName();
|
||||
this.children = menu.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getLabel()
|
||||
{
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label)
|
||||
{
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public List<TreeSelect> getChildren()
|
||||
{
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<TreeSelect> children)
|
||||
{
|
||||
this.children = children;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user