1.在菜单管理中,新增需要创建的菜单,如图
并添加查询、新增、修改、删除等按钮和对应的权限和路径
例如如果没有添加查询按钮,那么在修改的时候,会存在报错:没有权限。上图对应后台代码
2.domain中创建设计的表结构及操作,如
package com.ruoyi.project.system.domain;
import com.ruoyi.framework.web.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.ArrayList;
import java.util.List;
/**
* 场景表 sys_scene
*
* @author cxm
*/
public class SysScene extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 场景ID */
private Long sceneId;
/** 父场景ID */
private Long parentId;
/** 父场景ID */
private Long userId;
/** 祖级列表 */
private String ancestors;
/** 场景名称 */
private String sceneName;
/** 显示顺序 */
private Integer orderNum;
/** 场景状态:0正常,1停用 */
private String status;
/** 删除标志(0代表存在 2代表删除) */
private String delFlag;
/** 父场景名称 */
private String parentName;
/** 子场景 */
private List<SysScene> children = new ArrayList<SysScene>();
public Long getSceneId()
{
return sceneId;
}
public void setSceneId(Long sceneId)
{
this.sceneId = sceneId;
}
public Long getParentId()
{
return parentId;
}
public Long getUserId()
{
return userId;
}
public void setParentId(Long parentId)
{
this.parentId = parentId;
}
public void setUserId(Long userId)
{
this.userId = userId;
}
public String getAncestors()
{
return ancestors;
}
public void setAncestors(String ancestors)
{
this.ancestors = ancestors;
}
@NotBlank(message = "场景名称不能为空")
@Size(min = 0, max = 30, message = "场景名称长度不能超过30个字符")
public String getSceneName()
{
return sceneName;
}
public void setSceneName(String sceneName)
{
this.sceneName = sceneName;
}
@NotNull(message = "显示顺序不能为空")
public Integer getOrderNum()
{
return orderNum;
}
public void setOrderNum(Integer orderNum)
{
this.orderNum = orderNum;
}
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<SysScene> getChildren()
{
return children;
}
public void setChildren(List<SysScene> children)
{
this.children = children;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("sceneId", getSceneId())
.append("parentId", getParentId())
.append("userId", getUserId())
.append("ancestors", getAncestors())
.append("sceneName", getSceneName())
.append("orderNum", getOrderNum())
.append("status", getStatus())
.append("delFlag", getDelFlag())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.toString();
}
}
3.mapper
mapper定义具体操作数据库的方法,提供给mybatis使用,例如:
selectSceneList定义后,在xml里面调用
4.service
服务分为2个,一个是服务实现层:
一个是服务定义层: