菜单角色修改
This commit is contained in:
@@ -25,7 +25,6 @@ import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.nl.modules.common.utils.SecurityUtils;
|
||||
import org.nl.modules.logging.annotation.Log;
|
||||
import org.nl.modules.system.domain.Menu;
|
||||
import org.nl.modules.system.service.MenuService;
|
||||
import org.nl.modules.system.service.dto.MenuDto;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
@@ -35,7 +34,6 @@ import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author ludj
|
||||
@@ -82,8 +80,8 @@ public class MenuController {
|
||||
List<MenuDto> menuList = menuService.getMenus(id);
|
||||
menuSet.add(menuService.findById(id));
|
||||
menuSet = menuService.getChildMenus(menuList, menuSet);
|
||||
Set<String> ids = menuSet.stream().map(MenuDto::getMenu_id).collect(Collectors.toSet());
|
||||
return new ResponseEntity<>(ids, HttpStatus.OK);
|
||||
// Set<String> ids = menuSet.stream().map(MenuDto::getMenuId).collect(Collectors.toSet());
|
||||
return new ResponseEntity<>(null, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package org.nl.modules.system.service.dto;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.nl.modules.common.base.BaseDTO;
|
||||
@@ -32,7 +31,7 @@ import java.util.Objects;
|
||||
@Setter
|
||||
public class MenuDto extends BaseDTO implements Serializable {
|
||||
|
||||
private String menu_id;
|
||||
private Long menuId;
|
||||
|
||||
private List<MenuDto> children;
|
||||
|
||||
@@ -42,25 +41,25 @@ public class MenuDto extends BaseDTO implements Serializable {
|
||||
|
||||
private String title;
|
||||
|
||||
private Integer menu_sort;
|
||||
private Integer menuSort;
|
||||
|
||||
private String path;
|
||||
private String name;
|
||||
|
||||
private String component;
|
||||
|
||||
private String pid;
|
||||
private Long pid;
|
||||
|
||||
private Integer sub_count;
|
||||
private Integer subCount;
|
||||
|
||||
private Boolean i_frame;
|
||||
private Boolean iFrame;
|
||||
|
||||
|
||||
private Boolean cache;
|
||||
|
||||
private Boolean hidden;
|
||||
|
||||
private String component_name;
|
||||
private String componentName;
|
||||
|
||||
private String icon;
|
||||
|
||||
@@ -69,11 +68,11 @@ public class MenuDto extends BaseDTO implements Serializable {
|
||||
private boolean leaf;
|
||||
|
||||
public Boolean getHasChildren() {
|
||||
return sub_count > 0;
|
||||
return subCount > 0;
|
||||
}
|
||||
|
||||
public Boolean getLeaf() {
|
||||
return sub_count <= 0;
|
||||
return subCount <= 0;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
@@ -89,11 +88,11 @@ public class MenuDto extends BaseDTO implements Serializable {
|
||||
return false;
|
||||
}
|
||||
MenuDto menuDto = (MenuDto) o;
|
||||
return Objects.equals(menu_id, menuDto.menu_id);
|
||||
return Objects.equals(menuId, menuDto.menuId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(menu_id);
|
||||
return Objects.hash(menuId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ import org.nl.modules.tools.IdUtil;
|
||||
import org.nl.modules.wql.WQL;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.modules.wql.util.WqlUtil;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -69,21 +68,21 @@ public class MenuServiceImpl implements MenuService {
|
||||
@Override
|
||||
public MenuDto menuJsonToMenuDto(JSONObject json) {
|
||||
MenuDto menuDto = new MenuDto();
|
||||
menuDto.setMenu_id(json.getString("menu_id"));
|
||||
menuDto.setMenuId(json.getLong("menu_id"));
|
||||
menuDto.setType(json.getInteger("type"));
|
||||
menuDto.setPermission(json.getString("permission"));
|
||||
menuDto.setTitle(json.getString("title"));
|
||||
menuDto.setMenu_sort(json.getInteger("menu_sort"));
|
||||
menuDto.setMenuSort(json.getInteger("menu_sort"));
|
||||
menuDto.setPath(json.getString("path"));
|
||||
menuDto.setComponent(json.getString("component"));
|
||||
menuDto.setPid(json.getString("pid"));
|
||||
menuDto.setPid(json.getLong("pid"));
|
||||
menuDto.setIcon(json.getString("icon"));
|
||||
|
||||
menuDto.setSub_count(json.getInteger("sub_count"));
|
||||
menuDto.setI_frame("1".equals(json.getString("i_frame")));
|
||||
menuDto.setSubCount(json.getInteger("sub_count"));
|
||||
menuDto.setIFrame("1".equals(json.getString("i_frame")));
|
||||
menuDto.setCache("1".equals(json.getString("cache")));
|
||||
menuDto.setHidden("1".equals(json.getString("hidden")));
|
||||
menuDto.setComponent_name(json.getString("component_name"));
|
||||
menuDto.setComponentName(json.getString("component_name"));
|
||||
|
||||
//构建前端需要的数据结构树
|
||||
Integer sub_count = json.getInteger("sub_count");
|
||||
@@ -194,11 +193,11 @@ public class MenuServiceImpl implements MenuService {
|
||||
WQLObject menuTab = WQLObject.getWQLObject("sys_menu");
|
||||
|
||||
MenuDto newMenu = this.menuJsonToMenuDto(form);
|
||||
if (newMenu.getMenu_id().equals(newMenu.getPid())) {
|
||||
if (newMenu.getMenuId().equals(newMenu.getPid())) {
|
||||
throw new BadRequestException("上级不能为自己");
|
||||
}
|
||||
|
||||
if (newMenu.getI_frame()) {
|
||||
if (newMenu.getIFrame()) {
|
||||
String http = "http://", https = "https://";
|
||||
if (!(newMenu.getPath().toLowerCase().startsWith(http) || newMenu.getPath().toLowerCase().startsWith(https))) {
|
||||
throw new BadRequestException("外链必须以http://或者https://开头");
|
||||
@@ -212,15 +211,15 @@ public class MenuServiceImpl implements MenuService {
|
||||
JSONObject oldMenuJson = menuTab.query("menu_id = '" + form.getString("menu_id") + "'").uniqueResult(0);
|
||||
MenuDto oldMenu = this.menuJsonToMenuDto(oldMenuJson);
|
||||
// 记录的父节点ID
|
||||
String oldPid = oldMenu.getPid();
|
||||
String newPid = newMenu.getPid();
|
||||
menuTab.update(form);
|
||||
// String oldPid = oldMenu.getPid();
|
||||
// String newPid = newMenu.getPid();
|
||||
// menuTab.update(form);
|
||||
//
|
||||
// // 计算父级菜单节点数目
|
||||
// updateSubCnt(oldPid);
|
||||
// updateSubCnt(newPid);
|
||||
|
||||
// 计算父级菜单节点数目
|
||||
updateSubCnt(oldPid);
|
||||
updateSubCnt(newPid);
|
||||
|
||||
updateSystemType(newMenu.getMenu_id());
|
||||
// updateSystemType(newMenu.getMenuId());
|
||||
// 清理缓存
|
||||
// delCaches(resources.getId());
|
||||
}
|
||||
@@ -242,13 +241,13 @@ public class MenuServiceImpl implements MenuService {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delete(Set<MenuDto> menuSet) {
|
||||
for (MenuDto menu : menuSet) {
|
||||
/* for (MenuDto menu : menuSet) {
|
||||
// 清理缓存
|
||||
delCaches(menu.getMenu_id());
|
||||
// roleService.untiedMenu(menu.getMenu_id());
|
||||
WQLObject.getWQLObject("sys_menu").delete("menu_id = '" + menu.getMenu_id() + "'");
|
||||
updateSubCnt(menu.getPid());
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -274,7 +273,7 @@ public class MenuServiceImpl implements MenuService {
|
||||
@Override
|
||||
public List<MenuDto> getSuperior(MenuDto menuDto, List<MenuDto> menus) {
|
||||
WQLObject menuTab = WQLObject.getWQLObject("sys_menu");
|
||||
if (StrUtil.isEmpty(menuDto.getPid())) {
|
||||
if (ObjectUtil.isEmpty(menuDto.getPid())) {
|
||||
JSONArray arr = menuTab.query("pid is null").getResultJSONArray(0);
|
||||
for (int i = 0; i < arr.size(); i++) {
|
||||
JSONObject json = arr.getJSONObject(i);
|
||||
@@ -288,7 +287,7 @@ public class MenuServiceImpl implements MenuService {
|
||||
JSONObject json = arr.getJSONObject(i);
|
||||
menus.add(this.menuJsonToMenuDto(json));
|
||||
}
|
||||
return getSuperior(findById(menuDto.getPid()), menus);
|
||||
return getSuperior(findById(String.valueOf(menuDto.getPid())), menus);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -300,17 +299,17 @@ public class MenuServiceImpl implements MenuService {
|
||||
trees.add(menuDTO);
|
||||
}
|
||||
for (MenuDto it : menuDtos) {
|
||||
if (menuDTO.getMenu_id().equals(it.getPid())) {
|
||||
if (menuDTO.getMenuId().equals(it.getPid())) {
|
||||
if (menuDTO.getChildren() == null) {
|
||||
menuDTO.setChildren(new ArrayList<>());
|
||||
}
|
||||
menuDTO.getChildren().add(it);
|
||||
ids.add(it.getMenu_id());
|
||||
// ids.add(it.getMenuId());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (trees.size() == 0) {
|
||||
trees = menuDtos.stream().filter(s -> !ids.contains(s.getMenu_id())).collect(Collectors.toList());
|
||||
trees = menuDtos.stream().filter(s -> !ids.contains(s.getMenuId())).collect(Collectors.toList());
|
||||
}
|
||||
return trees;
|
||||
}
|
||||
@@ -322,15 +321,15 @@ public class MenuServiceImpl implements MenuService {
|
||||
if (menuDTO != null) {
|
||||
List<MenuDto> menuDtoList = menuDTO.getChildren();
|
||||
MenuVo menuVo = new MenuVo();
|
||||
menuVo.setName(ObjectUtil.isNotEmpty(menuDTO.getComponent_name()) ? menuDTO.getComponent_name() : menuDTO.getTitle());
|
||||
menuVo.setName(ObjectUtil.isNotEmpty(menuDTO.getComponentName()) ? menuDTO.getComponentName() : menuDTO.getTitle());
|
||||
// 一级目录需要加斜杠,不然会报警告
|
||||
menuVo.setPath(StrUtil.isEmpty(menuDTO.getPid()) ? "/" + menuDTO.getPath() : menuDTO.getPath());
|
||||
menuVo.setPath(ObjectUtil.isEmpty(menuDTO.getPid()) ? "/" + menuDTO.getPath() : menuDTO.getPath());
|
||||
menuVo.setHidden(menuDTO.getHidden());
|
||||
// 如果不是外链
|
||||
if (!menuDTO.getI_frame()) {
|
||||
if (StrUtil.isEmpty(menuDTO.getPid())) {
|
||||
if (!menuDTO.getIFrame()) {
|
||||
if (ObjectUtil.isEmpty(menuDTO.getPid())) {
|
||||
menuVo.setComponent(StrUtil.isEmpty(menuDTO.getComponent()) ? "Layout" : menuDTO.getComponent());
|
||||
} else if (!StrUtil.isEmpty(menuDTO.getPid()) && menuDTO.getType() == 0) {
|
||||
} else if (!ObjectUtil.isEmpty(menuDTO.getPid()) && menuDTO.getType() == 0) {
|
||||
menuVo.setComponent(StrUtil.isEmpty(menuDTO.getComponent()) ? "ParentView" : menuDTO.getComponent());
|
||||
|
||||
} else if (!StrUtil.isEmpty(menuDTO.getComponent())) {
|
||||
@@ -343,11 +342,11 @@ public class MenuServiceImpl implements MenuService {
|
||||
menuVo.setRedirect("noredirect");
|
||||
menuVo.setChildren(buildMenus(menuDtoList));
|
||||
// 处理是一级菜单并且没有子菜单的情况
|
||||
} else if (StrUtil.isEmpty(menuDTO.getPid())) {
|
||||
} else if (ObjectUtil.isEmpty(menuDTO.getPid())) {
|
||||
MenuVo menuVo1 = new MenuVo();
|
||||
menuVo1.setMeta(menuVo.getMeta());
|
||||
// 非外链
|
||||
if (!menuDTO.getI_frame()) {
|
||||
if (!menuDTO.getIFrame()) {
|
||||
menuVo1.setPath("index");
|
||||
menuVo1.setName(menuVo.getName());
|
||||
menuVo1.setComponent(menuVo.getComponent());
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package org.nl.system.controller.menu;
|
||||
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.nl.system.service.menu.ISysMenuService;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 菜单表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author generator
|
||||
* @since 2022-12-15
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("api/sysMenu")
|
||||
@RequiredArgsConstructor
|
||||
public class SysMenuController {
|
||||
private final ISysMenuService baseService;
|
||||
|
||||
@GetMapping
|
||||
@ApiOperation("查询菜单")
|
||||
@SaCheckPermission("menu:list")
|
||||
public ResponseEntity<Object> pageQuery(@RequestParam Map param, Pageable page) throws Exception {
|
||||
return new ResponseEntity<>(baseService.queryAll(param),HttpStatus.OK);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package org.nl.system.controller.role;
|
||||
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.system.service.role.ISysRoleService;
|
||||
import org.nl.system.service.role.dao.SysRole;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 角色表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author generator
|
||||
* @since 2022-12-15
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/sysRole")
|
||||
@RequiredArgsConstructor
|
||||
public class SysRoleController {
|
||||
private final ISysRoleService baseService;
|
||||
|
||||
@ApiOperation("分页查询角色")
|
||||
@GetMapping
|
||||
@SaCheckPermission("roles:list")
|
||||
public ResponseEntity<Object> pageQuery(Map param, PageQuery page) {
|
||||
/*QueryWrapper<SysRole> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.like("name", MapUtil.getStr(param, "name"));*/
|
||||
|
||||
LambdaQueryWrapper<SysRole> queryWrapper= new LambdaQueryWrapper<SysRole>()
|
||||
.like(SysRole::getName, MapUtil.getStr(param, "name"));
|
||||
|
||||
|
||||
Page<SysRole> roleList = baseService.page(page.build());
|
||||
|
||||
return new ResponseEntity<>(baseService.page(page.build(), queryWrapper), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package org.nl.system.service.menu;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.nl.modules.system.service.dto.MenuDto;
|
||||
import org.nl.system.service.menu.dao.SysMenu;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 菜单表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author generator
|
||||
* @since 2022-12-15
|
||||
*/
|
||||
public interface ISysMenuService extends IService<SysMenu> {
|
||||
/**
|
||||
* 查询全部数据,菜单不适用分页
|
||||
*
|
||||
* @param param 条件
|
||||
* @return /
|
||||
* @throws Exception /
|
||||
*/
|
||||
List<MenuDto> queryAll(Map<String, Object> param) throws Exception;
|
||||
|
||||
/**
|
||||
* 懒加载菜单数据
|
||||
*
|
||||
* @param pid /
|
||||
* @return /
|
||||
*/
|
||||
List<MenuDto> getMenus(Long pid);
|
||||
|
||||
/**
|
||||
* @param sysMenu
|
||||
* @return
|
||||
*/
|
||||
MenuDto doToDto(SysMenu sysMenu);
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
package org.nl.system.service.menu.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 菜单表
|
||||
* </p>
|
||||
*
|
||||
* @author generator
|
||||
* @since 2022-12-15
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("sys_menu")
|
||||
public class SysMenu implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 菜单标识
|
||||
*/
|
||||
@TableId(value = "menu_id", type = IdType.AUTO)
|
||||
private Long menuId;
|
||||
|
||||
/**
|
||||
* 上级菜单ID
|
||||
*/
|
||||
private Long pid;
|
||||
|
||||
/**
|
||||
* 子菜单数目
|
||||
*/
|
||||
private Integer subCount;
|
||||
|
||||
/**
|
||||
* 菜单类型
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 所属系统
|
||||
*/
|
||||
private String systemType;
|
||||
|
||||
/**
|
||||
* 菜单分类
|
||||
*/
|
||||
private String category;
|
||||
|
||||
/**
|
||||
* 菜单标题
|
||||
*/
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 组件名称
|
||||
*/
|
||||
private String componentName;
|
||||
|
||||
/**
|
||||
* 组件
|
||||
*/
|
||||
private String component;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer menuSort;
|
||||
|
||||
/**
|
||||
* 图标
|
||||
*/
|
||||
private String icon;
|
||||
|
||||
/**
|
||||
* 链接地址
|
||||
*/
|
||||
private String path;
|
||||
|
||||
/**
|
||||
* 是否外链
|
||||
*/
|
||||
private Boolean iFrame;
|
||||
|
||||
/**
|
||||
* 是否缓存
|
||||
*/
|
||||
private Boolean cache;
|
||||
|
||||
/**
|
||||
* 是否隐藏
|
||||
*/
|
||||
private Boolean hidden;
|
||||
|
||||
/**
|
||||
* 权限
|
||||
*/
|
||||
private String permission;
|
||||
|
||||
/**
|
||||
* 创建人标识
|
||||
*/
|
||||
private Long createId;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createName;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private String createTime;
|
||||
|
||||
/**
|
||||
* 修改人标识
|
||||
*/
|
||||
private Long updateOptid;
|
||||
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
private String updateOptname;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private String updateTime;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package org.nl.system.service.menu.dao.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.nl.system.service.menu.dao.SysMenu;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 菜单表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author generator
|
||||
* @since 2022-12-15
|
||||
*/
|
||||
public interface SysMenuMapper extends BaseMapper<SysMenu> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.nl.system.service.menu.dao.mapper.SysMenuMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,78 @@
|
||||
package org.nl.system.service.menu.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.nl.modules.system.service.dto.MenuDto;
|
||||
import org.nl.system.service.menu.ISysMenuService;
|
||||
import org.nl.system.service.menu.dao.SysMenu;
|
||||
import org.nl.system.service.menu.dao.mapper.SysMenuMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 菜单表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author generator
|
||||
* @since 2022-12-15
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> implements ISysMenuService {
|
||||
private final SysMenuMapper baseMapper;
|
||||
|
||||
@Override
|
||||
public List<MenuDto> queryAll(Map<String, Object> param) throws Exception {
|
||||
/*List<SysMenu> sysMenus = baseMapper.selectList(null);
|
||||
List<MenuDto> menus = sysMenus.stream().map(menu -> doToDto(menu)).collect(Collectors.toList());*/
|
||||
return getMenus(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MenuDto> getMenus(Long pid) {
|
||||
QueryWrapper<SysMenu> queryWrapper;
|
||||
if (pid != null && !pid.equals(0L)) {
|
||||
queryWrapper = new QueryWrapper<SysMenu>().eq("pid", pid);
|
||||
} else {
|
||||
queryWrapper = new QueryWrapper<SysMenu>().isNull("pid");
|
||||
}
|
||||
return baseMapper.selectList(queryWrapper).stream().map(menu -> doToDto(menu)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public MenuDto doToDto(SysMenu entity) {
|
||||
|
||||
MenuDto menuDto = new MenuDto();
|
||||
menuDto.setMenuId(entity.getMenuId());
|
||||
menuDto.setType(Integer.parseInt(entity.getType()));
|
||||
menuDto.setPermission(entity.getPermission());
|
||||
menuDto.setTitle(entity.getTitle());
|
||||
menuDto.setMenuSort(entity.getMenuSort());
|
||||
menuDto.setPath(entity.getPath());
|
||||
menuDto.setComponent(entity.getComponent());
|
||||
menuDto.setPid(entity.getPid());
|
||||
menuDto.setSubCount(entity.getSubCount());
|
||||
menuDto.setIFrame(entity.getIFrame());
|
||||
menuDto.setCache(entity.getCache());
|
||||
menuDto.setHidden(entity.getHidden());
|
||||
menuDto.setComponentName(entity.getComponentName());
|
||||
menuDto.setIcon(entity.getIcon());
|
||||
|
||||
//构建前端需要的数据结构树
|
||||
Integer sub_count = entity.getSubCount();
|
||||
if (sub_count <= 0) {
|
||||
menuDto.setLeaf(true);
|
||||
menuDto.setHasChildren(false);
|
||||
} else {
|
||||
menuDto.setLeaf(false);
|
||||
menuDto.setHasChildren(true);
|
||||
}
|
||||
return menuDto;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package org.nl.system.service.role;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.nl.system.service.role.dao.SysRole;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 角色表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author generator
|
||||
* @since 2022-12-15
|
||||
*/
|
||||
public interface ISysRoleService extends IService<SysRole> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package org.nl.system.service.role.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 角色表
|
||||
* </p>
|
||||
*
|
||||
* @author generator
|
||||
* @since 2022-12-15
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("sys_role")
|
||||
public class SysRole implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
private Long roleId;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 角色级别
|
||||
*/
|
||||
private BigDecimal level;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private BigDecimal orderSeq;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
private String isUsed;
|
||||
|
||||
/**
|
||||
* 是否删除
|
||||
*/
|
||||
private String isDelete;
|
||||
|
||||
/**
|
||||
* 创建人标识
|
||||
*/
|
||||
private Long createId;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createName;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private String createTime;
|
||||
|
||||
/**
|
||||
* 修改人标识
|
||||
*/
|
||||
private Long updateOptid;
|
||||
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
private String updateOptname;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private String updateTime;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package org.nl.system.service.role.dao.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.nl.system.service.role.dao.SysRole;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 角色表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author generator
|
||||
* @since 2022-12-15
|
||||
*/
|
||||
public interface SysRoleMapper extends BaseMapper<SysRole> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.nl.system.service.role.dao.mapper.SysRoleMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,20 @@
|
||||
package org.nl.system.service.role.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.nl.system.service.role.ISysRoleService;
|
||||
import org.nl.system.service.role.dao.SysRole;
|
||||
import org.nl.system.service.role.dao.mapper.SysRoleMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 角色表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author generator
|
||||
* @since 2022-12-15
|
||||
*/
|
||||
@Service
|
||||
public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> implements ISysRoleService {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user