## 先来看一下效果
### 新建类
### 例如创建的类文件名称为 LocationList
文件内填充以下内容
@Erupt(name = "库位管理",
linkTree = @LinkTree(field = "category") //左树右表配置
)
@Table(name = "base_inventory_list")
@Entity
public class LocationList extends BaseModel {
@EruptField(
views = @View(title = "库位名称"),
edit = @Edit(title = "库位名称", notNull = true, search = @Search(vague = true)) //模糊查询配置
)
private String name;
@ManyToOne
@EruptField(
views = @View(title = "所属分类", column = "name"),
edit = @Edit(title = "所属分类", type = EditType.REFERENCE_TREE, search = @Search, notNull = true, referenceTreeType = @ReferenceTreeType(pid = "parent.id"))
)
private LocationTree category; //GoodsCategory类定义请往下看
@EruptField(
views = @View(title = "库位地址"),
edit = @Edit(title = "库位地址", notNull = true, inputType = @InputType(fullSpan = true), search = @Search(vague = true)) //模糊查询配置
)
private String address;
@Lob //定义数据库类为大文本类型,支持存入更多的数据
@EruptField(
views = @View(title = "库位描述", type = ViewType.HTML),
edit = @Edit(title = "库位描述", type = EditType.HTML_EDITOR) //定义为富文本编辑器
)
private String description;
}
### 引入依赖 报红位置 alt+enter ,理论上需要引入的包是以下,别引错了
import xyz.erupt.annotation.Erupt;
import xyz.erupt.annotation.EruptField;
import xyz.erupt.annotation.sub_erupt.LinkTree;
import xyz.erupt.annotation.sub_field.Edit;
import xyz.erupt.annotation.sub_field.EditType;
import xyz.erupt.annotation.sub_field.View;
import xyz.erupt.annotation.sub_field.ViewType;
import xyz.erupt.annotation.sub_field.sub_edit.*;
import xyz.erupt.jpa.model.BaseModel;
import javax.persistence.Entity;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
### 再创建另外一个类文件 LocationTree ,填入以下内容
@Entity
@Table(name = "base_location_category")
@Erupt(
name = "库位分类",
orderBy = "LocationTree.sort",
tree = @Tree(id = "id", label = "name", pid = "parent.id")
)
public class LocationTree extends BaseModel {
@EruptField(
views = @View(title = "名称"),
edit = @Edit(title = "名称", notNull = true)
)
private String name;
@EruptField(
views = @View(title = "显示顺序"),
edit = @Edit(title = "显示顺序")
)
private Integer sort;
@ManyToOne
@EruptField(
edit = @Edit(
title = "上级树节点",
type = EditType.REFERENCE_TREE,
referenceTreeType = @ReferenceTreeType(pid = "parent.id")
)
)
private LocationTree parent;
}
### 启动项目,然后添加菜单
进入 系统管理--菜单维护
### 刷新页面,OK