jeebiz-cloud-authz-dbperms(数据权限)

数据权限组件(jeebiz-cloud-authz-dbperms)是基于mybatis-dbperms组件实现的业务数据过滤组件,该组件利用Mybatis插件原理,通过注解和接口获取限制数据后转换成表的数据过滤,从而实现数据权限控制!

1、组件包结构

2、表结果设计

3、表结构SQL

/* 数据权限表:数据权限对象表、数据权限组信息表、数据权限信息表、数据权限项信息表、数据权限-数据权限组关系表、数据权限角色关系表、
    数据权限组角色关系表、数据权限用户关系表、数据权限组用户关系表*/

-- Create table
create table SYS_DATA_PERMS_TABLE (
  T_ID            VARCHAR2(32) default sys_guid() NOT NULL,
  T_NAME          VARCHAR2(60),
  T_TABLE          VARCHAR2(100),
  T_STATUS        NUMBER(1) default 1 NOT NULL,
  T_ORDER       NUMBER(3) default 1 NOT NULL,
  CONSTRAINT DATA_PERMS_TABLE_PK PRIMARY KEY(T_ID)
);
-- Add comments to the table 
comment on table SYS_DATA_PERMS_TABLE  is '数据权限对象表';
-- Add comments to the columns 
comment on column SYS_DATA_PERMS_TABLE.T_ID  is '数据权限对象ID';
comment on column SYS_DATA_PERMS_TABLE.T_NAME  is '数据权限对象名称';
comment on column SYS_DATA_PERMS_TABLE.T_TABLE  is '受限表名称(实体表名称)';
comment on column SYS_DATA_PERMS_TABLE.T_STATUS  is '数据权限对象可用状态:(0:不可用|1:可用)';
comment on column SYS_DATA_PERMS_TABLE.T_ORDER  is '数据权限对象排序';

-- Create table
create table SYS_DATA_PERMS_TABLE_COLUMNS (
  T_ID            VARCHAR2(32) NOT NULL,
  C_ID            VARCHAR2(32) default sys_guid() NOT NULL,
  C_NAME          VARCHAR2(60),
  C_LABEL        VARCHAR2(100),
  C_SQL            CLOB,
  C_STATUS        NUMBER(1) default 1 NOT NULL,
  C_ORDER       NUMBER(3) default 1 NOT NULL,
  CONSTRAINT DATA_PERMS_TABLE_COLUMNS_PK PRIMARY KEY(C_ID)
);
-- Add comments to the table 
comment on table SYS_DATA_PERMS_TABLE_COLUMNS  is '数据权限对象字段表';
-- Add comments to the columns 
comment on column SYS_DATA_PERMS_TABLE_COLUMNS.T_ID  is '数据权限对象ID';
comment on column SYS_DATA_PERMS_TABLE_COLUMNS.C_ID  is '数据权限对象字段ID';
comment on column SYS_DATA_PERMS_TABLE_COLUMNS.C_NAME  is '受数据权限对象字段限制的业务数据表字段名称(实体表字段列名称)';
comment on column SYS_DATA_PERMS_TABLE_COLUMNS.C_LABEL  is '数据权限对象字段标签(页面显示名称)';
comment on column SYS_DATA_PERMS_TABLE_COLUMNS.C_SQL  is '受限数据项数据查询SQL';
comment on column SYS_DATA_PERMS_TABLE_COLUMNS.C_STATUS  is '受限数据项字段可用状态:(0:不可用|1:可用)';
comment on column SYS_DATA_PERMS_TABLE_COLUMNS.C_ORDER  is '受限数据项字段排序';

-- Create table
create table SYS_DATA_PERMS_GROUP (
  G_ID            VARCHAR2(32) default sys_guid() NOT NULL,
  G_NAME          VARCHAR2(60),
  G_INTRO        CLOB,
  G_STATUS        NUMBER(1) default 1 NOT NULL,
  G_ORDER       NUMBER(3) default 1 NOT NULL,
  G_TIME24        VARCHAR2(32) default to_char(sysdate ,'yyyy-mm-dd hh24:mi:ss'),
  CONSTRAINT DATA_PERMS_GROUP_PK PRIMARY KEY(G_ID)
);
-- Add comments to the table 
comment on table SYS_DATA_PERMS_GROUP  is '数据权限组信息表';
-- Add comments to the columns 
comment on column SYS_DATA_PERMS_GROUP.G_ID  is '数据权限组ID';
comment on column SYS_DATA_PERMS_GROUP.G_NAME  is '数据权限组名称';
comment on column SYS_DATA_PERMS_GROUP.G_INTRO  is '数据权限组简介';
comment on column SYS_DATA_PERMS_GROUP.G_STATUS  is '数据权限组可用状态:(0:不可用|1:可用)';
comment on column SYS_DATA_PERMS_GROUP.G_ORDER  is '数据权限组排序';
comment on column SYS_DATA_PERMS_GROUP.G_TIME24  is '数据权限组创建时间';

