parent
3bf173d744
commit
74daab066d
|
@ -27,7 +27,7 @@ import com.ruoyi.system.service.ISysDictTypeService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据字典信息
|
* 数据字典信息
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
|
@ -103,7 +103,7 @@ public class SysDictDataController extends BaseController
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult edit(@Validated @RequestBody SysDictData dict)
|
public AjaxResult edit(@Validated @RequestBody SysDictData dict)
|
||||||
{
|
{
|
||||||
dict.setUpdateBy(SecurityUtils.getUsername());
|
dict.setUpdateBy(SecurityUtils.getUsername());
|
||||||
return toAjax(dictDataService.updateDictData(dict));
|
return toAjax(dictDataService.updateDictData(dict));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,140 +0,0 @@
|
||||||
package com.ruoyi.web.controller.system;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
import com.ruoyi.common.annotation.Log;
|
|
||||||
import com.ruoyi.common.constant.Constants;
|
|
||||||
import com.ruoyi.common.constant.UserConstants;
|
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
|
||||||
import com.ruoyi.common.core.domain.entity.SysMenu;
|
|
||||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
|
||||||
import com.ruoyi.common.utils.SecurityUtils;
|
|
||||||
import com.ruoyi.common.utils.ServletUtils;
|
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
|
||||||
import com.ruoyi.framework.web.service.TokenService;
|
|
||||||
import com.ruoyi.system.service.ISysMenuService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 菜单信息
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/system/menu")
|
|
||||||
public class SysMenuController extends BaseController {
|
|
||||||
@Autowired
|
|
||||||
private ISysMenuService menuService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private TokenService tokenService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取菜单列表
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ss.hasPermi('system:menu:list')")
|
|
||||||
@GetMapping("/list")
|
|
||||||
public AjaxResult list(SysMenu menu) {
|
|
||||||
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
||||||
Long userId = loginUser.getUser().getUserId();
|
|
||||||
List<SysMenu> menus = menuService.selectMenuList(menu, userId);
|
|
||||||
return AjaxResult.success(menus);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据菜单编号获取详细信息
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ss.hasPermi('system:menu:query')")
|
|
||||||
@GetMapping(value = "/{menuId}")
|
|
||||||
public AjaxResult getInfo(@PathVariable Long menuId) {
|
|
||||||
return AjaxResult.success(menuService.selectMenuById(menuId));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取菜单下拉树列表
|
|
||||||
*/
|
|
||||||
@GetMapping("/treeselect")
|
|
||||||
public AjaxResult treeselect(SysMenu menu) {
|
|
||||||
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
||||||
Long userId = loginUser.getUser().getUserId();
|
|
||||||
List<SysMenu> menus = menuService.selectMenuList(menu, userId);
|
|
||||||
return AjaxResult.success(menuService.buildMenuTreeSelect(menus));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 加载对应角色菜单列表树
|
|
||||||
*/
|
|
||||||
@GetMapping(value = "/roleMenuTreeselect/{roleId}")
|
|
||||||
public AjaxResult roleMenuTreeselect(@PathVariable("roleId") Long roleId) {
|
|
||||||
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
||||||
List<SysMenu> menus = menuService.selectMenuList(loginUser.getUser().getUserId());
|
|
||||||
AjaxResult ajax = AjaxResult.success();
|
|
||||||
ajax.put("checkedKeys", menuService.selectMenuListByRoleId(roleId));
|
|
||||||
ajax.put("menus", menuService.buildMenuTreeSelect(menus));
|
|
||||||
return ajax;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增菜单
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ss.hasPermi('system:menu:add')")
|
|
||||||
@Log(title = "菜单管理", businessType = BusinessType.INSERT)
|
|
||||||
@PostMapping
|
|
||||||
public AjaxResult add(@Validated @RequestBody SysMenu menu) {
|
|
||||||
if (UserConstants.NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu))) {
|
|
||||||
return AjaxResult.error("新增菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
|
|
||||||
} else if (UserConstants.YES_FRAME.equals(menu.getIsFrame())
|
|
||||||
&& !StringUtils.startsWithAny(menu.getPath(), Constants.HTTP, Constants.HTTPS)) {
|
|
||||||
return AjaxResult.error("新增菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头");
|
|
||||||
}
|
|
||||||
menu.setCreateBy(SecurityUtils.getUsername());
|
|
||||||
return toAjax(menuService.insertMenu(menu));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改菜单
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ss.hasPermi('system:menu:edit')")
|
|
||||||
@Log(title = "菜单管理", businessType = BusinessType.UPDATE)
|
|
||||||
@PutMapping
|
|
||||||
public AjaxResult edit(@Validated @RequestBody SysMenu menu) {
|
|
||||||
if (UserConstants.NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu))) {
|
|
||||||
return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
|
|
||||||
} else if (UserConstants.YES_FRAME.equals(menu.getIsFrame())
|
|
||||||
&& !StringUtils.startsWithAny(menu.getPath(), Constants.HTTP, Constants.HTTPS)) {
|
|
||||||
return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头");
|
|
||||||
} else if (menu.getMenuId().equals(menu.getParentId())) {
|
|
||||||
return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,上级菜单不能选择自己");
|
|
||||||
}
|
|
||||||
menu.setUpdateBy(SecurityUtils.getUsername());
|
|
||||||
return toAjax(menuService.updateMenu(menu));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除菜单
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ss.hasPermi('system:menu:remove')")
|
|
||||||
@Log(title = "菜单管理", businessType = BusinessType.DELETE)
|
|
||||||
@DeleteMapping("/{menuId}")
|
|
||||||
public AjaxResult remove(@PathVariable("menuId") Long menuId) {
|
|
||||||
if (menuService.hasChildByMenuId(menuId)) {
|
|
||||||
return AjaxResult.error("存在子菜单,不允许删除");
|
|
||||||
}
|
|
||||||
if (menuService.checkMenuExistRole(menuId)) {
|
|
||||||
return AjaxResult.error("菜单已分配,不允许删除");
|
|
||||||
}
|
|
||||||
return toAjax(menuService.deleteMenuById(menuId));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,82 +0,0 @@
|
||||||
package com.ruoyi.common.core.domain.entity;
|
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
|
||||||
import javax.validation.constraints.Size;
|
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
|
||||||
import com.ruoyi.common.annotation.Excel;
|
|
||||||
import com.ruoyi.common.annotation.Excel.ColumnType;
|
|
||||||
import com.ruoyi.common.constant.UserConstants;
|
|
||||||
import com.ruoyi.common.core.domain.BaseEntity;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 字典数据表 sys_dict_data
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
public class SysDictData extends BaseEntity
|
|
||||||
{
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/** 字典编码 */
|
|
||||||
@Excel(name = "字典编码", cellType = ColumnType.NUMERIC)
|
|
||||||
private Long dictCode;
|
|
||||||
|
|
||||||
/** 字典排序 */
|
|
||||||
@Excel(name = "字典排序", cellType = ColumnType.NUMERIC)
|
|
||||||
private Long dictSort;
|
|
||||||
|
|
||||||
/** 字典标签 */
|
|
||||||
@Excel(name = "字典标签")
|
|
||||||
private String dictLabel;
|
|
||||||
|
|
||||||
/** 字典键值 */
|
|
||||||
@Excel(name = "字典键值")
|
|
||||||
private String dictValue;
|
|
||||||
|
|
||||||
/** 字典类型 */
|
|
||||||
@Excel(name = "字典类型")
|
|
||||||
private String dictType;
|
|
||||||
|
|
||||||
/** 样式属性(其他样式扩展) */
|
|
||||||
private String cssClass;
|
|
||||||
|
|
||||||
/** 表格字典样式 */
|
|
||||||
private String listClass;
|
|
||||||
|
|
||||||
/** 是否默认(Y是 N否) */
|
|
||||||
@Excel(name = "是否默认", readConverterExp = "Y=是,N=否")
|
|
||||||
private String isDefault;
|
|
||||||
|
|
||||||
/** 状态(0正常 1停用) */
|
|
||||||
@Excel(name = "状态", readConverterExp = "0=正常,1=停用")
|
|
||||||
private String status;
|
|
||||||
|
|
||||||
@NotBlank(message = "字典标签不能为空")
|
|
||||||
@Size(min = 0, max = 100, message = "字典标签长度不能超过100个字符")
|
|
||||||
public String getDictLabel()
|
|
||||||
{
|
|
||||||
return dictLabel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotBlank(message = "字典键值不能为空")
|
|
||||||
@Size(min = 0, max = 100, message = "字典键值长度不能超过100个字符")
|
|
||||||
public String getDictValue()
|
|
||||||
{
|
|
||||||
return dictValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotBlank(message = "字典类型不能为空")
|
|
||||||
@Size(min = 0, max = 100, message = "字典类型长度不能超过100个字符")
|
|
||||||
public String getDictType()
|
|
||||||
{
|
|
||||||
return dictType;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Size(min = 0, max = 100, message = "样式属性长度不能超过100个字符")
|
|
||||||
public String getCssClass()
|
|
||||||
{
|
|
||||||
return cssClass;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,50 +0,0 @@
|
||||||
package com.ruoyi.common.core.domain.entity;
|
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
|
||||||
import javax.validation.constraints.Size;
|
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
|
||||||
import com.ruoyi.common.annotation.Excel;
|
|
||||||
import com.ruoyi.common.annotation.Excel.ColumnType;
|
|
||||||
import com.ruoyi.common.core.domain.BaseEntity;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 字典类型表 sys_dict_type
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
public class SysDictType extends BaseEntity
|
|
||||||
{
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/** 字典主键 */
|
|
||||||
@Excel(name = "字典主键", cellType = ColumnType.NUMERIC)
|
|
||||||
private Long dictId;
|
|
||||||
|
|
||||||
/** 字典名称 */
|
|
||||||
@Excel(name = "字典名称")
|
|
||||||
private String dictName;
|
|
||||||
|
|
||||||
/** 字典类型 */
|
|
||||||
@Excel(name = "字典类型")
|
|
||||||
private String dictType;
|
|
||||||
|
|
||||||
/** 状态(0正常 1停用) */
|
|
||||||
@Excel(name = "状态", readConverterExp = "0=正常,1=停用")
|
|
||||||
private String status;
|
|
||||||
|
|
||||||
@NotBlank(message = "字典名称不能为空")
|
|
||||||
@Size(min = 0, max = 100, message = "字典类型名称长度不能超过100个字符")
|
|
||||||
public String getDictName()
|
|
||||||
{
|
|
||||||
return dictName;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotBlank(message = "字典类型不能为空")
|
|
||||||
@Size(min = 0, max = 100, message = "字典类型类型长度不能超过100个字符")
|
|
||||||
public String getDictType()
|
|
||||||
{
|
|
||||||
return dictType;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -83,11 +83,6 @@
|
||||||
where m.status = '0' and r.status = '0' and ur.user_id = #{userId}
|
where m.status = '0' and r.status = '0' and ur.user_id = #{userId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectMenuById" parameterType="Long" resultMap="SysMenuResult">
|
|
||||||
<include refid="selectMenuVo"/>
|
|
||||||
where menu_id = #{menuId}
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="hasChildByMenuId" resultType="Integer">
|
<select id="hasChildByMenuId" resultType="Integer">
|
||||||
select count(1) from sys_menu where parent_id = #{menuId}
|
select count(1) from sys_menu where parent_id = #{menuId}
|
||||||
</select>
|
</select>
|
||||||
|
@ -97,8 +92,4 @@
|
||||||
where menu_name=#{menuName} and parent_id = #{parentId} limit 1
|
where menu_name=#{menuName} and parent_id = #{parentId} limit 1
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<delete id="deleteMenuById" parameterType="Long">
|
|
||||||
delete from sys_menu where menu_id = #{menuId}
|
|
||||||
</delete>
|
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -24,10 +24,8 @@ const permission = {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
// 向后端请求路由数据
|
// 向后端请求路由数据
|
||||||
getRouters().then(res => {
|
getRouters().then(res => {
|
||||||
// const sdata = JSON.parse(JSON.stringify(res.data))
|
const sdata = JSON.parse(JSON.stringify(res.data))
|
||||||
// const rdata = JSON.parse(JSON.stringify(res.data))
|
const rdata = JSON.parse(JSON.stringify(res.data))
|
||||||
const sdata = JSON.parse(JSON.stringify(res))
|
|
||||||
const rdata = JSON.parse(JSON.stringify(res))
|
|
||||||
const sidebarRoutes = filterAsyncRouter(sdata)
|
const sidebarRoutes = filterAsyncRouter(sdata)
|
||||||
const rewriteRoutes = filterAsyncRouter(rdata, true)
|
const rewriteRoutes = filterAsyncRouter(rdata, true)
|
||||||
rewriteRoutes.push({ path: '*', redirect: '/404', hidden: true })
|
rewriteRoutes.push({ path: '*', redirect: '/404', hidden: true })
|
||||||
|
|
|
@ -50,8 +50,10 @@ const user = {
|
||||||
GetInfo({ commit, state }) {
|
GetInfo({ commit, state }) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
getInfo(state.token).then(res => {
|
getInfo(state.token).then(res => {
|
||||||
|
res = res.data; // 读取 data 数据
|
||||||
const user = res.user
|
const user = res.user
|
||||||
const avatar = user.avatar === "" ? require("@/assets/images/profile.jpg") : process.env.VUE_APP_BASE_API + user.avatar;
|
const avatar = user.avatar === "" ? require("@/assets/images/profile.jpg") : process.env.VUE_APP_BASE_API + user.avatar;
|
||||||
|
debugger
|
||||||
if (res.roles && res.roles.length > 0) { // 验证返回的roles是否是一个非空数组
|
if (res.roles && res.roles.length > 0) { // 验证返回的roles是否是一个非空数组
|
||||||
commit('SET_ROLES', res.roles)
|
commit('SET_ROLES', res.roles)
|
||||||
commit('SET_PERMISSIONS', res.permissions)
|
commit('SET_PERMISSIONS', res.permissions)
|
||||||
|
|
|
@ -76,7 +76,7 @@ service.interceptors.response.use(res => {
|
||||||
})
|
})
|
||||||
return Promise.reject('error')
|
return Promise.reject('error')
|
||||||
} else {
|
} else {
|
||||||
return res.data.data // 第二层 data 才是后端返回的 CommonResult.data
|
return res.data
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error => {
|
error => {
|
||||||
|
|
|
@ -51,8 +51,8 @@
|
||||||
<svg-icon :icon-class="scope.row.icon" />
|
<svg-icon :icon-class="scope.row.icon" />
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="orderNum" label="排序" width="60"></el-table-column>
|
<el-table-column prop="sort" label="排序" width="60"></el-table-column>
|
||||||
<el-table-column prop="perms" label="权限标识" :show-overflow-tooltip="true"></el-table-column>
|
<el-table-column prop="permission" label="权限标识" :show-overflow-tooltip="true"></el-table-column>
|
||||||
<el-table-column prop="component" label="组件路径" :show-overflow-tooltip="true"></el-table-column>
|
<el-table-column prop="component" label="组件路径" :show-overflow-tooltip="true"></el-table-column>
|
||||||
<el-table-column prop="status" label="状态" :formatter="statusFormat" width="80"></el-table-column>
|
<el-table-column prop="status" label="状态" :formatter="statusFormat" width="80"></el-table-column>
|
||||||
<el-table-column label="创建时间" align="center" prop="createTime">
|
<el-table-column label="创建时间" align="center" prop="createTime">
|
||||||
|
@ -62,16 +62,16 @@
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-button size="mini"
|
<el-button size="mini"
|
||||||
type="text"
|
type="text"
|
||||||
icon="el-icon-edit"
|
icon="el-icon-edit"
|
||||||
@click="handleUpdate(scope.row)"
|
@click="handleUpdate(scope.row)"
|
||||||
v-hasPermi="['system:menu:edit']"
|
v-hasPermi="['system:menu:edit']"
|
||||||
>修改</el-button>
|
>修改</el-button>
|
||||||
<el-button
|
<el-button
|
||||||
size="mini"
|
size="mini"
|
||||||
type="text"
|
type="text"
|
||||||
icon="el-icon-plus"
|
icon="el-icon-plus"
|
||||||
@click="handleAdd(scope.row)"
|
@click="handleAdd(scope.row)"
|
||||||
v-hasPermi="['system:menu:add']"
|
v-hasPermi="['system:menu:add']"
|
||||||
>新增</el-button>
|
>新增</el-button>
|
||||||
|
@ -104,14 +104,14 @@
|
||||||
<el-col :span="24">
|
<el-col :span="24">
|
||||||
<el-form-item label="菜单类型" prop="menuType">
|
<el-form-item label="菜单类型" prop="menuType">
|
||||||
<el-radio-group v-model="form.menuType">
|
<el-radio-group v-model="form.menuType">
|
||||||
<el-radio label="M">目录</el-radio>
|
<el-radio label="1">目录</el-radio>
|
||||||
<el-radio label="C">菜单</el-radio>
|
<el-radio label="2">菜单</el-radio>
|
||||||
<el-radio label="F">按钮</el-radio>
|
<el-radio label="3">按钮</el-radio>
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="24">
|
<el-col :span="24">
|
||||||
<el-form-item v-if="form.menuType != 'F'" label="菜单图标">
|
<el-form-item v-if="form.menuType != '3'" label="菜单图标">
|
||||||
<el-popover
|
<el-popover
|
||||||
placement="bottom-start"
|
placement="bottom-start"
|
||||||
width="460"
|
width="460"
|
||||||
|
@ -143,7 +143,7 @@
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item v-if="form.menuType != 'F'" label="是否外链">
|
<el-form-item v-if="form.menuType != '3'" label="是否外链">
|
||||||
<el-radio-group v-model="form.isFrame">
|
<el-radio-group v-model="form.isFrame">
|
||||||
<el-radio label="0">是</el-radio>
|
<el-radio label="0">是</el-radio>
|
||||||
<el-radio label="1">否</el-radio>
|
<el-radio label="1">否</el-radio>
|
||||||
|
@ -151,22 +151,22 @@
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item v-if="form.menuType != 'F'" label="路由地址" prop="path">
|
<el-form-item v-if="form.menuType != '3'" label="路由地址" prop="path">
|
||||||
<el-input v-model="form.path" placeholder="请输入路由地址" />
|
<el-input v-model="form.path" placeholder="请输入路由地址" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="12" v-if="form.menuType == 'C'">
|
<el-col :span="12" v-if="form.menuType == '2'">
|
||||||
<el-form-item label="组件路径" prop="component">
|
<el-form-item label="组件路径" prop="component">
|
||||||
<el-input v-model="form.component" placeholder="请输入组件路径" />
|
<el-input v-model="form.component" placeholder="请输入组件路径" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item v-if="form.menuType != 'M'" label="权限标识">
|
<el-form-item v-if="form.menuType != '1'" label="权限标识">
|
||||||
<el-input v-model="form.perms" placeholder="请权限标识" maxlength="50" />
|
<el-input v-model="form.perms" placeholder="请权限标识" maxlength="50" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item v-if="form.menuType != 'F'" label="显示状态">
|
<el-form-item v-if="form.menuType != '3'" label="显示状态">
|
||||||
<el-radio-group v-model="form.visible">
|
<el-radio-group v-model="form.visible">
|
||||||
<el-radio
|
<el-radio
|
||||||
v-for="dict in visibleOptions"
|
v-for="dict in visibleOptions"
|
||||||
|
@ -177,7 +177,7 @@
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item v-if="form.menuType != 'F'" label="菜单状态">
|
<el-form-item v-if="form.menuType != '3'" label="菜单状态">
|
||||||
<el-radio-group v-model="form.status">
|
<el-radio-group v-model="form.status">
|
||||||
<el-radio
|
<el-radio
|
||||||
v-for="dict in statusOptions"
|
v-for="dict in statusOptions"
|
||||||
|
@ -188,7 +188,7 @@
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item v-if="form.menuType == 'C'" label="是否缓存">
|
<el-form-item v-if="form.menuType == '2'" label="是否缓存">
|
||||||
<el-radio-group v-model="form.isCache">
|
<el-radio-group v-model="form.isCache">
|
||||||
<el-radio label="0">缓存</el-radio>
|
<el-radio label="0">缓存</el-radio>
|
||||||
<el-radio label="1">不缓存</el-radio>
|
<el-radio label="1">不缓存</el-radio>
|
||||||
|
@ -297,14 +297,14 @@ export default {
|
||||||
},
|
},
|
||||||
// 显示状态字典翻译
|
// 显示状态字典翻译
|
||||||
visibleFormat(row, column) {
|
visibleFormat(row, column) {
|
||||||
if (row.menuType == "F") {
|
if (row.menuType == "3") {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return this.selectDictLabel(this.visibleOptions, row.visible);
|
return this.selectDictLabel(this.visibleOptions, row.visible);
|
||||||
},
|
},
|
||||||
// 菜单状态字典翻译
|
// 菜单状态字典翻译
|
||||||
statusFormat(row, column) {
|
statusFormat(row, column) {
|
||||||
if (row.menuType == "F") {
|
if (row.menuType == "3") {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return this.selectDictLabel(this.statusOptions, row.status);
|
return this.selectDictLabel(this.statusOptions, row.status);
|
||||||
|
@ -321,7 +321,7 @@ export default {
|
||||||
parentId: 0,
|
parentId: 0,
|
||||||
menuName: undefined,
|
menuName: undefined,
|
||||||
icon: undefined,
|
icon: undefined,
|
||||||
menuType: "M",
|
menuType: "1",
|
||||||
orderNum: undefined,
|
orderNum: undefined,
|
||||||
isFrame: "1",
|
isFrame: "1",
|
||||||
isCache: "0",
|
isCache: "0",
|
||||||
|
@ -396,4 +396,4 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -12,13 +12,13 @@ import lombok.Getter;
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public enum CommonStatusEnum {
|
public enum CommonStatusEnum {
|
||||||
|
|
||||||
ENABLE("0", "开启"),
|
ENABLE(0, "开启"),
|
||||||
DISABLE("1", "关闭");
|
DISABLE(1, "关闭");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 状态值
|
* 状态值
|
||||||
*/
|
*/
|
||||||
private final String status;
|
private final Integer status;
|
||||||
/**
|
/**
|
||||||
* 状态名
|
* 状态名
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
package cn.iocoder.dashboard.common.enums;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通用状态枚举
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public enum OldCommonStatusEnum {
|
||||||
|
|
||||||
|
ENABLE("0", "开启"),
|
||||||
|
DISABLE("1", "关闭");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态值
|
||||||
|
*/
|
||||||
|
private final String status;
|
||||||
|
/**
|
||||||
|
* 状态名
|
||||||
|
*/
|
||||||
|
private final String name;
|
||||||
|
|
||||||
|
}
|
|
@ -4,7 +4,6 @@ import cn.iocoder.dashboard.common.exception.GlobalException;
|
||||||
import cn.iocoder.dashboard.common.exception.ServiceException;
|
import cn.iocoder.dashboard.common.exception.ServiceException;
|
||||||
import cn.iocoder.dashboard.common.pojo.CommonResult;
|
import cn.iocoder.dashboard.common.pojo.CommonResult;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.validation.BindException;
|
import org.springframework.validation.BindException;
|
||||||
import org.springframework.validation.FieldError;
|
import org.springframework.validation.FieldError;
|
||||||
import org.springframework.web.HttpRequestMethodNotSupportedException;
|
import org.springframework.web.HttpRequestMethodNotSupportedException;
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
### 请求 /menu/list 接口 => 成功
|
||||||
|
GET {{baseUrl}}//menu/list
|
||||||
|
Authorization: Bearer {{token}}
|
|
@ -0,0 +1,119 @@
|
||||||
|
package cn.iocoder.dashboard.modules.system.controller.permission;
|
||||||
|
|
||||||
|
import cn.iocoder.dashboard.common.pojo.CommonResult;
|
||||||
|
import cn.iocoder.dashboard.modules.system.controller.permission.vo.SysMenuListReqVO;
|
||||||
|
import cn.iocoder.dashboard.modules.system.controller.permission.vo.SysMenuRespVO;
|
||||||
|
import cn.iocoder.dashboard.modules.system.service.permission.SysMenuService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static cn.iocoder.dashboard.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
|
@Api(tags = "菜单 API")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/system/menu")
|
||||||
|
public class SysMenuController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private SysMenuService menuService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取菜单列表
|
||||||
|
*/
|
||||||
|
// @PreAuthorize("@ss.hasPermi('system:menu:list')")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public CommonResult<List<SysMenuRespVO>> list(SysMenuListReqVO reqVO) {
|
||||||
|
return success(menuService.listMenus(reqVO));
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * 根据菜单编号获取详细信息
|
||||||
|
// */
|
||||||
|
// @PreAuthorize("@ss.hasPermi('system:menu:query')")
|
||||||
|
// @GetMapping(value = "/{menuId}")
|
||||||
|
// public AjaxResult getInfo(@PathVariable Long menuId) {
|
||||||
|
// return AjaxResult.success(menuService.selectMenuById(menuId));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * 获取菜单下拉树列表
|
||||||
|
// */
|
||||||
|
// @GetMapping("/treeselect")
|
||||||
|
// public AjaxResult treeselect(SysMenu menu) {
|
||||||
|
// LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
||||||
|
// Long userId = loginUser.getUser().getUserId();
|
||||||
|
// List<SysMenu> menus = menuService.selectMenuList(menu, userId);
|
||||||
|
// return AjaxResult.success(menuService.buildMenuTreeSelect(menus));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * 加载对应角色菜单列表树
|
||||||
|
// */
|
||||||
|
// @GetMapping(value = "/roleMenuTreeselect/{roleId}")
|
||||||
|
// public AjaxResult roleMenuTreeselect(@PathVariable("roleId") Long roleId) {
|
||||||
|
// LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
||||||
|
// List<SysMenu> menus = menuService.selectMenuList(loginUser.getUser().getUserId());
|
||||||
|
// AjaxResult ajax = AjaxResult.success();
|
||||||
|
// ajax.put("checkedKeys", menuService.selectMenuListByRoleId(roleId));
|
||||||
|
// ajax.put("menus", menuService.buildMenuTreeSelect(menus));
|
||||||
|
// return ajax;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * 新增菜单
|
||||||
|
// */
|
||||||
|
// @PreAuthorize("@ss.hasPermi('system:menu:add')")
|
||||||
|
// @Log(title = "菜单管理", businessType = BusinessType.INSERT)
|
||||||
|
// @PostMapping
|
||||||
|
// public AjaxResult add(@Validated @RequestBody SysMenu menu) {
|
||||||
|
// if (UserConstants.NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu))) {
|
||||||
|
// return AjaxResult.error("新增菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
|
||||||
|
// } else if (UserConstants.YES_FRAME.equals(menu.getIsFrame())
|
||||||
|
// && !StringUtils.startsWithAny(menu.getPath(), Constants.HTTP, Constants.HTTPS)) {
|
||||||
|
// return AjaxResult.error("新增菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头");
|
||||||
|
// }
|
||||||
|
// menu.setCreateBy(SecurityUtils.getUsername());
|
||||||
|
// return toAjax(menuService.insertMenu(menu));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * 修改菜单
|
||||||
|
// */
|
||||||
|
// @PreAuthorize("@ss.hasPermi('system:menu:edit')")
|
||||||
|
// @Log(title = "菜单管理", businessType = BusinessType.UPDATE)
|
||||||
|
// @PutMapping
|
||||||
|
// public AjaxResult edit(@Validated @RequestBody SysMenu menu) {
|
||||||
|
// if (UserConstants.NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu))) {
|
||||||
|
// return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
|
||||||
|
// } else if (UserConstants.YES_FRAME.equals(menu.getIsFrame())
|
||||||
|
// && !StringUtils.startsWithAny(menu.getPath(), Constants.HTTP, Constants.HTTPS)) {
|
||||||
|
// return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头");
|
||||||
|
// } else if (menu.getMenuId().equals(menu.getParentId())) {
|
||||||
|
// return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,上级菜单不能选择自己");
|
||||||
|
// }
|
||||||
|
// menu.setUpdateBy(SecurityUtils.getUsername());
|
||||||
|
// return toAjax(menuService.updateMenu(menu));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * 删除菜单
|
||||||
|
// */
|
||||||
|
// @PreAuthorize("@ss.hasPermi('system:menu:remove')")
|
||||||
|
// @Log(title = "菜单管理", businessType = BusinessType.DELETE)
|
||||||
|
// @DeleteMapping("/{menuId}")
|
||||||
|
// public AjaxResult remove(@PathVariable("menuId") Long menuId) {
|
||||||
|
// if (menuService.hasChildByMenuId(menuId)) {
|
||||||
|
// return AjaxResult.error("存在子菜单,不允许删除");
|
||||||
|
// }
|
||||||
|
// if (menuService.checkMenuExistRole(menuId)) {
|
||||||
|
// return AjaxResult.error("菜单已分配,不允许删除");
|
||||||
|
// }
|
||||||
|
// return toAjax(menuService.deleteMenuById(menuId));
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,52 @@
|
||||||
|
package cn.iocoder.dashboard.modules.system.controller.permission.vo;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import javax.validation.constraints.Size;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 菜单 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||||
|
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class SysMenuBaseVO {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "菜单名称", required = true, example = "芋道")
|
||||||
|
@NotBlank(message = "菜单名称不能为空")
|
||||||
|
@Size(max = 50, message = "菜单名称长度不能超过50个字符")
|
||||||
|
private String menuName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "权限标识", example = "sys:menu:add", notes = "仅菜单类型为按钮时,才需要传递")
|
||||||
|
@Size(max = 100)
|
||||||
|
private String permission;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "类型", required = true, example = "1", notes = "参见 MenuTypeEnum 枚举类")
|
||||||
|
@NotBlank(message = "菜单类型不能为空")
|
||||||
|
private Integer menuType;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "显示顺序不能为空", required = true, example = "1024")
|
||||||
|
@NotBlank(message = "显示顺序不能为空")
|
||||||
|
private String sort;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "父菜单 ID", required = true, example = "1024")
|
||||||
|
@NotNull(message = "父菜单 ID 不能为空")
|
||||||
|
private Long parentId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "路由地址", example = "post", notes = "仅菜单类型为菜单或者目录时,才需要传")
|
||||||
|
@Size(max = 200, message = "路由地址不能超过200个字符")
|
||||||
|
private String path;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "菜单图标", example = "/menu/list", notes = "仅菜单类型为菜单或者目录时,才需要传")
|
||||||
|
private String icon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组件路径
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "组件路径", example = "system/post/index", notes = "仅菜单类型为菜单时,才需要传")
|
||||||
|
@Size(max = 200, message = "组件路径不能超过255个字符")
|
||||||
|
private String component;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
package cn.iocoder.dashboard.modules.system.controller.permission.vo;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import lombok.*;
|
||||||
|
|
||||||
|
@ApiModel("菜单创建 Request VO")
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class SysMenuCreateReqVO extends SysMenuBaseVO {
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
package cn.iocoder.dashboard.modules.system.controller.permission.vo;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@ApiModel("菜单列表 Request VO")
|
||||||
|
@Data
|
||||||
|
public class SysMenuListReqVO {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "菜单名称", example = "芋道", notes = "模糊匹配")
|
||||||
|
private String menuName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "展示状态", example = "1", notes = "参见 CommonStatusEnum 枚举类")
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package cn.iocoder.dashboard.modules.system.controller.permission.vo;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@ApiModel("菜单信息 Response VO")
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class SysMenuRespVO extends SysMenuBaseVO {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "菜单编号", required = true, example = "1024")
|
||||||
|
private Integer menuId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "创建时间", required = true, example = "时间戳格式")
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
package cn.iocoder.dashboard.modules.system.controller.permission.vo;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.*;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
@ApiModel("菜单更新 Request VO")
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class SysMenuUpdateReqVO extends SysMenuBaseVO {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "菜单编号", required = true, example = "1024")
|
||||||
|
@NotNull(message = "菜单编号不能为空")
|
||||||
|
private Integer menuId;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package cn.iocoder.dashboard.modules.system.convert.permission;
|
||||||
|
|
||||||
|
import cn.iocoder.dashboard.modules.system.controller.permission.vo.SysMenuRespVO;
|
||||||
|
import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.permission.SysMenuDO;
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface SysMenuConvert {
|
||||||
|
|
||||||
|
SysMenuConvert INSTANCE = Mappers.getMapper(SysMenuConvert.class);
|
||||||
|
|
||||||
|
List<SysMenuRespVO> convertList(List<SysMenuDO> list);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,68 @@
|
||||||
|
package cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.dict;
|
||||||
|
|
||||||
|
import cn.iocoder.dashboard.common.enums.CommonStatusEnum;
|
||||||
|
import cn.iocoder.dashboard.framework.excel.Excel;
|
||||||
|
import cn.iocoder.dashboard.framework.mybatis.core.BaseDO;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.Size;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典数据表
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
@TableName("sys_dict_data")
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class SysDictData extends BaseDO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典编码
|
||||||
|
*/
|
||||||
|
@TableId
|
||||||
|
@Excel(name = "字典编码", cellType = Excel.ColumnType.NUMERIC)
|
||||||
|
private Long dictCode;
|
||||||
|
/**
|
||||||
|
* 字典排序
|
||||||
|
*/
|
||||||
|
@Excel(name = "字典排序", cellType = Excel.ColumnType.NUMERIC)
|
||||||
|
private Long dictSort;
|
||||||
|
/**
|
||||||
|
* 字典标签
|
||||||
|
*/
|
||||||
|
@Excel(name = "字典标签")
|
||||||
|
@NotBlank(message = "字典标签不能为空")
|
||||||
|
@Size(max = 100, message = "字典标签长度不能超过100个字符")
|
||||||
|
private String dictLabel;
|
||||||
|
/**
|
||||||
|
* 字典键值
|
||||||
|
*/
|
||||||
|
@Excel(name = "字典键值")
|
||||||
|
@NotBlank(message = "字典键值不能为空")
|
||||||
|
@Size(max = 100, message = "字典键值长度不能超过100个字符")
|
||||||
|
private String dictValue;
|
||||||
|
/**
|
||||||
|
* 字典类型
|
||||||
|
*/
|
||||||
|
@Excel(name = "字典类型")
|
||||||
|
@NotBlank(message = "字典类型不能为空")
|
||||||
|
@Size(max = 100, message = "字典类型长度不能超过100个字符")
|
||||||
|
private String dictType;
|
||||||
|
/**
|
||||||
|
* 状态
|
||||||
|
*
|
||||||
|
* 枚举 {@link CommonStatusEnum}
|
||||||
|
*/
|
||||||
|
@Excel(name = "状态", readConverterExp = "0=正常,1=停用")
|
||||||
|
private Integer status;
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,55 @@
|
||||||
|
package cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.dict;
|
||||||
|
|
||||||
|
import cn.iocoder.dashboard.common.enums.CommonStatusEnum;
|
||||||
|
import cn.iocoder.dashboard.framework.excel.Excel;
|
||||||
|
import cn.iocoder.dashboard.framework.mybatis.core.BaseDO;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.Size;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典类型表
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
@TableName("sys_dict_type")
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class SysDictTypeDO extends BaseDO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典主键
|
||||||
|
*/
|
||||||
|
@TableId
|
||||||
|
@Excel(name = "字典主键", cellType = Excel.ColumnType.NUMERIC)
|
||||||
|
private Long dictId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典名称
|
||||||
|
*/
|
||||||
|
@Excel(name = "字典名称")
|
||||||
|
@NotBlank(message = "字典名称不能为空")
|
||||||
|
@Size(max = 100, message = "字典类型名称长度不能超过100个字符")
|
||||||
|
private String dictName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典类型
|
||||||
|
*/
|
||||||
|
@Excel(name = "字典类型")
|
||||||
|
@NotBlank(message = "字典类型不能为空")
|
||||||
|
@Size(max = 100, message = "字典类型类型长度不能超过100个字符")
|
||||||
|
private String dictType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态
|
||||||
|
*
|
||||||
|
* 枚举 {@link CommonStatusEnum}
|
||||||
|
*/
|
||||||
|
@Excel(name = "状态", readConverterExp = "0=正常,1=停用")
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
}
|
|
@ -1,16 +1,15 @@
|
||||||
package cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.permission;
|
package cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.permission;
|
||||||
|
|
||||||
|
import cn.iocoder.dashboard.common.enums.CommonStatusEnum;
|
||||||
import cn.iocoder.dashboard.framework.mybatis.core.BaseDO;
|
import cn.iocoder.dashboard.framework.mybatis.core.BaseDO;
|
||||||
|
import cn.iocoder.dashboard.modules.system.enums.permission.MenuTypeEnum;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
|
||||||
import javax.validation.constraints.Size;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 菜单权限表
|
* 菜单 DO
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
|
@ -24,57 +23,52 @@ public class SysMenuDO extends BaseDO {
|
||||||
*/
|
*/
|
||||||
@TableId
|
@TableId
|
||||||
private Long menuId;
|
private Long menuId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 菜单名称
|
* 菜单名称
|
||||||
*/
|
*/
|
||||||
@NotBlank(message = "菜单名称不能为空")
|
|
||||||
@Size(max = 50, message = "菜单名称长度不能超过50个字符")
|
|
||||||
private String menuName;
|
private String menuName;
|
||||||
|
/**
|
||||||
|
* 权限标识
|
||||||
|
*
|
||||||
|
* 一般格式为:${系统}:${模块}:${操作}
|
||||||
|
* 例如说:system:admin:add,即 system 服务的添加管理员。
|
||||||
|
*
|
||||||
|
* 当我们把该 SysMenuDO 赋予给角色后,意味着该角色有该资源:
|
||||||
|
* - 对于后端,配合 @PreAuthorize 注解,配置 API 接口需要该权限,从而对 API 接口进行权限控制。
|
||||||
|
* - 对于前端,配合前端标签,配置按钮是否展示,避免用户没有该权限时,结果可以看到该操作。
|
||||||
|
*/
|
||||||
|
private String permission;
|
||||||
|
/**
|
||||||
|
* 菜单类型
|
||||||
|
*
|
||||||
|
* 枚举 {@link MenuTypeEnum}
|
||||||
|
*/
|
||||||
|
private Integer menuType;
|
||||||
|
/**
|
||||||
|
* 显示顺序
|
||||||
|
*/
|
||||||
|
private String sort;
|
||||||
/**
|
/**
|
||||||
* 父菜单ID
|
* 父菜单ID
|
||||||
*/
|
*/
|
||||||
private Long parentId;
|
private Long parentId;
|
||||||
|
|
||||||
/**
|
|
||||||
* 显示顺序
|
|
||||||
*/
|
|
||||||
@NotBlank(message = "显示顺序不能为空")
|
|
||||||
private String orderNum;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 路由地址
|
* 路由地址
|
||||||
*/
|
*/
|
||||||
@Size(max = 200, message = "路由地址不能超过200个字符")
|
|
||||||
private String path;
|
private String path;
|
||||||
|
|
||||||
/**
|
|
||||||
* 组件路径
|
|
||||||
*/
|
|
||||||
@Size(max = 200, message = "组件路径不能超过255个字符")
|
|
||||||
private String component;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 类型(M目录 C菜单 F按钮)
|
|
||||||
*/
|
|
||||||
@NotBlank(message = "菜单类型不能为空")
|
|
||||||
private String menuType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 菜单状态(0显示 1隐藏)
|
|
||||||
*/
|
|
||||||
private String status;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限字符串
|
|
||||||
*/
|
|
||||||
@Size(max = 100, message = "权限标识长度不能超过100个字符")
|
|
||||||
private String permission;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 菜单图标
|
* 菜单图标
|
||||||
*/
|
*/
|
||||||
private String icon;
|
private String icon;
|
||||||
|
/**
|
||||||
|
* 组件路径
|
||||||
|
*/
|
||||||
|
private String component;
|
||||||
|
/**
|
||||||
|
* 状态
|
||||||
|
*
|
||||||
|
* 枚举 {@link CommonStatusEnum}
|
||||||
|
*/
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,14 +12,14 @@ import lombok.Getter;
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public enum MenuTypeEnum {
|
public enum MenuTypeEnum {
|
||||||
|
|
||||||
DIR("M"), // 目录
|
DIR(1), // 目录
|
||||||
MENU("C"), // 菜单
|
MENU(2), // 菜单
|
||||||
BUTTON("F") // 按钮
|
BUTTON(3) // 按钮
|
||||||
;
|
;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 类型
|
* 类型
|
||||||
*/
|
*/
|
||||||
private final String type;
|
private final Integer type;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,8 @@ import cn.hutool.core.util.StrUtil;
|
||||||
import cn.iocoder.dashboard.common.enums.CommonStatusEnum;
|
import cn.iocoder.dashboard.common.enums.CommonStatusEnum;
|
||||||
import cn.iocoder.dashboard.framework.security.config.SecurityProperties;
|
import cn.iocoder.dashboard.framework.security.config.SecurityProperties;
|
||||||
import cn.iocoder.dashboard.framework.security.core.LoginUser;
|
import cn.iocoder.dashboard.framework.security.core.LoginUser;
|
||||||
import cn.iocoder.dashboard.modules.system.controller.auth.vo.SysAuthPermissionInfoRespVO;
|
|
||||||
import cn.iocoder.dashboard.modules.system.controller.auth.vo.SysAuthMenuRespVO;
|
import cn.iocoder.dashboard.modules.system.controller.auth.vo.SysAuthMenuRespVO;
|
||||||
|
import cn.iocoder.dashboard.modules.system.controller.auth.vo.SysAuthPermissionInfoRespVO;
|
||||||
import cn.iocoder.dashboard.modules.system.convert.auth.SysAuthConvert;
|
import cn.iocoder.dashboard.modules.system.convert.auth.SysAuthConvert;
|
||||||
import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.permission.SysMenuDO;
|
import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.permission.SysMenuDO;
|
||||||
import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.permission.SysRoleDO;
|
import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.permission.SysRoleDO;
|
||||||
|
@ -252,7 +252,7 @@ public class SysAuthServiceImpl implements SysAuthService {
|
||||||
|
|
||||||
private static List<SysAuthMenuRespVO> buildRouterTree(List<SysMenuDO> menuList) {
|
private static List<SysAuthMenuRespVO> buildRouterTree(List<SysMenuDO> menuList) {
|
||||||
// 排序,保证菜单的有序性
|
// 排序,保证菜单的有序性
|
||||||
menuList.sort(Comparator.comparing(SysMenuDO::getOrderNum));
|
menuList.sort(Comparator.comparing(SysMenuDO::getSort));
|
||||||
// 构建菜单树
|
// 构建菜单树
|
||||||
// 使用 LinkedHashMap 的原因,是为了排序 。实际也可以用 Stream API ,就是太丑了。
|
// 使用 LinkedHashMap 的原因,是为了排序 。实际也可以用 Stream API ,就是太丑了。
|
||||||
Map<Long, SysAuthMenuRespVO> treeNodeMap = new LinkedHashMap<>();
|
Map<Long, SysAuthMenuRespVO> treeNodeMap = new LinkedHashMap<>();
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package cn.iocoder.dashboard.modules.system.service.permission;
|
package cn.iocoder.dashboard.modules.system.service.permission;
|
||||||
|
|
||||||
|
import cn.iocoder.dashboard.modules.system.controller.permission.vo.SysMenuListReqVO;
|
||||||
|
import cn.iocoder.dashboard.modules.system.controller.permission.vo.SysMenuRespVO;
|
||||||
import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.permission.SysMenuDO;
|
import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.permission.SysMenuDO;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -15,6 +17,14 @@ public interface SysMenuService {
|
||||||
*/
|
*/
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 筛选菜单列表
|
||||||
|
*
|
||||||
|
* @param reqVO 筛选条件请求 VO
|
||||||
|
* @return 菜单列表
|
||||||
|
*/
|
||||||
|
List<SysMenuRespVO> listMenus(SysMenuListReqVO reqVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得所有菜单,从缓存中
|
* 获得所有菜单,从缓存中
|
||||||
*
|
*
|
||||||
|
@ -24,7 +34,7 @@ public interface SysMenuService {
|
||||||
* @param menusStatuses 菜单状态数组
|
* @param menusStatuses 菜单状态数组
|
||||||
* @return 菜单列表
|
* @return 菜单列表
|
||||||
*/
|
*/
|
||||||
List<SysMenuDO> listMenusFromCache(Collection<String> menuTypes, Collection<String> menusStatuses);
|
List<SysMenuDO> listMenusFromCache(Collection<Integer> menuTypes, Collection<Integer> menusStatuses);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得指定编号的菜单数组,从缓存中
|
* 获得指定编号的菜单数组,从缓存中
|
||||||
|
@ -36,9 +46,7 @@ public interface SysMenuService {
|
||||||
* @param menusStatuses 菜单状态数组
|
* @param menusStatuses 菜单状态数组
|
||||||
* @return 菜单数组
|
* @return 菜单数组
|
||||||
*/
|
*/
|
||||||
List<SysMenuDO> listMenusFromCache(Collection<Long> menuIds, Collection<String> menuTypes,
|
List<SysMenuDO> listMenusFromCache(Collection<Long> menuIds, Collection<Integer> menuTypes,
|
||||||
Collection<String> menusStatuses);
|
Collection<Integer> menusStatuses);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,8 +29,8 @@ public interface SysPermissionService {
|
||||||
* @param menusStatuses 菜单状态数组
|
* @param menusStatuses 菜单状态数组
|
||||||
* @return 菜单列表
|
* @return 菜单列表
|
||||||
*/
|
*/
|
||||||
List<SysMenuDO> listRoleMenusFromCache(Collection<Long> roleIds, Collection<String> menuTypes,
|
List<SysMenuDO> listRoleMenusFromCache(Collection<Long> roleIds, Collection<Integer> menuTypes,
|
||||||
Collection<String> menusStatuses);
|
Collection<Integer> menusStatuses);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得用户拥有的角色编号数组
|
* 获得用户拥有的角色编号数组
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
package cn.iocoder.dashboard.modules.system.service.permission.impl;
|
package cn.iocoder.dashboard.modules.system.service.permission.impl;
|
||||||
|
|
||||||
|
import cn.iocoder.dashboard.modules.system.controller.permission.vo.SysMenuListReqVO;
|
||||||
|
import cn.iocoder.dashboard.modules.system.controller.permission.vo.SysMenuRespVO;
|
||||||
|
import cn.iocoder.dashboard.modules.system.convert.permission.SysMenuConvert;
|
||||||
import cn.iocoder.dashboard.modules.system.dal.mysql.dao.permission.SysMenuMapper;
|
import cn.iocoder.dashboard.modules.system.dal.mysql.dao.permission.SysMenuMapper;
|
||||||
import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.permission.SysMenuDO;
|
import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.permission.SysMenuDO;
|
||||||
import cn.iocoder.dashboard.modules.system.service.permission.SysMenuService;
|
import cn.iocoder.dashboard.modules.system.service.permission.SysMenuService;
|
||||||
|
@ -63,7 +66,14 @@ public class SysMenuServiceImpl implements SysMenuService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SysMenuDO> listMenusFromCache(Collection<String> menuTypes, Collection<String> menusStatuses) {
|
public List<SysMenuRespVO> listMenus(SysMenuListReqVO reqVO) {
|
||||||
|
List<SysMenuDO> list = menuMapper.selectList(null);
|
||||||
|
// TODO 排序
|
||||||
|
return SysMenuConvert.INSTANCE.convertList(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SysMenuDO> listMenusFromCache(Collection<Integer> menuTypes, Collection<Integer> menusStatuses) {
|
||||||
// 任一一个参数为空,则返回空
|
// 任一一个参数为空,则返回空
|
||||||
if (CollectionUtils.isAnyEmpty(menuTypes, menusStatuses)) {
|
if (CollectionUtils.isAnyEmpty(menuTypes, menusStatuses)) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
|
@ -75,8 +85,8 @@ public class SysMenuServiceImpl implements SysMenuService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SysMenuDO> listMenusFromCache(Collection<Long> menuIds, Collection<String> menuTypes,
|
public List<SysMenuDO> listMenusFromCache(Collection<Long> menuIds, Collection<Integer> menuTypes,
|
||||||
Collection<String> menusStatuses) {
|
Collection<Integer> menusStatuses) {
|
||||||
// 任一一个参数为空,则返回空
|
// 任一一个参数为空,则返回空
|
||||||
if (CollectionUtils.isAnyEmpty(menuIds, menuTypes, menusStatuses)) {
|
if (CollectionUtils.isAnyEmpty(menuIds, menuTypes, menusStatuses)) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
|
|
|
@ -78,8 +78,8 @@ public class SysPermissionServiceImpl implements SysPermissionService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SysMenuDO> listRoleMenusFromCache(Collection<Long> roleIds, Collection<String> menuTypes,
|
public List<SysMenuDO> listRoleMenusFromCache(Collection<Long> roleIds, Collection<Integer> menuTypes,
|
||||||
Collection<String> menusStatuses) {
|
Collection<Integer> menusStatuses) {
|
||||||
// 任一一个参数为空时,不返回任何菜单
|
// 任一一个参数为空时,不返回任何菜单
|
||||||
if (CollectionUtils.isAnyEmpty(roleIds, menusStatuses, menusStatuses)) {
|
if (CollectionUtils.isAnyEmpty(roleIds, menusStatuses, menusStatuses)) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
|
|
Loading…
Reference in New Issue