glj-代码提交

This commit is contained in:
管李杰 2024-05-27 10:22:52 +08:00
parent b274304f6c
commit df63d63a2d
43 changed files with 3371 additions and 6 deletions

View File

@ -14,7 +14,8 @@ public interface LauncherConstant {
/**
* nacos namespace id
*/
String NACOS_NAMESPACE = "62fddd43-b621-43f6-9733-75a6e4d6756b";
// String NACOS_NAMESPACE = "62fddd43-b621-43f6-9733-75a6e4d6756b";
String NACOS_NAMESPACE = "vordm";
/**
* nacos dev 地址

View File

@ -0,0 +1,33 @@
/*
* 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 com.kening.vordm.DTO;
import lombok.Data;
import java.io.Serializable;
/**
* 数据传输对象实体类
*
* @author Chill
*/
@Data
public class MenuDTO implements Serializable {
private static final long serialVersionUID = 1L;
private String alias;
private String path;
}

View File

@ -0,0 +1,70 @@
package com.kening.vordm.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 首页轮播管理
* @TableName install
*/
@TableName(value ="install")
@Data
public class Install implements Serializable {
/**
* 首页轮播
*/
@TableId
private Long id;
/**
* 名称
*/
private String title;
/**
* 图片信息
*/
private String images;
/**
* 连接
*/
private String link;
/**
* 种类
*/
private String sort;
/**
* 是否删除0未删除/1已删除
*/
private Integer isDeleted;
/**
* 创建时间
*/
private Date createTime;
/**
* 状态
*/
private Integer status;
/**
* 名称_查询
*/
@TableField(exist = false)
private String name;
@TableField(exist = false)
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,142 @@
/*
* 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 com.kening.vordm.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springblade.core.tool.utils.Func;
import java.io.Serializable;
/**
* 实体类
*
* @author Chill
*/
@Data
@TableName("blade_menu")
@ApiModel(value = "Menu对象", description = "Menu对象")
public class Menu implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@JsonSerialize(using = ToStringSerializer.class)
@ApiModelProperty(value = "主键")
@TableId(value = "id", type = IdType.ASSIGN_ID)
private Long id;
/**
* 菜单父主键
*/
@JsonSerialize(using = ToStringSerializer.class)
@ApiModelProperty(value = "菜单父主键")
private Long parentId;
/**
* 菜单编号
*/
@ApiModelProperty(value = "菜单编号")
private String code;
/**
* 菜单名称
*/
@ApiModelProperty(value = "菜单名称")
private String name;
/**
* 菜单别名
*/
@ApiModelProperty(value = "菜单别名")
private String alias;
/**
* 请求地址
*/
@ApiModelProperty(value = "请求地址")
private String path;
/**
* 菜单资源
*/
@ApiModelProperty(value = "菜单资源")
private String source;
/**
* 排序
*/
@ApiModelProperty(value = "排序")
private Integer sort;
/**
* 菜单类型
*/
@ApiModelProperty(value = "菜单类型")
private Integer category;
/**
* 操作按钮类型
*/
@ApiModelProperty(value = "操作按钮类型")
private Integer action;
/**
* 是否打开新页面
*/
@ApiModelProperty(value = "是否打开新页面")
private Integer isOpen;
/**
* 备注
*/
@ApiModelProperty(value = "备注")
private String remark;
/**
* 是否已删除
*/
@TableLogic
@ApiModelProperty(value = "是否已删除")
private Integer isDeleted;
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
Menu other = (Menu) obj;
if (Func.equals(this.getId(), other.getId())) {
return true;
}
return false;
}
}

View File

@ -0,0 +1,128 @@
/*
* 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 com.kening.vordm.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* 行政区划表实体类
*
* @author Chill
*/
@Data
@TableName("blade_region")
@ApiModel(value = "Region对象", description = "行政区划表")
public class Region implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 区划编号
*/
@TableId(value = "code", type = IdType.INPUT)
@ApiModelProperty(value = "区划编号")
private String code;
/**
* 父区划编号
*/
@ApiModelProperty(value = "父区划编号")
private String parentCode;
/**
* 祖区划编号
*/
@ApiModelProperty(value = "祖区划编号")
private String ancestors;
/**
* 区划名称
*/
@ApiModelProperty(value = "区划名称")
private String name;
/**
* 省级区划编号
*/
@ApiModelProperty(value = "省级区划编号")
private String provinceCode;
/**
* 省级名称
*/
@ApiModelProperty(value = "省级名称")
private String provinceName;
/**
* 市级区划编号
*/
@ApiModelProperty(value = "市级区划编号")
private String cityCode;
/**
* 市级名称
*/
@ApiModelProperty(value = "市级名称")
private String cityName;
/**
* 区级区划编号
*/
@ApiModelProperty(value = "区级区划编号")
private String districtCode;
/**
* 区级名称
*/
@ApiModelProperty(value = "区级名称")
private String districtName;
/**
* 镇级区划编号
*/
@ApiModelProperty(value = "镇级区划编号")
private String townCode;
/**
* 镇级名称
*/
@ApiModelProperty(value = "镇级名称")
private String townName;
/**
* 村级区划编号
*/
@ApiModelProperty(value = "村级区划编号")
private String villageCode;
/**
* 村级名称
*/
@ApiModelProperty(value = "村级名称")
private String villageName;
/**
* 层级
*/
@ApiModelProperty(value = "层级")
private Integer regionLevel;
/**
* 排序
*/
@ApiModelProperty(value = "排序")
private Integer sort;
/**
* 备注
*/
@ApiModelProperty(value = "备注")
private String remark;
}

View File

@ -0,0 +1,90 @@
/*
* 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 com.kening.vordm.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* 实体类
*
* @author Chill
*/
@Data
@TableName("blade_role")
@ApiModel(value = "Role对象", description = "Role对象")
public class Role implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@JsonSerialize(using = ToStringSerializer.class)
@ApiModelProperty(value = "主键")
@TableId(value = "id", type = IdType.ASSIGN_ID)
private Long id;
/**
* 租户ID
*/
@ApiModelProperty(value = "租户ID")
private String tenantId;
/**
* 父主键
*/
@JsonSerialize(using = ToStringSerializer.class)
@ApiModelProperty(value = "父主键")
private Long parentId;
/**
* 角色名
*/
@ApiModelProperty(value = "角色名")
private String roleName;
/**
* 排序
*/
@ApiModelProperty(value = "排序")
private Integer sort;
/**
* 角色别名
*/
@ApiModelProperty(value = "角色别名")
private String roleAlias;
/**
* 是否已删除
*/
@TableLogic
@ApiModelProperty(value = "是否已删除")
private Integer isDeleted;
}

View File

@ -0,0 +1,65 @@
/*
* 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 com.kening.vordm.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 io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* 实体类
*
* @author Chill
*/
@Data
@TableName("blade_role_menu")
@ApiModel(value = "RoleMenu对象", description = "RoleMenu对象")
public class RoleMenu implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@JsonSerialize(using = ToStringSerializer.class)
@ApiModelProperty(value = "主键")
@TableId(value = "id", type = IdType.ASSIGN_ID)
private Long id;
/**
* 菜单id
*/
@JsonSerialize(using = ToStringSerializer.class)
@ApiModelProperty(value = "菜单id")
private Long menuId;
/**
* 角色id
*/
@JsonSerialize(using = ToStringSerializer.class)
@ApiModelProperty(value = "角色id")
private Long roleId;
}

View File

@ -0,0 +1,71 @@
/*
* 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 com.kening.vordm.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 io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* 实体类
*
* @author Chill
*/
@Data
@TableName("blade_role_scope")
@ApiModel(value = "RoleScope对象", description = "RoleScope对象")
public class RoleScope implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@JsonSerialize(using = ToStringSerializer.class)
@ApiModelProperty(value = "主键")
@TableId(value = "id", type = IdType.ASSIGN_ID)
private Long id;
/**
* 权限类型
*/
@ApiModelProperty(value = "权限类型")
private Integer scopeCategory;
/**
* 权限id
*/
@JsonSerialize(using = ToStringSerializer.class)
@ApiModelProperty(value = "权限id")
private Long scopeId;
/**
* 角色id
*/
@JsonSerialize(using = ToStringSerializer.class)
@ApiModelProperty(value = "角色id")
private Long roleId;
}

View File

@ -0,0 +1,37 @@
/*
* 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 com.kening.vordm.vo;
import lombok.Data;
import java.util.List;
/**
* CheckedTreeVO
*
* @author Chill
*/
@Data
public class CheckedTreeVO {
private List<String> menu;
private List<String> dataScope;
private List<String> apiScope;
}

View File

@ -0,0 +1,39 @@
/*
* 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 com.kening.vordm.vo;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* GrantTreeVO
*
* @author Chill
*/
@Data
public class GrantTreeVO implements Serializable {
private static final long serialVersionUID = 1L;
private List<MenuVO> menu;
private List<MenuVO> dataScope;
private List<MenuVO> apiScope;
}

View File