-- Create table
create table SYS_DATA_PERMS (
  P_ID           VARCHAR2(32) default sys_guid() NOT NULL,
  P_NAME          VARCHAR2(60) NOT NULL,
  P_TYPE         NUMBER(1) default 1 NOT NULL,
  P_INTRO          CLOB,
  P_TABLE       VARCHAR2(100) NOT NULL,
  P_RELATION       VARCHAR2(20) NOT NULL,
  P_STATUS        NUMBER(1) default 1 NOT NULL,
  P_ORDER        NUMBER(4) default 1 NOT NULL,
  CONSTRAINT PK_DATA_PERMS_RULE PRIMARY KEY(P_ID)
);
-- Add comments to the table 
comment on table SYS_DATA_PERMS  is '数据权限表';
-- Add comments to the columns 
comment on column SYS_DATA_PERMS.P_ID  is '数据权限ID';
comment on column SYS_DATA_PERMS.P_NAME  is '数据权限名称';
comment on column SYS_DATA_PERMS.P_TYPE  is '数据权限类型(1:原生|2:继承|3:复制)';
comment on column SYS_DATA_PERMS.P_INTRO  is '数据权限简介';
comment on column SYS_DATA_PERMS.P_TABLE  is '受限表名称(实体表名称)';
comment on column SYS_DATA_PERMS.P_RELATION  is '数据权限项关系 and/or';
comment on column SYS_DATA_PERMS.P_STATUS  is '数据权限可用状态:(0:不可用|1:可用)';
comment on column SYS_DATA_PERMS.P_ORDER  is '数据权限排序';

-- Create table
create table SYS_DATA_PERMS_ITEM (
  P_ID           VARCHAR2(32) NOT NULL,
  I_ID           VARCHAR2(32) default sys_guid() NOT NULL,
  I_COLUMN       VARCHAR2(100) NOT NULL,
  I_NAME          VARCHAR2(100) NOT NULL,
  I_CONDITION   VARCHAR2(50) NOT NULL,
  I_PINYIN       VARCHAR2(100) NOT NULL,
  I_PERMS        CLOB,
  I_STATUS        NUMBER(1) default 1 NOT NULL,
  I_ORDER        NUMBER(4) default 1 NOT NULL,
  CONSTRAINT DATA_PERMS_ITEM_PK PRIMARY KEY(I_ID)
);
-- Add comments to the table 
comment on table SYS_DATA_PERMS_ITEM  is '数据权限项信息表';
-- Add comments to the columns 
comment on column SYS_DATA_PERMS_ITEM.P_ID  is '数据权限ID';
comment on column SYS_DATA_PERMS_ITEM.I_ID  is '数据权限项ID';
comment on column SYS_DATA_PERMS_ITEM.I_COLUMN  is '受限表字段名称(实体表字段列名称)';
comment on column SYS_DATA_PERMS_ITEM.I_NAME  is '数据权限项名称(实体表字段中文名称)';
comment on column SYS_DATA_PERMS_ITEM.I_PINYIN  is '受限表字段中文拼音';
comment on column SYS_DATA_PERMS_ITEM.I_CONDITION  is '受限表字段与限制条件之间的关联条件';
comment on column SYS_DATA_PERMS_ITEM.I_PERMS  is '受限表字段限制条件';
comment on column SYS_DATA_PERMS_ITEM.I_STATUS  is '数据权限项可用状态:(0:不可用|1:可用)';
comment on column SYS_DATA_PERMS_ITEM.I_ORDER  is '数据权限项排序';

-- Create table
create table SYS_DATA_PERMS_GROUP_REL (
  G_ID            VARCHAR2(32) NOT NULL,
  P_ID             VARCHAR2(32) NOT NULL,
  CONSTRAINT DATA_PERMS_GROUP_UK UNIQUE(G_ID,P_ID)
);
-- Add comments to the table 
comment on table SYS_DATA_PERMS_GROUP_REL  is '数据权限-数据权限组关系表';
-- Add comments to the columns 
comment on column SYS_DATA_PERMS_GROUP_REL.G_ID  is '数据权限组ID';
comment on column SYS_DATA_PERMS_GROUP_REL.P_ID  is '数据权限ID';

