diff --git a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/TopMenu.java b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/TopMenu.java new file mode 100644 index 00000000..e596c8c3 --- /dev/null +++ b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/TopMenu.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 庄骞 (smallchill@163.com) + */ +package org.springblade.system.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springblade.core.mp.base.BaseEntity; + +/** + * 顶部菜单表实体类 + * + * @author BladeX + * @since 2019-07-14 + */ +@Data +@TableName("blade_top_menu") +@EqualsAndHashCode(callSuper = true) +@ApiModel(value = "TopMenu对象", description = "顶部菜单表") +public class TopMenu extends BaseEntity { + + private static final long serialVersionUID = 1L; + + /** + * 顶部菜单编号 + */ + @ApiModelProperty(value = "顶部菜单编号") + private String code; + /** + * 顶部菜单名 + */ + @ApiModelProperty(value = "顶部菜单名") + private String name; + /** + * 顶部菜单资源 + */ + @ApiModelProperty(value = "顶部菜单资源") + private String source; + /** + * 顶部菜单排序 + */ + @ApiModelProperty(value = "顶部菜单排序") + private Integer sort; + + +} diff --git a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/TopMenuSetting.java b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/TopMenuSetting.java new file mode 100644 index 00000000..7e3beb8e --- /dev/null +++ b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/TopMenuSetting.java @@ -0,0 +1,38 @@ +package org.springblade.system.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.Data; + +/** + * TopMenuSetting + * + * @author Chill + */ +@Data +@TableName("blade_top_menu_setting") +public class TopMenuSetting { + + /** + * 主键id + */ + @JsonSerialize(using = ToStringSerializer.class) + @TableId(value = "id", type = IdType.ID_WORKER) + private Long id; + + /** + * 顶部菜单id + */ + @JsonSerialize(using = ToStringSerializer.class) + private Long topMenuId; + + /** + * 菜单id + */ + @JsonSerialize(using = ToStringSerializer.class) + private Long menuId; + +} diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/controller/MenuController.java b/blade-service/blade-system/src/main/java/org/springblade/system/controller/MenuController.java index d8141a03..840fcfab 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/controller/MenuController.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/controller/MenuController.java @@ -186,11 +186,35 @@ public class MenuController extends BladeController { return R.data(vo); } + /** + * 获取顶部菜单树形结构 + */ + @GetMapping("/grant-top-tree") + @ApiOperationSupport(order = 10) + @ApiOperation(value = "顶部菜单树形结构", notes = "顶部菜单树形结构") + public R grantTopTree(BladeUser user) { + GrantTreeVO vo = new GrantTreeVO(); + vo.setMenu(menuService.grantTopTree(user)); + return R.data(vo); + } + + /** + * 获取顶部菜单树形结构 + */ + @GetMapping("/top-tree-keys") + @ApiOperationSupport(order = 11) + @ApiOperation(value = "顶部菜单所分配的树", notes = "顶部菜单所分配的树") + public R topTreeKeys(String topMenuIds) { + CheckedTreeVO vo = new CheckedTreeVO(); + vo.setMenu(menuService.topTreeKeys(topMenuIds)); + return R.data(vo); + } + /** * 获取配置的角色权限 */ @GetMapping("auth-routes") - @ApiOperationSupport(order = 10) + @ApiOperationSupport(order = 12) @ApiOperation(value = "菜单的角色权限") public R> authRoutes(BladeUser user) { if (Func.isEmpty(user)) { diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/controller/TopMenuController.java b/blade-service/blade-system/src/main/java/org/springblade/system/controller/TopMenuController.java new file mode 100644 index 00000000..7c4aab69 --- /dev/null +++ b/blade-service/blade-system/src/main/java/org/springblade/system/controller/TopMenuController.java @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 庄骞 (smallchill@163.com) + */ +package org.springblade.system.controller; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiOperationSupport; +import io.swagger.annotations.ApiParam; +import lombok.AllArgsConstructor; +import org.springblade.core.boot.ctrl.BladeController; +import org.springblade.core.mp.support.Condition; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.Func; +import org.springblade.system.entity.TopMenu; +import org.springblade.system.service.ITopMenuService; +import org.springframework.cache.annotation.CacheEvict; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; + +import static org.springblade.core.cache.constant.CacheConstant.SYS_CACHE; + +/** + * 顶部菜单表 控制器 + * + * @author BladeX + * @since 2019-07-14 + */ +@RestController +@AllArgsConstructor +@RequestMapping("/topmenu") +@Api(value = "顶部菜单表", tags = "顶部菜单") +public class TopMenuController extends BladeController { + + private ITopMenuService topMenuService; + + /** + * 详情 + */ + @GetMapping("/detail") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "详情", notes = "传入topMenu") + public R detail(TopMenu topMenu) { + TopMenu detail = topMenuService.getOne(Condition.getQueryWrapper(topMenu)); + return R.data(detail); + } + + /** + * 分页 顶部菜单表 + */ + @GetMapping("/list") + @ApiOperationSupport(order = 2) + @ApiOperation(value = "分页", notes = "传入topMenu") + public R> list(TopMenu topMenu, Query query) { + IPage pages = topMenuService.page(Condition.getPage(query), Condition.getQueryWrapper(topMenu)); + return R.data(pages); + } + + /** + * 新增 顶部菜单表 + */ + @PostMapping("/save") + @ApiOperationSupport(order = 4) + @ApiOperation(value = "新增", notes = "传入topMenu") + public R save(@Valid @RequestBody TopMenu topMenu) { + return R.status(topMenuService.save(topMenu)); + } + + /** + * 修改 顶部菜单表 + */ + @PostMapping("/update") + @ApiOperationSupport(order = 5) + @ApiOperation(value = "修改", notes = "传入topMenu") + public R update(@Valid @RequestBody TopMenu topMenu) { + return R.status(topMenuService.updateById(topMenu)); + } + + /** + * 新增或修改 顶部菜单表 + */ + @PostMapping("/submit") + @ApiOperationSupport(order = 6) + @ApiOperation(value = "新增或修改", notes = "传入topMenu") + public R submit(@Valid @RequestBody TopMenu topMenu) { + return R.status(topMenuService.saveOrUpdate(topMenu)); + } + + + /** + * 删除 顶部菜单表 + */ + @PostMapping("/remove") + @ApiOperationSupport(order = 7) + @ApiOperation(value = "逻辑删除", notes = "传入ids") + public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { + return R.status(topMenuService.deleteLogic(Func.toLongList(ids))); + } + + /** + * 设置顶部菜单 + */ + @PostMapping("/grant") + @ApiOperationSupport(order = 8) + @ApiOperation(value = "顶部菜单配置", notes = "传入topMenuId集合以及menuId集合") + @CacheEvict(cacheNames = {SYS_CACHE}, allEntries = true) + public R grant(@ApiParam(value = "topMenuId集合", required = true) @RequestParam String topMenuIds, + @ApiParam(value = "menuId集合", required = true) @RequestParam String menuIds) { + boolean temp = topMenuService.grant(Func.toLongList(topMenuIds), Func.toLongList(menuIds)); + return R.status(temp); + } + + +} diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/mapper/MenuMapper.java b/blade-service/blade-system/src/main/java/org/springblade/system/mapper/MenuMapper.java index 2cdf41bc..d3b6eee5 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/mapper/MenuMapper.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/mapper/MenuMapper.java @@ -63,6 +63,21 @@ public interface MenuMapper extends BaseMapper { */ List grantTreeByRole(List roleId); + /** + * 顶部菜单树形结构 + * + * @return + */ + List grantTopTree(); + + /** + * 顶部菜单树形结构 + * + * @param roleId + * @return + */ + List grantTopTreeByRole(List roleId); + /** * 数据权限授权树形结构 * diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/mapper/MenuMapper.xml b/blade-service/blade-system/src/main/java/org/springblade/system/mapper/MenuMapper.xml index 9babb0f3..295baefd 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/mapper/MenuMapper.xml +++ b/blade-service/blade-system/src/main/java/org/springblade/system/mapper/MenuMapper.xml @@ -27,12 +27,6 @@ - - - select - id, code, parent_id, name, alias, path, source, sort, category, action, is_open, remark, is_deleted - - @@ -128,6 +122,26 @@ order by sort + + + +