@ -0,0 +1,49 @@
/*
* 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 com.kening.vordm.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* GrantVO
*
* @author Chill
*/
@Data
public class GrantVO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "roleIds集合")
private List<Long> roleIds;
@ApiModelProperty(value = "menuIds集合")
private List<Long> menuIds;
@ApiModelProperty(value = "topMenuIds集合")
private List<Long> topMenuIds;
@ApiModelProperty(value = "dataScopeIds集合")
private List<Long> dataScopeIds;
@ApiModelProperty(value = "apiScopeIds集合")
private List<Long> apiScopeIds;
}

View File

@ -0,0 +1,94 @@
/*
* 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 com.kening.vordm.vo;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.kening.vordm.entity.Menu;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.tool.node.INode;
import java.util.ArrayList;
import java.util.List;
/**
* 视图实体类
*
* @author Chill
*/
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "MenuVO对象", description = "MenuVO对象")
public class MenuVO extends Menu implements INode<MenuVO> {
private static final long serialVersionUID = 1L;
/**
* 主键ID
*/
@JsonSerialize(using = ToStringSerializer.class)
private Long id;
/**
* 父节点ID
*/
@JsonSerialize(using = ToStringSerializer.class)
private Long parentId;
/**
* 子孙节点
*/
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private List<MenuVO> children;
/**
* 是否有子孙节点
*/
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private Boolean hasChildren;
@Override
public List<MenuVO> getChildren() {
if (this.children == null) {
this.children = new ArrayList<>();
}
return this.children;
}
/**
* 上级菜单
*/
private String parentName;
/**
* 菜单类型
*/
private String categoryName;
/**
* 按钮功能
*/
private String actionName;
/**
* 是否新窗口打开
*/
private String isOpenName;
}

View File

@ -0,0 +1,89 @@
/*
* 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 com.kening.vordm.vo;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.kening.vordm.entity.Region;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.tool.node.INode;
import org.springblade.core.tool.utils.Func;
import java.util.ArrayList;
import java.util.List;
/**
* 行政区划表视图实体类
*
* @author Chill
*/
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "RegionVO对象", description = "行政区划表")
public class RegionVO extends Region implements INode<RegionVO> {
private static final long serialVersionUID = 1L;
/**
* 主键ID
*/
@JsonSerialize(using = ToStringSerializer.class)
private Long id;
/**
* 父节点ID
*/
@JsonSerialize(using = ToStringSerializer.class)
private Long parentId;
/**
* 父节点名称
*/
private String parentName;
/**
* 是否有子孙节点
*/
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private Boolean hasChildren;
/**
* 子孙节点
*/
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private List<RegionVO> children;
@Override
public Long getId() {
return Func.toLong(this.getCode());
}
@Override
public Long getParentId() {
return Func.toLong(this.getParentCode());
}
@Override
public List<RegionVO> getChildren() {
if (this.children == null) {
this.children = new ArrayList<>();
}
return this.children;
}
}

View File

@ -0,0 +1,35 @@
/*
* 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 com.kening.vordm.vo;
import com.kening.vordm.entity.RoleMenu;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 视图实体类
*
* @author Chill
*/
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "RoleMenuVO对象", description = "RoleMenuVO对象")
public class RoleMenuVO extends RoleMenu {
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,72 @@
/*
* 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 com.kening.vordm.vo;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.kening.vordm.entity.Role;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.tool.node.INode;
import java.util.ArrayList;
import java.util.List;
/**
* 视图实体类
*
* @author Chill
*/
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "RoleVO对象", description = "RoleVO对象")
public class RoleVO extends Role implements INode<RoleVO> {
private static final long serialVersionUID = 1L;
/**
* 主键ID
*/
@JsonSerialize(using = ToStringSerializer.class)
private Long id;
/**
* 父节点ID
*/
@JsonSerialize(using = ToStringSerializer.class)
private Long parentId;
/**
* 子孙节点
*/
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private List<RoleVO> children;
@Override
public List<RoleVO> getChildren() {
if (this.children == null) {
this.children = new ArrayList<>();
}
return this.children;
}
/**
* 上级角色
*/
private String parentName;
}

View File