-- Create table
create table SYS_DATA_PERMS_ROLE_REL (
  APP_ID         VARCHAR2(32) NOT NULL,
  P_ID              VARCHAR2(32) NOT NULL,
  R_ID              VARCHAR2(32) NOT NULL,
  CONSTRAINT DATA_PERMS_ROLE_UK UNIQUE(P_ID,R_ID)
);
-- Add comments to the table 
comment on table SYS_DATA_PERMS_ROLE_REL  is '数据权限角色关系表';
-- Add comments to the columns 
comment on column SYS_DATA_PERMS_ROLE_REL.APP_ID  is '应用ID';
comment on column SYS_DATA_PERMS_ROLE_REL.R_ID  is '角色ID';
comment on column SYS_DATA_PERMS_ROLE_REL.P_ID  is '数据权限ID';

-- Create table
create table SYS_DATA_PERMS_USER_REL (
  APP_ID          VARCHAR2(32) NOT NULL,
  U_ID             VARCHAR2(32) NOT NULL,
  P_ID             VARCHAR2(32) NOT NULL,
  CONSTRAINT DATA_PERMS_USER_UK UNIQUE(P_ID,U_ID)
);
-- Add comments to the table 
comment on table SYS_DATA_PERMS_USER_REL  is '数据权限用户关系表';
-- Add comments to the columns 
comment on column SYS_DATA_PERMS_USER_REL.APP_ID  is '应用ID';
comment on column SYS_DATA_PERMS_USER_REL.U_ID  is '用户ID';
comment on column SYS_DATA_PERMS_USER_REL.P_ID  is '数据权限ID';

-- Create table
create table SYS_DATA_PERMS_GROUP_ROLE_REL (
  APP_ID          VARCHAR2(32) NOT NULL,
  R_ID             VARCHAR2(32) NOT NULL,
  G_ID            VARCHAR2(32) NOT NULL,
  CONSTRAINT DATA_PERMS_GROUP_ROLE_UK UNIQUE(G_ID,R_ID)
);
-- Add comments to the table 
comment on table SYS_DATA_PERMS_GROUP_ROLE_REL  is '数据权限组角色关系表';
-- Add comments to the columns 
comment on column SYS_DATA_PERMS_GROUP_ROLE_REL.APP_ID  is '应用ID';
comment on column SYS_DATA_PERMS_GROUP_ROLE_REL.R_ID  is '角色ID';
comment on column SYS_DATA_PERMS_GROUP_ROLE_REL.G_ID  is '数据权限组ID';

-- Create table
create table SYS_DATA_PERMS_GROUP_USER_REL (
  APP_ID          VARCHAR2(32) NOT NULL,
  G_ID            VARCHAR2(32) NOT NULL,
  U_ID             VARCHAR2(32) NOT NULL,
  CONSTRAINT DATA_PERMS_GROUP_USER_UK UNIQUE(G_ID,U_ID)
);
-- Add comments to the table 
comment on table SYS_DATA_PERMS_GROUP_USER_REL  is '数据权限组用户关系表';
-- Add comments to the columns
comment on column SYS_DATA_PERMS_GROUP_USER_REL.APP_ID  is '应用ID'; 
comment on column SYS_DATA_PERMS_GROUP_USER_REL.U_ID  is '用户ID';
comment on column SYS_DATA_PERMS_GROUP_USER_REL.G_ID  is '数据权限组ID';

-- Create table
create table SYS_DATA_PERMS_SPCL (
  T_ID            VARCHAR2(32) default sys_guid() NOT NULL,
  T_CODE          VARCHAR2(60),
  T_NAME          VARCHAR2(60),
  T_STATUS        NUMBER(1) default 1 NOT NULL,
  T_ORDER       NUMBER(3) default 1 NOT NULL,
  CONSTRAINT DATA_PERMS_SPCL_PK PRIMARY KEY(T_ID)
);
-- Add comments to the table 
comment on table SYS_DATA_PERMS_SPCL  is '数据权限专项表';
-- Add comments to the columns 
comment on column SYS_DATA_PERMS_SPCL.T_ID  is '数据权限专项ID';
comment on column SYS_DATA_PERMS_SPCL.T_CODE  is '数据权限专项编码(对应程序中的)';
comment on column SYS_DATA_PERMS_SPCL.T_NAME  is '数据权限专项名称';
comment on column SYS_DATA_PERMS_SPCL.T_STATUS  is '数据权限专项可用状态:(0:不可用|1:可用)';
comment on column SYS_DATA_PERMS_SPCL.T_ORDER  is '数据权限专项排序';

