Commit 74daab066d13edcd476eca0371e122270a9b5aff
1 parent
3bf173d7
1. 开始迁移 menu 模块,完成 menu 列表的接口
2. 开始迁移 dict 模块,梳理了下整体的表结构,删除无用字段
Showing
29 changed files
with
514 additions
and
370 deletions
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictDataController.java
| ... | ... | @@ -27,7 +27,7 @@ import com.ruoyi.system.service.ISysDictTypeService; |
| 27 | 27 | |
| 28 | 28 | /** |
| 29 | 29 | * 数据字典信息 |
| 30 | - * | |
| 30 | + * | |
| 31 | 31 | * @author ruoyi |
| 32 | 32 | */ |
| 33 | 33 | @RestController |
| ... | ... | @@ -103,7 +103,7 @@ public class SysDictDataController extends BaseController |
| 103 | 103 | @PutMapping |
| 104 | 104 | public AjaxResult edit(@Validated @RequestBody SysDictData dict) |
| 105 | 105 | { |
| 106 | - dict.setUpdateBy(SecurityUtils.getUsername()); | |
| 106 | + dict.setUpdateBy(SecurityUtils.getUsername()); | |
| 107 | 107 | return toAjax(dictDataService.updateDictData(dict)); |
| 108 | 108 | } |
| 109 | 109 | ... | ... |
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysMenuController.java deleted
| 1 | -package com.ruoyi.web.controller.system; | |
| 2 | - | |
| 3 | -import java.util.List; | |
| 4 | - | |
| 5 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 6 | -import org.springframework.security.access.prepost.PreAuthorize; | |
| 7 | -import org.springframework.validation.annotation.Validated; | |
| 8 | -import org.springframework.web.bind.annotation.DeleteMapping; | |
| 9 | -import org.springframework.web.bind.annotation.GetMapping; | |
| 10 | -import org.springframework.web.bind.annotation.PathVariable; | |
| 11 | -import org.springframework.web.bind.annotation.PostMapping; | |
| 12 | -import org.springframework.web.bind.annotation.PutMapping; | |
| 13 | -import org.springframework.web.bind.annotation.RequestBody; | |
| 14 | -import org.springframework.web.bind.annotation.RequestMapping; | |
| 15 | -import org.springframework.web.bind.annotation.RestController; | |
| 16 | -import com.ruoyi.common.annotation.Log; | |
| 17 | -import com.ruoyi.common.constant.Constants; | |
| 18 | -import com.ruoyi.common.constant.UserConstants; | |
| 19 | -import com.ruoyi.common.core.controller.BaseController; | |
| 20 | -import com.ruoyi.common.core.domain.AjaxResult; | |
| 21 | -import com.ruoyi.common.core.domain.entity.SysMenu; | |
| 22 | -import com.ruoyi.common.core.domain.model.LoginUser; | |
| 23 | -import com.ruoyi.common.enums.BusinessType; | |
| 24 | -import com.ruoyi.common.utils.SecurityUtils; | |
| 25 | -import com.ruoyi.common.utils.ServletUtils; | |
| 26 | -import com.ruoyi.common.utils.StringUtils; | |
| 27 | -import com.ruoyi.framework.web.service.TokenService; | |
| 28 | -import com.ruoyi.system.service.ISysMenuService; | |
| 29 | - | |
| 30 | -/** | |
| 31 | - * 菜单信息 | |
| 32 | - * | |
| 33 | - * @author ruoyi | |
| 34 | - */ | |
| 35 | -@RestController | |
| 36 | -@RequestMapping("/system/menu") | |
| 37 | -public class SysMenuController extends BaseController { | |
| 38 | - @Autowired | |
| 39 | - private ISysMenuService menuService; | |
| 40 | - | |
| 41 | - @Autowired | |
| 42 | - private TokenService tokenService; | |
| 43 | - | |
| 44 | - /** | |
| 45 | - * 获取菜单列表 | |
| 46 | - */ | |
| 47 | - @PreAuthorize("@ss.hasPermi('system:menu:list')") | |
| 48 | - @GetMapping("/list") | |
| 49 | - public AjaxResult list(SysMenu menu) { | |
| 50 | - LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); | |
| 51 | - Long userId = loginUser.getUser().getUserId(); | |
| 52 | - List<SysMenu> menus = menuService.selectMenuList(menu, userId); | |
| 53 | - return AjaxResult.success(menus); | |
| 54 | - } | |
| 55 | - | |
| 56 | - /** | |
| 57 | - * 根据菜单编号获取详细信息 | |
| 58 | - */ | |
| 59 | - @PreAuthorize("@ss.hasPermi('system:menu:query')") | |
| 60 | - @GetMapping(value = "/{menuId}") | |
| 61 | - public AjaxResult getInfo(@PathVariable Long menuId) { | |
| 62 | - return AjaxResult.success(menuService.selectMenuById(menuId)); | |
| 63 | - } | |
| 64 | - | |
| 65 | - /** | |
| 66 | - * 获取菜单下拉树列表 | |
| 67 | - */ | |
| 68 | - @GetMapping("/treeselect") | |
| 69 | - public AjaxResult treeselect(SysMenu menu) { | |
| 70 | - LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); | |
| 71 | - Long userId = loginUser.getUser().getUserId(); | |
| 72 | - List<SysMenu> menus = menuService.selectMenuList(menu, userId); | |
| 73 | - return AjaxResult.success(menuService.buildMenuTreeSelect(menus)); | |
| 74 | - } | |
| 75 | - | |
| 76 | - /** | |
| 77 | - * 加载对应角色菜单列表树 | |
| 78 | - */ | |
| 79 | - @GetMapping(value = "/roleMenuTreeselect/{roleId}") | |
| 80 | - public AjaxResult roleMenuTreeselect(@PathVariable("roleId") Long roleId) { | |
| 81 | - LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); | |
| 82 | - List<SysMenu> menus = menuService.selectMenuList(loginUser.getUser().getUserId()); | |
| 83 | - AjaxResult ajax = AjaxResult.success(); | |
| 84 | - ajax.put("checkedKeys", menuService.selectMenuListByRoleId(roleId)); | |
| 85 | - ajax.put("menus", menuService.buildMenuTreeSelect(menus)); | |
| 86 | - return ajax; | |
| 87 | - } | |
| 88 | - | |
| 89 | - /** | |
| 90 | - * 新增菜单 | |
| 91 | - */ | |
| 92 | - @PreAuthorize("@ss.hasPermi('system:menu:add')") | |
| 93 | - @Log(title = "菜单管理", businessType = BusinessType.INSERT) | |
| 94 | - @PostMapping | |
| 95 | - public AjaxResult add(@Validated @RequestBody SysMenu menu) { | |
| 96 | - if (UserConstants.NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu))) { | |
| 97 | - return AjaxResult.error("新增菜单'" + menu.getMenuName() + "'失败,菜单名称已存在"); | |
| 98 | - } else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) | |
| 99 | - && !StringUtils.startsWithAny(menu.getPath(), Constants.HTTP, Constants.HTTPS)) { | |
| 100 | - return AjaxResult.error("新增菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头"); | |
| 101 | - } | |
| 102 | - menu.setCreateBy(SecurityUtils.getUsername()); | |
| 103 | - return toAjax(menuService.insertMenu(menu)); | |
| 104 | - } | |
| 105 | - | |
| 106 | - /** | |
| 107 | - * 修改菜单 | |
| 108 | - */ | |
| 109 | - @PreAuthorize("@ss.hasPermi('system:menu:edit')") | |
| 110 | - @Log(title = "菜单管理", businessType = BusinessType.UPDATE) | |
| 111 | - @PutMapping | |
| 112 | - public AjaxResult edit(@Validated @RequestBody SysMenu menu) { | |
| 113 | - if (UserConstants.NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu))) { | |
| 114 | - return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在"); | |
| 115 | - } else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) | |
| 116 | - && !StringUtils.startsWithAny(menu.getPath(), Constants.HTTP, Constants.HTTPS)) { | |
| 117 | - return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头"); | |
| 118 | - } else if (menu.getMenuId().equals(menu.getParentId())) { | |
| 119 | - return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,上级菜单不能选择自己"); | |
| 120 | - } | |
| 121 | - menu.setUpdateBy(SecurityUtils.getUsername()); | |
| 122 | - return toAjax(menuService.updateMenu(menu)); | |
| 123 | - } | |
| 124 | - | |
| 125 | - /** | |
| 126 | - * 删除菜单 | |
| 127 | - */ | |
| 128 | - @PreAuthorize("@ss.hasPermi('system:menu:remove')") | |
| 129 | - @Log(title = "菜单管理", businessType = BusinessType.DELETE) | |
| 130 | - @DeleteMapping("/{menuId}") | |
| 131 | - public AjaxResult remove(@PathVariable("menuId") Long menuId) { | |
| 132 | - if (menuService.hasChildByMenuId(menuId)) { | |
| 133 | - return AjaxResult.error("存在子菜单,不允许删除"); | |
| 134 | - } | |
| 135 | - if (menuService.checkMenuExistRole(menuId)) { | |
| 136 | - return AjaxResult.error("菜单已分配,不允许删除"); | |
| 137 | - } | |
| 138 | - return toAjax(menuService.deleteMenuById(menuId)); | |
| 139 | - } | |
| 140 | -} |
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDictData.java deleted
| 1 | -package com.ruoyi.common.core.domain.entity; | |
| 2 | - | |
| 3 | -import javax.validation.constraints.NotBlank; | |
| 4 | -import javax.validation.constraints.Size; | |
| 5 | -import org.apache.commons.lang3.builder.ToStringBuilder; | |
| 6 | -import org.apache.commons.lang3.builder.ToStringStyle; | |
| 7 | -import com.ruoyi.common.annotation.Excel; | |
| 8 | -import com.ruoyi.common.annotation.Excel.ColumnType; | |
| 9 | -import com.ruoyi.common.constant.UserConstants; | |
| 10 | -import com.ruoyi.common.core.domain.BaseEntity; | |
| 11 | - | |
| 12 | -/** | |
| 13 | - * 字典数据表 sys_dict_data | |
| 14 | - * | |
| 15 | - * @author ruoyi | |
| 16 | - */ | |
| 17 | -public class SysDictData extends BaseEntity | |
| 18 | -{ | |
| 19 | - private static final long serialVersionUID = 1L; | |
| 20 | - | |
| 21 | - /** 字典编码 */ | |
| 22 | - @Excel(name = "字典编码", cellType = ColumnType.NUMERIC) | |
| 23 | - private Long dictCode; | |
| 24 | - | |
| 25 | - /** 字典排序 */ | |
| 26 | - @Excel(name = "字典排序", cellType = ColumnType.NUMERIC) | |
| 27 | - private Long dictSort; | |
| 28 | - | |
| 29 | - /** 字典标签 */ | |
| 30 | - @Excel(name = "字典标签") | |
| 31 | - private String dictLabel; | |
| 32 | - | |
| 33 | - /** 字典键值 */ | |
| 34 | - @Excel(name = "字典键值") | |
| 35 | - private String dictValue; | |
| 36 | - | |
| 37 | - /** 字典类型 */ | |
| 38 | - @Excel(name = "字典类型") | |
| 39 | - private String dictType; | |
| 40 | - | |
| 41 | - /** 样式属性(其他样式扩展) */ | |
| 42 | - private String cssClass; | |
| 43 | - | |
| 44 | - /** 表格字典样式 */ | |
| 45 | - private String listClass; | |
| 46 | - | |
| 47 | - /** 是否默认(Y是 N否) */ | |
| 48 | - @Excel(name = "是否默认", readConverterExp = "Y=是,N=否") | |
| 49 | - private String isDefault; | |
| 50 | - | |
| 51 | - /** 状态(0正常 1停用) */ | |
| 52 | - @Excel(name = "状态", readConverterExp = "0=正常,1=停用") | |
| 53 | - private String status; | |
| 54 | - | |
| 55 | - @NotBlank(message = "字典标签不能为空") | |
| 56 | - @Size(min = 0, max = 100, message = "字典标签长度不能超过100个字符") | |
| 57 | - public String getDictLabel() | |
| 58 | - { | |
| 59 | - return dictLabel; | |
| 60 | - } | |
| 61 | - | |
| 62 | - @NotBlank(message = "字典键值不能为空") | |
| 63 | - @Size(min = 0, max = 100, message = "字典键值长度不能超过100个字符") | |
| 64 | - public String getDictValue() | |
| 65 | - { | |
| 66 | - return dictValue; | |
| 67 | - } | |
| 68 | - | |
| 69 | - @NotBlank(message = "字典类型不能为空") | |
| 70 | - @Size(min = 0, max = 100, message = "字典类型长度不能超过100个字符") | |
| 71 | - public String getDictType() | |
| 72 | - { | |
| 73 | - return dictType; | |
| 74 | - } | |
| 75 | - | |
| 76 | - @Size(min = 0, max = 100, message = "样式属性长度不能超过100个字符") | |
| 77 | - public String getCssClass() | |
| 78 | - { | |
| 79 | - return cssClass; | |
| 80 | - } | |
| 81 | - | |
| 82 | -} |
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDictType.java deleted
| 1 | -package com.ruoyi.common.core.domain.entity; | |
| 2 | - | |
| 3 | -import javax.validation.constraints.NotBlank; | |
| 4 | -import javax.validation.constraints.Size; | |
| 5 | -import org.apache.commons.lang3.builder.ToStringBuilder; | |
| 6 | -import org.apache.commons.lang3.builder.ToStringStyle; | |
| 7 | -import com.ruoyi.common.annotation.Excel; | |
| 8 | -import com.ruoyi.common.annotation.Excel.ColumnType; | |
| 9 | -import com.ruoyi.common.core.domain.BaseEntity; | |
| 10 | - | |
| 11 | -/** | |
| 12 | - * 字典类型表 sys_dict_type | |
| 13 | - * | |
| 14 | - * @author ruoyi | |
| 15 | - */ | |
| 16 | -public class SysDictType extends BaseEntity | |
| 17 | -{ | |
| 18 | - private static final long serialVersionUID = 1L; | |
| 19 | - | |
| 20 | - /** 字典主键 */ | |
| 21 | - @Excel(name = "字典主键", cellType = ColumnType.NUMERIC) | |
| 22 | - private Long dictId; | |
| 23 | - | |
| 24 | - /** 字典名称 */ | |
| 25 | - @Excel(name = "字典名称") | |
| 26 | - private String dictName; | |
| 27 | - | |
| 28 | - /** 字典类型 */ | |
| 29 | - @Excel(name = "字典类型") | |
| 30 | - private String dictType; | |
| 31 | - | |
| 32 | - /** 状态(0正常 1停用) */ | |
| 33 | - @Excel(name = "状态", readConverterExp = "0=正常,1=停用") | |
| 34 | - private String status; | |
| 35 | - | |
| 36 | - @NotBlank(message = "字典名称不能为空") | |
| 37 | - @Size(min = 0, max = 100, message = "字典类型名称长度不能超过100个字符") | |
| 38 | - public String getDictName() | |
| 39 | - { | |
| 40 | - return dictName; | |
| 41 | - } | |
| 42 | - | |
| 43 | - @NotBlank(message = "字典类型不能为空") | |
| 44 | - @Size(min = 0, max = 100, message = "字典类型类型长度不能超过100个字符") | |
| 45 | - public String getDictType() | |
| 46 | - { | |
| 47 | - return dictType; | |
| 48 | - } | |
| 49 | - | |
| 50 | -} |
ruoyi-system/src/main/resources/mapper/system/SysMenuMapper.xml
| ... | ... | @@ -83,11 +83,6 @@ |
| 83 | 83 | where m.status = '0' and r.status = '0' and ur.user_id = #{userId} |
| 84 | 84 | </select> |
| 85 | 85 | |
| 86 | - <select id="selectMenuById" parameterType="Long" resultMap="SysMenuResult"> | |
| 87 | - <include refid="selectMenuVo"/> | |
| 88 | - where menu_id = #{menuId} | |
| 89 | - </select> | |
| 90 | - | |
| 91 | 86 | <select id="hasChildByMenuId" resultType="Integer"> |
| 92 | 87 | select count(1) from sys_menu where parent_id = #{menuId} |
| 93 | 88 | </select> |
| ... | ... | @@ -97,8 +92,4 @@ |
| 97 | 92 | where menu_name=#{menuName} and parent_id = #{parentId} limit 1 |
| 98 | 93 | </select> |
| 99 | 94 | |
| 100 | - <delete id="deleteMenuById" parameterType="Long"> | |
| 101 | - delete from sys_menu where menu_id = #{menuId} | |
| 102 | - </delete> | |
| 103 | - | |
| 104 | 95 | </mapper> | ... | ... |
ruoyi-ui/src/store/modules/permission.js
| ... | ... | @@ -24,10 +24,8 @@ const permission = { |
| 24 | 24 | return new Promise(resolve => { |
| 25 | 25 | // 向后端请求路由数据 |
| 26 | 26 | getRouters().then(res => { |
| 27 | - // const sdata = JSON.parse(JSON.stringify(res.data)) | |
| 28 | - // const rdata = JSON.parse(JSON.stringify(res.data)) | |
| 29 | - const sdata = JSON.parse(JSON.stringify(res)) | |
| 30 | - const rdata = JSON.parse(JSON.stringify(res)) | |
| 27 | + const sdata = JSON.parse(JSON.stringify(res.data)) | |
| 28 | + const rdata = JSON.parse(JSON.stringify(res.data)) | |
| 31 | 29 | const sidebarRoutes = filterAsyncRouter(sdata) |
| 32 | 30 | const rewriteRoutes = filterAsyncRouter(rdata, true) |
| 33 | 31 | rewriteRoutes.push({ path: '*', redirect: '/404', hidden: true }) | ... | ... |
ruoyi-ui/src/store/modules/user.js
| ... | ... | @@ -50,8 +50,10 @@ const user = { |
| 50 | 50 | GetInfo({ commit, state }) { |
| 51 | 51 | return new Promise((resolve, reject) => { |
| 52 | 52 | getInfo(state.token).then(res => { |
| 53 | + res = res.data; // 读取 data 数据 | |
| 53 | 54 | const user = res.user |
| 54 | 55 | const avatar = user.avatar === "" ? require("@/assets/images/profile.jpg") : process.env.VUE_APP_BASE_API + user.avatar; |
| 56 | + debugger | |
| 55 | 57 | if (res.roles && res.roles.length > 0) { // 验证返回的roles是否是一个非空数组 |
| 56 | 58 | commit('SET_ROLES', res.roles) |
| 57 | 59 | commit('SET_PERMISSIONS', res.permissions) | ... | ... |
ruoyi-ui/src/utils/request.js
ruoyi-ui/src/views/system/menu/index.vue
| ... | ... | @@ -51,8 +51,8 @@ |
| 51 | 51 | <svg-icon :icon-class="scope.row.icon" /> |
| 52 | 52 | </template> |
| 53 | 53 | </el-table-column> |
| 54 | - <el-table-column prop="orderNum" label="排序" width="60"></el-table-column> | |
| 55 | - <el-table-column prop="perms" label="权限标识" :show-overflow-tooltip="true"></el-table-column> | |
| 54 | + <el-table-column prop="sort" label="排序" width="60"></el-table-column> | |
| 55 | + <el-table-column prop="permission" label="权限标识" :show-overflow-tooltip="true"></el-table-column> | |
| 56 | 56 | <el-table-column prop="component" label="组件路径" :show-overflow-tooltip="true"></el-table-column> |
| 57 | 57 | <el-table-column prop="status" label="状态" :formatter="statusFormat" width="80"></el-table-column> |
| 58 | 58 | <el-table-column label="创建时间" align="center" prop="createTime"> |
| ... | ... | @@ -62,16 +62,16 @@ |
| 62 | 62 | </el-table-column> |
| 63 | 63 | <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> |
| 64 | 64 | <template slot-scope="scope"> |
| 65 | - <el-button size="mini" | |
| 66 | - type="text" | |
| 67 | - icon="el-icon-edit" | |
| 65 | + <el-button size="mini" | |
| 66 | + type="text" | |
| 67 | + icon="el-icon-edit" | |
| 68 | 68 | @click="handleUpdate(scope.row)" |
| 69 | 69 | v-hasPermi="['system:menu:edit']" |
| 70 | 70 | >修改</el-button> |
| 71 | - <el-button | |
| 72 | - size="mini" | |
| 73 | - type="text" | |
| 74 | - icon="el-icon-plus" | |
| 71 | + <el-button | |
| 72 | + size="mini" | |
| 73 | + type="text" | |
| 74 | + icon="el-icon-plus" | |
| 75 | 75 | @click="handleAdd(scope.row)" |
| 76 | 76 | v-hasPermi="['system:menu:add']" |
| 77 | 77 | >新增</el-button> |
| ... | ... | @@ -104,14 +104,14 @@ |
| 104 | 104 | <el-col :span="24"> |
| 105 | 105 | <el-form-item label="菜单类型" prop="menuType"> |
| 106 | 106 | <el-radio-group v-model="form.menuType"> |
| 107 | - <el-radio label="M">目录</el-radio> | |
| 108 | - <el-radio label="C">菜单</el-radio> | |
| 109 | - <el-radio label="F">按钮</el-radio> | |
| 107 | + <el-radio label="1">目录</el-radio> | |
| 108 | + <el-radio label="2">菜单</el-radio> | |
| 109 | + <el-radio label="3">按钮</el-radio> | |
| 110 | 110 | </el-radio-group> |
| 111 | 111 | </el-form-item> |
| 112 | 112 | </el-col> |
| 113 | 113 | <el-col :span="24"> |
| 114 | - <el-form-item v-if="form.menuType != 'F'" label="菜单图标"> | |
| 114 | + <el-form-item v-if="form.menuType != '3'" label="菜单图标"> | |
| 115 | 115 | <el-popover |
| 116 | 116 | placement="bottom-start" |
| 117 | 117 | width="460" |
| ... | ... | @@ -143,7 +143,7 @@ |
| 143 | 143 | </el-form-item> |
| 144 | 144 | </el-col> |
| 145 | 145 | <el-col :span="12"> |
| 146 | - <el-form-item v-if="form.menuType != 'F'" label="是否外链"> | |
| 146 | + <el-form-item v-if="form.menuType != '3'" label="是否外链"> | |
| 147 | 147 | <el-radio-group v-model="form.isFrame"> |
| 148 | 148 | <el-radio label="0">是</el-radio> |
| 149 | 149 | <el-radio label="1">否</el-radio> |
| ... | ... | @@ -151,22 +151,22 @@ |
| 151 | 151 | </el-form-item> |
| 152 | 152 | </el-col> |
| 153 | 153 | <el-col :span="12"> |
| 154 | - <el-form-item v-if="form.menuType != 'F'" label="路由地址" prop="path"> | |
| 154 | + <el-form-item v-if="form.menuType != '3'" label="路由地址" prop="path"> | |
| 155 | 155 | <el-input v-model="form.path" placeholder="请输入路由地址" /> |
| 156 | 156 | </el-form-item> |
| 157 | 157 | </el-col> |
| 158 | - <el-col :span="12" v-if="form.menuType == 'C'"> | |
| 158 | + <el-col :span="12" v-if="form.menuType == '2'"> | |
| 159 | 159 | <el-form-item label="组件路径" prop="component"> |
| 160 | 160 | <el-input v-model="form.component" placeholder="请输入组件路径" /> |
| 161 | 161 | </el-form-item> |
| 162 | 162 | </el-col> |
| 163 | 163 | <el-col :span="12"> |
| 164 | - <el-form-item v-if="form.menuType != 'M'" label="权限标识"> | |
| 164 | + <el-form-item v-if="form.menuType != '1'" label="权限标识"> | |
| 165 | 165 | <el-input v-model="form.perms" placeholder="请权限标识" maxlength="50" /> |
| 166 | 166 | </el-form-item> |
| 167 | 167 | </el-col> |
| 168 | 168 | <el-col :span="12"> |
| 169 | - <el-form-item v-if="form.menuType != 'F'" label="显示状态"> | |
| 169 | + <el-form-item v-if="form.menuType != '3'" label="显示状态"> | |
| 170 | 170 | <el-radio-group v-model="form.visible"> |
| 171 | 171 | <el-radio |
| 172 | 172 | v-for="dict in visibleOptions" |
| ... | ... | @@ -177,7 +177,7 @@ |
| 177 | 177 | </el-form-item> |
| 178 | 178 | </el-col> |
| 179 | 179 | <el-col :span="12"> |
| 180 | - <el-form-item v-if="form.menuType != 'F'" label="菜单状态"> | |
| 180 | + <el-form-item v-if="form.menuType != '3'" label="菜单状态"> | |
| 181 | 181 | <el-radio-group v-model="form.status"> |
| 182 | 182 | <el-radio |
| 183 | 183 | v-for="dict in statusOptions" |
| ... | ... | @@ -188,7 +188,7 @@ |
| 188 | 188 | </el-form-item> |
| 189 | 189 | </el-col> |
| 190 | 190 | <el-col :span="12"> |
| 191 | - <el-form-item v-if="form.menuType == 'C'" label="是否缓存"> | |
| 191 | + <el-form-item v-if="form.menuType == '2'" label="是否缓存"> | |
| 192 | 192 | <el-radio-group v-model="form.isCache"> |
| 193 | 193 | <el-radio label="0">缓存</el-radio> |
| 194 | 194 | <el-radio label="1">不缓存</el-radio> |
| ... | ... | @@ -297,14 +297,14 @@ export default { |
| 297 | 297 | }, |
| 298 | 298 | // 显示状态字典翻译 |
| 299 | 299 | visibleFormat(row, column) { |
| 300 | - if (row.menuType == "F") { | |
| 300 | + if (row.menuType == "3") { | |
| 301 | 301 | return ""; |
| 302 | 302 | } |
| 303 | 303 | return this.selectDictLabel(this.visibleOptions, row.visible); |
| 304 | 304 | }, |
| 305 | 305 | // 菜单状态字典翻译 |
| 306 | 306 | statusFormat(row, column) { |
| 307 | - if (row.menuType == "F") { | |
| 307 | + if (row.menuType == "3") { | |
| 308 | 308 | return ""; |
| 309 | 309 | } |
| 310 | 310 | return this.selectDictLabel(this.statusOptions, row.status); |
| ... | ... | @@ -321,7 +321,7 @@ export default { |
| 321 | 321 | parentId: 0, |
| 322 | 322 | menuName: undefined, |
| 323 | 323 | icon: undefined, |
| 324 | - menuType: "M", | |
| 324 | + menuType: "1", | |
| 325 | 325 | orderNum: undefined, |
| 326 | 326 | isFrame: "1", |
| 327 | 327 | isCache: "0", |
| ... | ... | @@ -396,4 +396,4 @@ export default { |
| 396 | 396 | } |
| 397 | 397 | } |
| 398 | 398 | }; |
| 399 | -</script> | |
| 400 | 399 | \ No newline at end of file |
| 400 | +</script> | ... | ... |
src/main/java/cn/iocoder/dashboard/common/enums/CommonStatusEnum.java
| ... | ... | @@ -12,13 +12,13 @@ import lombok.Getter; |
| 12 | 12 | @AllArgsConstructor |
| 13 | 13 | public enum CommonStatusEnum { |
| 14 | 14 | |
| 15 | - ENABLE("0", "开启"), | |
| 16 | - DISABLE("1", "关闭"); | |
| 15 | + ENABLE(0, "开启"), | |
| 16 | + DISABLE(1, "关闭"); | |
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * 状态值 |
| 20 | 20 | */ |
| 21 | - private final String status; | |
| 21 | + private final Integer status; | |
| 22 | 22 | /** |
| 23 | 23 | * 状态名 |
| 24 | 24 | */ | ... | ... |
src/main/java/cn/iocoder/dashboard/common/enums/OldCommonStatusEnum.java
0 → 100644
| 1 | +package cn.iocoder.dashboard.common.enums; | |
| 2 | + | |
| 3 | +import lombok.AllArgsConstructor; | |
| 4 | +import lombok.Getter; | |
| 5 | + | |
| 6 | +/** | |
| 7 | + * 通用状态枚举 | |
| 8 | + * | |
| 9 | + * @author 芋道源码 | |
| 10 | + */ | |
| 11 | +@Getter | |
| 12 | +@AllArgsConstructor | |
| 13 | +public enum OldCommonStatusEnum { | |
| 14 | + | |
| 15 | + ENABLE("0", "开启"), | |
| 16 | + DISABLE("1", "关闭"); | |
| 17 | + | |
| 18 | + /** | |
| 19 | + * 状态值 | |
| 20 | + */ | |
| 21 | + private final String status; | |
| 22 | + /** | |
| 23 | + * 状态名 | |
| 24 | + */ | |
| 25 | + private final String name; | |
| 26 | + | |
| 27 | +} | ... | ... |
src/main/java/cn/iocoder/dashboard/framework/web/core/handler/GlobalExceptionHandler.java
| ... | ... | @@ -4,7 +4,6 @@ import cn.iocoder.dashboard.common.exception.GlobalException; |
| 4 | 4 | import cn.iocoder.dashboard.common.exception.ServiceException; |
| 5 | 5 | import cn.iocoder.dashboard.common.pojo.CommonResult; |
| 6 | 6 | import lombok.extern.slf4j.Slf4j; |
| 7 | -import org.springframework.beans.factory.annotation.Value; | |
| 8 | 7 | import org.springframework.validation.BindException; |
| 9 | 8 | import org.springframework.validation.FieldError; |
| 10 | 9 | import org.springframework.web.HttpRequestMethodNotSupportedException; | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/SysMenuController.http
0 → 100644
src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/SysMenuController.java
0 → 100644
| 1 | +package cn.iocoder.dashboard.modules.system.controller.permission; | |
| 2 | + | |
| 3 | +import cn.iocoder.dashboard.common.pojo.CommonResult; | |
| 4 | +import cn.iocoder.dashboard.modules.system.controller.permission.vo.SysMenuListReqVO; | |
| 5 | +import cn.iocoder.dashboard.modules.system.controller.permission.vo.SysMenuRespVO; | |
| 6 | +import cn.iocoder.dashboard.modules.system.service.permission.SysMenuService; | |
| 7 | +import io.swagger.annotations.Api; | |
| 8 | +import org.springframework.web.bind.annotation.GetMapping; | |
| 9 | +import org.springframework.web.bind.annotation.RequestMapping; | |
| 10 | +import org.springframework.web.bind.annotation.RestController; | |
| 11 | + | |
| 12 | +import javax.annotation.Resource; | |
| 13 | +import java.util.List; | |
| 14 | + | |
| 15 | +import static cn.iocoder.dashboard.common.pojo.CommonResult.success; | |
| 16 | + | |
| 17 | +@Api(tags = "菜单 API") | |
| 18 | +@RestController | |
| 19 | +@RequestMapping("/system/menu") | |
| 20 | +public class SysMenuController { | |
| 21 | + | |
| 22 | + @Resource | |
| 23 | + private SysMenuService menuService; | |
| 24 | + | |
| 25 | + /** | |
| 26 | + * 获取菜单列表 | |
| 27 | + */ | |
| 28 | +// @PreAuthorize("@ss.hasPermi('system:menu:list')") | |
| 29 | + @GetMapping("/list") | |
| 30 | + public CommonResult<List<SysMenuRespVO>> list(SysMenuListReqVO reqVO) { | |
| 31 | + return success(menuService.listMenus(reqVO)); | |
| 32 | + } | |
| 33 | +// | |
| 34 | +// /** | |
| 35 | +// * 根据菜单编号获取详细信息 | |
| 36 | +// */ | |
| 37 | +// @PreAuthorize("@ss.hasPermi('system:menu:query')") | |
| 38 | +// @GetMapping(value = "/{menuId}") | |
| 39 | +// public AjaxResult getInfo(@PathVariable Long menuId) { | |
| 40 | +// return AjaxResult.success(menuService.selectMenuById(menuId)); | |
| 41 | +// } | |
| 42 | +// | |
| 43 | +// /** | |
| 44 | +// * 获取菜单下拉树列表 | |
| 45 | +// */ | |
| 46 | +// @GetMapping("/treeselect") | |
| 47 | +// public AjaxResult treeselect(SysMenu menu) { | |
| 48 | +// LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); | |
| 49 | +// Long userId = loginUser.getUser().getUserId(); | |
| 50 | +// List<SysMenu> menus = menuService.selectMenuList(menu, userId); | |
| 51 | +// return AjaxResult.success(menuService.buildMenuTreeSelect(menus)); | |
| 52 | +// } | |
| 53 | +// | |
| 54 | +// /** | |
| 55 | +// * 加载对应角色菜单列表树 | |
| 56 | +// */ | |
| 57 | +// @GetMapping(value = "/roleMenuTreeselect/{roleId}") | |
| 58 | +// public AjaxResult roleMenuTreeselect(@PathVariable("roleId") Long roleId) { | |
| 59 | +// LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); | |
| 60 | +// List<SysMenu> menus = menuService.selectMenuList(loginUser.getUser().getUserId()); | |
| 61 | +// AjaxResult ajax = AjaxResult.success(); | |
| 62 | +// ajax.put("checkedKeys", menuService.selectMenuListByRoleId(roleId)); | |
| 63 | +// ajax.put("menus", menuService.buildMenuTreeSelect(menus)); | |
| 64 | +// return ajax; | |
| 65 | +// } | |
| 66 | +// | |
| 67 | +// /** | |
| 68 | +// * 新增菜单 | |
| 69 | +// */ | |
| 70 | +// @PreAuthorize("@ss.hasPermi('system:menu:add')") | |
| 71 | +// @Log(title = "菜单管理", businessType = BusinessType.INSERT) | |
| 72 | +// @PostMapping | |
| 73 | +// public AjaxResult add(@Validated @RequestBody SysMenu menu) { | |
| 74 | +// if (UserConstants.NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu))) { | |
| 75 | +// return AjaxResult.error("新增菜单'" + menu.getMenuName() + "'失败,菜单名称已存在"); | |
| 76 | +// } else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) | |
| 77 | +// && !StringUtils.startsWithAny(menu.getPath(), Constants.HTTP, Constants.HTTPS)) { | |
| 78 | +// return AjaxResult.error("新增菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头"); | |
| 79 | +// } | |
| 80 | +// menu.setCreateBy(SecurityUtils.getUsername()); | |
| 81 | +// return toAjax(menuService.insertMenu(menu)); | |
| 82 | +// } | |
| 83 | +// | |
| 84 | +// /** | |
| 85 | +// * 修改菜单 | |
| 86 | +// */ | |
| 87 | +// @PreAuthorize("@ss.hasPermi('system:menu:edit')") | |
| 88 | +// @Log(title = "菜单管理", businessType = BusinessType.UPDATE) | |
| 89 | +// @PutMapping | |
| 90 | +// public AjaxResult edit(@Validated @RequestBody SysMenu menu) { | |
| 91 | +// if (UserConstants.NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu))) { | |
| 92 | +// return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在"); | |
| 93 | +// } else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) | |
| 94 | +// && !StringUtils.startsWithAny(menu.getPath(), Constants.HTTP, Constants.HTTPS)) { | |
| 95 | +// return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头"); | |
| 96 | +// } else if (menu.getMenuId().equals(menu.getParentId())) { | |
| 97 | +// return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,上级菜单不能选择自己"); | |
| 98 | +// } | |
| 99 | +// menu.setUpdateBy(SecurityUtils.getUsername()); | |
| 100 | +// return toAjax(menuService.updateMenu(menu)); | |
| 101 | +// } | |
| 102 | +// | |
| 103 | +// /** | |
| 104 | +// * 删除菜单 | |
| 105 | +// */ | |
| 106 | +// @PreAuthorize("@ss.hasPermi('system:menu:remove')") | |
| 107 | +// @Log(title = "菜单管理", businessType = BusinessType.DELETE) | |
| 108 | +// @DeleteMapping("/{menuId}") | |
| 109 | +// public AjaxResult remove(@PathVariable("menuId") Long menuId) { | |
| 110 | +// if (menuService.hasChildByMenuId(menuId)) { | |
| 111 | +// return AjaxResult.error("存在子菜单,不允许删除"); | |
| 112 | +// } | |
| 113 | +// if (menuService.checkMenuExistRole(menuId)) { | |
| 114 | +// return AjaxResult.error("菜单已分配,不允许删除"); | |
| 115 | +// } | |
| 116 | +// return toAjax(menuService.deleteMenuById(menuId)); | |
| 117 | +// } | |
| 118 | + | |
| 119 | +} | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/SysMenuBaseVO.java
0 → 100644
| 1 | +package cn.iocoder.dashboard.modules.system.controller.permission.vo; | |
| 2 | + | |
| 3 | +import io.swagger.annotations.ApiModelProperty; | |
| 4 | +import lombok.Data; | |
| 5 | + | |
| 6 | +import javax.validation.constraints.NotBlank; | |
| 7 | +import javax.validation.constraints.NotNull; | |
| 8 | +import javax.validation.constraints.Size; | |
| 9 | + | |
| 10 | +/** | |
| 11 | + * 菜单 Base VO,提供给添加、修改、详细的子 VO 使用 | |
| 12 | + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | |
| 13 | + */ | |
| 14 | +@Data | |
| 15 | +public class SysMenuBaseVO { | |
| 16 | + | |
| 17 | + @ApiModelProperty(value = "菜单名称", required = true, example = "芋道") | |
| 18 | + @NotBlank(message = "菜单名称不能为空") | |
| 19 | + @Size(max = 50, message = "菜单名称长度不能超过50个字符") | |
| 20 | + private String menuName; | |
| 21 | + | |
| 22 | + @ApiModelProperty(value = "权限标识", example = "sys:menu:add", notes = "仅菜单类型为按钮时,才需要传递") | |
| 23 | + @Size(max = 100) | |
| 24 | + private String permission; | |
| 25 | + | |
| 26 | + @ApiModelProperty(value = "类型", required = true, example = "1", notes = "参见 MenuTypeEnum 枚举类") | |
| 27 | + @NotBlank(message = "菜单类型不能为空") | |
| 28 | + private Integer menuType; | |
| 29 | + | |
| 30 | + @ApiModelProperty(value = "显示顺序不能为空", required = true, example = "1024") | |
| 31 | + @NotBlank(message = "显示顺序不能为空") | |
| 32 | + private String sort; | |
| 33 | + | |
| 34 | + @ApiModelProperty(value = "父菜单 ID", required = true, example = "1024") | |
| 35 | + @NotNull(message = "父菜单 ID 不能为空") | |
| 36 | + private Long parentId; | |
| 37 | + | |
| 38 | + @ApiModelProperty(value = "路由地址", example = "post", notes = "仅菜单类型为菜单或者目录时,才需要传") | |
| 39 | + @Size(max = 200, message = "路由地址不能超过200个字符") | |
| 40 | + private String path; | |
| 41 | + | |
| 42 | + @ApiModelProperty(value = "菜单图标", example = "/menu/list", notes = "仅菜单类型为菜单或者目录时,才需要传") | |
| 43 | + private String icon; | |
| 44 | + | |
| 45 | + /** | |
| 46 | + * 组件路径 | |
| 47 | + */ | |
| 48 | + @ApiModelProperty(value = "组件路径", example = "system/post/index", notes = "仅菜单类型为菜单时,才需要传") | |
| 49 | + @Size(max = 200, message = "组件路径不能超过255个字符") | |
| 50 | + private String component; | |
| 51 | + | |
| 52 | +} | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/SysMenuCreateReqVO.java
0 → 100644
src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/SysMenuListReqVO.java
0 → 100644
| 1 | +package cn.iocoder.dashboard.modules.system.controller.permission.vo; | |
| 2 | + | |
| 3 | +import io.swagger.annotations.ApiModel; | |
| 4 | +import io.swagger.annotations.ApiModelProperty; | |
| 5 | +import lombok.AllArgsConstructor; | |
| 6 | +import lombok.Builder; | |
| 7 | +import lombok.Data; | |
| 8 | +import lombok.NoArgsConstructor; | |
| 9 | + | |
| 10 | +@ApiModel("菜单列表 Request VO") | |
| 11 | +@Data | |
| 12 | +public class SysMenuListReqVO { | |
| 13 | + | |
| 14 | + @ApiModelProperty(value = "菜单名称", example = "芋道", notes = "模糊匹配") | |
| 15 | + private String menuName; | |
| 16 | + | |
| 17 | + @ApiModelProperty(value = "展示状态", example = "1", notes = "参见 CommonStatusEnum 枚举类") | |
| 18 | + private Integer status; | |
| 19 | + | |
| 20 | +} | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/SysMenuRespVO.java
0 → 100644
| 1 | +package cn.iocoder.dashboard.modules.system.controller.permission.vo; | |
| 2 | + | |
| 3 | +import io.swagger.annotations.ApiModel; | |
| 4 | +import io.swagger.annotations.ApiModelProperty; | |
| 5 | +import lombok.AllArgsConstructor; | |
| 6 | +import lombok.Data; | |
| 7 | +import lombok.EqualsAndHashCode; | |
| 8 | +import lombok.NoArgsConstructor; | |
| 9 | + | |
| 10 | +import java.util.Date; | |
| 11 | + | |
| 12 | +@ApiModel("菜单信息 Response VO") | |
| 13 | +@Data | |
| 14 | +@NoArgsConstructor | |
| 15 | +@AllArgsConstructor | |
| 16 | +@EqualsAndHashCode(callSuper = true) | |
| 17 | +public class SysMenuRespVO extends SysMenuBaseVO { | |
| 18 | + | |
| 19 | + @ApiModelProperty(value = "菜单编号", required = true, example = "1024") | |
| 20 | + private Integer menuId; | |
| 21 | + | |
| 22 | + @ApiModelProperty(value = "创建时间", required = true, example = "时间戳格式") | |
| 23 | + private Date createTime; | |
| 24 | + | |
| 25 | +} | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/SysMenuUpdateReqVO.java
0 → 100644
| 1 | +package cn.iocoder.dashboard.modules.system.controller.permission.vo; | |
| 2 | + | |
| 3 | +import io.swagger.annotations.ApiModel; | |
| 4 | +import io.swagger.annotations.ApiModelProperty; | |
| 5 | +import lombok.*; | |
| 6 | + | |
| 7 | +import javax.validation.constraints.NotNull; | |
| 8 | + | |
| 9 | +@ApiModel("菜单更新 Request VO") | |
| 10 | +@Data | |
| 11 | +@EqualsAndHashCode(callSuper = true) | |
| 12 | +public class SysMenuUpdateReqVO extends SysMenuBaseVO { | |
| 13 | + | |
| 14 | + @ApiModelProperty(value = "菜单编号", required = true, example = "1024") | |
| 15 | + @NotNull(message = "菜单编号不能为空") | |
| 16 | + private Integer menuId; | |
| 17 | + | |
| 18 | +} | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/system/convert/permission/SysMenuConvert.java
0 → 100644
| 1 | +package cn.iocoder.dashboard.modules.system.convert.permission; | |
| 2 | + | |
| 3 | +import cn.iocoder.dashboard.modules.system.controller.permission.vo.SysMenuRespVO; | |
| 4 | +import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.permission.SysMenuDO; | |
| 5 | +import org.mapstruct.Mapper; | |
| 6 | +import org.mapstruct.factory.Mappers; | |
| 7 | + | |
| 8 | +import java.util.List; | |
| 9 | + | |
| 10 | +@Mapper | |
| 11 | +public interface SysMenuConvert { | |
| 12 | + | |
| 13 | + SysMenuConvert INSTANCE = Mappers.getMapper(SysMenuConvert.class); | |
| 14 | + | |
| 15 | + List<SysMenuRespVO> convertList(List<SysMenuDO> list); | |
| 16 | + | |
| 17 | +} | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/dataobject/dict/SysDictData.java
0 → 100644
| 1 | +package cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.dict; | |
| 2 | + | |
| 3 | +import cn.iocoder.dashboard.common.enums.CommonStatusEnum; | |
| 4 | +import cn.iocoder.dashboard.framework.excel.Excel; | |
| 5 | +import cn.iocoder.dashboard.framework.mybatis.core.BaseDO; | |
| 6 | +import com.baomidou.mybatisplus.annotation.TableId; | |
| 7 | +import com.baomidou.mybatisplus.annotation.TableName; | |
| 8 | +import lombok.Data; | |
| 9 | +import lombok.EqualsAndHashCode; | |
| 10 | + | |
| 11 | +import javax.validation.constraints.NotBlank; | |
| 12 | +import javax.validation.constraints.Size; | |
| 13 | + | |
| 14 | +/** | |
| 15 | + * 字典数据表 | |
| 16 | + * | |
| 17 | + * @author ruoyi | |
| 18 | + */ | |
| 19 | +@TableName("sys_dict_data") | |
| 20 | +@Data | |
| 21 | +@EqualsAndHashCode(callSuper = true) | |
| 22 | +public class SysDictData extends BaseDO { | |
| 23 | + | |
| 24 | + /** | |
| 25 | + * 字典编码 | |
| 26 | + */ | |
| 27 | + @TableId | |
| 28 | + @Excel(name = "字典编码", cellType = Excel.ColumnType.NUMERIC) | |
| 29 | + private Long dictCode; | |
| 30 | + /** | |
| 31 | + * 字典排序 | |
| 32 | + */ | |
| 33 | + @Excel(name = "字典排序", cellType = Excel.ColumnType.NUMERIC) | |
| 34 | + private Long dictSort; | |
| 35 | + /** | |
| 36 | + * 字典标签 | |
| 37 | + */ | |
| 38 | + @Excel(name = "字典标签") | |
| 39 | + @NotBlank(message = "字典标签不能为空") | |
| 40 | + @Size(max = 100, message = "字典标签长度不能超过100个字符") | |
| 41 | + private String dictLabel; | |
| 42 | + /** | |
| 43 | + * 字典键值 | |
| 44 | + */ | |
| 45 | + @Excel(name = "字典键值") | |
| 46 | + @NotBlank(message = "字典键值不能为空") | |
| 47 | + @Size(max = 100, message = "字典键值长度不能超过100个字符") | |
| 48 | + private String dictValue; | |
| 49 | + /** | |
| 50 | + * 字典类型 | |
| 51 | + */ | |
| 52 | + @Excel(name = "字典类型") | |
| 53 | + @NotBlank(message = "字典类型不能为空") | |
| 54 | + @Size(max = 100, message = "字典类型长度不能超过100个字符") | |
| 55 | + private String dictType; | |
| 56 | + /** | |
| 57 | + * 状态 | |
| 58 | + * | |
| 59 | + * 枚举 {@link CommonStatusEnum} | |
| 60 | + */ | |
| 61 | + @Excel(name = "状态", readConverterExp = "0=正常,1=停用") | |
| 62 | + private Integer status; | |
| 63 | + /** | |
| 64 | + * 备注 | |
| 65 | + */ | |
| 66 | + private String remark; | |
| 67 | + | |
| 68 | +} | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/dataobject/dict/SysDictTypeDO.java
0 → 100644
| 1 | +package cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.dict; | |
| 2 | + | |
| 3 | +import cn.iocoder.dashboard.common.enums.CommonStatusEnum; | |
| 4 | +import cn.iocoder.dashboard.framework.excel.Excel; | |
| 5 | +import cn.iocoder.dashboard.framework.mybatis.core.BaseDO; | |
| 6 | +import com.baomidou.mybatisplus.annotation.TableId; | |
| 7 | +import com.baomidou.mybatisplus.annotation.TableName; | |
| 8 | +import lombok.Data; | |
| 9 | +import lombok.EqualsAndHashCode; | |
| 10 | + | |
| 11 | +import javax.validation.constraints.NotBlank; | |
| 12 | +import javax.validation.constraints.Size; | |
| 13 | + | |
| 14 | +/** | |
| 15 | + * 字典类型表 | |
| 16 | + * | |
| 17 | + * @author ruoyi | |
| 18 | + */ | |
| 19 | +@TableName("sys_dict_type") | |
| 20 | +@Data | |
| 21 | +@EqualsAndHashCode(callSuper = true) | |
| 22 | +public class SysDictTypeDO extends BaseDO { | |
| 23 | + | |
| 24 | + /** | |
| 25 | + * 字典主键 | |
| 26 | + */ | |
| 27 | + @TableId | |
| 28 | + @Excel(name = "字典主键", cellType = Excel.ColumnType.NUMERIC) | |
| 29 | + private Long dictId; | |
| 30 | + | |
| 31 | + /** | |
| 32 | + * 字典名称 | |
| 33 | + */ | |
| 34 | + @Excel(name = "字典名称") | |
| 35 | + @NotBlank(message = "字典名称不能为空") | |
| 36 | + @Size(max = 100, message = "字典类型名称长度不能超过100个字符") | |
| 37 | + private String dictName; | |
| 38 | + | |
| 39 | + /** | |
| 40 | + * 字典类型 | |
| 41 | + */ | |
| 42 | + @Excel(name = "字典类型") | |
| 43 | + @NotBlank(message = "字典类型不能为空") | |
| 44 | + @Size(max = 100, message = "字典类型类型长度不能超过100个字符") | |
| 45 | + private String dictType; | |
| 46 | + | |
| 47 | + /** | |
| 48 | + * 状态 | |
| 49 | + * | |
| 50 | + * 枚举 {@link CommonStatusEnum} | |
| 51 | + */ | |
| 52 | + @Excel(name = "状态", readConverterExp = "0=正常,1=停用") | |
| 53 | + private Integer status; | |
| 54 | + | |
| 55 | +} | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/dataobject/permission/SysMenuDO.java
| 1 | 1 | package cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.permission; |
| 2 | 2 | |
| 3 | +import cn.iocoder.dashboard.common.enums.CommonStatusEnum; | |
| 3 | 4 | import cn.iocoder.dashboard.framework.mybatis.core.BaseDO; |
| 5 | +import cn.iocoder.dashboard.modules.system.enums.permission.MenuTypeEnum; | |
| 4 | 6 | import com.baomidou.mybatisplus.annotation.TableId; |
| 5 | 7 | import com.baomidou.mybatisplus.annotation.TableName; |
| 6 | 8 | import lombok.Data; |
| 7 | 9 | import lombok.EqualsAndHashCode; |
| 8 | 10 | |
| 9 | -import javax.validation.constraints.NotBlank; | |
| 10 | -import javax.validation.constraints.Size; | |
| 11 | - | |
| 12 | 11 | /** |
| 13 | - * 菜单权限表 | |
| 12 | + * 菜单 DO | |
| 14 | 13 | * |
| 15 | 14 | * @author ruoyi |
| 16 | 15 | */ |
| ... | ... | @@ -24,57 +23,52 @@ public class SysMenuDO extends BaseDO { |
| 24 | 23 | */ |
| 25 | 24 | @TableId |
| 26 | 25 | private Long menuId; |
| 27 | - | |
| 28 | 26 | /** |
| 29 | 27 | * 菜单名称 |
| 30 | 28 | */ |
| 31 | - @NotBlank(message = "菜单名称不能为空") | |
| 32 | - @Size(max = 50, message = "菜单名称长度不能超过50个字符") | |
| 33 | 29 | private String menuName; |
| 34 | - | |
| 35 | 30 | /** |
| 36 | - * 父菜单ID | |
| 31 | + * 权限标识 | |
| 32 | + * | |
| 33 | + * 一般格式为:${系统}:${模块}:${操作} | |
| 34 | + * 例如说:system:admin:add,即 system 服务的添加管理员。 | |
| 35 | + * | |
| 36 | + * 当我们把该 SysMenuDO 赋予给角色后,意味着该角色有该资源: | |
| 37 | + * - 对于后端,配合 @PreAuthorize 注解,配置 API 接口需要该权限,从而对 API 接口进行权限控制。 | |
| 38 | + * - 对于前端,配合前端标签,配置按钮是否展示,避免用户没有该权限时,结果可以看到该操作。 | |
| 37 | 39 | */ |
| 38 | - private Long parentId; | |
| 39 | - | |
| 40 | + private String permission; | |
| 40 | 41 | /** |
| 41 | - * 显示顺序 | |
| 42 | + * 菜单类型 | |
| 43 | + * | |
| 44 | + * 枚举 {@link MenuTypeEnum} | |
| 42 | 45 | */ |
| 43 | - @NotBlank(message = "显示顺序不能为空") | |
| 44 | - private String orderNum; | |
| 45 | - | |
| 46 | + private Integer menuType; | |
| 46 | 47 | /** |
| 47 | - * 路由地址 | |
| 48 | + * 显示顺序 | |
| 48 | 49 | */ |
| 49 | - @Size(max = 200, message = "路由地址不能超过200个字符") | |
| 50 | - private String path; | |
| 51 | - | |
| 50 | + private String sort; | |
| 52 | 51 | /** |
| 53 | - * 组件路径 | |
| 52 | + * 父菜单ID | |
| 54 | 53 | */ |
| 55 | - @Size(max = 200, message = "组件路径不能超过255个字符") | |
| 56 | - private String component; | |
| 57 | - | |
| 54 | + private Long parentId; | |
| 58 | 55 | /** |
| 59 | - * 类型(M目录 C菜单 F按钮) | |
| 56 | + * 路由地址 | |
| 60 | 57 | */ |
| 61 | - @NotBlank(message = "菜单类型不能为空") | |
| 62 | - private String menuType; | |
| 63 | - | |
| 58 | + private String path; | |
| 64 | 59 | /** |
| 65 | - * 菜单状态(0显示 1隐藏) | |
| 60 | + * 菜单图标 | |
| 66 | 61 | */ |
| 67 | - private String status; | |
| 68 | - | |
| 62 | + private String icon; | |
| 69 | 63 | /** |
| 70 | - * 权限字符串 | |
| 64 | + * 组件路径 | |
| 71 | 65 | */ |
| 72 | - @Size(max = 100, message = "权限标识长度不能超过100个字符") | |
| 73 | - private String permission; | |
| 74 | - | |
| 66 | + private String component; | |
| 75 | 67 | /** |
| 76 | - * 菜单图标 | |
| 68 | + * 状态 | |
| 69 | + * | |
| 70 | + * 枚举 {@link CommonStatusEnum} | |
| 77 | 71 | */ |
| 78 | - private String icon; | |
| 72 | + private Integer status; | |
| 79 | 73 | |
| 80 | 74 | } | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/system/enums/permission/MenuTypeEnum.java
| ... | ... | @@ -12,14 +12,14 @@ import lombok.Getter; |
| 12 | 12 | @AllArgsConstructor |
| 13 | 13 | public enum MenuTypeEnum { |
| 14 | 14 | |
| 15 | - DIR("M"), // 目录 | |
| 16 | - MENU("C"), // 菜单 | |
| 17 | - BUTTON("F") // 按钮 | |
| 15 | + DIR(1), // 目录 | |
| 16 | + MENU(2), // 菜单 | |
| 17 | + BUTTON(3) // 按钮 | |
| 18 | 18 | ; |
| 19 | 19 | |
| 20 | 20 | /** |
| 21 | 21 | * 类型 |
| 22 | 22 | */ |
| 23 | - private final String type; | |
| 23 | + private final Integer type; | |
| 24 | 24 | |
| 25 | 25 | } | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/system/service/auth/impl/SysAuthServiceImpl.java
| ... | ... | @@ -5,8 +5,8 @@ import cn.hutool.core.util.StrUtil; |
| 5 | 5 | import cn.iocoder.dashboard.common.enums.CommonStatusEnum; |
| 6 | 6 | import cn.iocoder.dashboard.framework.security.config.SecurityProperties; |
| 7 | 7 | import cn.iocoder.dashboard.framework.security.core.LoginUser; |
| 8 | -import cn.iocoder.dashboard.modules.system.controller.auth.vo.SysAuthPermissionInfoRespVO; | |
| 9 | 8 | import cn.iocoder.dashboard.modules.system.controller.auth.vo.SysAuthMenuRespVO; |
| 9 | +import cn.iocoder.dashboard.modules.system.controller.auth.vo.SysAuthPermissionInfoRespVO; | |
| 10 | 10 | import cn.iocoder.dashboard.modules.system.convert.auth.SysAuthConvert; |
| 11 | 11 | import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.permission.SysMenuDO; |
| 12 | 12 | import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.permission.SysRoleDO; |
| ... | ... | @@ -252,7 +252,7 @@ public class SysAuthServiceImpl implements SysAuthService { |
| 252 | 252 | |
| 253 | 253 | private static List<SysAuthMenuRespVO> buildRouterTree(List<SysMenuDO> menuList) { |
| 254 | 254 | // 排序,保证菜单的有序性 |
| 255 | - menuList.sort(Comparator.comparing(SysMenuDO::getOrderNum)); | |
| 255 | + menuList.sort(Comparator.comparing(SysMenuDO::getSort)); | |
| 256 | 256 | // 构建菜单树 |
| 257 | 257 | // 使用 LinkedHashMap 的原因,是为了排序 。实际也可以用 Stream API ,就是太丑了。 |
| 258 | 258 | Map<Long, SysAuthMenuRespVO> treeNodeMap = new LinkedHashMap<>(); | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/system/service/permission/SysMenuService.java
| 1 | 1 | package cn.iocoder.dashboard.modules.system.service.permission; |
| 2 | 2 | |
| 3 | +import cn.iocoder.dashboard.modules.system.controller.permission.vo.SysMenuListReqVO; | |
| 4 | +import cn.iocoder.dashboard.modules.system.controller.permission.vo.SysMenuRespVO; | |
| 3 | 5 | import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.permission.SysMenuDO; |
| 4 | 6 | |
| 5 | 7 | import java.util.Collection; |
| ... | ... | @@ -16,6 +18,14 @@ public interface SysMenuService { |
| 16 | 18 | void init(); |
| 17 | 19 | |
| 18 | 20 | /** |
| 21 | + * 筛选菜单列表 | |
| 22 | + * | |
| 23 | + * @param reqVO 筛选条件请求 VO | |
| 24 | + * @return 菜单列表 | |
| 25 | + */ | |
| 26 | + List<SysMenuRespVO> listMenus(SysMenuListReqVO reqVO); | |
| 27 | + | |
| 28 | + /** | |
| 19 | 29 | * 获得所有菜单,从缓存中 |
| 20 | 30 | * |
| 21 | 31 | * 任一参数为空时,则返回为空 |
| ... | ... | @@ -24,7 +34,7 @@ public interface SysMenuService { |
| 24 | 34 | * @param menusStatuses 菜单状态数组 |
| 25 | 35 | * @return 菜单列表 |
| 26 | 36 | */ |
| 27 | - List<SysMenuDO> listMenusFromCache(Collection<String> menuTypes, Collection<String> menusStatuses); | |
| 37 | + List<SysMenuDO> listMenusFromCache(Collection<Integer> menuTypes, Collection<Integer> menusStatuses); | |
| 28 | 38 | |
| 29 | 39 | /** |
| 30 | 40 | * 获得指定编号的菜单数组,从缓存中 |
| ... | ... | @@ -36,9 +46,7 @@ public interface SysMenuService { |
| 36 | 46 | * @param menusStatuses 菜单状态数组 |
| 37 | 47 | * @return 菜单数组 |
| 38 | 48 | */ |
| 39 | - List<SysMenuDO> listMenusFromCache(Collection<Long> menuIds, Collection<String> menuTypes, | |
| 40 | - Collection<String> menusStatuses); | |
| 41 | - | |
| 42 | - | |
| 49 | + List<SysMenuDO> listMenusFromCache(Collection<Long> menuIds, Collection<Integer> menuTypes, | |
| 50 | + Collection<Integer> menusStatuses); | |
| 43 | 51 | |
| 44 | 52 | } | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/system/service/permission/SysPermissionService.java
| ... | ... | @@ -29,8 +29,8 @@ public interface SysPermissionService { |
| 29 | 29 | * @param menusStatuses 菜单状态数组 |
| 30 | 30 | * @return 菜单列表 |
| 31 | 31 | */ |
| 32 | - List<SysMenuDO> listRoleMenusFromCache(Collection<Long> roleIds, Collection<String> menuTypes, | |
| 33 | - Collection<String> menusStatuses); | |
| 32 | + List<SysMenuDO> listRoleMenusFromCache(Collection<Long> roleIds, Collection<Integer> menuTypes, | |
| 33 | + Collection<Integer> menusStatuses); | |
| 34 | 34 | |
| 35 | 35 | /** |
| 36 | 36 | * 获得用户拥有的角色编号数组 | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/system/service/permission/impl/SysMenuServiceImpl.java
| 1 | 1 | package cn.iocoder.dashboard.modules.system.service.permission.impl; |
| 2 | 2 | |
| 3 | +import cn.iocoder.dashboard.modules.system.controller.permission.vo.SysMenuListReqVO; | |
| 4 | +import cn.iocoder.dashboard.modules.system.controller.permission.vo.SysMenuRespVO; | |
| 5 | +import cn.iocoder.dashboard.modules.system.convert.permission.SysMenuConvert; | |
| 3 | 6 | import cn.iocoder.dashboard.modules.system.dal.mysql.dao.permission.SysMenuMapper; |
| 4 | 7 | import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.permission.SysMenuDO; |
| 5 | 8 | import cn.iocoder.dashboard.modules.system.service.permission.SysMenuService; |
| ... | ... | @@ -63,7 +66,14 @@ public class SysMenuServiceImpl implements SysMenuService { |
| 63 | 66 | } |
| 64 | 67 | |
| 65 | 68 | @Override |
| 66 | - public List<SysMenuDO> listMenusFromCache(Collection<String> menuTypes, Collection<String> menusStatuses) { | |
| 69 | + public List<SysMenuRespVO> listMenus(SysMenuListReqVO reqVO) { | |
| 70 | + List<SysMenuDO> list = menuMapper.selectList(null); | |
| 71 | + // TODO 排序 | |
| 72 | + return SysMenuConvert.INSTANCE.convertList(list); | |
| 73 | + } | |
| 74 | + | |
| 75 | + @Override | |
| 76 | + public List<SysMenuDO> listMenusFromCache(Collection<Integer> menuTypes, Collection<Integer> menusStatuses) { | |
| 67 | 77 | // 任一一个参数为空,则返回空 |
| 68 | 78 | if (CollectionUtils.isAnyEmpty(menuTypes, menusStatuses)) { |
| 69 | 79 | return Collections.emptyList(); |
| ... | ... | @@ -75,8 +85,8 @@ public class SysMenuServiceImpl implements SysMenuService { |
| 75 | 85 | } |
| 76 | 86 | |
| 77 | 87 | @Override |
| 78 | - public List<SysMenuDO> listMenusFromCache(Collection<Long> menuIds, Collection<String> menuTypes, | |
| 79 | - Collection<String> menusStatuses) { | |
| 88 | + public List<SysMenuDO> listMenusFromCache(Collection<Long> menuIds, Collection<Integer> menuTypes, | |
| 89 | + Collection<Integer> menusStatuses) { | |
| 80 | 90 | // 任一一个参数为空,则返回空 |
| 81 | 91 | if (CollectionUtils.isAnyEmpty(menuIds, menuTypes, menusStatuses)) { |
| 82 | 92 | return Collections.emptyList(); | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/system/service/permission/impl/SysPermissionServiceImpl.java
| ... | ... | @@ -78,8 +78,8 @@ public class SysPermissionServiceImpl implements SysPermissionService { |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | @Override |
| 81 | - public List<SysMenuDO> listRoleMenusFromCache(Collection<Long> roleIds, Collection<String> menuTypes, | |
| 82 | - Collection<String> menusStatuses) { | |
| 81 | + public List<SysMenuDO> listRoleMenusFromCache(Collection<Long> roleIds, Collection<Integer> menuTypes, | |
| 82 | + Collection<Integer> menusStatuses) { | |
| 83 | 83 | // 任一一个参数为空时,不返回任何菜单 |
| 84 | 84 | if (CollectionUtils.isAnyEmpty(roleIds, menusStatuses, menusStatuses)) { |
| 85 | 85 | return Collections.emptyList(); | ... | ... |