diff --git a/kn-launcher/src/main/java/org/springblade/common/constant/LauncherConstant.java b/kn-launcher/src/main/java/org/springblade/common/constant/LauncherConstant.java index 7f36900..13bcd16 100644 --- a/kn-launcher/src/main/java/org/springblade/common/constant/LauncherConstant.java +++ b/kn-launcher/src/main/java/org/springblade/common/constant/LauncherConstant.java @@ -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 地址 diff --git a/kn-service-api/biz-vordm-api/src/main/java/com/kening/vordm/DTO/MenuDTO.java b/kn-service-api/biz-vordm-api/src/main/java/com/kening/vordm/DTO/MenuDTO.java new file mode 100644 index 0000000..1cf8ace --- /dev/null +++ b/kn-service-api/biz-vordm-api/src/main/java/com/kening/vordm/DTO/MenuDTO.java @@ -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; +} diff --git a/kn-service-api/biz-vordm-api/src/main/java/com/kening/vordm/entity/Install.java b/kn-service-api/biz-vordm-api/src/main/java/com/kening/vordm/entity/Install.java new file mode 100644 index 0000000..aa0f9e4 --- /dev/null +++ b/kn-service-api/biz-vordm-api/src/main/java/com/kening/vordm/entity/Install.java @@ -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; + +} diff --git a/kn-service-api/biz-vordm-api/src/main/java/com/kening/vordm/entity/Menu.java b/kn-service-api/biz-vordm-api/src/main/java/com/kening/vordm/entity/Menu.java new file mode 100644 index 0000000..3944912 --- /dev/null +++ b/kn-service-api/biz-vordm-api/src/main/java/com/kening/vordm/entity/Menu.java @@ -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; + } + +} diff --git a/kn-service-api/biz-vordm-api/src/main/java/com/kening/vordm/entity/Region.java b/kn-service-api/biz-vordm-api/src/main/java/com/kening/vordm/entity/Region.java new file mode 100644 index 0000000..d1903a4 --- /dev/null +++ b/kn-service-api/biz-vordm-api/src/main/java/com/kening/vordm/entity/Region.java @@ -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; + + +} diff --git a/kn-service-api/biz-vordm-api/src/main/java/com/kening/vordm/entity/Role.java b/kn-service-api/biz-vordm-api/src/main/java/com/kening/vordm/entity/Role.java new file mode 100644 index 0000000..c15b7f1 --- /dev/null +++ b/kn-service-api/biz-vordm-api/src/main/java/com/kening/vordm/entity/Role.java @@ -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; + + +} diff --git a/kn-service-api/biz-vordm-api/src/main/java/com/kening/vordm/entity/RoleMenu.java b/kn-service-api/biz-vordm-api/src/main/java/com/kening/vordm/entity/RoleMenu.java new file mode 100644 index 0000000..91a783c --- /dev/null +++ b/kn-service-api/biz-vordm-api/src/main/java/com/kening/vordm/entity/RoleMenu.java @@ -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; + + +} diff --git a/kn-service-api/biz-vordm-api/src/main/java/com/kening/vordm/entity/RoleScope.java b/kn-service-api/biz-vordm-api/src/main/java/com/kening/vordm/entity/RoleScope.java new file mode 100644 index 0000000..6ab17d4 --- /dev/null +++ b/kn-service-api/biz-vordm-api/src/main/java/com/kening/vordm/entity/RoleScope.java @@ -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; + + +} diff --git a/kn-service-api/biz-vordm-api/src/main/java/com/kening/vordm/vo/CheckedTreeVO.java b/kn-service-api/biz-vordm-api/src/main/java/com/kening/vordm/vo/CheckedTreeVO.java new file mode 100644 index 0000000..fe09bb9 --- /dev/null +++ b/kn-service-api/biz-vordm-api/src/main/java/com/kening/vordm/vo/CheckedTreeVO.java @@ -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 menu; + + private List dataScope; + + private List apiScope; + +} diff --git a/kn-service-api/biz-vordm-api/src/main/java/com/kening/vordm/vo/GrantTreeVO.java b/kn-service-api/biz-vordm-api/src/main/java/com/kening/vordm/vo/GrantTreeVO.java new file mode 100644 index 0000000..4340f9a --- /dev/null +++ b/kn-service-api/biz-vordm-api/src/main/java/com/kening/vordm/vo/GrantTreeVO.java @@ -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 menu; + + private List dataScope; + + private List apiScope; + +} diff --git a/kn-service-api/biz-vordm-api/src/main/java/com/kening/vordm/vo/GrantVO.java b/kn-service-api/biz-vordm-api/src/main/java/com/kening/vordm/vo/GrantVO.java new file mode 100644 index 0000000..b2deeb4 --- /dev/null +++ b/kn-service-api/biz-vordm-api/src/main/java/com/kening/vordm/vo/GrantVO.java @@ -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 roleIds; + + @ApiModelProperty(value = "menuIds集合") + private List menuIds; + + @ApiModelProperty(value = "topMenuIds集合") + private List topMenuIds; + + @ApiModelProperty(value = "dataScopeIds集合") + private List dataScopeIds; + + @ApiModelProperty(value = "apiScopeIds集合") + private List apiScopeIds; + +} diff --git a/kn-service-api/biz-vordm-api/src/main/java/com/kening/vordm/vo/MenuVO.java b/kn-service-api/biz-vordm-api/src/main/java/com/kening/vordm/vo/MenuVO.java new file mode 100644 index 0000000..a1079f4 --- /dev/null +++ b/kn-service-api/biz-vordm-api/src/main/java/com/kening/vordm/vo/MenuVO.java @@ -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 { + 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 children; + + /** + * 是否有子孙节点 + */ + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private Boolean hasChildren; + + @Override + public List getChildren() { + if (this.children == null) { + this.children = new ArrayList<>(); + } + return this.children; + } + + /** + * 上级菜单 + */ + private String parentName; + + /** + * 菜单类型 + */ + private String categoryName; + + /** + * 按钮功能 + */ + private String actionName; + + /** + * 是否新窗口打开 + */ + private String isOpenName; +} diff --git a/kn-service-api/biz-vordm-api/src/main/java/com/kening/vordm/vo/RegionVO.java b/kn-service-api/biz-vordm-api/src/main/java/com/kening/vordm/vo/RegionVO.java new file mode 100644 index 0000000..5cdb80d --- /dev/null +++ b/kn-service-api/biz-vordm-api/src/main/java/com/kening/vordm/vo/RegionVO.java @@ -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 { + 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 children; + + @Override + public Long getId() { + return Func.toLong(this.getCode()); + } + + @Override + public Long getParentId() { + return Func.toLong(this.getParentCode()); + } + + @Override + public List getChildren() { + if (this.children == null) { + this.children = new ArrayList<>(); + } + return this.children; + } +} diff --git a/kn-service-api/biz-vordm-api/src/main/java/com/kening/vordm/vo/RoleMenuVO.java b/kn-service-api/biz-vordm-api/src/main/java/com/kening/vordm/vo/RoleMenuVO.java new file mode 100644 index 0000000..af996be --- /dev/null +++ b/kn-service-api/biz-vordm-api/src/main/java/com/kening/vordm/vo/RoleMenuVO.java @@ -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; + +} diff --git a/kn-service-api/biz-vordm-api/src/main/java/com/kening/vordm/vo/RoleVO.java b/kn-service-api/biz-vordm-api/src/main/java/com/kening/vordm/vo/RoleVO.java new file mode 100644 index 0000000..13cf3c0 --- /dev/null +++ b/kn-service-api/biz-vordm-api/src/main/java/com/kening/vordm/vo/RoleVO.java @@ -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 { + 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 children; + + @Override + public List getChildren() { + if (this.children == null) { + this.children = new ArrayList<>(); + } + return this.children; + } + + /** + * 上级角色 + */ + private String parentName; +} diff --git a/kn-service/biz-vordm/src/main/java/com/kening/vordm/controller/AdministratorController.java b/kn-service/biz-vordm/src/main/java/com/kening/vordm/controller/AdministratorController.java index 964a98a..9b09a87 100644 --- a/kn-service/biz-vordm/src/main/java/com/kening/vordm/controller/AdministratorController.java +++ b/kn-service/biz-vordm/src/main/java/com/kening/vordm/controller/AdministratorController.java @@ -39,10 +39,8 @@ public class AdministratorController { * @return */ @GetMapping("/pages") - public R> pages(Query query, @RequestParam Map params){ + public R> pages(Query query, @RequestParam Map 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))); } diff --git a/kn-service/biz-vordm/src/main/java/com/kening/vordm/controller/DisasterInfoController.java b/kn-service/biz-vordm/src/main/java/com/kening/vordm/controller/DisasterInfoController.java index 1f9c5a9..1180738 100644 --- a/kn-service/biz-vordm/src/main/java/com/kening/vordm/controller/DisasterInfoController.java +++ b/kn-service/biz-vordm/src/main/java/com/kening/vordm/controller/DisasterInfoController.java @@ -176,6 +176,19 @@ public class DisasterInfoController { return R.data(dataMap); } + + /** + * 后台首页灾害信息统计 国家/灾害类型 取前十 + * + * @param + * @return + */ + @GetMapping("/getCountryDisaster") + public R> getCountryDisaster() { + return R.data(disasterInfoService.getLeft2Data()); + } + + /** * 首页数据展示,包括响应中和未响应 * diff --git a/kn-service/biz-vordm/src/main/java/com/kening/vordm/controller/InstallController.java b/kn-service/biz-vordm/src/main/java/com/kening/vordm/controller/InstallController.java new file mode 100644 index 0000000..cd1e390 --- /dev/null +++ b/kn-service/biz-vordm/src/main/java/com/kening/vordm/controller/InstallController.java @@ -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> list(Install install, Query query) { + QueryWrapper queryWrapper = Condition.getQueryWrapper(install); + if (!install.getName().isEmpty()){ + queryWrapper.like("title",install.getName()); + } + IPage pages = installService.page(Condition.getPage(query), queryWrapper); + return R.data(pages); + } + + /** + * 获取所有图片 + * @return + */ + @GetMapping("/getListAll") + public R> 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 detail(@ApiParam(value = "主键", required = true) @RequestParam String id) { + Install detail = installService.getById(id); + return R.data(detail); + } +} diff --git a/kn-service/biz-vordm/src/main/java/com/kening/vordm/controller/MenuController.java b/kn-service/biz-vordm/src/main/java/com/kening/vordm/controller/MenuController.java new file mode 100644 index 0000000..69a97a9 --- /dev/null +++ b/kn-service/biz-vordm/src/main/java/com/kening/vordm/controller/MenuController.java @@ -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 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(@ApiIgnore @RequestParam Map menu) { + List 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 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> lazyList(Long parentId, @ApiIgnore @RequestParam Map menu) { + List 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> menuList(@ApiIgnore @RequestParam Map menu) { + List 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> lazyMenuList(Long parentId, @ApiIgnore @RequestParam Map menu) { + List 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> routes(BladeUser user, Long topMenuId) { + List list = menuService.routes((user == null) ? null : user.getRoleId(), topMenuId); + return R.data(list); + } + + /** + * 前端按钮数据 + */ + @GetMapping("/buttons") + @ApiOperationSupport(order = 10) + @ApiOperation(value = "前端按钮数据", notes = "前端按钮数据") + public R> buttons(BladeUser user) { + List list = menuService.buttons(user.getRoleId()); + return R.data(list); + } + + /** + * 获取菜单树形结构 + */ + @GetMapping("/tree") + @ApiOperationSupport(order = 11) + @ApiOperation(value = "树形结构", notes = "树形结构") + public R> tree() { + List tree = menuService.tree(); + return R.data(tree); + } + + /** + * 获取权限分配树形结构 + */ + @GetMapping("/grant-tree") + @ApiOperationSupport(order = 12) + @ApiOperation(value = "权限分配树形结构", notes = "权限分配树形结构") + public R 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 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> authRoutes(BladeUser user) { + if (Func.isEmpty(user)) { + return null; + } + return R.data(menuService.authRoutes(user)); + } +} diff --git a/kn-service/biz-vordm/src/main/java/com/kening/vordm/controller/RoleController.java b/kn-service/biz-vordm/src/main/java/com/kening/vordm/controller/RoleController.java new file mode 100644 index 0000000..1d27d57 --- /dev/null +++ b/kn-service/biz-vordm/src/main/java/com/kening/vordm/controller/RoleController.java @@ -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 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(@ApiIgnore @RequestParam Map role, BladeUser bladeUser) { + QueryWrapper queryWrapper = Condition.getQueryWrapper(role, Role.class); + List 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> tree(String tenantId, BladeUser bladeUser) { + List tree = roleService.tree(Func.toStrWithEmpty(tenantId, bladeUser.getTenantId())); + return R.data(tree); + } + + /** + * 获取指定角色树形结构 + */ + @GetMapping("/tree-by-id") + @ApiOperationSupport(order = 4) + @ApiOperation(value = "树形结构", notes = "树形结构") + public R> treeById(BladeUser bladeUser) { + List 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> treeByUser() { + List tree = roleService.treeByUser(); + return R.data(tree); + } + +} diff --git a/kn-service/biz-vordm/src/main/java/com/kening/vordm/mapper/InstallMapper.java b/kn-service/biz-vordm/src/main/java/com/kening/vordm/mapper/InstallMapper.java new file mode 100644 index 0000000..c48ac4d --- /dev/null +++ b/kn-service/biz-vordm/src/main/java/com/kening/vordm/mapper/InstallMapper.java @@ -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 { + +} + + + + diff --git a/kn-service/biz-vordm/src/main/java/com/kening/vordm/mapper/InstallMapper.xml b/kn-service/biz-vordm/src/main/java/com/kening/vordm/mapper/InstallMapper.xml new file mode 100644 index 0000000..328786c --- /dev/null +++ b/kn-service/biz-vordm/src/main/java/com/kening/vordm/mapper/InstallMapper.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + id,title,Images, + link,sort,is_deleted, + create_time,status + + diff --git a/kn-service/biz-vordm/src/main/java/com/kening/vordm/mapper/MenuMapper.java b/kn-service/biz-vordm/src/main/java/com/kening/vordm/mapper/MenuMapper.java new file mode 100644 index 0000000..4be5a3d --- /dev/null +++ b/kn-service/biz-vordm/src/main/java/com/kening/vordm/mapper/MenuMapper.java @@ -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 { + + /** + * 懒加载列表 + * + * @param parentId + * @param param + * @return + */ + List lazyList(Long parentId, Map param); + + /** + * 懒加载菜单列表 + * + * @param parentId + * @param param + * @return + */ + List lazyMenuList(Long parentId, Map param); + + /** + * 树形结构 + * + * @return + */ + List tree(); + + /** + * 授权树形结构 + * + * @return + */ + List grantTree(); + + /** + * 授权树形结构 + * + * @param roleId + * @return + */ + List grantTreeByRole(List roleId); + + /** + * 顶部菜单树形结构 + * + * @return + */ + List grantTopTree(); + + /** + * 顶部菜单树形结构 + * + * @param roleId + * @return + */ + List grantTopTreeByRole(List roleId); + + /** + * 数据权限授权树形结构 + * + * @return + */ + List grantDataScopeTree(); + + /** + * 接口权限授权树形结构 + * + * @return + */ + List grantApiScopeTree(); + + /** + * 数据权限授权树形结构 + * + * @param roleId + * @return + */ + List grantDataScopeTreeByRole(List roleId); + + /** + * 接口权限授权树形结构 + * + * @param roleId + * @return + */ + List grantApiScopeTreeByRole(List roleId); + + /** + * 所有菜单 + * + * @return + */ + List allMenu(); + + /** + * 权限配置菜单 + * + * @param roleId + * @param topMenuId + * @return + */ + List roleMenu(List roleId, Long topMenuId); + + /** + * 菜单树形结构 + * + * @param roleId + * @return + */ + List routes(List roleId); + + /** + * 按钮树形结构 + * + * @return + */ + List allButtons(); + + /** + * 按钮树形结构 + * + * @param roleId + * @return + */ + List buttons(List roleId); + + /** + * 获取配置的角色权限 + * + * @param roleIds + * @return + */ + List authRoutes(List roleIds); +} diff --git a/kn-service/biz-vordm/src/main/java/com/kening/vordm/mapper/MenuMapper.xml b/kn-service/biz-vordm/src/main/java/com/kening/vordm/mapper/MenuMapper.xml new file mode 100644 index 0000000..f571c6b --- /dev/null +++ b/kn-service/biz-vordm/src/main/java/com/kening/vordm/mapper/MenuMapper.xml @@ -0,0 +1,461 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/kn-service/biz-vordm/src/main/java/com/kening/vordm/mapper/RoleMapper.java b/kn-service/biz-vordm/src/main/java/com/kening/vordm/mapper/RoleMapper.java new file mode 100644 index 0000000..6ab156e --- /dev/null +++ b/kn-service/biz-vordm/src/main/java/com/kening/vordm/mapper/RoleMapper.java @@ -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 { + + /** + * 自定义分页 + * + * @param page + * @param role + * @return + */ + List selectRolePage(IPage page, RoleVO role); + + /** + * 获取树形节点 + * + * @param tenantId + * @param excludeRole + * @return + */ + List tree(String tenantId, String excludeRole); + + /** + * 获取角色名 + * + * @param ids + * @return + */ + List getRoleNames(Long[] ids); + + /** + * 获取角色名 + * + * @param ids + * @return + */ + List getRoleAliases(Long[] ids); + + /** + * 根据父id获得树 + * @param ids + * @return + */ + List treeByParentIds(List ids); + + /** + * 根据id获得list + * @param ids + * @return + */ + List treeByIds(Long[] ids); +} diff --git a/kn-service/biz-vordm/src/main/java/com/kening/vordm/mapper/RoleMapper.xml b/kn-service/biz-vordm/src/main/java/com/kening/vordm/mapper/RoleMapper.xml new file mode 100644 index 0000000..7d3cd90 --- /dev/null +++ b/kn-service/biz-vordm/src/main/java/com/kening/vordm/mapper/RoleMapper.xml @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/kn-service/biz-vordm/src/main/java/com/kening/vordm/mapper/RoleMenuMapper.java b/kn-service/biz-vordm/src/main/java/com/kening/vordm/mapper/RoleMenuMapper.java new file mode 100644 index 0000000..bbf882e --- /dev/null +++ b/kn-service/biz-vordm/src/main/java/com/kening/vordm/mapper/RoleMenuMapper.java @@ -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 { + + /** + * 自定义分页 + * @param page + * @param roleMenu + * @return + */ + List selectRoleMenuPage(IPage page, RoleMenuVO roleMenu); + +} diff --git a/kn-service/biz-vordm/src/main/java/com/kening/vordm/mapper/RoleMenuMapper.xml b/kn-service/biz-vordm/src/main/java/com/kening/vordm/mapper/RoleMenuMapper.xml new file mode 100644 index 0000000..2eeac12 --- /dev/null +++ b/kn-service/biz-vordm/src/main/java/com/kening/vordm/mapper/RoleMenuMapper.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + diff --git a/kn-service/biz-vordm/src/main/java/com/kening/vordm/mapper/RoleScopeMapper.java b/kn-service/biz-vordm/src/main/java/com/kening/vordm/mapper/RoleScopeMapper.java new file mode 100644 index 0000000..0a48248 --- /dev/null +++ b/kn-service/biz-vordm/src/main/java/com/kening/vordm/mapper/RoleScopeMapper.java @@ -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 { + +} diff --git a/kn-service/biz-vordm/src/main/java/com/kening/vordm/mapper/RoleScopeMapper.xml b/kn-service/biz-vordm/src/main/java/com/kening/vordm/mapper/RoleScopeMapper.xml new file mode 100644 index 0000000..0df5bee --- /dev/null +++ b/kn-service/biz-vordm/src/main/java/com/kening/vordm/mapper/RoleScopeMapper.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/kn-service/biz-vordm/src/main/java/com/kening/vordm/service/IMenuService.java b/kn-service/biz-vordm/src/main/java/com/kening/vordm/service/IMenuService.java new file mode 100644 index 0000000..2235229 --- /dev/null +++ b/kn-service/biz-vordm/src/main/java/com/kening/vordm/service/IMenuService.java @@ -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 { + + /** + * 懒加载列表 + * + * @param parentId + * @param param + * @return + */ + List lazyList(Long parentId, Map param); + + /** + * 懒加载菜单列表 + * + * @param parentId + * @param param + * @return + */ + List lazyMenuList(Long parentId, Map param); + + /** + * 菜单树形结构 + * + * @param roleId + * @param topMenuId + * @return + */ + List routes(String roleId, Long topMenuId); + + /** + * 按钮树形结构 + * + * @param roleId + * @return + */ + List buttons(String roleId); + + /** + * 树形结构 + * + * @return + */ + List tree(); + + /** + * 授权树形结构 + * + * @param user + * @return + */ + List grantTree(BladeUser user); + + /** + * 顶部菜单树形结构 + * + * @param user + * @return + */ + List grantTopTree(BladeUser user); + + /** + * 数据权限授权树形结构 + * + * @param user + * @return + */ + List grantDataScopeTree(BladeUser user); + + /** + * 接口权限授权树形结构 + * + * @param user + * @return + */ + List grantApiScopeTree(BladeUser user); + + /** + * 默认选中节点 + * + * @param roleIds + * @return + */ + List roleTreeKeys(String roleIds); + + /** + * 默认选中节点 + * + * @param roleIds + * @return + */ + List dataScopeTreeKeys(String roleIds); + + /** + * 默认选中节点 + * + * @param roleIds + * @return + */ + List apiScopeTreeKeys(String roleIds); + + /** + * 获取配置的角色权限 + * + * @param user + * @return + */ + List authRoutes(BladeUser user); + + /** + * 删除菜单 + * + * @param ids + * @return + */ + boolean removeMenu(String ids); + + /** + * 提交 + * + * @param menu + * @return + */ + boolean submit(Menu menu); + +} diff --git a/kn-service/biz-vordm/src/main/java/com/kening/vordm/service/IRoleMenuService.java b/kn-service/biz-vordm/src/main/java/com/kening/vordm/service/IRoleMenuService.java new file mode 100644 index 0000000..b379018 --- /dev/null +++ b/kn-service/biz-vordm/src/main/java/com/kening/vordm/service/IRoleMenuService.java @@ -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 { + +} diff --git a/kn-service/biz-vordm/src/main/java/com/kening/vordm/service/IRoleScopeService.java b/kn-service/biz-vordm/src/main/java/com/kening/vordm/service/IRoleScopeService.java new file mode 100644 index 0000000..e41d37f --- /dev/null +++ b/kn-service/biz-vordm/src/main/java/com/kening/vordm/service/IRoleScopeService.java @@ -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 { + +} diff --git a/kn-service/biz-vordm/src/main/java/com/kening/vordm/service/IRoleService.java b/kn-service/biz-vordm/src/main/java/com/kening/vordm/service/IRoleService.java new file mode 100644 index 0000000..77f8465 --- /dev/null +++ b/kn-service/biz-vordm/src/main/java/com/kening/vordm/service/IRoleService.java @@ -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 { + + /** + * 自定义分页 + * + * @param page + * @param role + * @return + */ + IPage selectRolePage(IPage page, RoleVO role); + + /** + * 树形结构 + * + * @param tenantId + * @return + */ + List tree(String tenantId); + + + /** + * 获取角色ID + * + * @param tenantId + * @param roleNames + * @return + */ + String getRoleIds(String tenantId, String roleNames); + + /** + * 获取角色名 + * + * @param roleIds + * @return + */ + List getRoleNames(String roleIds); + + /** + * 获取角色名 + * + * @param roleIds + * @return + */ + List getRoleAliases(String roleIds); + + /** + * 提交 + * + * @param role + * @return + */ + boolean submit(Role role); + + /** + * 获取当前用户有权限的角色树形结构 + * @return + */ + List treeByUser(); + + /** + * 权限配置 + * + * @param roleIds 角色id集合 + * @param menuIds 菜单id集合 + * @param dataScopeIds 数据权限id集合 + * @param apiScopeIds 接口权限id集合 + * @return 是否成功 + */ + boolean grant(@NotEmpty List roleIds, List menuIds, List dataScopeIds, List apiScopeIds); +} diff --git a/kn-service/biz-vordm/src/main/java/com/kening/vordm/service/InstallService.java b/kn-service/biz-vordm/src/main/java/com/kening/vordm/service/InstallService.java new file mode 100644 index 0000000..1e06c0c --- /dev/null +++ b/kn-service/biz-vordm/src/main/java/com/kening/vordm/service/InstallService.java @@ -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 { + +} diff --git a/kn-service/biz-vordm/src/main/java/com/kening/vordm/service/impl/AdministratorServiceImpl.java b/kn-service/biz-vordm/src/main/java/com/kening/vordm/service/impl/AdministratorServiceImpl.java index fe645bd..83ff243 100644 --- a/kn-service/biz-vordm/src/main/java/com/kening/vordm/service/impl/AdministratorServiceImpl.java +++ b/kn-service/biz-vordm/src/main/java/com/kening/vordm/service/impl/AdministratorServiceImpl.java @@ -77,8 +77,8 @@ public class AdministratorServiceImpl extends BaseServiceImpl + implements InstallService{ + +} + + + + diff --git a/kn-service/biz-vordm/src/main/java/com/kening/vordm/service/impl/MenuServiceImpl.java b/kn-service/biz-vordm/src/main/java/com/kening/vordm/service/impl/MenuServiceImpl.java new file mode 100644 index 0000000..5983b16 --- /dev/null +++ b/kn-service/biz-vordm/src/main/java/com/kening/vordm/service/impl/MenuServiceImpl.java @@ -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 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 lazyList(Long parentId, Map param) { + if (Func.isEmpty(Func.toStr(param.get(PARENT_ID)))) { + parentId = null; + } + return baseMapper.lazyList(parentId, param); + } + + @Override + public List lazyMenuList(Long parentId, Map param) { + if (Func.isEmpty(Func.toStr(param.get(PARENT_ID)))) { + parentId = null; + } + return baseMapper.lazyMenuList(parentId, param); + } + + + @Override + public List routes(String roleId, Long topMenuId) { + if (StringUtil.isBlank(roleId)) { + return null; + } + List allMenus = baseMapper.allMenu(); + List roleMenus = (AuthUtil.isAdministrator() && Func.isEmpty(topMenuId)) ? allMenus : baseMapper.roleMenu(Func.toLongList(roleId), topMenuId); + return buildRoutes(allMenus, roleMenus); + } + + private List buildRoutes(List allMenus, List roleMenus) { + List routes = new LinkedList<>(roleMenus); + roleMenus.forEach(roleMenu -> recursion(allMenus, routes, roleMenu)); + routes.sort(Comparator.comparing(Menu::getSort)); + MenuWrapper menuWrapper = new MenuWrapper(); + List collect = routes.stream().filter(x -> Func.equals(x.getCategory(), 1)).collect(Collectors.toList()); + return menuWrapper.listNodeVO(collect); + } + + private void recursion(List allMenus, List routes, Menu roleMenu) { + Optional 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 buttons(String roleId) { + List buttons = (AuthUtil.isAdministrator()) ? baseMapper.allButtons() : baseMapper.buttons(Func.toLongList(roleId)); + MenuWrapper menuWrapper = new MenuWrapper(); + return menuWrapper.listNodeVO(buttons); + } + + @Override + public List tree() { + return ForestNodeMerger.merge(baseMapper.tree()); + } + + @Override + public List grantTree(BladeUser user) { + return ForestNodeMerger.merge(user.getTenantId().equals(BladeConstant.ADMIN_TENANT_ID) ? baseMapper.grantTree() : baseMapper.grantTreeByRole(Func.toLongList(user.getRoleId()))); + } + + @Override + public List grantTopTree(BladeUser user) { + return ForestNodeMerger.merge(user.getTenantId().equals(BladeConstant.ADMIN_TENANT_ID) ? baseMapper.grantTopTree() : baseMapper.grantTopTreeByRole(Func.toLongList(user.getRoleId()))); + } + + @Override + public List grantDataScopeTree(BladeUser user) { + return ForestNodeMerger.merge(user.getTenantId().equals(BladeConstant.ADMIN_TENANT_ID) ? baseMapper.grantDataScopeTree() : baseMapper.grantDataScopeTreeByRole(Func.toLongList(user.getRoleId()))); + } + + @Override + public List grantApiScopeTree(BladeUser user) { + return ForestNodeMerger.merge(user.getTenantId().equals(BladeConstant.ADMIN_TENANT_ID) ? baseMapper.grantApiScopeTree() : baseMapper.grantApiScopeTreeByRole(Func.toLongList(user.getRoleId()))); + } + + @Override + public List roleTreeKeys(String roleIds) { + List roleMenus = roleMenuService.list(Wrappers.query().lambda().in(RoleMenu::getRoleId, Func.toLongList(roleIds))); + return roleMenus.stream().map(roleMenu -> Func.toStr(roleMenu.getMenuId())).collect(Collectors.toList()); + } + + @Override + public List dataScopeTreeKeys(String roleIds) { + List roleScopes = roleScopeService.list(Wrappers.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 apiScopeTreeKeys(String roleIds) { + List roleScopes = roleScopeService.list(Wrappers.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 authRoutes(BladeUser user) { + List routes = baseMapper.authRoutes(Func.toLongList(user.getRoleId())); + List 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.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 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); + } + +} diff --git a/kn-service/biz-vordm/src/main/java/com/kening/vordm/service/impl/RoleMenuServiceImpl.java b/kn-service/biz-vordm/src/main/java/com/kening/vordm/service/impl/RoleMenuServiceImpl.java new file mode 100644 index 0000000..740754b --- /dev/null +++ b/kn-service/biz-vordm/src/main/java/com/kening/vordm/service/impl/RoleMenuServiceImpl.java @@ -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 implements IRoleMenuService { + +} diff --git a/kn-service/biz-vordm/src/main/java/com/kening/vordm/service/impl/RoleScopeServiceImpl.java b/kn-service/biz-vordm/src/main/java/com/kening/vordm/service/impl/RoleScopeServiceImpl.java new file mode 100644 index 0000000..b8d3468 --- /dev/null +++ b/kn-service/biz-vordm/src/main/java/com/kening/vordm/service/impl/RoleScopeServiceImpl.java @@ -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 implements IRoleScopeService { + +} diff --git a/kn-service/biz-vordm/src/main/java/com/kening/vordm/service/impl/RoleServiceImpl.java b/kn-service/biz-vordm/src/main/java/com/kening/vordm/service/impl/RoleServiceImpl.java new file mode 100644 index 0000000..4bdd0c8 --- /dev/null +++ b/kn-service/biz-vordm/src/main/java/com/kening/vordm/service/impl/RoleServiceImpl.java @@ -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 implements IRoleService { + + private final IRoleMenuService roleMenuService; + private final IRoleScopeService roleScopeService; + + @Override + public IPage selectRolePage(IPage page, RoleVO role) { + return page.setRecords(baseMapper.selectRolePage(page, role)); + } + + @Override + public List 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 roleIds, List menuIds) { + roleIds.forEach(roleId -> baseMapper.selectList(Wrappers.query().lambda().eq(Role::getParentId, roleId)).forEach(role -> { + List roleMenuList = roleMenuService.list(Wrappers.query().lambda().eq(RoleMenu::getRoleId, role.getId())); + // 子节点过滤出父节点删除的菜单集合 + List collectRoleMenuIds = roleMenuList.stream().map(RoleMenu::getMenuId).filter(menuId -> !menuIds.contains(menuId)).collect(Collectors.toList()); + if (collectRoleMenuIds.size() > 0) { + // 删除子节点权限外的菜单集合 + roleMenuService.remove(Wrappers.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 roleList = baseMapper.selectList(Wrappers.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 getRoleNames(String roleIds) { + return baseMapper.getRoleNames(Func.toLongArray(roleIds)); + } + + @Override + public List 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 treeByUser() { + String roleIds=AuthUtil.getUser().getRoleId(); + List roleVOS=baseMapper.treeByIds(Func.toLongArray(roleIds)); + List parentIds=new LinkedList<>(); + roleVOS.forEach(roleVO -> { + parentIds.add(roleVO.getId()); + }); + List 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 roleIds, List menuIds, List dataScopeIds, List apiScopeIds) { + return grantRoleMenu(roleIds, menuIds) && grantDataScope(roleIds, dataScopeIds) && grantApiScope(roleIds, apiScopeIds); + } + + private boolean grantRoleMenu(List roleIds, List menuIds) { + // 删除角色配置的菜单集合 + roleMenuService.remove(Wrappers.update().lambda().in(RoleMenu::getRoleId, roleIds)); + // 组装配置 + List 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 roleIds, List dataScopeIds) { + // 删除角色配置的数据权限集合 + roleScopeService.remove(Wrappers.update().lambda().eq(RoleScope::getScopeCategory, DATA_SCOPE_CATEGORY).in(RoleScope::getRoleId, roleIds)); + // 组装配置 + List 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 roleIds, List apiScopeIds) { + // 删除角色配置的接口权限集合 + roleScopeService.remove(Wrappers.update().lambda().eq(RoleScope::getScopeCategory, API_SCOPE_CATEGORY).in(RoleScope::getRoleId, roleIds)); + // 组装配置 + List 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; + } + +} diff --git a/kn-service/biz-vordm/src/main/java/com/kening/vordm/wrapper/MenuWrapper.java b/kn-service/biz-vordm/src/main/java/com/kening/vordm/wrapper/MenuWrapper.java new file mode 100644 index 0000000..708498b --- /dev/null +++ b/kn-service/biz-vordm/src/main/java/com/kening/vordm/wrapper/MenuWrapper.java @@ -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 { + + public static MenuWrapper build() { + return new MenuWrapper(); + } + + @Override + public MenuVO entityVO(Menu menu) { + return Objects.requireNonNull(BeanUtil.copy(menu, MenuVO.class)); + } + + public List listNodeVO(List list) { + List collect = list.stream().map(menu -> BeanUtil.copy(menu, MenuVO.class)).collect(Collectors.toList()); + return ForestNodeMerger.merge(collect); + } + + public List listNodeLazyVO(List list) { + return ForestNodeMerger.merge(list); + } + +} diff --git a/kn-service/biz-vordm/src/main/java/com/kening/vordm/wrapper/RoleWrapper.java b/kn-service/biz-vordm/src/main/java/com/kening/vordm/wrapper/RoleWrapper.java new file mode 100644 index 0000000..345ca26 --- /dev/null +++ b/kn-service/biz-vordm/src/main/java/com/kening/vordm/wrapper/RoleWrapper.java @@ -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 { + + public static RoleWrapper build() { + return new RoleWrapper(); + } + + @Override + public RoleVO entityVO(Role role) { + return Objects.requireNonNull(BeanUtil.copy(role, RoleVO.class)); + } + + + public List listNodeVO(List list) { + List collect = list.stream().map(this::entityVO).collect(Collectors.toList()); + return ForestNodeMerger.merge(collect); + } + +}