-- Create table
create table SYS_DATA_PERMS_SPCL_COLUMNS (
  T_ID            VARCHAR2(32) NOT NULL,
  C_ID            VARCHAR2(32) default sys_guid() NOT NULL,
  C_TABLE          VARCHAR2(100),
  C_NAME          VARCHAR2(60),
  C_LABEL        VARCHAR2(100),
  C_SQL            VARCHAR2(2000),
  C_STATUS        NUMBER(1) default 1 NOT NULL,
  C_ORDER       NUMBER(3) default 1 NOT NULL,
  CONSTRAINT DATA_PERMS_SPCL_COLUMNS_PK PRIMARY KEY(C_ID)
);
-- Add comments to the table 
comment on table SYS_DATA_PERMS_SPCL_COLUMNS  is '数据权限专项字段表';
-- Add comments to the columns 
comment on column SYS_DATA_PERMS_SPCL_COLUMNS.T_ID  is '数据权限专项ID';
comment on column SYS_DATA_PERMS_SPCL_COLUMNS.C_ID  is '数据权限专项字段ID';
comment on column SYS_DATA_PERMS_SPCL_COLUMNS.C_TABLE  is '受限表名称(实体表名称)';
comment on column SYS_DATA_PERMS_SPCL_COLUMNS.C_NAME  is '受数据权限专项字段限制的业务数据表字段名称(实体表字段列名称)';
comment on column SYS_DATA_PERMS_SPCL_COLUMNS.C_LABEL  is '数据权限专项字段标签(页面显示名称)';
comment on column SYS_DATA_PERMS_SPCL_COLUMNS.C_SQL  is '受限数据项数据查询SQL';
comment on column SYS_DATA_PERMS_SPCL_COLUMNS.C_STATUS  is '受限数据项字段可用状态:(0:不可用|1:可用)';
comment on column SYS_DATA_PERMS_SPCL_COLUMNS.C_ORDER  is '受限数据项字段排序';

-- Create table
create table SYS_DATA_PERMS_SPCL_ROLE_REL (
  APP_ID          VARCHAR2(32) NOT NULL,
  R_ID             VARCHAR2(32) NOT NULL,
  T_ID            VARCHAR2(32) NOT NULL,
  CONSTRAINT DATA_PERMS_SPCL_ROLE_UK UNIQUE(T_ID,R_ID)
);
-- Add comments to the table 
comment on table SYS_DATA_PERMS_SPCL_ROLE_REL  is '数据权限专项角色关系表';
-- Add comments to the columns 
comment on column SYS_DATA_PERMS_SPCL_ROLE_REL.APP_ID  is '应用ID';
comment on column SYS_DATA_PERMS_SPCL_ROLE_REL.R_ID  is '角色ID';
comment on column SYS_DATA_PERMS_SPCL_ROLE_REL.T_ID  is '数据权限专项ID';

-- Create table
create table SYS_DATA_PERMS_SPCL_USER_REL (
  APP_ID          VARCHAR2(32) NOT NULL,
  T_ID            VARCHAR2(32) NOT NULL,
  U_ID             VARCHAR2(32) NOT NULL,
  CONSTRAINT DATA_PERMS_SPCL_USER_UK UNIQUE(T_ID,U_ID)
);
-- Add comments to the table 
comment on table SYS_DATA_PERMS_SPCL_USER_REL  is '数据权限专项用户关系表';
-- Add comments to the columns
comment on column SYS_DATA_PERMS_SPCL_USER_REL.APP_ID  is '应用ID'; 
comment on column SYS_DATA_PERMS_SPCL_USER_REL.U_ID  is '用户ID';
comment on column SYS_DATA_PERMS_SPCL_USER_REL.T_ID  is '数据权限专项ID';

4、初始化规则权限

