mirror of
https://gitee.com/youlaitech/youlai-mall.git
synced 2024-12-23 05:00:25 +08:00
添加菜单接口
This commit is contained in:
parent
76eec829fd
commit
900d663f00
@ -2,7 +2,8 @@ package com.youlai.admin.controller;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.youlai.admin.entity.SysDept;
|
||||
import com.youlai.admin.common.AdminConstant;
|
||||
import com.youlai.admin.domain.entity.SysDept;
|
||||
import com.youlai.admin.service.ISysDeptService;
|
||||
import com.youlai.common.result.Result;
|
||||
import io.swagger.annotations.Api;
|
||||
@ -13,7 +14,9 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Api(tags = "部门接口")
|
||||
@RestController
|
||||
@ -27,7 +30,8 @@ public class SysDeptController {
|
||||
@ApiOperation(value = "列表分页", httpMethod = "GET")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "name", value = "部门名称", paramType = "query", dataType = "String"),
|
||||
@ApiImplicitParam(name = "mode", value = "查询模式(mode:1-表格数据)", defaultValue = "1", paramType = "query", dataType = "Integer"),
|
||||
@ApiImplicitParam(name = "status", value = "部门状态", paramType = "query", dataType = "Integer"),
|
||||
@ApiImplicitParam(name = "mode", value = "查询模式(mode:1-表格数据 2-树形下拉)", defaultValue = "1", paramType = "query", dataType = "Integer"),
|
||||
})
|
||||
@GetMapping
|
||||
public Result list(@RequestParam(required = false, defaultValue = "1") Integer mode,
|
||||
@ -38,13 +42,11 @@ public class SysDeptController {
|
||||
.orderByDesc(SysDept::getUpdateTime)
|
||||
.orderByDesc(SysDept::getCreateTime);
|
||||
List list;
|
||||
if (mode.equals(1)) {
|
||||
// 表格数据
|
||||
if (mode.equals(1)) { // 表格数据
|
||||
baseQuery = baseQuery.like(StrUtil.isNotBlank(name), SysDept::getName, name)
|
||||
.eq(status != null, SysDept::getStatus, status);
|
||||
list = iSysDeptService.listForTableData(baseQuery);
|
||||
} else if (mode.equals(2)) {
|
||||
// tree-select 树形下拉数据
|
||||
} else if (mode.equals(2)) { // tree-select 树形下拉数据
|
||||
list = iSysDeptService.listForTreeSelect(baseQuery);
|
||||
} else {
|
||||
list = iSysDeptService.list(baseQuery);
|
||||
@ -64,8 +66,16 @@ public class SysDeptController {
|
||||
@ApiImplicitParam(name = "sysDept", value = "实体JSON对象", required = true, paramType = "body", dataType = "SysDept")
|
||||
@PostMapping
|
||||
public Result add(@RequestBody SysDept sysDept) {
|
||||
boolean status = iSysDeptService.save(sysDept);
|
||||
return Result.status(status);
|
||||
Integer parentId = sysDept.getParentId();
|
||||
String treePath;
|
||||
if (parentId.equals(AdminConstant.ROOT_DEPT_ID)) {
|
||||
treePath = String.valueOf(AdminConstant.ROOT_DEPT_ID);
|
||||
} else {
|
||||
SysDept parentDept = iSysDeptService.getById(parentId);
|
||||
treePath = Optional.ofNullable(parentDept).map(dept -> dept.getParentId() + "," + dept.getTreePath()).get();
|
||||
}
|
||||
sysDept.setTreePath(treePath);
|
||||
return Result.status(iSysDeptService.save(sysDept));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改部门", httpMethod = "PUT")
|
||||
@ -77,6 +87,16 @@ public class SysDeptController {
|
||||
public Result update(
|
||||
@PathVariable Integer id,
|
||||
@RequestBody SysDept sysDept) {
|
||||
|
||||
Integer parentId = sysDept.getParentId();
|
||||
String treePath;
|
||||
if (parentId.equals(AdminConstant.ROOT_DEPT_ID)) {
|
||||
treePath = String.valueOf(AdminConstant.ROOT_DEPT_ID);
|
||||
} else {
|
||||
SysDept parentDept = iSysDeptService.getById(parentId);
|
||||
treePath = Optional.ofNullable(parentDept).map(dept -> dept.getParentId() + "," + dept.getTreePath()).get();
|
||||
}
|
||||
sysDept.setTreePath(treePath);
|
||||
boolean status = iSysDeptService.updateById(sysDept);
|
||||
return Result.status(status);
|
||||
}
|
||||
@ -85,7 +105,12 @@ public class SysDeptController {
|
||||
@ApiImplicitParam(name = "ids[]", value = "id集合", required = true, paramType = "query", allowMultiple = true, dataType = "Integer")
|
||||
@DeleteMapping
|
||||
public Result delete(@RequestParam("ids") List<Integer> ids) {
|
||||
boolean status = iSysDeptService.removeByIds(ids);
|
||||
return Result.status(status);
|
||||
|
||||
// 删除部门以及子部门
|
||||
Optional.ofNullable(ids).orElse(new ArrayList<>()).forEach(id ->
|
||||
iSysDeptService.remove(new LambdaQueryWrapper<SysDept>().eq(SysDept::getId, id)
|
||||
.or().apply("concat (',',tree_path,',') like concat('%,',{1},',%')", id))
|
||||
);
|
||||
return Result.success();
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package com.youlai.admin.controller;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.youlai.admin.entity.SysDict;
|
||||
import com.youlai.admin.domain.entity.SysDict;
|
||||
import com.youlai.admin.service.ISysDictService;
|
||||
import com.youlai.common.result.PageResult;
|
||||
import com.youlai.common.result.Result;
|
||||
|
@ -3,7 +3,7 @@ package com.youlai.admin.controller;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.youlai.admin.entity.SysDictType;
|
||||
import com.youlai.admin.domain.entity.SysDictType;
|
||||
import com.youlai.admin.service.ISysDictTypeService;
|
||||
import com.youlai.common.result.PageResult;
|
||||
import com.youlai.common.result.Result;
|
||||
|
@ -3,7 +3,8 @@ package com.youlai.admin.controller;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.youlai.admin.entity.SysMenu;
|
||||
import com.youlai.admin.domain.entity.SysMenu;
|
||||
import com.youlai.admin.domain.entity.SysMenu;
|
||||
import com.youlai.admin.service.ISysMenuService;
|
||||
import com.youlai.common.result.PageResult;
|
||||
import com.youlai.common.result.Result;
|
||||
@ -24,31 +25,29 @@ import java.util.List;
|
||||
@Slf4j
|
||||
public class SysMenuController {
|
||||
|
||||
|
||||
@Autowired
|
||||
private ISysMenuService iSysMenuService;
|
||||
|
||||
@ApiOperation(value = "列表分页", httpMethod = "GET")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "page", value = "页码", paramType = "query", dataType = "Integer"),
|
||||
@ApiImplicitParam(name = "limit", value = "每页数量", paramType = "query", dataType = "Integer"),
|
||||
@ApiImplicitParam(name = "username", value = "菜单名", paramType = "query", dataType = "String"),
|
||||
@ApiImplicitParam(name = "name", value = "菜单名称", paramType = "query", dataType = "String"),
|
||||
@ApiImplicitParam(name = "mode", value = "查询模式: 1-表格数据 2-树形下拉", paramType = "query", dataType = "Integer")
|
||||
})
|
||||
@GetMapping
|
||||
public Result list(Integer page, Integer limit, String name) {
|
||||
LambdaQueryWrapper<SysMenu> queryWrapper = new LambdaQueryWrapper<SysMenu>()
|
||||
.like(StrUtil.isNotBlank(name), SysMenu::getName, name)
|
||||
public Result list(String name,Integer mode) {
|
||||
LambdaQueryWrapper<SysMenu> baseQuery = new LambdaQueryWrapper<SysMenu>()
|
||||
.orderByAsc(SysMenu::getSort)
|
||||
.orderByDesc(SysMenu::getUpdateTime)
|
||||
.orderByDesc(SysMenu::getCreateTime);
|
||||
|
||||
if (page != null && limit != null) {
|
||||
Page<SysMenu> result = iSysMenuService.page(new Page<>(page, limit) ,queryWrapper);
|
||||
|
||||
return PageResult.success(result.getRecords(), result.getTotal());
|
||||
} else if (limit != null) {
|
||||
queryWrapper.last("LIMIT " + limit);
|
||||
List list;
|
||||
if (mode.equals(1)) { // 表格数据
|
||||
baseQuery = baseQuery.like(StrUtil.isNotBlank(name), SysMenu::getName, name);
|
||||
list = iSysMenuService.listForTableData(baseQuery);
|
||||
} else if (mode.equals(2)) { // tree-select 树形下拉数据
|
||||
list = iSysMenuService.listForTreeSelect(baseQuery);
|
||||
} else {
|
||||
list = iSysMenuService.list(baseQuery);
|
||||
}
|
||||
List<SysMenu> list = iSysMenuService.list(queryWrapper);
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@ package com.youlai.admin.controller;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.youlai.admin.entity.SysRole;
|
||||
import com.youlai.admin.domain.entity.SysRole;
|
||||
import com.youlai.admin.service.ISysRoleService;
|
||||
import com.youlai.common.result.PageResult;
|
||||
import com.youlai.common.result.Result;
|
||||
@ -32,7 +32,7 @@ public class SysRoleController {
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "page", value = "页码", paramType = "query", dataType = "Integer"),
|
||||
@ApiImplicitParam(name = "limit", value = "每页数量", paramType = "query", dataType = "Integer"),
|
||||
@ApiImplicitParam(name = "username", value = "角色名", paramType = "query", dataType = "String"),
|
||||
@ApiImplicitParam(name = "username", value = "角色名称", paramType = "query", dataType = "String"),
|
||||
})
|
||||
@GetMapping
|
||||
public Result list(Integer page, Integer limit, String name) {
|
||||
@ -43,7 +43,6 @@ public class SysRoleController {
|
||||
|
||||
if (page != null && limit != null) {
|
||||
Page<SysRole> result = iSysRoleService.page(new Page<>(page, limit) ,queryWrapper);
|
||||
|
||||
return PageResult.success(result.getRecords(), result.getTotal());
|
||||
} else if (limit != null) {
|
||||
queryWrapper.last("LIMIT " + limit);
|
||||
|
@ -3,18 +3,17 @@ package com.youlai.admin.controller;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSON;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.youlai.admin.api.dto.UserDTO;
|
||||
import com.youlai.admin.entity.SysUser;
|
||||
import com.youlai.admin.entity.SysUserRole;
|
||||
import com.youlai.admin.domain.entity.SysUser;
|
||||
import com.youlai.admin.domain.entity.SysUserRole;
|
||||
import com.youlai.admin.service.ISysRoleService;
|
||||
import com.youlai.admin.service.ISysUserRoleService;
|
||||
import com.youlai.admin.service.ISysUserService;
|
||||
import com.youlai.admin.vo.UserVO;
|
||||
import com.youlai.admin.domain.vo.UserVO;
|
||||
import com.youlai.common.auth.constant.AuthConstant;
|
||||
import com.youlai.common.result.PageResult;
|
||||
import com.youlai.common.result.Result;
|
||||
@ -24,13 +23,10 @@ import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.server.reactive.ServerHttpRequest;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Date;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -129,7 +125,6 @@ public class SysUserController {
|
||||
userDTO.setRoles(roles);
|
||||
}
|
||||
}
|
||||
|
||||
return userDTO;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.youlai.admin.entity;
|
||||
package com.youlai.admin.domain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
@ -1,4 +1,4 @@
|
||||
package com.youlai.admin.entity;
|
||||
package com.youlai.admin.domain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
@ -1,4 +1,4 @@
|
||||
package com.youlai.admin.entity;
|
||||
package com.youlai.admin.domain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
@ -1,4 +1,4 @@
|
||||
package com.youlai.admin.entity;
|
||||
package com.youlai.admin.domain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
@ -1,4 +1,4 @@
|
||||
package com.youlai.admin.entity;
|
||||
package com.youlai.admin.domain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.Data;
|
@ -1,4 +1,4 @@
|
||||
package com.youlai.admin.entity;
|
||||
package com.youlai.admin.domain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
@ -1,4 +1,4 @@
|
||||
package com.youlai.admin.entity;
|
||||
package com.youlai.admin.domain.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.youlai.admin.entity;
|
||||
package com.youlai.admin.domain.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.youlai.admin.entity;
|
||||
package com.youlai.admin.domain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.youlai.common.core.entity.BaseEntity;
|
@ -1,4 +1,4 @@
|
||||
package com.youlai.admin.entity;
|
||||
package com.youlai.admin.domain.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
@ -1,7 +1,5 @@
|
||||
package com.youlai.admin.vo;
|
||||
package com.youlai.admin.domain.vo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
@ -0,0 +1,31 @@
|
||||
package com.youlai.admin.domain.vo;
|
||||
|
||||
import com.youlai.common.core.entity.BaseEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class MenuVO extends BaseEntity {
|
||||
|
||||
private Integer id;
|
||||
|
||||
private String name;
|
||||
|
||||
private Integer parentId;
|
||||
|
||||
private String icon;
|
||||
|
||||
private Integer sort;
|
||||
|
||||
private Integer visible;
|
||||
|
||||
private Integer status;
|
||||
|
||||
private String path;
|
||||
|
||||
private String perms;
|
||||
|
||||
private List<MenuVO> children;
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.youlai.admin.vo;
|
||||
package com.youlai.admin.domain.vo;
|
||||
|
||||
|
||||
import lombok.Data;
|
@ -1,4 +1,4 @@
|
||||
package com.youlai.admin.vo;
|
||||
package com.youlai.admin.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.youlai.admin.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.youlai.admin.entity.SysDept;
|
||||
import com.youlai.admin.domain.entity.SysDept;
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
@Mapper
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.youlai.admin.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.youlai.admin.entity.SysDict;
|
||||
import com.youlai.admin.domain.entity.SysDict;
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
@Mapper
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.youlai.admin.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.youlai.admin.entity.SysDictType;
|
||||
import com.youlai.admin.domain.entity.SysDictType;
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
@Mapper
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.youlai.admin.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.youlai.admin.entity.SysMenu;
|
||||
import com.youlai.admin.domain.entity.SysMenu;
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
@Mapper
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.youlai.admin.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.youlai.admin.entity.SysPermission;
|
||||
import com.youlai.admin.domain.entity.SysPermission;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.youlai.admin.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.youlai.admin.entity.SysRole;
|
||||
import com.youlai.admin.domain.entity.SysRole;
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
@Mapper
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.youlai.admin.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.youlai.admin.entity.SysRoleMenu;
|
||||
import com.youlai.admin.domain.entity.SysRoleMenu;
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
@Mapper
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.youlai.admin.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.youlai.admin.entity.SysRolePermission;
|
||||
import com.youlai.admin.domain.entity.SysRolePermission;
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
@Mapper
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.youlai.admin.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.youlai.admin.entity.SysUser;
|
||||
import com.youlai.admin.domain.entity.SysUser;
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
@Mapper
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.youlai.admin.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.youlai.admin.entity.SysUserRole;
|
||||
import com.youlai.admin.domain.entity.SysUserRole;
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
@Mapper
|
||||
|
@ -3,9 +3,9 @@ package com.youlai.admin.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.youlai.admin.entity.SysDept;
|
||||
import com.youlai.admin.vo.DeptVO;
|
||||
import com.youlai.admin.vo.TreeSelectVO;
|
||||
import com.youlai.admin.domain.entity.SysDept;
|
||||
import com.youlai.admin.domain.vo.DeptVO;
|
||||
import com.youlai.admin.domain.vo.TreeSelectVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -2,7 +2,7 @@ package com.youlai.admin.service;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.youlai.admin.entity.SysDict;
|
||||
import com.youlai.admin.domain.entity.SysDict;
|
||||
|
||||
public interface ISysDictService extends IService<SysDict> {
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package com.youlai.admin.service;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.youlai.admin.entity.SysDictType;
|
||||
import com.youlai.admin.domain.entity.SysDictType;
|
||||
|
||||
|
||||
public interface ISysDictTypeService extends IService<SysDictType> {
|
||||
|
@ -1,8 +1,17 @@
|
||||
package com.youlai.admin.service;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.youlai.admin.entity.SysMenu;
|
||||
import com.youlai.admin.domain.entity.SysMenu;
|
||||
import com.youlai.admin.domain.vo.MenuVO;
|
||||
import com.youlai.admin.domain.vo.TreeSelectVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ISysMenuService extends IService<SysMenu> {
|
||||
|
||||
List<MenuVO> listForTableData(LambdaQueryWrapper<SysMenu> baseQuery);
|
||||
|
||||
List<TreeSelectVO> listForTreeSelect(LambdaQueryWrapper<SysMenu> baseQuery);
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package com.youlai.admin.service;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.youlai.admin.entity.SysPermission;
|
||||
import com.youlai.admin.domain.entity.SysPermission;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -2,7 +2,7 @@ package com.youlai.admin.service;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.youlai.admin.entity.SysRoleMenu;
|
||||
import com.youlai.admin.domain.entity.SysRoleMenu;
|
||||
|
||||
public interface ISysRoleMenuService extends IService<SysRoleMenu> {
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package com.youlai.admin.service;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.youlai.admin.entity.SysRolePermission;
|
||||
import com.youlai.admin.domain.entity.SysRolePermission;
|
||||
|
||||
public interface ISysRolePermissionService extends IService<SysRolePermission> {
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package com.youlai.admin.service;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.youlai.admin.entity.SysRole;
|
||||
import com.youlai.admin.domain.entity.SysRole;
|
||||
|
||||
public interface ISysRoleService extends IService<SysRole> {
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package com.youlai.admin.service;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.youlai.admin.entity.SysUserRole;
|
||||
import com.youlai.admin.domain.entity.SysUserRole;
|
||||
|
||||
public interface ISysUserRoleService extends IService<SysUserRole> {
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package com.youlai.admin.service;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.youlai.admin.entity.SysUser;
|
||||
import com.youlai.admin.domain.entity.SysUser;
|
||||
|
||||
public interface ISysUserService extends IService<SysUser> {
|
||||
}
|
||||
|
@ -4,11 +4,11 @@ import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.youlai.admin.common.AdminConstant;
|
||||
import com.youlai.admin.entity.SysDept;
|
||||
import com.youlai.admin.domain.entity.SysDept;
|
||||
import com.youlai.admin.mapper.SysDeptMapper;
|
||||
import com.youlai.admin.service.ISysDeptService;
|
||||
import com.youlai.admin.vo.DeptVO;
|
||||
import com.youlai.admin.vo.TreeSelectVO;
|
||||
import com.youlai.admin.domain.vo.DeptVO;
|
||||
import com.youlai.admin.domain.vo.TreeSelectVO;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -26,6 +26,16 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<TreeSelectVO> listForTreeSelect(LambdaQueryWrapper<SysDept> baseQuery) {
|
||||
List<SysDept> deptList = this.baseMapper.selectList(baseQuery);
|
||||
List<TreeSelectVO> list = recursionForTreeSelect(AdminConstant.ROOT_DEPT_ID, deptList);
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 递归生成部门表格数据
|
||||
* @param parentId
|
||||
@ -47,12 +57,6 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TreeSelectVO> listForTreeSelect(LambdaQueryWrapper<SysDept> baseQuery) {
|
||||
List<SysDept> deptList = this.baseMapper.selectList(baseQuery);
|
||||
List<TreeSelectVO> list = recursionForTreeSelect(AdminConstant.ROOT_DEPT_ID, deptList);
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归生成部门树形下拉数据
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.youlai.admin.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.youlai.admin.entity.SysDict;
|
||||
import com.youlai.admin.domain.entity.SysDict;
|
||||
import com.youlai.admin.mapper.SysDictMapper;
|
||||
import com.youlai.admin.service.ISysDictService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.youlai.admin.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.youlai.admin.entity.SysDictType;
|
||||
import com.youlai.admin.domain.entity.SysDictType;
|
||||
import com.youlai.admin.mapper.SysDictTypeMapper;
|
||||
import com.youlai.admin.service.ISysDictTypeService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -1,12 +1,86 @@
|
||||
package com.youlai.admin.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.youlai.admin.entity.SysMenu;
|
||||
import com.youlai.admin.common.AdminConstant;
|
||||
import com.youlai.admin.domain.entity.SysMenu;
|
||||
import com.youlai.admin.domain.entity.SysMenu;
|
||||
import com.youlai.admin.domain.vo.MenuVO;
|
||||
import com.youlai.admin.domain.vo.MenuVO;
|
||||
import com.youlai.admin.domain.vo.TreeSelectVO;
|
||||
import com.youlai.admin.mapper.SysMenuMapper;
|
||||
import com.youlai.admin.service.ISysMenuService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> implements ISysMenuService {
|
||||
|
||||
|
||||
@Override
|
||||
public List<MenuVO> listForTableData(LambdaQueryWrapper<SysMenu> baseQuery) {
|
||||
List<SysMenu> deptList = this.baseMapper.selectList(baseQuery);
|
||||
List<MenuVO> list = recursionForTableData(AdminConstant.ROOT_DEPT_ID, deptList);
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<TreeSelectVO> listForTreeSelect(LambdaQueryWrapper<SysMenu> baseQuery) {
|
||||
List<SysMenu> deptList = this.baseMapper.selectList(baseQuery);
|
||||
List<TreeSelectVO> list = recursionForTreeSelect(AdminConstant.ROOT_DEPT_ID, deptList);
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 递归生成部门表格数据
|
||||
* @param parentId
|
||||
* @param deptList
|
||||
* @return
|
||||
*/
|
||||
public static List<MenuVO> recursionForTableData(int parentId, List<SysMenu> deptList) {
|
||||
List<MenuVO> list = new ArrayList<>();
|
||||
Optional.ofNullable(deptList).orElse(new ArrayList<>())
|
||||
.stream()
|
||||
.filter(dept -> dept.getParentId().equals(parentId))
|
||||
.forEach(dept -> {
|
||||
MenuVO deptVO = new MenuVO();
|
||||
BeanUtil.copyProperties(dept, deptVO);
|
||||
List<MenuVO> children = recursionForTableData(dept.getId(), deptList);
|
||||
deptVO.setChildren(children);
|
||||
list.add(deptVO);
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 递归生成部门树形下拉数据
|
||||
* @param parentId
|
||||
* @param deptList
|
||||
* @return
|
||||
*/
|
||||
public static List<TreeSelectVO> recursionForTreeSelect(int parentId, List<SysMenu> deptList) {
|
||||
List<TreeSelectVO> list = new ArrayList<>();
|
||||
Optional.ofNullable(deptList).orElse(new ArrayList<>())
|
||||
.stream()
|
||||
.filter(dept -> dept.getParentId().equals(parentId))
|
||||
.forEach(dept -> {
|
||||
TreeSelectVO treeSelectVO = new TreeSelectVO();
|
||||
treeSelectVO.setId(dept.getId().toString());
|
||||
treeSelectVO.setLabel(dept.getName());
|
||||
List<TreeSelectVO> children = recursionForTreeSelect(dept.getId(), deptList);
|
||||
treeSelectVO.setChildren(children);
|
||||
list.add(treeSelectVO);
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.youlai.admin.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.youlai.admin.entity.SysPermission;
|
||||
import com.youlai.admin.domain.entity.SysPermission;
|
||||
import com.youlai.admin.mapper.SysPermissionMapper;
|
||||
import com.youlai.admin.service.ISysPermissionService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.youlai.admin.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.youlai.admin.entity.SysRoleMenu;
|
||||
import com.youlai.admin.domain.entity.SysRoleMenu;
|
||||
import com.youlai.admin.mapper.SysRoleMenuMapper;
|
||||
import com.youlai.admin.service.ISysRoleMenuService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.youlai.admin.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.youlai.admin.entity.SysRolePermission;
|
||||
import com.youlai.admin.domain.entity.SysRolePermission;
|
||||
import com.youlai.admin.mapper.SysRolePermissionMapper;
|
||||
import com.youlai.admin.service.ISysRolePermissionService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.youlai.admin.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.youlai.admin.entity.SysRole;
|
||||
import com.youlai.admin.domain.entity.SysRole;
|
||||
import com.youlai.admin.mapper.SysRoleMapper;
|
||||
import com.youlai.admin.service.ISysRoleService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.youlai.admin.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.youlai.admin.entity.SysUserRole;
|
||||
import com.youlai.admin.domain.entity.SysUserRole;
|
||||
import com.youlai.admin.mapper.SysUserRoleMapper;
|
||||
import com.youlai.admin.service.ISysUserRoleService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.youlai.admin.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.youlai.admin.entity.SysUser;
|
||||
import com.youlai.admin.domain.entity.SysUser;
|
||||
import com.youlai.admin.mapper.SysUserMapper;
|
||||
import com.youlai.admin.service.ISysUserService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
Loading…
Reference in New Issue
Block a user