@ -39,10 +39,8 @@ public class AdministratorController {
* @return
*/
@GetMapping("/pages")
public R<IPage<Administrator>> pages(Query query, @RequestParam Map<String,Object> params){
public R<IPage<Administrator>> pages(Query query, @RequestParam Map<String,Object> params,@RequestParam String tenantId){
//查出角色名为chief的角色id 放入params中进行分页查询
Long roleId = service.getChiefRole("chief");
params.put("roleId_equal",String.valueOf(roleId));
return R.data(service.page(Condition.getPage(query),Condition.getQueryWrapper(params,Administrator.class)));
}

View File

@ -176,6 +176,19 @@ public class DisasterInfoController {
return R.data(dataMap);
}
/**
* 后台首页灾害信息统计 国家/灾害类型 取前十
*
* @param
* @return
*/
@GetMapping("/getCountryDisaster")
public R<List<GroupByUse>> getCountryDisaster() {
return R.data(disasterInfoService.getLeft2Data());
}
/**
* 首页数据展示包括响应中和未响应
*

View File

@ -0,0 +1,64 @@
package com.kening.vordm.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.kening.vordm.entity.Contact;
import com.kening.vordm.entity.Install;
import com.kening.vordm.service.InstallService;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.List;
@RestController
@AllArgsConstructor
@RequestMapping("/ui/install")
public class InstallController {
private InstallService installService;
@GetMapping("/list")
public R<IPage<Install>> list(Install install, Query query) {
QueryWrapper<Install> queryWrapper = Condition.getQueryWrapper(install);
if (!install.getName().isEmpty()){
queryWrapper.like("title",install.getName());
}
IPage<Install> pages = installService.page(Condition.getPage(query), queryWrapper);
return R.data(pages);
}
/**
* 获取所有图片
* @return
*/
@GetMapping("/getListAll")
public R<List<Install>> getListAll() {
return R.data(installService.list());
}
@PostMapping("/save")
public R save(@ApiParam(value = "Install对象", required = true) @RequestBody Install install) {
return R.status(installService.save(install));
}
@PostMapping("/update")
public R update(@ApiParam(value = "Install对象", required = true) @RequestBody Install install) {
return R.status(installService.updateById(install));
}
@PostMapping("/remove")
public R remove(@ApiParam(value = "主键", required = true) @RequestParam String ids) {
return R.status(installService.removeByIds(Arrays.asList(ids.split(","))));
}
@GetMapping("/detail")
public R<Install> detail(@ApiParam(value = "主键", required = true) @RequestParam String id) {
Install detail = installService.getById(id);
return R.data(detail);
}
}

View File

@ -0,0 +1,249 @@
/*
* 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 com.kening.vordm.controller;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.kening.vordm.entity.Menu;
import com.kening.vordm.service.IMenuService;
import com.kening.vordm.vo.CheckedTreeVO;
import com.kening.vordm.vo.GrantTreeVO;
import com.kening.vordm.vo.MenuVO;
import com.kening.vordm.wrapper.MenuWrapper;
import io.swagger.annotations.*;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.cache.utils.CacheUtil;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.secure.BladeUser;
import org.springblade.core.tenant.annotation.NonDS;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.support.Kv;
import org.springblade.core.tool.utils.Func;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import javax.validation.Valid;
import java.util.List;
import java.util.Map;
import static org.springblade.core.cache.constant.CacheConstant.MENU_CACHE;
/**
* 控制器
*
* @author Chill
*/
@NonDS
@RestController
@AllArgsConstructor
@RequestMapping("/ui/menu")
@Api(value = "菜单", tags = "菜单")
public class MenuController extends BladeController {
private final IMenuService menuService;
/**
* 详情
*/
@GetMapping("/detail")
@ApiOperationSupport(order = 1)
@ApiOperation(value = "详情", notes = "传入menu")
public R<MenuVO> detail(Menu menu) {
Menu detail = menuService.getOne(Condition.getQueryWrapper(menu));
return R.data(MenuWrapper.build().entityVO(detail));
}
/**
* 列表
*/
@GetMapping("/list")
@ApiImplicitParams({
@ApiImplicitParam(name = "code", value = "菜单编号", paramType = "query", dataType = "string"),
@ApiImplicitParam(name = "name", value = "菜单名称", paramType = "query", dataType = "string")
})
@ApiOperationSupport(order = 2)
@ApiOperation(value = "列表", notes = "传入menu")
public R<List<MenuVO>> list(@ApiIgnore @RequestParam Map<String, Object> menu) {
List<Menu> list = menuService.list(Condition.getQueryWrapper(menu, Menu.class).lambda().orderByAsc(Menu::getSort));
return R.data(MenuWrapper.build().listNodeVO(list));
}
/**
* 获取权限分配树形结构
*/
@GetMapping("/role-tree-keys")
@ApiOperationSupport(order = 13)
@ApiOperation(value = "角色所分配的树", notes = "角色所分配的树")
public R<CheckedTreeVO> roleTreeKeys(String roleIds) {
CheckedTreeVO vo = new CheckedTreeVO();
vo.setMenu(menuService.roleTreeKeys(roleIds));
vo.setDataScope(menuService.dataScopeTreeKeys(roleIds));
vo.setApiScope(menuService.apiScopeTreeKeys(roleIds));
return R.data(vo);
}
/**
* 懒加载列表
*/
@GetMapping("/lazy-list")
@ApiImplicitParams({
@ApiImplicitParam(name = "code", value = "菜单编号", paramType = "query", dataType = "string"),
@ApiImplicitParam(name = "name", value = "菜单名称", paramType = "query", dataType = "string")
})
@ApiOperationSupport(order = 3)
@ApiOperation(value = "懒加载列表", notes = "传入menu")
public R<List<MenuVO>> lazyList(Long parentId, @ApiIgnore @RequestParam Map<String, Object> menu) {
List<MenuVO> list = menuService.lazyList(parentId, menu);
return R.data(MenuWrapper.build().listNodeLazyVO(list));
}
/**
* 菜单列表
*/
@GetMapping("/menu-list")
@ApiImplicitParams({
@ApiImplicitParam(name = "code", value = "菜单编号", paramType = "query", dataType = "string"),
@ApiImplicitParam(name = "name", value = "菜单名称", paramType = "query", dataType = "string")
})
@ApiOperationSupport(order = 4)
@ApiOperation(value = "菜单列表", notes = "传入menu")
public R<List<MenuVO>> menuList(@ApiIgnore @RequestParam Map<String, Object> menu) {
List<Menu> list = menuService.list(Condition.getQueryWrapper(menu, Menu.class).lambda().eq(Menu::getCategory, 1).orderByAsc(Menu::getSort));
return R.data(MenuWrapper.build().listNodeVO(list));
}
/**
* 懒加载菜单列表
*/
@GetMapping("/lazy-menu-list")
@ApiImplicitParams({
@ApiImplicitParam(name = "code", value = "菜单编号", paramType = "query", dataType = "string"),
@ApiImplicitParam(name = "name", value = "菜单名称", paramType = "query", dataType = "string")
})
@ApiOperationSupport(order = 5)
@ApiOperation(value = "懒加载菜单列表", notes = "传入menu")
public R<List<MenuVO>> lazyMenuList(Long parentId, @ApiIgnore @RequestParam Map<String, Object> menu) {
List<MenuVO> list = menuService.lazyMenuList(parentId, menu);
return R.data(MenuWrapper.build().listNodeLazyVO(list));
}
/**
* 新增或修改
*/
@PostMapping("/submit")
@ApiOperationSupport(order = 6)
@ApiOperation(value = "新增或修改", notes = "传入menu")
public R submit(@Valid @RequestBody Menu menu) {
if (menuService.submit(menu)) {
CacheUtil.clear(MENU_CACHE);
CacheUtil.clear(MENU_CACHE, Boolean.FALSE);
// 返回懒加载树更新节点所需字段
Kv kv = Kv.create().set("id", String.valueOf(menu.getId()));
return R.data(kv);
}
return R.fail("操作失败");
}
/**
* 删除
*/
@PostMapping("/remove")
@ApiOperationSupport(order = 7)
@ApiOperation(value = "删除", notes = "传入ids")
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
CacheUtil.clear(MENU_CACHE);
CacheUtil.clear(MENU_CACHE, Boolean.FALSE);
return R.status(menuService.removeMenu(ids));
}
/**
* 前端菜单数据
*/
@GetMapping("/routes")
@ApiOperationSupport(order = 8)
@ApiOperation(value = "前端菜单数据", notes = "前端菜单数据")
public R<List<MenuVO>> routes(BladeUser user, Long topMenuId) {
List<MenuVO> list = menuService.routes((user == null) ? null : user.getRoleId(), topMenuId);
return R.data(list);
}
/**
* 前端按钮数据
*/
@GetMapping("/buttons")
@ApiOperationSupport(order = 10)
@ApiOperation(value = "前端按钮数据", notes = "前端按钮数据")
public R<List<MenuVO>> buttons(BladeUser user) {
List<MenuVO> list = menuService.buttons(user.getRoleId());
return R.data(list);
}
/**
* 获取菜单树形结构
*/
@GetMapping("/tree")
@ApiOperationSupport(order = 11)
@ApiOperation(value = "树形结构", notes = "树形结构")
public R<List<MenuVO>> tree() {
List<MenuVO> tree = menuService.tree();
return R.data(tree);
}
/**
* 获取权限分配树形结构
*/
@GetMapping("/grant-tree")
@ApiOperationSupport(order = 12)
@ApiOperation(value = "权限分配树形结构", notes = "权限分配树形结构")
public R<GrantTreeVO> grantTree(BladeUser user) {
GrantTreeVO vo = new GrantTreeVO();
vo.setMenu(menuService.grantTree(user));
vo.setDataScope(menuService.grantDataScopeTree(user));
vo.setApiScope(menuService.grantApiScopeTree(user));
return R.data(vo);
}
/**
* 获取顶部菜单树形结构
*/
@GetMapping("/grant-top-tree")
@ApiOperationSupport(order = 14)
@ApiOperation(value = "顶部菜单树形结构", notes = "顶部菜单树形结构")
public R<GrantTreeVO> grantTopTree(BladeUser user) {
GrantTreeVO vo = new GrantTreeVO();
vo.setMenu(menuService.grantTopTree(user));
return R.data(vo);
}
/**
* 获取配置的角色权限
*/
@GetMapping("auth-routes")
@ApiOperationSupport(order = 17)
@ApiOperation(value = "菜单的角色权限")
public R<List<Kv>> authRoutes(BladeUser user) {
if (Func.isEmpty(user)) {
return null;
}
return R.data(menuService.authRoutes(user));
}
}

View File

@ -0,0 +1,156 @@
/*
* 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 com.kening.vordm.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.kening.vordm.entity.Role;
import com.kening.vordm.service.IRoleService;
import com.kening.vordm.vo.GrantVO;
import com.kening.vordm.vo.RoleVO;
import com.kening.vordm.wrapper.RoleWrapper;
import io.swagger.annotations.*;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.cache.utils.CacheUtil;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.secure.BladeUser;
import org.springblade.core.tenant.annotation.NonDS;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.constant.BladeConstant;
import org.springblade.core.tool.node.TreeNode;
import org.springblade.core.tool.utils.Func;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import javax.validation.Valid;
import java.util.List;
import java.util.Map;
import static org.springblade.core.cache.constant.CacheConstant.SYS_CACHE;
/**
* 控制器
*
* @author Chill
*/
@NonDS
@RestController
@AllArgsConstructor
@RequestMapping("/role")
@Api(value = "角色", tags = "角色")
//@PreAuth(RoleConstant.HAS_ROLE_ADMIN)
public class RoleController extends BladeController {
private final IRoleService roleService;
/**
* 详情
*/
@GetMapping("/detail")
@ApiOperationSupport(order = 1)
@ApiOperation(value = "详情", notes = "传入role")
public R<RoleVO> detail(Role role) {
Role detail = roleService.getOne(Condition.getQueryWrapper(role));
return R.data(RoleWrapper.build().entityVO(detail));
}
/**
* 列表
*/
@GetMapping("/list")
@ApiImplicitParams({
@ApiImplicitParam(name = "roleName", value = "参数名称", paramType = "query", dataType = "string"),
@ApiImplicitParam(name = "roleAlias", value = "角色别名", paramType = "query", dataType = "string")
})
@ApiOperationSupport(order = 2)
@ApiOperation(value = "列表", notes = "传入role")
public R<List<RoleVO>> list(@ApiIgnore @RequestParam Map<String, Object> role, BladeUser bladeUser) {
QueryWrapper<Role> queryWrapper = Condition.getQueryWrapper(role, Role.class);
List<Role> list = roleService.list((!bladeUser.getTenantId().equals(BladeConstant.ADMIN_TENANT_ID)) ? queryWrapper.lambda().eq(Role::getTenantId, bladeUser.getTenantId()) : queryWrapper);
return R.data(RoleWrapper.build().listNodeVO(list));
}
/**
* 获取角色树形结构
*/
@GetMapping("/tree")
@ApiOperationSupport(order = 3)
@ApiOperation(value = "树形结构", notes = "树形结构")
public R<List<RoleVO>> tree(String tenantId, BladeUser bladeUser) {
List<RoleVO> tree = roleService.tree(Func.toStrWithEmpty(tenantId, bladeUser.getTenantId()));
return R.data(tree);
}
/**
* 获取指定角色树形结构
*/
@GetMapping("/tree-by-id")
@ApiOperationSupport(order = 4)
@ApiOperation(value = "树形结构", notes = "树形结构")
public R<List<RoleVO>> treeById(BladeUser bladeUser) {
List<RoleVO> tree = roleService.tree(bladeUser.getTenantId());
return R.data(tree);
}
/**
* 新增或修改
*/
@PostMapping("/submit")
@ApiOperationSupport(order = 5)
@ApiOperation(value = "新增或修改", notes = "传入role")
public R submit(@Valid @RequestBody Role role) {
CacheUtil.clear(SYS_CACHE);
return R.status(roleService.submit(role));
}
/**
* 删除
*/
@PostMapping("/remove")
@ApiOperationSupport(order = 6)
@ApiOperation(value = "删除", notes = "传入ids")
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
CacheUtil.clear(SYS_CACHE);
return R.status(roleService.removeByIds(Func.toLongList(ids)));
}
/**
* 设置角色权限
*/
@PostMapping("/grant")
@ApiOperationSupport(order = 7)
@ApiOperation(value = "权限设置", notes = "传入roleId集合以及menuId集合")
public R grant(@RequestBody GrantVO grantVO) {
CacheUtil.clear(SYS_CACHE);
boolean temp = roleService.grant(grantVO.getRoleIds(), grantVO.getMenuIds(), grantVO.getDataScopeIds(), grantVO.getApiScopeIds());
return R.status(temp);
}
/**
* 获取当前用户有权限的角色树形结构
*/
@GetMapping("/tree-by-user")
@ApiOperationSupport(order = 8)
@ApiOperation(value = "树形结构", notes = "树形结构")
public R<List<TreeNode>> treeByUser() {
List<TreeNode> tree = roleService.treeByUser();
return R.data(tree);
}
}