DELETE SYS_DATA_PERMS_TABLE;
DELETE SYS_DATA_PERMS_TABLE_COLUMNS;
DELETE SYS_DATA_PERMS_GROUP;
DELETE SYS_DATA_PERMS;
DELETE SYS_DATA_PERMS_ITEM;
DELETE SYS_DATA_PERMS_ROLE_REL;
DELETE SYS_DATA_PERMS_USER_REL;
DELETE SYS_DATA_PERMS_GROUP_REL;
DELETE SYS_DATA_PERMS_GROUP_ROLE_REL;
DELETE SYS_DATA_PERMS_GROUP_USER_REL;
DELETE SYS_DATA_PERMS_SPCL;
DELETE SYS_DATA_PERMS_SPCL_COLUMNS;
DELETE SYS_DATA_PERMS_SPCL_ROLE_REL;
DELETE SYS_DATA_PERMS_SPCL_USER_REL;

insert into SYS_DATA_PERMS_TABLE (T_ID, T_NAME, T_TABLE, T_STATUS, T_ORDER)
values ('98DD429B8D05A864E050A8C0A1022DF2', '学年', 'GXXX_XNXQDMB', 1, 1);

insert into SYS_DATA_PERMS_TABLE_COLUMNS (T_ID, C_ID, C_NAME, C_LABEL, C_SQL, C_STATUS, C_ORDER)
values ('98DD429B8D05A864E050A8C0A1022DF2', '99434675997FE68FE050A8C0A1025D4B', 'XNM', '学年码', 'select distinct t.xnm as KEY, t.xnm || ''年'' as VALUE from GXXX_XNXQDMB t  order by t.xnm desc', 1, 1);


insert into SYS_DATA_PERMS_TABLE (T_ID, T_NAME, T_TABLE, T_STATUS, T_ORDER)
values ('98DD429B8D06A864E050A8C0A1022DF2', '学期', 'GXXX_XNXQDMB', 1, 2);

insert into SYS_DATA_PERMS_TABLE_COLUMNS (T_ID, C_ID, C_NAME, C_LABEL, C_SQL, C_STATUS, C_ORDER)
values ('98DD429B8D06A864E050A8C0A1022DF2', '994346759980E68FE050A8C0A1025D4B', 'XQM', '学期码', 'select distinct t.xqm as KEY,  ''第'' || t.xqm  || ''学期'' as VALUE from GXXX_XNXQDMB t  order by t.xqm asc', 1, 1);

insert into SYS_DATA_PERMS_TABLE (T_ID, T_NAME, T_TABLE, T_STATUS, T_ORDER)
values ('9942FEF2AA56B144E050A8C0A10256B2', '校区', 'GXXX_XNXQDMB', 1, 1);

insert into SYS_DATA_PERMS_TABLE_COLUMNS (T_ID, C_ID, C_NAME, C_LABEL, C_SQL, C_STATUS, C_ORDER)
values ('9942FEF2AA56B144E050A8C0A10256B2', '994346759981E68FE050A8C0A1025D4B', 'XQID', '校区ID', 'SELECT T.ID AS KEY, T.XQMC AS VALUE FROM GXXX_XQXXB T WHERE t.SFQY = 1 ORDER BY t.XQH ASC', 1, 1);

insert into SYS_DATA_PERMS_TABLE (T_ID, T_NAME, T_TABLE, T_STATUS, T_ORDER)
values ('9942FEF2AA57B144E050A8C0A10256B2', '教学院系', 'GXXX_XYXXB', 1, 2);

insert into SYS_DATA_PERMS_TABLE_COLUMNS (T_ID, C_ID, C_NAME, C_LABEL, C_SQL, C_STATUS, C_ORDER)
values ('9942FEF2AA57B144E050A8C0A10256B2', '994346759982E68FE050A8C0A1025D4B', 'ID', '教学院系ID', 'SELECT T.ID AS KEY, T.DWMC AS VALUE FROM GXXX_XYXXB T WHERE t.SFQY = 1 AND t.DWLBM = 1 ORDER BY t.DWH ASC', 1, 1);

insert into SYS_DATA_PERMS_TABLE (T_ID, T_NAME, T_TABLE, T_STATUS, T_ORDER)
values ('9942FEF2AA58B144E050A8C0A10256B2', '科研机构', 'GXXX_XYXXB', 1, 3);

insert into SYS_DATA_PERMS_TABLE_COLUMNS (T_ID, C_ID, C_NAME, C_LABEL, C_SQL, C_STATUS, C_ORDER)
values ('9942FEF2AA58B144E050A8C0A10256B2', '994346759983E68FE050A8C0A1025D4B', 'ID', '科研机构ID', 'SELECT T.ID AS KEY, T.DWMC AS VALUE FROM GXXX_XYXXB T WHERE t.SFQY = 1 AND t.DWLBM = 2 ORDER BY t.DWH ASC', 1, 1);

