diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictDataController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictDataController.java index 8d0e87091..5dc5019e7 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictDataController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictDataController.java @@ -27,7 +27,7 @@ import com.ruoyi.system.service.ISysDictTypeService; /** * 数据字典信息 - * + * * @author ruoyi */ @RestController @@ -103,7 +103,7 @@ public class SysDictDataController extends BaseController @PutMapping public AjaxResult edit(@Validated @RequestBody SysDictData dict) { - dict.setUpdateBy(SecurityUtils.getUsername()); + dict.setUpdateBy(SecurityUtils.getUsername()); return toAjax(dictDataService.updateDictData(dict)); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysMenuController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysMenuController.java deleted file mode 100644 index 89c6b691a..000000000 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysMenuController.java +++ /dev/null @@ -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 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 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 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)); - } -} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDictData.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDictData.java deleted file mode 100644 index 6edd5011c..000000000 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDictData.java +++ /dev/null @@ -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; - } - -} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDictType.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDictType.java deleted file mode 100644 index 4a4eb6304..000000000 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDictType.java +++ /dev/null @@ -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; - } - -} diff --git a/ruoyi-system/src/main/resources/mapper/system/SysMenuMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysMenuMapper.xml index 77d6f5737..98343b99b 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysMenuMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysMenuMapper.xml @@ -83,11 +83,6 @@ where m.status = '0' and r.status = '0' and ur.user_id = #{userId} - - @@ -97,8 +92,4 @@ where menu_name=#{menuName} and parent_id = #{parentId} limit 1 - - delete from sys_menu where menu_id = #{menuId} - - diff --git a/ruoyi-ui/src/store/modules/permission.js b/ruoyi-ui/src/store/modules/permission.js index 85018b1e0..f7fdb19c6 100644 --- a/ruoyi-ui/src/store/modules/permission.js +++ b/ruoyi-ui/src/store/modules/permission.js @@ -24,10 +24,8 @@ const permission = { return new Promise(resolve => { // 向后端请求路由数据 getRouters().then(res => { - // const sdata = 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 sdata = JSON.parse(JSON.stringify(res.data)) + const rdata = JSON.parse(JSON.stringify(res.data)) const sidebarRoutes = filterAsyncRouter(sdata) const rewriteRoutes = filterAsyncRouter(rdata, true) rewriteRoutes.push({ path: '*', redirect: '/404', hidden: true }) diff --git a/ruoyi-ui/src/store/modules/user.js b/ruoyi-ui/src/store/modules/user.js index ae3931f2f..ec95c5faa 100644 --- a/ruoyi-ui/src/store/modules/user.js +++ b/ruoyi-ui/src/store/modules/user.js @@ -50,8 +50,10 @@ const user = { GetInfo({ commit, state }) { return new Promise((resolve, reject) => { getInfo(state.token).then(res => { + res = res.data; // 读取 data 数据 const user = res.user 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是否是一个非空数组 commit('SET_ROLES', res.roles) commit('SET_PERMISSIONS', res.permissions) diff --git a/ruoyi-ui/src/utils/request.js b/ruoyi-ui/src/utils/request.js index 2e246035d..4febc4c87 100644 --- a/ruoyi-ui/src/utils/request.js +++ b/ruoyi-ui/src/utils/request.js @@ -76,7 +76,7 @@ service.interceptors.response.use(res => { }) return Promise.reject('error') } else { - return res.data.data // 第二层 data 才是后端返回的 CommonResult.data + return res.data } }, error => { diff --git a/ruoyi-ui/src/views/system/menu/index.vue b/ruoyi-ui/src/views/system/menu/index.vue index dcbff6b9b..b2d535329 100644 --- a/ruoyi-ui/src/views/system/menu/index.vue +++ b/ruoyi-ui/src/views/system/menu/index.vue @@ -51,8 +51,8 @@ - - + + @@ -62,16 +62,16 @@