View File

@ -0,0 +1,18 @@
package com.kening.vordm.mapper;
import com.kening.vordm.entity.Install;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @author G
* @description 针对表install(首页轮播管理)的数据库操作Mapper
* @createDate 2024-05-23 15:09:50
* @Entity com.kening.vordm.entity.Install
*/
public interface InstallMapper extends BaseMapper<Install> {
}

View File

@ -0,0 +1,23 @@
<?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="com.kening.vordm.mapper.InstallMapper">
<resultMap id="BaseResultMap" type="com.kening.vordm.entity.Install">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="title" column="title" jdbcType="VARCHAR"/>
<result property="images" column="Images" jdbcType="VARCHAR"/>
<result property="link" column="link" jdbcType="VARCHAR"/>
<result property="sort" column="sort" jdbcType="VARCHAR"/>
<result property="isDeleted" column="is_deleted" jdbcType="INTEGER"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="status" column="status" jdbcType="INTEGER"/>
</resultMap>
<sql id="Base_Column_List">
id,title,Images,
link,sort,is_deleted,
create_time,status
</sql>
</mapper>

View File

@ -0,0 +1,166 @@
/*
* 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 com.kening.vordm.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.kening.vordm.DTO.MenuDTO;
import com.kening.vordm.entity.Menu;
import com.kening.vordm.vo.MenuVO;
import java.util.List;
import java.util.Map;
/**
* MenuMapper 接口
*
* @author Chill
*/
public interface MenuMapper extends BaseMapper<Menu> {
/**
* 懒加载列表
*
* @param parentId
* @param param
* @return
*/
List<MenuVO> lazyList(Long parentId, Map<String, Object> param);
/**
* 懒加载菜单列表
*
* @param parentId
* @param param
* @return
*/
List<MenuVO> lazyMenuList(Long parentId, Map<String, Object> param);
/**
* 树形结构
*
* @return
*/
List<MenuVO> tree();
/**
* 授权树形结构
*
* @return
*/
List<MenuVO> grantTree();
/**
* 授权树形结构
*
* @param roleId
* @return
*/
List<MenuVO> grantTreeByRole(List<Long> roleId);
/**
* 顶部菜单树形结构
*
* @return
*/
List<MenuVO> grantTopTree();
/**
* 顶部菜单树形结构
*
* @param roleId
* @return
*/
List<MenuVO> grantTopTreeByRole(List<Long> roleId);
/**
* 数据权限授权树形结构
*
* @return
*/
List<MenuVO> grantDataScopeTree();
/**
* 接口权限授权树形结构
*
* @return
*/
List<MenuVO> grantApiScopeTree();
/**
* 数据权限授权树形结构
*
* @param roleId
* @return
*/
List<MenuVO> grantDataScopeTreeByRole(List<Long> roleId);
/**
* 接口权限授权树形结构
*
* @param roleId
* @return
*/
List<MenuVO> grantApiScopeTreeByRole(List<Long> roleId);
/**
* 所有菜单
*
* @return
*/
List<Menu> allMenu();
/**
* 权限配置菜单
*
* @param roleId
* @param topMenuId
* @return
*/
List<Menu> roleMenu(List<Long> roleId, Long topMenuId);
/**
* 菜单树形结构
*
* @param roleId
* @return
*/
List<Menu> routes(List<Long> roleId);
/**
* 按钮树形结构
*
* @return
*/
List<Menu> allButtons();
/**
* 按钮树形结构
*
* @param roleId
* @return
*/
List<Menu> buttons(List<Long> roleId);
/**
* 获取配置的角色权限
*
* @param roleIds
* @return
*/
List<MenuDTO> authRoutes(List<Long> roleIds);
}

View File

