新增角色权限关联表
This commit is contained in:
parent
abd03dd5a5
commit
9b1144d0cb
@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/custom/permission")
|
||||
@ -59,7 +60,6 @@ public class PermissionController {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//参数查询
|
||||
|
||||
|
||||
|
||||
@ -10,10 +10,10 @@ import java.util.Date;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Table("yfsjglpt_model_menu_permission")
|
||||
@Table("yfsjglpt_model_menu_dictionary")
|
||||
public class ModelMenuPermissionPojo {
|
||||
|
||||
@RowID(sequence = "yfsjglpt_model_menu_permission_s", type = RowIDType.UUID)
|
||||
@RowID(sequence = "yfsjglpt_model_menu_dictionary_s", type = RowIDType.UUID)
|
||||
private String id ;
|
||||
/** 上级ID,; */
|
||||
private String parentId ;
|
||||
@ -33,4 +33,10 @@ public class ModelMenuPermissionPojo {
|
||||
private String lastUpdatedBy ;
|
||||
/** 最后更新时间,; */
|
||||
private Date lastUpdateDate ;
|
||||
|
||||
public ModelMenuPermissionPojo(String id, String parentId, String menuName) {
|
||||
this.id = id;
|
||||
this.parentId = parentId;
|
||||
this.menuName = menuName;
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,33 @@
|
||||
package com.xdap.self_development.pojo;
|
||||
|
||||
import com.definesys.mpaas.query.annotation.RowID;
|
||||
import com.definesys.mpaas.query.annotation.RowIDType;
|
||||
import com.definesys.mpaas.query.annotation.Table;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Table("yfsjglpt_model_role_permission")
|
||||
public class ModelRolePermissionPojo {
|
||||
|
||||
@RowID(sequence = "yfsjglpt_model_role_permission_s", type = RowIDType.UUID)
|
||||
/** ID,; */
|
||||
private String id ;
|
||||
/** 角色ID,; */
|
||||
private String roleId ;
|
||||
/** 权限路径ID,; */
|
||||
private String perId ;
|
||||
/** 是否启用,0:未启用;1:启用,; */
|
||||
private int isEnable ;
|
||||
/** 创建人,; */
|
||||
private String createdBy ;
|
||||
/** 创建时间,; */
|
||||
private Date creationDate ;
|
||||
/** 最后更新人,; */
|
||||
private String lastUpdatedBy ;
|
||||
/** 最后更新时间,; */
|
||||
private Date lastUpdateDate ;
|
||||
}
|
||||
@ -4,6 +4,7 @@ package com.xdap.self_development.service;
|
||||
import com.xdap.self_development.pojo.view.MenuListView;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface ModelMenuPermissionService {
|
||||
|
||||
|
||||
@ -14,10 +14,7 @@ import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@ -29,33 +26,39 @@ public class ModelMenuPermissionServiceImpl implements ModelMenuPermissionServic
|
||||
BusinessDatabase businessDatabase;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<MenuListView> selectMenus() {
|
||||
List<MenuListView> menuListViews = new ArrayList<MenuListView>();
|
||||
public List<MenuListView> selectMenus() {
|
||||
|
||||
Map<String, MenuListView> nodeMap = new HashMap<>();
|
||||
List<MenuListView> views = new ArrayList<>();
|
||||
List<ModelMenuPermissionPojo> permissionPojos = businessDatabase.getBusinessDatabase()
|
||||
.doQuery(ModelMenuPermissionPojo.class);
|
||||
|
||||
for (ModelMenuPermissionPojo pojo : permissionPojos) {
|
||||
MenuListView menuListView = new MenuListView();
|
||||
String id = pojo.getId();
|
||||
menuListView.setId(id);
|
||||
menuListView.setMenu(pojo.getMenuName());
|
||||
List<ModelMenuPermissionPojo> pojos = permissionPojos.stream().filter(x -> x.getParentId().equals(id)).collect(Collectors.toList());
|
||||
|
||||
if (ObjectUtils.isNotEmpty(pojos)) {
|
||||
ArrayList<MenuListView> menuListViews1 = new ArrayList<MenuListView>();
|
||||
|
||||
for (ModelMenuPermissionPojo pojo2 : pojos) {
|
||||
MenuListView menuListView1 = new MenuListView();
|
||||
String id2 = pojo2.getId();
|
||||
menuListView1.setId(id2);
|
||||
menuListView1.setMenu(pojo2.getMenuName());
|
||||
menuListViews1.add(menuListView1);
|
||||
}
|
||||
menuListView.setListViews(menuListViews1);
|
||||
}
|
||||
menuListViews.add(menuListView);
|
||||
MenuListView node = new MenuListView();
|
||||
node.setId(pojo.getId());
|
||||
node.setMenu(pojo.getMenuName());
|
||||
node.setListViews(new ArrayList<>());
|
||||
nodeMap.put(pojo.getId(), node);
|
||||
}
|
||||
return menuListViews;
|
||||
|
||||
for (ModelMenuPermissionPojo pojo : permissionPojos) {
|
||||
String parentId = pojo.getParentId();
|
||||
MenuListView currentNode = nodeMap.get(pojo.getId());
|
||||
|
||||
if (ObjectUtils.isEmpty(parentId) || !nodeMap.containsKey(parentId)) {
|
||||
// 根节点
|
||||
views.add(currentNode);
|
||||
} else {
|
||||
// 子节点,添加到父节点
|
||||
MenuListView parentNode = nodeMap.get(parentId);
|
||||
if (parentNode.getListViews() == null) {
|
||||
parentNode.setListViews(new ArrayList<>());
|
||||
}
|
||||
parentNode.getListViews().add(currentNode);
|
||||
}
|
||||
}
|
||||
|
||||
return views;
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,8 +43,8 @@ CREATE TABLE yfsjglpt_model_roles(
|
||||
|
||||
-- 菜单权限
|
||||
|
||||
DROP TABLE IF EXISTS yfsjglpt_model_menu_permission;
|
||||
CREATE TABLE yfsjglpt_model_menu_permission(
|
||||
DROP TABLE IF EXISTS yfsjglpt_model_menu_dictionary;
|
||||
CREATE TABLE yfsjglpt_model_menu_dictionary(
|
||||
`id` VARCHAR(64) NOT NULL COMMENT 'ID',
|
||||
`parent_id` VARCHAR(64) COMMENT '上级ID',
|
||||
`menu_name` VARCHAR(64) COMMENT '菜单名称',
|
||||
@ -56,10 +56,10 @@ CREATE TABLE yfsjglpt_model_menu_permission(
|
||||
`last_updated_by` VARCHAR(64) COMMENT '最后更新人',
|
||||
`last_update_date` DATETIME COMMENT '最后更新时间',
|
||||
PRIMARY KEY (`id`)
|
||||
) COMMENT '菜单权限';
|
||||
) COMMENT '菜单字典表';
|
||||
|
||||
|
||||
-- 菜单参数关联表
|
||||
-- 菜单参数关联表(权限路径表)
|
||||
DROP TABLE IF EXISTS yfsjglpt_model_menu_parameter;
|
||||
CREATE TABLE yfsjglpt_model_menu_parameter(
|
||||
`id` VARCHAR(64) NOT NULL COMMENT 'ID',
|
||||
@ -72,7 +72,7 @@ CREATE TABLE yfsjglpt_model_menu_parameter(
|
||||
`last_updated_by` VARCHAR(64) COMMENT '最后更新人',
|
||||
`last_update_date` DATETIME COMMENT '最后更新时间',
|
||||
PRIMARY KEY (`id`)
|
||||
) COMMENT '菜单参数关联表';
|
||||
) COMMENT '菜单参数关联表(权限路径表)';
|
||||
|
||||
-- 部门或用户关联角色表
|
||||
DROP TABLE IF EXISTS yfsjglpt_model_dep_user_role;
|
||||
@ -88,3 +88,18 @@ CREATE TABLE yfsjglpt_model_dep_user_role(
|
||||
PRIMARY KEY (`id`)
|
||||
) COMMENT '部门或用户关联角色表';
|
||||
|
||||
|
||||
--角色权限关联表
|
||||
DROP TABLE IF EXISTS yc_datasource_0.yfsjglpt_model_role_permission;
|
||||
CREATE TABLE yc_datasource_0.yfsjglpt_model_role_permission(
|
||||
`id` VARCHAR(64) NOT NULL COMMENT 'ID',
|
||||
`role_id` VARCHAR(64) COMMENT '角色ID',
|
||||
`per_id` VARCHAR(64) COMMENT '权限路径ID',
|
||||
`is_enable` INT DEFAULT 1 COMMENT '是否启用;0:未启用;1:启用',
|
||||
`created_by` VARCHAR(64) COMMENT '创建人',
|
||||
`creation_date` DATETIME COMMENT '创建时间',
|
||||
`last_updated_by` VARCHAR(64) COMMENT '最后更新人',
|
||||
`last_update_date` DATETIME COMMENT '最后更新时间',
|
||||
PRIMARY KEY (`id`)
|
||||
) COMMENT '角色权限关联表';
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user