菜单&数据权限新增(展开/折叠 全选/全不选 父子联动)
ÎļþÃû´Ó sql/ry_20200901.sql ÐÞ¸Ä |
| | |
| | | -- ----------------------------
|
| | | drop table if exists sys_role;
|
| | | create table sys_role (
|
| | | role_id bigint(20) not null auto_increment comment 'è§è²ID',
|
| | | role_name varchar(30) not null comment 'è§è²åç§°',
|
| | | role_key varchar(100) not null comment 'è§è²æéå符串',
|
| | | role_sort int(4) not null comment 'æ¾ç¤ºé¡ºåº',
|
| | | data_scope char(1) default '1' comment 'æ°æ®èå´ï¼1ï¼å
¨é¨æ°æ®æé 2ï¼èªå®æ°æ®æé 3ï¼æ¬é¨é¨æ°æ®æé 4ï¼æ¬é¨é¨å以䏿°æ®æéï¼',
|
| | | status char(1) not null comment 'è§è²ç¶æï¼0æ£å¸¸ 1åç¨ï¼',
|
| | | del_flag char(1) default '0' comment 'å 餿 å¿ï¼0代表åå¨ 2代表å é¤ï¼',
|
| | | create_by varchar(64) default '' comment 'å建è
',
|
| | | create_time datetime comment 'å建æ¶é´',
|
| | | update_by varchar(64) default '' comment 'æ´æ°è
',
|
| | | update_time datetime comment 'æ´æ°æ¶é´',
|
| | | remark varchar(500) default null comment '夿³¨',
|
| | | role_id bigint(20) not null auto_increment comment 'è§è²ID',
|
| | | role_name varchar(30) not null comment 'è§è²åç§°',
|
| | | role_key varchar(100) not null comment 'è§è²æéå符串',
|
| | | role_sort int(4) not null comment 'æ¾ç¤ºé¡ºåº',
|
| | | data_scope char(1) default '1' comment 'æ°æ®èå´ï¼1ï¼å
¨é¨æ°æ®æé 2ï¼èªå®æ°æ®æé 3ï¼æ¬é¨é¨æ°æ®æé 4ï¼æ¬é¨é¨å以䏿°æ®æéï¼',
|
| | | menu_check_strictly tinyint(1) default 1 comment 'èåæ éæ©é¡¹æ¯å¦å
³èæ¾ç¤º',
|
| | | dept_check_strictly tinyint(1) default 1 comment 'é¨é¨æ 鿩项æ¯å¦å
³èæ¾ç¤º',
|
| | | status char(1) not null comment 'è§è²ç¶æï¼0æ£å¸¸ 1åç¨ï¼',
|
| | | del_flag char(1) default '0' comment 'å 餿 å¿ï¼0代表åå¨ 2代表å é¤ï¼',
|
| | | create_by varchar(64) default '' comment 'å建è
',
|
| | | create_time datetime comment 'å建æ¶é´',
|
| | | update_by varchar(64) default '' comment 'æ´æ°è
',
|
| | | update_time datetime comment 'æ´æ°æ¶é´',
|
| | | remark varchar(500) default null comment '夿³¨',
|
| | | primary key (role_id)
|
| | | ) engine=innodb auto_increment=100 comment = 'è§è²ä¿¡æ¯è¡¨';
|
| | |
|
| | | -- ----------------------------
|
| | | -- åå§å-è§è²ä¿¡æ¯è¡¨æ°æ®
|
| | | -- ----------------------------
|
| | | insert into sys_role values('1', 'è¶
级管çå', 'admin', 1, 1, '0', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', 'è¶
级管çå');
|
| | | insert into sys_role values('2', 'æ®éè§è²', 'common', 2, 2, '0', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', 'æ®éè§è²');
|
| | | insert into sys_role values('1', 'è¶
级管çå', 'admin', 1, 1, 1, 1, '0', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', 'è¶
级管çå');
|
| | | insert into sys_role values('2', 'æ®éè§è²', 'common', 2, 2, 1, 1, '0', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', 'æ®éè§è²');
|
| | |
|
| | |
|
| | | -- ----------------------------
|
| | |
| | | @Excel(name = "æ°æ®èå´", readConverterExp = "1=æææ°æ®æé,2=èªå®ä¹æ°æ®æé,3=æ¬é¨é¨æ°æ®æé,4=æ¬é¨é¨å以䏿°æ®æé")
|
| | | private String dataScope;
|
| | |
|
| | | /** èåæ éæ©é¡¹æ¯å¦å
³èæ¾ç¤ºï¼0ï¼ç¶åäºç¸å
³èæ¾ç¤º 1ï¼ç¶åä¸äºç¸å
³èæ¾ç¤ºï¼ */
|
| | | private boolean menuCheckStrictly;
|
| | |
|
| | | /** é¨é¨æ 鿩项æ¯å¦å
³èæ¾ç¤ºï¼0ï¼ç¶åäºç¸å
³èæ¾ç¤º 1ï¼ç¶åä¸äºç¸å
³èæ¾ç¤ºï¼ */
|
| | | private boolean deptCheckStrictly;
|
| | |
|
| | | /** è§è²ç¶æï¼0æ£å¸¸ 1åç¨ï¼ */
|
| | | @Excel(name = "è§è²ç¶æ", readConverterExp = "0=æ£å¸¸,1=åç¨")
|
| | | private String status;
|
| | |
| | | this.dataScope = dataScope;
|
| | | }
|
| | |
|
| | | public boolean isMenuCheckStrictly()
|
| | | {
|
| | | return menuCheckStrictly;
|
| | | }
|
| | |
|
| | | public void setMenuCheckStrictly(boolean menuCheckStrictly)
|
| | | {
|
| | | this.menuCheckStrictly = menuCheckStrictly;
|
| | | }
|
| | |
|
| | | public boolean isDeptCheckStrictly()
|
| | | {
|
| | | return deptCheckStrictly;
|
| | | }
|
| | |
|
| | | public void setDeptCheckStrictly(boolean deptCheckStrictly)
|
| | | {
|
| | | this.deptCheckStrictly = deptCheckStrictly;
|
| | | }
|
| | |
|
| | | public String getStatus()
|
| | | {
|
| | | return status;
|
| | |
| | | * æ ¹æ®è§è²IDæ¥è¯¢é¨é¨æ ä¿¡æ¯
|
| | | *
|
| | | * @param roleId è§è²ID
|
| | | * @param deptCheckStrictly é¨é¨æ 鿩项æ¯å¦å
³èæ¾ç¤º
|
| | | * @return éä¸é¨é¨å表
|
| | | */
|
| | | public List<Integer> selectDeptListByRoleId(Long roleId);
|
| | | public List<Integer> selectDeptListByRoleId(@Param("roleId") Long roleId, @Param("deptCheckStrictly") boolean deptCheckStrictly);
|
| | |
|
| | | /**
|
| | | * æ ¹æ®é¨é¨IDæ¥è¯¢ä¿¡æ¯
|
| | |
| | | * æ ¹æ®è§è²IDæ¥è¯¢èåæ ä¿¡æ¯
|
| | | *
|
| | | * @param roleId è§è²ID
|
| | | * @param menuCheckStrictly èåæ éæ©é¡¹æ¯å¦å
³èæ¾ç¤º
|
| | | * @return éä¸èåå表
|
| | | */
|
| | | public List<Integer> selectMenuListByRoleId(Long roleId);
|
| | | public List<Integer> selectMenuListByRoleId(@Param("roleId") Long roleId, @Param("menuCheckStrictly") boolean menuCheckStrictly);
|
| | |
|
| | | /**
|
| | | * æ ¹æ®èåIDæ¥è¯¢ä¿¡æ¯
|
| | |
| | | import com.ruoyi.framework.aspectj.lang.annotation.DataScope;
|
| | | import com.ruoyi.framework.web.domain.TreeSelect;
|
| | | import com.ruoyi.project.system.domain.SysDept;
|
| | | import com.ruoyi.project.system.domain.SysRole;
|
| | | import com.ruoyi.project.system.mapper.SysDeptMapper;
|
| | | import com.ruoyi.project.system.mapper.SysRoleMapper;
|
| | | import com.ruoyi.project.system.service.ISysDeptService;
|
| | |
|
| | | /**
|
| | |
| | | {
|
| | | @Autowired
|
| | | private SysDeptMapper deptMapper;
|
| | | |
| | | @Autowired
|
| | | private SysRoleMapper roleMapper;
|
| | |
|
| | | /**
|
| | | * æ¥è¯¢é¨é¨ç®¡çæ°æ®
|
| | |
| | | @Override
|
| | | public List<Integer> selectDeptListByRoleId(Long roleId)
|
| | | {
|
| | | return deptMapper.selectDeptListByRoleId(roleId);
|
| | | SysRole role = roleMapper.selectRoleById(roleId);
|
| | | return deptMapper.selectDeptListByRoleId(roleId, role.isDeptCheckStrictly());
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | import com.ruoyi.common.utils.StringUtils;
|
| | | import com.ruoyi.framework.web.domain.TreeSelect;
|
| | | import com.ruoyi.project.system.domain.SysMenu;
|
| | | import com.ruoyi.project.system.domain.SysRole;
|
| | | import com.ruoyi.project.system.domain.SysUser;
|
| | | import com.ruoyi.project.system.domain.vo.MetaVo;
|
| | | import com.ruoyi.project.system.domain.vo.RouterVo;
|
| | | import com.ruoyi.project.system.mapper.SysMenuMapper;
|
| | | import com.ruoyi.project.system.mapper.SysRoleMapper;
|
| | | import com.ruoyi.project.system.mapper.SysRoleMenuMapper;
|
| | | import com.ruoyi.project.system.service.ISysMenuService;
|
| | |
|
| | |
| | |
|
| | | @Autowired
|
| | | private SysMenuMapper menuMapper;
|
| | | |
| | | @Autowired
|
| | | private SysRoleMapper roleMapper;
|
| | |
|
| | | @Autowired
|
| | | private SysRoleMenuMapper roleMenuMapper;
|
| | |
| | | @Override
|
| | | public List<Integer> selectMenuListByRoleId(Long roleId)
|
| | | {
|
| | | return menuMapper.selectMenuListByRoleId(roleId);
|
| | | SysRole role = roleMapper.selectRoleById(roleId);
|
| | | return menuMapper.selectMenuListByRoleId(roleId, role.isMenuCheckStrictly());
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | order by d.parent_id, d.order_num
|
| | | </select>
|
| | |
|
| | | <select id="selectDeptListByRoleId" parameterType="Long" resultType="Integer">
|
| | | select d.dept_id, d.parent_id
|
| | | <select id="selectDeptListByRoleId" resultType="Integer">
|
| | | select d.dept_id
|
| | | from sys_dept d
|
| | | left join sys_role_dept rd on d.dept_id = rd.dept_id
|
| | | where rd.role_id = #{roleId}
|
| | | and d.dept_id not in (select d.parent_id from sys_dept d inner join sys_role_dept rd on d.dept_id = rd.dept_id and rd.role_id = #{roleId})
|
| | | <if test="deptCheckStrictly">
|
| | | and d.dept_id not in (select d.parent_id from sys_dept d inner join sys_role_dept rd on d.dept_id = rd.dept_id and rd.role_id = #{roleId})
|
| | | </if>
|
| | | order by d.parent_id, d.order_num
|
| | | </select>
|
| | |
|
| | |
| | | order by m.parent_id, m.order_num
|
| | | </select>
|
| | |
|
| | | <select id="selectMenuListByRoleId" parameterType="Long" resultType="Integer">
|
| | | select m.menu_id, m.parent_id
|
| | | <select id="selectMenuListByRoleId" resultType="Integer">
|
| | | select m.menu_id
|
| | | from sys_menu m
|
| | | left join sys_role_menu rm on m.menu_id = rm.menu_id
|
| | | where rm.role_id = #{roleId}
|
| | | and m.menu_id not in (select m.parent_id from sys_menu m inner join sys_role_menu rm on m.menu_id = rm.menu_id and rm.role_id = #{roleId})
|
| | | <if test="menuCheckStrictly">
|
| | | and m.menu_id not in (select m.parent_id from sys_menu m inner join sys_role_menu rm on m.menu_id = rm.menu_id and rm.role_id = #{roleId})
|
| | | </if>
|
| | | order by m.parent_id, m.order_num
|
| | | </select>
|
| | |
|
| | |
| | | <mapper namespace="com.ruoyi.project.system.mapper.SysRoleMapper">
|
| | |
|
| | | <resultMap type="SysRole" id="SysRoleResult">
|
| | | <id property="roleId" column="role_id" />
|
| | | <result property="roleName" column="role_name" />
|
| | | <result property="roleKey" column="role_key" />
|
| | | <result property="roleSort" column="role_sort" />
|
| | | <result property="dataScope" column="data_scope" />
|
| | | <result property="status" column="status" />
|
| | | <result property="delFlag" column="del_flag" />
|
| | | <result property="createBy" column="create_by" />
|
| | | <result property="createTime" column="create_time" />
|
| | | <result property="updateBy" column="update_by" />
|
| | | <result property="updateTime" column="update_time" />
|
| | | <result property="remark" column="remark" />
|
| | | <id property="roleId" column="role_id" />
|
| | | <result property="roleName" column="role_name" />
|
| | | <result property="roleKey" column="role_key" />
|
| | | <result property="roleSort" column="role_sort" />
|
| | | <result property="dataScope" column="data_scope" />
|
| | | <result property="menuCheckStrictly" column="menu_check_strictly" />
|
| | | <result property="deptCheckStrictly" column="dept_check_strictly" />
|
| | | <result property="status" column="status" />
|
| | | <result property="delFlag" column="del_flag" />
|
| | | <result property="createBy" column="create_by" />
|
| | | <result property="createTime" column="create_time" />
|
| | | <result property="updateBy" column="update_by" />
|
| | | <result property="updateTime" column="update_time" />
|
| | | <result property="remark" column="remark" />
|
| | | </resultMap>
|
| | |
|
| | | <sql id="selectRoleVo">
|
| | | select distinct r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope,
|
| | | select distinct r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.menu_check_strictly, r.dept_check_strictly,
|
| | | r.status, r.del_flag, r.create_time, r.remark
|
| | | from sys_role r
|
| | | left join sys_user_role ur on ur.role_id = r.role_id
|
| | |
| | | <if test="roleKey != null and roleKey != ''">role_key,</if>
|
| | | <if test="roleSort != null and roleSort != ''">role_sort,</if>
|
| | | <if test="dataScope != null and dataScope != ''">data_scope,</if>
|
| | | <if test="menuCheckStrictly != null and menuCheckStrictly != ''">menu_check_strictly,</if>
|
| | | <if test="deptCheckStrictly != null and deptCheckStrictly != ''">dept_check_strictly,</if>
|
| | | <if test="status != null and status != ''">status,</if>
|
| | | <if test="remark != null and remark != ''">remark,</if>
|
| | | <if test="createBy != null and createBy != ''">create_by,</if>
|
| | |
| | | <if test="roleKey != null and roleKey != ''">#{roleKey},</if>
|
| | | <if test="roleSort != null and roleSort != ''">#{roleSort},</if>
|
| | | <if test="dataScope != null and dataScope != ''">#{dataScope},</if>
|
| | | <if test="menuCheckStrictly != null">#{menu_check_strictly},</if>
|
| | | <if test="deptCheckStrictly != null">#{dept_check_strictly},</if>
|
| | | <if test="status != null and status != ''">#{status},</if>
|
| | | <if test="remark != null and remark != ''">#{remark},</if>
|
| | | <if test="createBy != null and createBy != ''">#{createBy},</if>
|
| | |
| | | <if test="roleKey != null and roleKey != ''">role_key = #{roleKey},</if>
|
| | | <if test="roleSort != null and roleSort != ''">role_sort = #{roleSort},</if>
|
| | | <if test="dataScope != null and dataScope != ''">data_scope = #{dataScope},</if>
|
| | | <if test="menuCheckStrictly != null">menu_check_strictly = #{menuCheckStrictly},</if>
|
| | | <if test="deptCheckStrictly != null">dept_check_strictly = #{deptCheckStrictly},</if>
|
| | | <if test="status != null and status != ''">status = #{status},</if>
|
| | | <if test="remark != null">remark = #{remark},</if>
|
| | | <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|