@ -0,0 +1,461 @@
<?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="com.kening.vordm.mapper.MenuMapper">
<!-- 通用查询映射结果 -->
<resultMap id="menuResultMap" type="com.kening.vordm.entity.Menu">
<id column="id" property="id"/>
<result column="code" property="code"/>
<result column="parent_id" property="parentId"/>
<result column="name" property="name"/>
<result column="alias" property="alias"/>
<result column="path" property="path"/>
<result column="source" property="source"/>
<result column="sort" property="sort"/>
<result column="category" property="category"/>
<result column="action" property="action"/>
<result column="is_open" property="isOpen"/>
<result column="remark" property="remark"/>
<result column="is_deleted" property="isDeleted"/>
</resultMap>
<resultMap id="menuVOResultMap" type="com.kening.vordm.vo.MenuVO">
<id column="id" property="id"/>
<result column="code" property="code"/>
<result column="parent_id" property="parentId"/>
<result column="name" property="name"/>
<result column="alias" property="alias"/>
<result column="path" property="path"/>
<result column="source" property="source"/>
<result column="sort" property="sort"/>
<result column="category" property="category"/>
<result column="action" property="action"/>
<result column="is_open" property="isOpen"/>
<result column="remark" property="remark"/>
<result column="is_deleted" property="isDeleted"/>
<result column="has_children" property="hasChildren"/>
</resultMap>
<resultMap id="treeNodeResultMap" type="org.springblade.core.tool.node.TreeNode">
<id column="id" property="id"/>
<result column="parent_id" property="parentId"/>
<result column="title" property="title"/>
<result column="value" property="value"/>
<result column="key" property="key"/>
</resultMap>
<select id="lazyList" resultMap="menuVOResultMap">
SELECT
menu.*,
(
SELECT
CASE WHEN count( 1 ) > 0 THEN 1 ELSE 0 END
FROM
blade_menu
WHERE
parent_id = menu.id AND is_deleted = 0
) AS "has_children"
FROM
blade_menu menu
WHERE menu.is_deleted = 0
<if test="param1!=null">
and menu.parent_id = #{param1}
</if>
<if test="param2.name!=null and param2.name!=''">
and menu.name like concat(concat('%', #{param2.name}),'%')
</if>
<if test="param2.code!=null and param2.code!=''">
and menu.code like concat(concat('%', #{param2.code}),'%')
</if>
<if test="param2.alias!=null and param2.alias!=''">
and menu.alias like concat(concat('%', #{param2.alias}),'%')
</if>
ORDER BY menu.sort
</select>
<select id="lazyMenuList" resultMap="menuVOResultMap">
SELECT
menu.*,
(
SELECT
CASE WHEN count( 1 ) > 0 THEN 1 ELSE 0 END
FROM
blade_menu
WHERE
parent_id = menu.id AND is_deleted = 0 AND category = 1
) AS "has_children"
FROM
blade_menu menu
WHERE menu.is_deleted = 0 AND menu.category = 1
<if test="param1!=null">
and menu.parent_id = #{param1}
</if>
<if test="param2.name!=null and param2.name!=''">
and menu.name like concat(concat('%', #{param2.name}),'%')
</if>
<if test="param2.code!=null and param2.code!=''">
and menu.code like concat(concat('%', #{param2.code}),'%')
</if>
<if test="param2.alias!=null and param2.alias!=''">
and menu.alias like concat(concat('%', #{param2.alias}),'%')
</if>
ORDER BY menu.sort
</select>
<select id="tree" resultMap="treeNodeResultMap">
select id, parent_id, name as title, id as "value", id as "key" from blade_menu where is_deleted = 0 and category = 1
</select>
<select id="allMenu" resultMap="menuResultMap">
select * from blade_menu where is_deleted = 0 and category = 1
</select>
<select id="roleMenu" resultMap="menuResultMap">
select * from blade_menu where is_deleted = 0 and id IN
( SELECT menu_id FROM blade_role_menu WHERE role_id IN
<foreach collection="param1" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
)
<if test="param2!=null and param2>0">
AND id IN
(
SELECT menu_id FROM blade_top_menu_setting WHERE top_menu_id = #{param2}
)
</if>
</select>
<select id="routes" resultMap="menuResultMap">
SELECT
*
FROM
blade_menu
WHERE
is_deleted = 0 and category = 1
and id IN ( SELECT menu_id FROM blade_role_menu WHERE role_id IN
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach> )
</select>
<select id="allButtons" resultMap="menuResultMap">
SELECT
id,
parent_id,
CODE,
NAME,
alias,
path,
source,
action,
sort
FROM
blade_menu
WHERE
(
category = 2 OR id IN ( SELECT parent_id FROM blade_menu WHERE is_deleted = 0 AND category = 2 )
)
AND is_deleted = 0
ORDER BY sort
</select>
<select id="buttons" resultMap="menuResultMap">
SELECT * FROM (
SELECT
id,
parent_id,
code,
name,
alias,
path,
source,
action,
sort
FROM
blade_menu
WHERE
is_deleted = 0 and id IN (
SELECT parent_id FROM blade_menu
WHERE ( category = 2 AND id IN ( SELECT menu_id FROM blade_role_menu WHERE role_id IN
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
) ) )
UNION ALL
SELECT
id,
parent_id,
code,
name,
alias,
path,
source,
action,
sort
FROM
blade_menu
WHERE
is_deleted = 0 and category = 2 AND id IN ( SELECT menu_id FROM blade_role_menu WHERE role_id IN
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>)
) menu ORDER BY sort
</select>
<select id="grantTree" resultMap="treeNodeResultMap">
select id, parent_id, name as title, id as "value", id as "key" from blade_menu where is_deleted = 0 order by sort
</select>
<select id="grantTreeByRole" resultMap="treeNodeResultMap">
select id, parent_id, name as title, id as "value", id as "key" from blade_menu where is_deleted = 0
and id in ( select menu_id from blade_role_menu where role_id in
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach> )
or id in (
select parent_id from blade_menu where is_deleted = 0
and id in ( select menu_id from blade_role_menu where role_id in
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach> )
)
order by sort
</select>
<select id="grantTopTree" resultMap="treeNodeResultMap">
select id, parent_id, name as title, id as "value", id as "key" from blade_menu where category = 1 and is_deleted = 0 order by sort
</select>
<select id="grantTopTreeByRole" resultMap="treeNodeResultMap">
select id, parent_id, name as title, id as "value", id as "key" from blade_menu where category = 1 and is_deleted = 0
and id in ( select menu_id from blade_role_menu where role_id in
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach> )
or id in (
select parent_id from blade_menu where is_deleted = 0
and id in ( select menu_id from blade_role_menu where role_id in
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach> )
)
order by sort
</select>
<select id="grantDataScopeTree" resultMap="treeNodeResultMap">
SELECT
*
FROM
(
SELECT
id,
parent_id,
NAME AS title,
id AS "value",
id AS "key"
FROM
blade_menu
WHERE
category = 1
AND is_deleted = 0
AND id IN ( SELECT menu_id FROM blade_scope_data WHERE is_deleted = 0 AND menu_id IS NOT NULL )
) menu
UNION ALL
SELECT
id,
menu_id AS parent_id,
scope_name AS title,
id AS "value",
id AS "key"
FROM
blade_scope_data
WHERE
is_deleted = 0
AND menu_id IS NOT NULL
</select>
<select id="grantApiScopeTree" resultMap="treeNodeResultMap">
SELECT
*
FROM
(
SELECT
id,
parent_id,
NAME AS title,
id AS "value",
id AS "key"
FROM
blade_menu
WHERE
category = 1
AND is_deleted = 0
AND id IN ( SELECT menu_id FROM blade_scope_api WHERE is_deleted = 0 AND menu_id IS NOT NULL )
) menu
UNION ALL
SELECT
id,
menu_id AS parent_id,
scope_name AS title,
id AS "value",
id AS "key"
FROM
blade_scope_api
WHERE
is_deleted = 0
AND menu_id IS NOT NULL
</select>
<select id="grantDataScopeTreeByRole" resultMap="treeNodeResultMap">
SELECT
*
FROM
(
SELECT
id,
parent_id,
NAME AS title,
id AS "value",
id AS "key"
FROM
blade_menu
WHERE
category = 1
AND is_deleted = 0
AND id IN ( SELECT menu_id FROM blade_scope_data WHERE is_deleted = 0 AND menu_id IS NOT NULL )
AND (
id IN (
select menu_id from blade_role_menu where role_id in
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
)
OR id IN (
select parent_id from blade_menu where is_deleted = 0
and id in ( select menu_id from blade_role_menu where role_id in
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach> )
)
)
) menu
UNION ALL
SELECT
id,
menu_id AS parent_id,
scope_name AS title,
id AS "value",
id AS "key"
FROM
blade_scope_data
WHERE
is_deleted = 0
AND (
menu_id IN (
select menu_id from blade_role_menu where role_id in
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
)
OR menu_id IN (
select parent_id from blade_menu where is_deleted = 0
and id in ( select menu_id from blade_role_menu where role_id in
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach> )
)
)
AND menu_id IS NOT NULL
</select>
<select id="grantApiScopeTreeByRole" resultMap="treeNodeResultMap">
SELECT
*
FROM
(
SELECT
id,
parent_id,
NAME AS title,
id AS "value",
id AS "key"
FROM
blade_menu
WHERE
category = 1
AND is_deleted = 0
AND id IN ( SELECT menu_id FROM blade_scope_api WHERE is_deleted = 0 AND menu_id IS NOT NULL )
AND (
id IN (
select menu_id from blade_role_menu where role_id in
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
)
OR id IN (
select parent_id from blade_menu where is_deleted = 0
and id in (
select menu_id from blade_role_menu where role_id in
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach> )
)
)
) menu
UNION ALL
SELECT
id,
menu_id AS parent_id,
scope_name AS title,
id AS "value",
id AS "key"
FROM
blade_scope_api
WHERE
is_deleted = 0
AND
(
menu_id IN (
select menu_id from blade_role_menu where role_id in
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
)
OR menu_id IN (
select parent_id from blade_menu where is_deleted = 0
and id in ( select menu_id from blade_role_menu where role_id in
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach> )
)
)
AND menu_id IS NOT NULL
</select>
<select id="authRoutes" resultType="com.kening.vordm.DTO.MenuDTO">
SELECT
GROUP_CONCAT(r.role_alias) as alias,
m.path
FROM
blade_role_menu rm
LEFT JOIN blade_menu m ON rm.menu_id = m.id
LEFT JOIN blade_role r ON rm.role_id = r.id
WHERE
rm.role_id IN
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
AND m.path IS NOT NULL and m.is_deleted = 0
GROUP BY m.path
</select>
</mapper>

View File

@ -0,0 +1,81 @@
/*
* 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 com.kening.vordm.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.kening.vordm.entity.Role;
import com.kening.vordm.vo.RoleVO;
import org.springblade.core.tool.node.TreeNode;
import java.util.List;
/**
* Mapper 接口
*
* @author Chill
*/
public interface RoleMapper extends BaseMapper<Role> {
/**
* 自定义分页
*
* @param page
* @param role
* @return
*/
List<RoleVO> selectRolePage(IPage page, RoleVO role);
/**
* 获取树形节点
*
* @param tenantId
* @param excludeRole
* @return
*/
List<RoleVO> tree(String tenantId, String excludeRole);
/**
* 获取角色名
*
* @param ids
* @return
*/
List<String> getRoleNames(Long[] ids);
/**
* 获取角色名
*
* @param ids
* @return
*/
List<String> getRoleAliases(Long[] ids);
/**
* 根据父id获得树
* @param ids
* @return
*/
List<TreeNode> treeByParentIds(List<Long> ids);
/**
* 根据id获得list
* @param ids
* @return
*/
List<TreeNode> treeByIds(Long[] ids);
}

View File

@ -0,0 +1,87 @@
<?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="com.kening.vordm.mapper.RoleMapper">
<!-- 通用查询映射结果 -->
<resultMap id="roleResultMap" type="com.kening.vordm.entity.Role">
<id column="id" property="id"/>
<result column="parent_id" property="parentId"/>
<result column="role_name" property="roleName"/>
<result column="sort" property="sort"/>
<result column="role_alias" property="roleAlias"/>
<result column="is_deleted" property="isDeleted"/>
</resultMap>
<resultMap id="treeNodeResultMap" type="org.springblade.core.tool.node.TreeNode">
<id column="id" property="id"/>
<result column="parent_id" property="parentId"/>
<result column="title" property="title"/>
<result column="value" property="value"/>
<result column="key" property="key"/>
</resultMap>
<select id="selectRolePage" resultMap="roleResultMap">
select * from blade_role where is_deleted = 0
</select>
<select id="tree" resultMap="treeNodeResultMap">
select id, parent_id, role_name as title, id as "value", id as "key" from blade_role where is_deleted = 0
<if test="param1!=null">
and tenant_id = #{param1}
</if>
<if test="param2!=null">
and role_alias &lt;&gt; #{param2}
</if>
</select>
<select id="getRoleNames" resultType="java.lang.String">
SELECT
role_name
FROM
blade_role
WHERE
id IN
<foreach collection="array" item="ids" index="index" open="(" close=")" separator=",">
#{ids}
</foreach>
and is_deleted = 0
</select>
<select id="getRoleAliases" resultType="java.lang.String">
SELECT
role_alias
FROM
blade_role
WHERE
id IN
<foreach collection="array" item="ids" index="index" open="(" close=")" separator=",">
#{ids}
</foreach>
and is_deleted = 0
</select>
<select id="treeByParentIds" resultMap="treeNodeResultMap">
SELECT
id, parent_id, role_name as title, id as "value", id as "key"
FROM
blade_role
WHERE
parent_id IN
<foreach collection="ids" item="id" index="index" open="(" close=")" separator=",">
#{id}
</foreach>
and is_deleted = 0
</select>
<select id="treeByIds" resultMap="treeNodeResultMap">
SELECT
id, parent_id, role_name as title, id as "value", id as "key"
FROM
blade_role
WHERE
id IN
<foreach collection="array" item="ids" index="index" open="(" close=")" separator=",">
#{ids}
</foreach>
and is_deleted = 0
</select>
</mapper>

View File

@ -0,0 +1,41 @@
/*
* 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 com.kening.vordm.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.kening.vordm.entity.RoleMenu;
import com.kening.vordm.vo.RoleMenuVO;
import java.util.List;
/**
* Mapper 接口
*
* @author Chill
*/
public interface RoleMenuMapper extends BaseMapper<RoleMenu> {
/**
* 自定义分页
* @param page
* @param roleMenu
* @return
*/
List<RoleMenuVO> selectRoleMenuPage(IPage page, RoleMenuVO roleMenu);
}

View File

@ -0,0 +1,16 @@
<?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="com.kening.vordm.mapper.RoleMenuMapper">
<!-- 通用查询映射结果 -->
<resultMap id="roleMenuResultMap" type="com.kening.vordm.entity.RoleMenu">
<id column="id" property="id"/>
<result column="menu_id" property="menuId"/>
<result column="role_id" property="roleId"/>
</resultMap>
<select id="selectRoleMenuPage" resultMap="roleMenuResultMap">
select * from blade_role_menu where is_deleted = 0
</select>
</mapper>

View File

@ -0,0 +1,29 @@
/*
* 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 com.kening.vordm.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.kening.vordm.entity.RoleScope;
/**
* Mapper 接口
*
* @author Chill
*/
public interface RoleScopeMapper extends BaseMapper<RoleScope> {
}

View File

@ -0,0 +1,12 @@
<?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="com.kening.vordm.mapper.RoleScopeMapper">
<!-- 通用查询映射结果 -->
<resultMap id="roleMenuResultMap" type="com.kening.vordm.entity.RoleScope">
<id column="id" property="id"/>
<result column="scope_id" property="scopeId"/>
<result column="role_id" property="roleId"/>
</resultMap>
</mapper>

View File

@ -0,0 +1,157 @@
/*
* 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 com.kening.vordm.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.kening.vordm.entity.Menu;
import com.kening.vordm.vo.MenuVO;
import org.springblade.core.secure.BladeUser;
import org.springblade.core.tool.support.Kv;
import java.util.List;
import java.util.Map;
/**
* 服务类
*
* @author Chill
*/
public interface IMenuService extends IService<Menu> {
/**
* 懒加载列表
*
* @param parentId
* @param param
* @return
*/
List<MenuVO> lazyList(Long parentId, Map<String, Object> param);
/**
* 懒加载菜单列表
*
* @param parentId
* @param param
* @return
*/
List<MenuVO> lazyMenuList(Long parentId, Map<String, Object> param);
/**
* 菜单树形结构
*
* @param roleId
* @param topMenuId
* @return
*/
List<MenuVO> routes(String roleId, Long topMenuId);
/**
* 按钮树形结构
*
* @param roleId
* @return
*/
List<MenuVO> buttons(String roleId);
/**
* 树形结构
*
* @return
*/
List<MenuVO> tree();
/**
* 授权树形结构
*
* @param user
* @return
*/
List<MenuVO> grantTree(BladeUser user);
/**
* 顶部菜单树形结构
*
* @param user
* @return
*/
List<MenuVO> grantTopTree(BladeUser user);
/**
* 数据权限授权树形结构
*
* @param user
* @return
*/
List<MenuVO> grantDataScopeTree(BladeUser user);
/**
* 接口权限授权树形结构
*
* @param user
* @return
*/
List<MenuVO> grantApiScopeTree(BladeUser user);
/**
* 默认选中节点
*
* @param roleIds
* @return
*/
List<String> roleTreeKeys(String roleIds);
/**
* 默认选中节点
*
* @param roleIds
* @return
*/
List<String> dataScopeTreeKeys(String roleIds);
/**
* 默认选中节点
*
* @param roleIds
* @return
*/
List<String> apiScopeTreeKeys(String roleIds);
/**
* 获取配置的角色权限
*
* @param user
* @return
*/
List<Kv> authRoutes(BladeUser user);
/**
* 删除菜单
*
* @param ids
* @return
*/
boolean removeMenu(String ids);
/**
* 提交
*
* @param menu
* @return
*/
boolean submit(Menu menu);
}

View File

@ -0,0 +1,29 @@
/*
* 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 com.kening.vordm.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.kening.vordm.entity.RoleMenu;
/**
* 服务类
*
* @author Chill
*/
public interface IRoleMenuService extends IService<RoleMenu> {
}

View File

@ -0,0 +1,29 @@
/*
* 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 com.kening.vordm.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.kening.vordm.entity.RoleScope;
/**
* 服务类
*
* @author Chill
*/
public interface IRoleScopeService extends IService<RoleScope> {
}

View File

@ -0,0 +1,102 @@
/*
* 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 com.kening.vordm.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.kening.vordm.entity.Role;
import com.kening.vordm.vo.RoleVO;
import org.springblade.core.tool.node.TreeNode;
import javax.validation.constraints.NotEmpty;
import java.util.List;
/**
* 服务类
*
* @author Chill
*/
public interface IRoleService extends IService<Role> {
/**
* 自定义分页
*
* @param page
* @param role
* @return
*/
IPage<RoleVO> selectRolePage(IPage<RoleVO> page, RoleVO role);
/**
* 树形结构
*
* @param tenantId
* @return
*/
List<RoleVO> tree(String tenantId);
/**
* 获取角色ID
*
* @param tenantId
* @param roleNames
* @return
*/
String getRoleIds(String tenantId, String roleNames);
/**
* 获取角色名
*
* @param roleIds
* @return
*/
List<String> getRoleNames(String roleIds);
/**
* 获取角色名
*
* @param roleIds
* @return
*/
List<String> getRoleAliases(String roleIds);
/**
* 提交
*
* @param role
* @return
*/
boolean submit(Role role);
/**
* 获取当前用户有权限的角色树形结构
* @return
*/
List<TreeNode> treeByUser();
/**
* 权限配置
*
* @param roleIds 角色id集合
* @param menuIds 菜单id集合
* @param dataScopeIds 数据权限id集合
* @param apiScopeIds 接口权限id集合
* @return 是否成功
*/
boolean grant(@NotEmpty List<Long> roleIds, List<Long> menuIds, List<Long> dataScopeIds, List<Long> apiScopeIds);
}

View File

@ -0,0 +1,13 @@
package com.kening.vordm.service;
import com.kening.vordm.entity.Install;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @author G
* @description 针对表install(首页轮播管理)的数据库操作Service
* @createDate 2024-05-23 15:09:50
*/
public interface InstallService extends IService<Install> {
}

View File

@ -77,8 +77,8 @@ public class AdministratorServiceImpl extends BaseServiceImpl<AdministratorMappe
//密码默认为1234
administrator.setPassword(DigestUtil.encrypt(s));
//角色为chief
Long roleId = baseMapper.getChiefRole("chief");
administrator.setRoleId(String.valueOf(roleId));
// Long roleId = baseMapper.getChiefRole("chief");
// administrator.setRoleId(String.valueOf(roleId));
//保存chief管理员信息
save(administrator);
try{

View File

@ -0,0 +1,22 @@
package com.kening.vordm.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kening.vordm.entity.Install;
import com.kening.vordm.service.InstallService;
import com.kening.vordm.mapper.InstallMapper;
import org.springframework.stereotype.Service;
/**
* @author G
* @description 针对表install(首页轮播管理)的数据库操作Service实现
* @createDate 2024-05-23 15:09:50
*/
@Service
public class InstallServiceImpl extends ServiceImpl<InstallMapper, Install>
implements InstallService{
}

View File

@ -0,0 +1,200 @@
/*
* 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 com.kening.vordm.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kening.vordm.DTO.MenuDTO;
import com.kening.vordm.entity.Menu;
import com.kening.vordm.entity.RoleMenu;
import com.kening.vordm.entity.RoleScope;
import com.kening.vordm.mapper.MenuMapper;
import com.kening.vordm.service.IMenuService;
import com.kening.vordm.service.IRoleMenuService;
import com.kening.vordm.service.IRoleScopeService;
import com.kening.vordm.vo.MenuVO;
import com.kening.vordm.wrapper.MenuWrapper;
import lombok.AllArgsConstructor;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.secure.BladeUser;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.constant.BladeConstant;
import org.springblade.core.tool.node.ForestNodeMerger;
import org.springblade.core.tool.support.Kv;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.stream.Collectors;
import static org.springblade.core.cache.constant.CacheConstant.MENU_CACHE;
/**
* 服务实现类
*
* @author Chill
*/
@Service
@AllArgsConstructor
public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements IMenuService {
private final IRoleMenuService roleMenuService;
private final IRoleScopeService roleScopeService;
private final static String PARENT_ID = "parentId";
private final static Integer MENU_CATEGORY = 1;
@Override
public List<MenuVO> lazyList(Long parentId, Map<String, Object> param) {
if (Func.isEmpty(Func.toStr(param.get(PARENT_ID)))) {
parentId = null;
}
return baseMapper.lazyList(parentId, param);
}
@Override
public List<MenuVO> lazyMenuList(Long parentId, Map<String, Object> param) {
if (Func.isEmpty(Func.toStr(param.get(PARENT_ID)))) {
parentId = null;
}
return baseMapper.lazyMenuList(parentId, param);
}
@Override
public List<MenuVO> routes(String roleId, Long topMenuId) {
if (StringUtil.isBlank(roleId)) {
return null;
}
List<Menu> allMenus = baseMapper.allMenu();
List<Menu> roleMenus = (AuthUtil.isAdministrator() && Func.isEmpty(topMenuId)) ? allMenus : baseMapper.roleMenu(Func.toLongList(roleId), topMenuId);
return buildRoutes(allMenus, roleMenus);
}
private List<MenuVO> buildRoutes(List<Menu> allMenus, List<Menu> roleMenus) {
List<Menu> routes = new LinkedList<>(roleMenus);
roleMenus.forEach(roleMenu -> recursion(allMenus, routes, roleMenu));
routes.sort(Comparator.comparing(Menu::getSort));
MenuWrapper menuWrapper = new MenuWrapper();
List<Menu> collect = routes.stream().filter(x -> Func.equals(x.getCategory(), 1)).collect(Collectors.toList());
return menuWrapper.listNodeVO(collect);
}
private void recursion(List<Menu> allMenus, List<Menu> routes, Menu roleMenu) {
Optional<Menu> menu = allMenus.stream().filter(x -> Func.equals(x.getId(), roleMenu.getParentId())).findFirst();
if (menu.isPresent() && !routes.contains(menu.get())) {
routes.add(menu.get());
recursion(allMenus, routes, menu.get());
}
}
@Override
public List<MenuVO> buttons(String roleId) {
List<Menu> buttons = (AuthUtil.isAdministrator()) ? baseMapper.allButtons() : baseMapper.buttons(Func.toLongList(roleId));
MenuWrapper menuWrapper = new MenuWrapper();
return menuWrapper.listNodeVO(buttons);
}
@Override
public List<MenuVO> tree() {
return ForestNodeMerger.merge(baseMapper.tree());
}
@Override
public List<MenuVO> grantTree(BladeUser user) {
return ForestNodeMerger.merge(user.getTenantId().equals(BladeConstant.ADMIN_TENANT_ID) ? baseMapper.grantTree() : baseMapper.grantTreeByRole(Func.toLongList(user.getRoleId())));
}
@Override
public List<MenuVO> grantTopTree(BladeUser user) {
return ForestNodeMerger.merge(user.getTenantId().equals(BladeConstant.ADMIN_TENANT_ID) ? baseMapper.grantTopTree() : baseMapper.grantTopTreeByRole(Func.toLongList(user.getRoleId())));
}
@Override
public List<MenuVO> grantDataScopeTree(BladeUser user) {
return ForestNodeMerger.merge(user.getTenantId().equals(BladeConstant.ADMIN_TENANT_ID) ? baseMapper.grantDataScopeTree() : baseMapper.grantDataScopeTreeByRole(Func.toLongList(user.getRoleId())));
}
@Override
public List<MenuVO> grantApiScopeTree(BladeUser user) {
return ForestNodeMerger.merge(user.getTenantId().equals(BladeConstant.ADMIN_TENANT_ID) ? baseMapper.grantApiScopeTree() : baseMapper.grantApiScopeTreeByRole(Func.toLongList(user.getRoleId())));
}
@Override
public List<String> roleTreeKeys(String roleIds) {
List<RoleMenu> roleMenus = roleMenuService.list(Wrappers.<RoleMenu>query().lambda().in(RoleMenu::getRoleId, Func.toLongList(roleIds)));
return roleMenus.stream().map(roleMenu -> Func.toStr(roleMenu.getMenuId())).collect(Collectors.toList());
}
@Override
public List<String> dataScopeTreeKeys(String roleIds) {
List<RoleScope> roleScopes = roleScopeService.list(Wrappers.<RoleScope>query().lambda().eq(RoleScope::getScopeCategory, 1).in(RoleScope::getRoleId, Func.toLongList(roleIds)));
return roleScopes.stream().map(roleScope -> Func.toStr(roleScope.getScopeId())).collect(Collectors.toList());
}
@Override
public List<String> apiScopeTreeKeys(String roleIds) {
List<RoleScope> roleScopes = roleScopeService.list(Wrappers.<RoleScope>query().lambda().eq(RoleScope::getScopeCategory, 2).in(RoleScope::getRoleId, Func.toLongList(roleIds)));
return roleScopes.stream().map(roleScope -> Func.toStr(roleScope.getScopeId())).collect(Collectors.toList());
}
@Override
@Cacheable(cacheNames = MENU_CACHE, key = "'auth:routes:' + #user.roleId")
public List<Kv> authRoutes(BladeUser user) {
List<MenuDTO> routes = baseMapper.authRoutes(Func.toLongList(user.getRoleId()));
List<Kv> list = new ArrayList<>();
routes.forEach(route -> list.add(Kv.create().set(route.getPath(), Kv.create().set("authority", Func.toStrArray(route.getAlias())))));
return list;
}
@Override
public boolean removeMenu(String ids) {
Integer cnt = baseMapper.selectCount(Wrappers.<Menu>query().lambda().in(Menu::getParentId, Func.toLongList(ids)));
if (cnt > 0) {
throw new ServiceException("请先删除子节点!");
}
return removeByIds(Func.toLongList(ids));
}
@Override
public boolean submit(Menu menu) {
LambdaQueryWrapper<Menu> menuQueryWrapper = Wrappers.lambdaQuery();
if (menu.getId() == null) {
menuQueryWrapper.eq(Menu::getCode, menu.getCode()).or(
wrapper -> wrapper.eq(Menu::getName, menu.getName()).eq(Menu::getCategory, MENU_CATEGORY)
);
} else {
menuQueryWrapper.ne(Menu::getId, menu.getId()).and(
wrapper -> wrapper.eq(Menu::getCode, menu.getCode()).or(
o -> o.eq(Menu::getName, menu.getName()).eq(Menu::getCategory, MENU_CATEGORY)
)
);
}
Integer cnt = baseMapper.selectCount(menuQueryWrapper);
if (cnt > 0) {
throw new ServiceException("菜单名或编号已存在!");
}
if (menu.getParentId() == null && menu.getId() == null) {
menu.setParentId(BladeConstant.TOP_PARENT_ID);
}
menu.setIsDeleted(BladeConstant.DB_NOT_DELETED);
return saveOrUpdate(menu);
}
}

View File

@ -0,0 +1,33 @@
/*
* 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 com.kening.vordm.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kening.vordm.entity.RoleMenu;
import com.kening.vordm.mapper.RoleMenuMapper;
import com.kening.vordm.service.IRoleMenuService;
import org.springframework.stereotype.Service;
/**
* 服务实现类
*
* @author Chill
*/
@Service
public class RoleMenuServiceImpl extends ServiceImpl<RoleMenuMapper, RoleMenu> implements IRoleMenuService {
}

View File

@ -0,0 +1,33 @@
/*
* 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 com.kening.vordm.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kening.vordm.entity.RoleScope;
import com.kening.vordm.mapper.RoleScopeMapper;
import com.kening.vordm.service.IRoleScopeService;
import org.springframework.stereotype.Service;
/**
* 服务实现类
*
* @author Chill
*/
@Service
public class RoleScopeServiceImpl extends ServiceImpl<RoleScopeMapper, RoleScope> implements IRoleScopeService {
}

View File

@ -0,0 +1,212 @@
/*
* 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 com.kening.vordm.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kening.vordm.entity.Role;
import com.kening.vordm.entity.RoleMenu;
import com.kening.vordm.entity.RoleScope;
import com.kening.vordm.mapper.RoleMapper;
import com.kening.vordm.service.IRoleMenuService;
import com.kening.vordm.service.IRoleScopeService;
import com.kening.vordm.service.IRoleService;
import com.kening.vordm.vo.RoleVO;
import lombok.AllArgsConstructor;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.constant.BladeConstant;
import org.springblade.core.tool.constant.RoleConstant;
import org.springblade.core.tool.node.ForestNodeMerger;
import org.springblade.core.tool.node.TreeNode;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.Func;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import javax.validation.constraints.NotEmpty;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;
import static org.springblade.common.constant.CommonConstant.API_SCOPE_CATEGORY;
import static org.springblade.common.constant.CommonConstant.DATA_SCOPE_CATEGORY;
/**
* 服务实现类
*
* @author Chill
*/
@Service
@Validated
@AllArgsConstructor
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IRoleService {
private final IRoleMenuService roleMenuService;
private final IRoleScopeService roleScopeService;
@Override
public IPage<RoleVO> selectRolePage(IPage<RoleVO> page, RoleVO role) {
return page.setRecords(baseMapper.selectRolePage(page, role));
}
@Override
public List<RoleVO> tree(String tenantId) {
String userRole = AuthUtil.getUserRole();
String excludeRole = null;
if (!CollectionUtil.contains(Func.toStrArray(userRole), RoleConstant.ADMIN) && !CollectionUtil.contains(Func.toStrArray(userRole), RoleConstant.ADMINISTRATOR)) {
excludeRole = RoleConstant.ADMINISTRATOR;
}
return ForestNodeMerger.merge(baseMapper.tree(tenantId, excludeRole));
}
private void recursionRoleMenu(List<Long> roleIds, List<Long> menuIds) {
roleIds.forEach(roleId -> baseMapper.selectList(Wrappers.<Role>query().lambda().eq(Role::getParentId, roleId)).forEach(role -> {
List<RoleMenu> roleMenuList = roleMenuService.list(Wrappers.<RoleMenu>query().lambda().eq(RoleMenu::getRoleId, role.getId()));
// 子节点过滤出父节点删除的菜单集合
List<Long> collectRoleMenuIds = roleMenuList.stream().map(RoleMenu::getMenuId).filter(menuId -> !menuIds.contains(menuId)).collect(Collectors.toList());
if (collectRoleMenuIds.size() > 0) {
// 删除子节点权限外的菜单集合
roleMenuService.remove(Wrappers.<RoleMenu>update().lambda().eq(RoleMenu::getRoleId, role.getId()).in(RoleMenu::getMenuId, collectRoleMenuIds));
// 递归设置下属角色菜单集合
recursionRoleMenu(Collections.singletonList(role.getId()), menuIds);
}
}));
}
@Override
public String getRoleIds(String tenantId, String roleNames) {
List<Role> roleList = baseMapper.selectList(Wrappers.<Role>query().lambda().eq(Role::getTenantId, tenantId).in(Role::getRoleName, Func.toStrList(roleNames)));
if (roleList != null && roleList.size() > 0) {
return roleList.stream().map(role -> Func.toStr(role.getId())).distinct().collect(Collectors.joining(","));
}
return null;
}
@Override
public List<String> getRoleNames(String roleIds) {
return baseMapper.getRoleNames(Func.toLongArray(roleIds));
}
@Override
public List<String> getRoleAliases(String roleIds) {
return baseMapper.getRoleAliases(Func.toLongArray(roleIds));
}
@Override
public boolean submit(Role role) {
if (!AuthUtil.isAdministrator()) {
if (Func.toStr(role.getRoleAlias()).equals(RoleConstant.ADMINISTRATOR)) {
throw new ServiceException("无权限创建超管角色!");
}
}
if (Func.isEmpty(role.getParentId())) {
role.setTenantId(AuthUtil.getTenantId());
role.setParentId(BladeConstant.TOP_PARENT_ID);
}
if (role.getParentId() > 0) {
Role parent = getById(role.getParentId());
if (Func.toLong(role.getParentId()) == Func.toLong(role.getId())) {
throw new ServiceException("父节点不可选择自身!");
}
role.setTenantId(parent.getTenantId());
}
role.setIsDeleted(BladeConstant.DB_NOT_DELETED);
return saveOrUpdate(role);
}
@Override
public List<TreeNode> treeByUser() {
String roleIds=AuthUtil.getUser().getRoleId();
List<TreeNode> roleVOS=baseMapper.treeByIds(Func.toLongArray(roleIds));
List<Long> parentIds=new LinkedList<>();
roleVOS.forEach(roleVO -> {
parentIds.add(roleVO.getId());
});
List<TreeNode> roles=baseMapper.treeByParentIds(parentIds);
if(CollectionUtil.isNotEmpty(roles)){
roleVOS.addAll(roles);
}
return ForestNodeMerger.merge(roleVOS);
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean grant(@NotEmpty List<Long> roleIds, List<Long> menuIds, List<Long> dataScopeIds, List<Long> apiScopeIds) {
return grantRoleMenu(roleIds, menuIds) && grantDataScope(roleIds, dataScopeIds) && grantApiScope(roleIds, apiScopeIds);
}
private boolean grantRoleMenu(List<Long> roleIds, List<Long> menuIds) {
// 删除角色配置的菜单集合
roleMenuService.remove(Wrappers.<RoleMenu>update().lambda().in(RoleMenu::getRoleId, roleIds));
// 组装配置
List<RoleMenu> roleMenus = new ArrayList<>();
roleIds.forEach(roleId -> menuIds.forEach(menuId -> {
RoleMenu roleMenu = new RoleMenu();
roleMenu.setRoleId(roleId);
roleMenu.setMenuId(menuId);
roleMenus.add(roleMenu);
}));
// 新增配置
roleMenuService.saveBatch(roleMenus);
// 递归设置下属角色菜单集合
recursionRoleMenu(roleIds, menuIds);
return true;
}
private boolean grantDataScope(List<Long> roleIds, List<Long> dataScopeIds) {
// 删除角色配置的数据权限集合
roleScopeService.remove(Wrappers.<RoleScope>update().lambda().eq(RoleScope::getScopeCategory, DATA_SCOPE_CATEGORY).in(RoleScope::getRoleId, roleIds));
// 组装配置
List<RoleScope> roleDataScopes = new ArrayList<>();
roleIds.forEach(roleId -> dataScopeIds.forEach(scopeId -> {
RoleScope roleScope = new RoleScope();
roleScope.setScopeCategory(DATA_SCOPE_CATEGORY);
roleScope.setRoleId(roleId);
roleScope.setScopeId(scopeId);
roleDataScopes.add(roleScope);
}));
// 新增配置
roleScopeService.saveBatch(roleDataScopes);
return true;
}
private boolean grantApiScope(List<Long> roleIds, List<Long> apiScopeIds) {
// 删除角色配置的接口权限集合
roleScopeService.remove(Wrappers.<RoleScope>update().lambda().eq(RoleScope::getScopeCategory, API_SCOPE_CATEGORY).in(RoleScope::getRoleId, roleIds));
// 组装配置
List<RoleScope> roleApiScopes = new ArrayList<>();
roleIds.forEach(roleId -> apiScopeIds.forEach(scopeId -> {
RoleScope roleScope = new RoleScope();
roleScope.setScopeCategory(API_SCOPE_CATEGORY);
roleScope.setScopeId(scopeId);
roleScope.setRoleId(roleId);
roleApiScopes.add(roleScope);
}));
// 新增配置
roleScopeService.saveBatch(roleApiScopes);
return true;
}
}

View File

@ -0,0 +1,55 @@
/*
* 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 com.kening.vordm.wrapper;
import com.kening.vordm.entity.Menu;
import com.kening.vordm.vo.MenuVO;
import org.springblade.core.mp.support.BaseEntityWrapper;
import org.springblade.core.tool.node.ForestNodeMerger;
import org.springblade.core.tool.utils.BeanUtil;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* 包装类,返回视图层所需的字段
*
* @author Chill
*/
public class MenuWrapper extends BaseEntityWrapper<Menu, MenuVO> {
public static MenuWrapper build() {
return new MenuWrapper();
}
@Override
public MenuVO entityVO(Menu menu) {
return Objects.requireNonNull(BeanUtil.copy(menu, MenuVO.class));
}
public List<MenuVO> listNodeVO(List<Menu> list) {
List<MenuVO> collect = list.stream().map(menu -> BeanUtil.copy(menu, MenuVO.class)).collect(Collectors.toList());
return ForestNodeMerger.merge(collect);
}
public List<MenuVO> listNodeLazyVO(List<MenuVO> list) {
return ForestNodeMerger.merge(list);
}
}

View File

@ -0,0 +1,51 @@
/*
* 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 com.kening.vordm.wrapper;
import com.kening.vordm.entity.Role;
import com.kening.vordm.vo.RoleVO;
import org.springblade.core.mp.support.BaseEntityWrapper;
import org.springblade.core.tool.node.ForestNodeMerger;
import org.springblade.core.tool.utils.BeanUtil;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* 包装类,返回视图层所需的字段
*
* @author Chill
*/
public class RoleWrapper extends BaseEntityWrapper<Role, RoleVO> {
public static RoleWrapper build() {
return new RoleWrapper();
}
@Override
public RoleVO entityVO(Role role) {
return Objects.requireNonNull(BeanUtil.copy(role, RoleVO.class));
}
public List<RoleVO> listNodeVO(List<Role> list) {
List<RoleVO> collect = list.stream().map(this::entityVO).collect(Collectors.toList());
return ForestNodeMerger.merge(collect);
}
}