insert into SYS_DATA_PERMS_TABLE (T_ID, T_NAME, T_TABLE, T_STATUS, T_ORDER)
values ('9942FEF2AA59B144E050A8C0A10256B2', '公共服务部门', 'GXXX_XYXXB', 1, 4);

insert into SYS_DATA_PERMS_TABLE_COLUMNS (T_ID, C_ID, C_NAME, C_LABEL, C_SQL, C_STATUS, C_ORDER)
values ('9942FEF2AA59B144E050A8C0A10256B2', '994346759984E68FE050A8C0A1025D4B', 'ID', '公共服务部门ID', 'SELECT T.ID AS KEY, T.DWMC AS VALUE FROM GXXX_XYXXB T WHERE t.SFQY = 1 AND t.DWLBM = 3 ORDER BY t.DWH ASC', 1, 1);

insert into SYS_DATA_PERMS_TABLE (T_ID, T_NAME, T_TABLE, T_STATUS, T_ORDER)
values ('9942FEF2AA5AB144E050A8C0A10256B2', '党务部门', 'GXXX_XYXXB', 1, 5);

insert into SYS_DATA_PERMS_TABLE_COLUMNS (T_ID, C_ID, C_NAME, C_LABEL, C_SQL, C_STATUS, C_ORDER)
values ('9942FEF2AA5AB144E050A8C0A10256B2', '994346759985E68FE050A8C0A1025D4B', 'ID', '党务部门ID', 'SELECT T.ID AS KEY, T.DWMC AS VALUE FROM GXXX_XYXXB T WHERE t.SFQY = 1 AND t.DWLBM = 4 ORDER BY t.DWH ASC', 1, 1);

insert into SYS_DATA_PERMS_TABLE (T_ID, T_NAME, T_TABLE, T_STATUS, T_ORDER)
values ('9942FEF2AA5BB144E050A8C0A10256B2', '行政机构', 'GXXX_XYXXB', 1, 6);

insert into SYS_DATA_PERMS_TABLE_COLUMNS (T_ID, C_ID, C_NAME, C_LABEL, C_SQL, C_STATUS, C_ORDER)
values ('9942FEF2AA5BB144E050A8C0A10256B2', '994346759986E68FE050A8C0A1025D4B', 'ID', '行政机构ID', 'SELECT T.ID AS KEY, T.DWMC AS VALUE FROM GXXX_XYXXB T WHERE t.SFQY = 1 AND t.DWLBM = 5 ORDER BY t.DWH ASC', 1, 1);

insert into SYS_DATA_PERMS_TABLE (T_ID, T_NAME, T_TABLE, T_STATUS, T_ORDER)
values ('9942FEF2AA5CB144E050A8C0A10256B2', '附属单位', 'GXXX_XYXXB', 1, 7);

insert into SYS_DATA_PERMS_TABLE_COLUMNS (T_ID, C_ID, C_NAME, C_LABEL, C_SQL, C_STATUS, C_ORDER)
values ('9942FEF2AA5CB144E050A8C0A10256B2', '994346759987E68FE050A8C0A1025D4B', 'ID', '附属单位ID', 'SELECT T.ID AS KEY, T.DWMC AS VALUE FROM GXXX_XYXXB T WHERE t.SFQY = 1 AND t.DWLBM = 6 ORDER BY t.DWH ASC', 1, 1);

insert into SYS_DATA_PERMS_TABLE (T_ID, T_NAME, T_TABLE, T_STATUS, T_ORDER)
values ('9942FEF2AA5DB144E050A8C0A10256B2', '后勤部门', 'GXXX_XYXXB', 1, 8);

insert into SYS_DATA_PERMS_TABLE_COLUMNS (T_ID, C_ID, C_NAME, C_LABEL, C_SQL, C_STATUS, C_ORDER)
values ('9942FEF2AA5DB144E050A8C0A10256B2', '994346759988E68FE050A8C0A1025D4B', 'ID', '后勤部门ID', 'SELECT T.ID AS KEY, T.DWMC AS VALUE FROM GXXX_XYXXB T WHERE t.SFQY = 1 AND t.DWLBM = 7 ORDER BY t.DWH ASC', 1, 1);

insert into SYS_DATA_PERMS_TABLE (T_ID, T_NAME, T_TABLE, T_STATUS, T_ORDER)
values ('9942FEF2AA5EB144E050A8C0A10256B2', '校办企业', 'GXXX_XYXXB', 1, 9);

