1. 修改 MenuDO 的字段,menuId 改成 id,menuName 改成 name
2. 添加 Menu 的创建、修改、删除接口
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package cn.iocoder.dashboard.modules.system.controller.auth.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
@@ -15,32 +16,22 @@ import java.util.List;
|
||||
@Builder
|
||||
public class SysAuthMenuRespVO {
|
||||
|
||||
/**
|
||||
* 菜单编号
|
||||
*/
|
||||
private Long menuId;
|
||||
/**
|
||||
* 父菜单编号
|
||||
*/
|
||||
@ApiModelProperty(value = "菜单名称", required = true, example = "芋道")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "父菜单 ID", required = true, example = "1024")
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 菜单名称
|
||||
*/
|
||||
private String menuName;
|
||||
@ApiModelProperty(value = "菜单名称", required = true, example = "芋道")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 路由地址
|
||||
*/
|
||||
@ApiModelProperty(value = "路由地址", example = "post", notes = "仅菜单类型为菜单或者目录时,才需要传")
|
||||
private String path;
|
||||
/**
|
||||
* 组件地址
|
||||
*/
|
||||
|
||||
@ApiModelProperty(value = "组件路径", example = "system/post/index", notes = "仅菜单类型为菜单时,才需要传")
|
||||
private String component;
|
||||
|
||||
/**
|
||||
* 菜单图标
|
||||
*/
|
||||
@ApiModelProperty(value = "菜单图标", example = "/menu/list", notes = "仅菜单类型为菜单或者目录时,才需要传")
|
||||
private String icon;
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,9 +12,9 @@ public class SysDataDictSimpleVO {
|
||||
private String dictType;
|
||||
|
||||
@ApiModelProperty(value = "字典键值", required = true, example = "1")
|
||||
private String dictValue;
|
||||
private String value;
|
||||
|
||||
@ApiModelProperty(value = "字典标签", required = true, example = "男")
|
||||
private String dictLabel;
|
||||
private String label;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
package cn.iocoder.dashboard.modules.system.controller.permission;
|
||||
|
||||
import cn.iocoder.dashboard.common.pojo.CommonResult;
|
||||
import cn.iocoder.dashboard.modules.system.controller.permission.vo.SysMenuCreateReqVO;
|
||||
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.controller.permission.vo.SysMenuUpdateReqVO;
|
||||
import cn.iocoder.dashboard.modules.system.convert.permission.SysMenuConvert;
|
||||
import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.permission.SysMenuDO;
|
||||
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 io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
@@ -22,24 +26,21 @@ public class SysMenuController {
|
||||
@Resource
|
||||
private SysMenuService menuService;
|
||||
|
||||
/**
|
||||
* 获取菜单列表
|
||||
*/
|
||||
@ApiOperation("获取菜单列表")
|
||||
// @PreAuthorize("@ss.hasPermi('system:menu:list')")
|
||||
@GetMapping("/list")
|
||||
public CommonResult<List<SysMenuRespVO>> list(SysMenuListReqVO reqVO) {
|
||||
return success(menuService.listMenus(reqVO));
|
||||
}
|
||||
//
|
||||
// /**
|
||||
// * 根据菜单编号获取详细信息
|
||||
// */
|
||||
|
||||
@ApiOperation("获取菜单信息")
|
||||
@GetMapping("/get")
|
||||
// @PreAuthorize("@ss.hasPermi('system:menu:query')")
|
||||
// @GetMapping(value = "/{menuId}")
|
||||
// public AjaxResult getInfo(@PathVariable Long menuId) {
|
||||
// return AjaxResult.success(menuService.selectMenuById(menuId));
|
||||
// }
|
||||
//
|
||||
public CommonResult<SysMenuRespVO> getMenu(Long id) {
|
||||
SysMenuDO menu = menuService.getMenu(id);
|
||||
return success(SysMenuConvert.INSTANCE.convert(menu));
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 获取菜单下拉树列表
|
||||
// */
|
||||
@@ -63,57 +64,31 @@ public class SysMenuController {
|
||||
// ajax.put("menus", menuService.buildMenuTreeSelect(menus));
|
||||
// return ajax;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 新增菜单
|
||||
// */
|
||||
|
||||
@ApiOperation("新增菜单")
|
||||
// @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));
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 修改菜单
|
||||
// */
|
||||
@PostMapping("/create")
|
||||
public CommonResult<Long> createMenu(@Validated @RequestBody SysMenuCreateReqVO reqVO) {
|
||||
Long menuId = menuService.createMenu(reqVO);
|
||||
return success(menuId);
|
||||
}
|
||||
|
||||
@ApiOperation("修改菜单")
|
||||
// @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')")
|
||||
@PostMapping("/update")
|
||||
public CommonResult<Boolean> updateMenu(@Validated @RequestBody SysMenuUpdateReqVO reqVO) {
|
||||
menuService.updateMenu(reqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@ApiOperation("删除菜单")
|
||||
// @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));
|
||||
// }
|
||||
public CommonResult<Boolean> deleteMenu(@RequestParam("id") Long id) {
|
||||
menuService.deleteMenu(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,15 +17,15 @@ public class SysMenuBaseVO {
|
||||
@ApiModelProperty(value = "菜单名称", required = true, example = "芋道")
|
||||
@NotBlank(message = "菜单名称不能为空")
|
||||
@Size(max = 50, message = "菜单名称长度不能超过50个字符")
|
||||
private String menuName;
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "权限标识", example = "sys:menu:add", notes = "仅菜单类型为按钮时,才需要传递")
|
||||
@Size(max = 100)
|
||||
private String permission;
|
||||
|
||||
@ApiModelProperty(value = "类型", required = true, example = "1", notes = "参见 MenuTypeEnum 枚举类")
|
||||
@ApiModelProperty(value = "类型", required = true, example = "1", notes = "参见 SysMenuTypeEnum 枚举类")
|
||||
@NotBlank(message = "菜单类型不能为空")
|
||||
private Integer menuType;
|
||||
private Integer type;
|
||||
|
||||
@ApiModelProperty(value = "显示顺序不能为空", required = true, example = "1024")
|
||||
@NotBlank(message = "显示顺序不能为空")
|
||||
|
||||
@@ -14,7 +14,7 @@ public class SysMenuListReqVO {
|
||||
@ApiModelProperty(value = "菜单名称", example = "芋道", notes = "模糊匹配")
|
||||
private String menuName;
|
||||
|
||||
@ApiModelProperty(value = "展示状态", example = "1", notes = "参见 CommonStatusEnum 枚举类")
|
||||
@ApiModelProperty(value = "展示状态", example = "1", notes = "参见 SysCommonStatusEnum 枚举类")
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
|
||||
@@ -17,9 +17,9 @@ import java.util.Date;
|
||||
public class SysMenuRespVO extends SysMenuBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "菜单编号", required = true, example = "1024")
|
||||
private Integer menuId;
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "状态", required = true, example = "1", notes = "参见 CommonStatusEnum 枚举类")
|
||||
@ApiModelProperty(value = "状态", required = true, example = "1", notes = "参见 SysCommonStatusEnum 枚举类")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "创建时间", required = true, example = "时间戳格式")
|
||||
|
||||
@@ -13,6 +13,6 @@ public class SysMenuUpdateReqVO extends SysMenuBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "菜单编号", required = true, example = "1024")
|
||||
@NotNull(message = "菜单编号不能为空")
|
||||
private Integer menuId;
|
||||
private Long id;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user