insert into SYS_DATA_PERMS_TABLE_COLUMNS (T_ID, C_ID, C_NAME, C_LABEL, C_SQL, C_STATUS, C_ORDER)
values ('9942FEF2AA5EB144E050A8C0A10256B2', '994346759989E68FE050A8C0A1025D4B', 'ID', '校办企业ID', 'SELECT T.ID AS KEY, T.DWMC AS VALUE FROM GXXX_XYXXB T WHERE t.SFQY = 1 AND t.DWLBM = 8 ORDER BY t.DWH ASC', 1, 1);

insert into SYS_DATA_PERMS_TABLE (T_ID, T_NAME, T_TABLE, T_STATUS, T_ORDER)
values ('9942FEF2AA5FB144E050A8C0A10256B2', '专业', 'GXXX_ZYXXB', 1, 10);

insert into SYS_DATA_PERMS_TABLE_COLUMNS (T_ID, C_ID, C_NAME, C_LABEL, C_SQL, C_STATUS, C_ORDER)
values ('9942FEF2AA5FB144E050A8C0A10256B2', '99434675998AE68FE050A8C0A1025D4B', 'ID', '专业ID', 'SELECT T.ID AS KEY, T.ZYMC AS VALUE FROM GXXX_ZYXXB T WHERE t.SFQY = 1 ORDER BY t.DWH,T.ZYH ASC', 1, 1);

insert into SYS_DATA_PERMS_TABLE (T_ID, T_NAME, T_TABLE, T_STATUS, T_ORDER)
values ('9942FEF2AA60B144E050A8C0A10256B2', '班级', 'GXXX_BJXXB', 1, 11);

insert into SYS_DATA_PERMS_TABLE_COLUMNS (T_ID, C_ID, C_NAME, C_LABEL, C_SQL, C_STATUS, C_ORDER)
values ('9942FEF2AA60B144E050A8C0A10256B2', '99434675998BE68FE050A8C0A1025D4B', 'ID', '班级ID', 'SELECT T.ID AS KEY, T.BJMC AS VALUE FROM GXXX_BJXXB T ORDER BY T.BH ASC', 1, 1);

insert into SYS_DATA_PERMS_TABLE (T_ID, T_NAME, T_TABLE, T_STATUS, T_ORDER)
values ('99D3064910B4315FE050A8C0A1026506', '教职工', 'GXJG_JZGXXB', 1, 12);

insert into SYS_DATA_PERMS_TABLE_COLUMNS (T_ID, C_ID, C_NAME, C_LABEL, C_SQL, C_STATUS, C_ORDER)
values ('99D3064910B4315FE050A8C0A1026506', '99D3064910BF315FE050A8C0A1026506', 'DWH', '所属部门', 'SELECT T.ID AS KEY, T.DWMC AS VALUE FROM GXXX_XYXXB T WHERE t.SFQY = 1 ORDER BY t.DWLBM,t.DWH ASC', 1, 1);

insert into SYS_DATA_PERMS_TABLE_COLUMNS (T_ID, C_ID, C_NAME, C_LABEL, C_SQL, C_STATUS, C_ORDER)
values ('99D3064910B4315FE050A8C0A1026506', '99D3064910BE315FE050A8C0A1026506', 'XQH', '所属校区', 'SELECT T.ID AS KEY, T.XQMC AS VALUE FROM GXXX_XQXXB T WHERE t.SFQY = 1 ORDER BY t.XQH ASC', 1, 1);

insert into SYS_DATA_PERMS_TABLE (T_ID, T_NAME, T_TABLE, T_STATUS, T_ORDER)
values ('99D3064910B5315FE050A8C0A1026506', '学生', 'GXXS_XJZTXXB', 1, 13);

insert into SYS_DATA_PERMS_TABLE_COLUMNS (T_ID, C_ID, C_NAME, C_LABEL, C_SQL, C_STATUS, C_ORDER)
values ('99D3064910B5315FE050A8C0A1026506', '99D3064910BA315FE050A8C0A1026506', 'XQID', '校区', 'SELECT T.ID AS KEY, T.XQMC AS VALUE FROM GXXX_XQXXB T WHERE t.SFQY = 1 ORDER BY t.XQH ASC', 1, 1);

insert into SYS_DATA_PERMS_TABLE_COLUMNS (T_ID, C_ID, C_NAME, C_LABEL, C_SQL, C_STATUS, C_ORDER)
values ('99D3064910B5315FE050A8C0A1026506', '99D3064910B9315FE050A8C0A1026506', 'YXID', '学院', 'SELECT T.ID AS KEY, T.DWMC AS VALUE FROM GXXX_XYXXB T WHERE t.SFQY = 1 ORDER BY t.DWLBM,t.DWH ASC', 1, 1);

insert into SYS_DATA_PERMS_TABLE_COLUMNS (T_ID, C_ID, C_NAME, C_LABEL, C_SQL, C_STATUS, C_ORDER)
values ('99D3064910B5315FE050A8C0A1026506', '99D3064910BB315FE050A8C0A1026506', 'ZYID', '专业', 'SELECT T.ID AS KEY, T.ZYMC AS VALUE FROM GXXX_ZYXXB T WHERE t.SFQY = 1 ORDER BY t.DWH,T.ZYH ASC', 1, 1);

insert into SYS_DATA_PERMS_TABLE_COLUMNS (T_ID, C_ID, C_NAME, C_LABEL, C_SQL, C_STATUS, C_ORDER)
values ('99D3064910B5315FE050A8C0A1026506', '99D3064910BC315FE050A8C0A1026506', 'BJID', '班级', 'SELECT T.ID AS KEY, T.BJMC AS VALUE FROM GXXX_BJXXB T ORDER BY T.BH ASC', 1, 1);

insert into SYS_DATA_PERMS_TABLE_COLUMNS (T_ID, C_ID, C_NAME, C_LABEL, C_SQL, C_STATUS, C_ORDER)
values ('99D3064910B5315FE050A8C0A1026506', '99D3064910BD315FE050A8C0A1026506', 'SZNJ', '年级', 'SELECT distinct t.SZNJ as KEY, t.SZNJ || ''年'' AS VALUE from GXXS_XJZTXXB t WHERE t.SZNJ is not null ORDER BY t.SZNJ DESC', 1, 1);

/*
INSERT INTO SYS_DATA_PERMS_TABLE  (T_NAME, T_TABLE, T_COLUMN, T_LABEL, T_SQL, T_STATUS, T_ORDER)
SELECT t.G_TEXT,
       'SYS_EXTRAS_PAIRVALUE',
       'D_KEY',
       t.G_TEXT,
       ' SELECT T.D_KEY AS KEY, T.D_TEXT AS VALUE FROM SYS_EXTRAS_PAIRVALUE T WHERE T.D_STATUS = 1 AND t.D_GROUP = ''' ||
       t.G_KEY || ''' ORDER BY NVL(T.D_ORDER, 0) ASC',
       1,
       t.G_ORDER
  FROM SYS_EXTRAS_PAIRGROUP t;
  */

5、初始化特殊权限

增加一个特殊权限主要在于增加SYS_DATA_PERMS_SPCL表和SYS_DATA_PERMS_SPCL_COLUMNS记录

insert into SYS_DATA_PERMS_SPCL (T_ID, T_NAME, T_CODE, T_STATUS, T_ORDER)
values ('9A1A6386C4BB8CA4E050A8C0A102690C', '辅导员管理班级', 'S002', 1, 2);

insert into SYS_DATA_PERMS_SPCL_COLUMNS (T_ID, C_ID, C_TABLE, C_NAME, C_LABEL, C_SQL, C_STATUS, C_ORDER)
values ('9A1A6386C4BB8CA4E050A8C0A102690C', '9A1D266431EC8466E050A8C0A1027D4D', 'GXXX_BJXXB', 'FDYGH', '辅导员', 'ukey', 1, 1);

insert into SYS_DATA_PERMS_SPCL (T_ID, T_NAME, T_CODE, T_STATUS, T_ORDER)
values ('9A1A6386C4BC8CA4E050A8C0A102690C', '班主任管理班级', 'S003', 1, 3);

insert into SYS_DATA_PERMS_SPCL_COLUMNS (T_ID, C_ID, C_TABLE, C_NAME, C_LABEL, C_SQL, C_STATUS, C_ORDER)
values ('9A1A6386C4BA8CA4E050A8C0A102690C', '9A1B6311EB9956B5E050A8C0A1027D7F', 'GXXX_BJXXB', 'BZRGH', '班主任', 'ukey', 1, 1);

6、代码示例

在Dao接口或者指定的方法上增加@RequiresPermissions注解

@Mapper
@RequiresPermissions
public interface IDataPermissionDao extends BaseDao<DataPermissionModel> {
}
作者:Jeebiz  创建时间:2019-12-24 11:40
 更新时间:2023-12-20 16:58