feat:新增deps和授权类型,用于解决依赖问题
This commit is contained in:
@@ -103,6 +103,7 @@ public class RoleGroupController {
|
|||||||
List<CoreRoleGroupRx> list = coreRoleService.getGroupRxMapper().selectList(new QueryWrapper<CoreRoleGroupRx>()
|
List<CoreRoleGroupRx> list = coreRoleService.getGroupRxMapper().selectList(new QueryWrapper<CoreRoleGroupRx>()
|
||||||
.eq(CoreRoleGroupRx.IS_DELETED, 0)
|
.eq(CoreRoleGroupRx.IS_DELETED, 0)
|
||||||
.eq("group_id", dto.getId())
|
.eq("group_id", dto.getId())
|
||||||
|
.eq("type", "bind")
|
||||||
);
|
);
|
||||||
return ApiResp.respOK(list);
|
return ApiResp.respOK(list);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,4 +14,4 @@ public interface CoreRoleGroupRxMapper extends BaseMapper<CoreRoleGroupRx> {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int batchInsert(@Param("list") List<CoreRoleGroupRx> coreRoleGroupRxs);
|
int batchInsert(@Param("list") List<CoreRoleGroupRx> coreRoleGroupRxs);
|
||||||
}
|
}
|
||||||
@@ -90,6 +90,12 @@ public class CoreRoleAuthority extends DaoBase {
|
|||||||
@TableField(value = "`source`")
|
@TableField(value = "`source`")
|
||||||
private String source;
|
private String source;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 依赖权限
|
||||||
|
*/
|
||||||
|
@TableField(value = "deps")
|
||||||
|
private String deps;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 扩展1
|
* 扩展1
|
||||||
*/
|
*/
|
||||||
@@ -342,6 +348,24 @@ public class CoreRoleAuthority extends DaoBase {
|
|||||||
this.source = source;
|
this.source = source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取依赖权限
|
||||||
|
*
|
||||||
|
* @return deps - 依赖权限
|
||||||
|
*/
|
||||||
|
public String getDeps() {
|
||||||
|
return deps;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置依赖权限
|
||||||
|
*
|
||||||
|
* @param deps 依赖权限
|
||||||
|
*/
|
||||||
|
public void setDeps(String deps) {
|
||||||
|
this.deps = deps;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取扩展1
|
* 获取扩展1
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -24,6 +24,12 @@ public class CoreRoleGroupRx extends DaoBase {
|
|||||||
@TableField(value = "menu_id")
|
@TableField(value = "menu_id")
|
||||||
private String menuId;
|
private String menuId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关联类型:dep-依赖,bind-绑定
|
||||||
|
*/
|
||||||
|
@TableField(value = "`type`")
|
||||||
|
private String type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取角色id
|
* 获取角色id
|
||||||
*
|
*
|
||||||
@@ -59,4 +65,22 @@ public class CoreRoleGroupRx extends DaoBase {
|
|||||||
public void setMenuId(String menuId) {
|
public void setMenuId(String menuId) {
|
||||||
this.menuId = menuId;
|
this.menuId = menuId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取关联类型:dep-依赖,bind-绑定
|
||||||
|
*
|
||||||
|
* @return type - 关联类型:dep-依赖,bind-绑定
|
||||||
|
*/
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置关联类型:dep-依赖,bind-绑定
|
||||||
|
*
|
||||||
|
* @param type 关联类型:dep-依赖,bind-绑定
|
||||||
|
*/
|
||||||
|
public void setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -7,6 +7,7 @@ import cn.hutool.core.date.DateUtil;
|
|||||||
import cn.hutool.core.lang.Validator;
|
import cn.hutool.core.lang.Validator;
|
||||||
import cn.hutool.core.map.MapUtil;
|
import cn.hutool.core.map.MapUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.tiesheng.annotation.role.RoleAuthority;
|
import com.tiesheng.annotation.role.RoleAuthority;
|
||||||
import com.tiesheng.role.mapper.*;
|
import com.tiesheng.role.mapper.*;
|
||||||
@@ -130,7 +131,17 @@ public class CoreRoleService extends TsServiceBase<CoreRoleGroupMapper, CoreRole
|
|||||||
CoreRoleGroupRx coreRoleGroupRx = new CoreRoleGroupRx();
|
CoreRoleGroupRx coreRoleGroupRx = new CoreRoleGroupRx();
|
||||||
coreRoleGroupRx.setGroupId(roleGroup.getId());
|
coreRoleGroupRx.setGroupId(roleGroup.getId());
|
||||||
coreRoleGroupRx.setMenuId(authority.getId());
|
coreRoleGroupRx.setMenuId(authority.getId());
|
||||||
|
coreRoleGroupRx.setType("bind");
|
||||||
list.add(coreRoleGroupRx);
|
list.add(coreRoleGroupRx);
|
||||||
|
|
||||||
|
List<String> deps = JSONUtil.toList(authority.getDeps(), String.class);
|
||||||
|
for (String dep : deps) {
|
||||||
|
CoreRoleGroupRx depRx = new CoreRoleGroupRx();
|
||||||
|
depRx.setGroupId(roleGroup.getId());
|
||||||
|
depRx.setMenuId(StrUtil.format("{}_{}", authority.getService(), dep));
|
||||||
|
depRx.setType("dep");
|
||||||
|
list.add(depRx);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CollUtil.isNotEmpty(list)) {
|
if (CollUtil.isNotEmpty(list)) {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.tiesheng.role.service;
|
package com.tiesheng.role.service;
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
import com.tiesheng.annotation.role.RoleAuthority;
|
import com.tiesheng.annotation.role.RoleAuthority;
|
||||||
import com.tiesheng.role.mapper.CoreRoleAuthorityMapper;
|
import com.tiesheng.role.mapper.CoreRoleAuthorityMapper;
|
||||||
import com.tiesheng.role.mapper.CoreRoleUserMapper;
|
import com.tiesheng.role.mapper.CoreRoleUserMapper;
|
||||||
@@ -74,6 +75,7 @@ public class RoleAuthorityHandler implements TsAuthorityHandler {
|
|||||||
menuAuthority.setPlatform(menuPlatform);
|
menuAuthority.setPlatform(menuPlatform);
|
||||||
menuAuthority.setVersion(version);
|
menuAuthority.setVersion(version);
|
||||||
menuAuthority.setSource("auto");
|
menuAuthority.setSource("auto");
|
||||||
|
menuAuthority.setDeps(JSONUtil.toJsonStr(menu.deps()));
|
||||||
menuAuthority.setId(StrUtil.join("_", menuAuthority.getService(), menuAuthority.getNo()));
|
menuAuthority.setId(StrUtil.join("_", menuAuthority.getService(), menuAuthority.getNo()));
|
||||||
list.add(menuAuthority);
|
list.add(menuAuthority);
|
||||||
|
|
||||||
@@ -88,6 +90,7 @@ public class RoleAuthorityHandler implements TsAuthorityHandler {
|
|||||||
point.setParent(menuAuthority.getId());
|
point.setParent(menuAuthority.getId());
|
||||||
point.setVersion(version);
|
point.setVersion(version);
|
||||||
point.setSource("auto");
|
point.setSource("auto");
|
||||||
|
point.setDeps(JSONUtil.toJsonStr(authority.deps()));
|
||||||
point.setPlatform(StrUtil.emptyToDefault(authority.platform(), menuPlatform));
|
point.setPlatform(StrUtil.emptyToDefault(authority.platform(), menuPlatform));
|
||||||
point.setId(StrUtil.join("_", point.getService(), point.getNo()));
|
point.setId(StrUtil.join("_", point.getService(), point.getNo()));
|
||||||
list.add(point);
|
list.add(point);
|
||||||
|
|||||||
@@ -102,5 +102,10 @@ alter table core_role_authority
|
|||||||
alter table core_role_authority
|
alter table core_role_authority
|
||||||
add source varchar(10) null comment '权限来源:auto-自动生成,input-添加' after version;
|
add source varchar(10) null comment '权限来源:auto-自动生成,input-添加' after version;
|
||||||
|
|
||||||
|
alter table core_role_authority
|
||||||
|
add deps text null comment '依赖权限' after source;
|
||||||
|
|
||||||
|
alter table core_role_group_rx
|
||||||
|
add type varchar(10) null comment '关联类型:dep-依赖,bind-绑定';
|
||||||
|
|
||||||
SET FOREIGN_KEY_CHECKS = 1;
|
SET FOREIGN_KEY_CHECKS = 1;
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
<result column="platform" jdbcType="VARCHAR" property="platform" />
|
<result column="platform" jdbcType="VARCHAR" property="platform" />
|
||||||
<result column="version" jdbcType="VARCHAR" property="version" />
|
<result column="version" jdbcType="VARCHAR" property="version" />
|
||||||
<result column="source" jdbcType="VARCHAR" property="source" />
|
<result column="source" jdbcType="VARCHAR" property="source" />
|
||||||
|
<result column="deps" jdbcType="LONGVARCHAR" property="deps" />
|
||||||
<result column="ext1" jdbcType="VARCHAR" property="ext1" />
|
<result column="ext1" jdbcType="VARCHAR" property="ext1" />
|
||||||
<result column="ext2" jdbcType="VARCHAR" property="ext2" />
|
<result column="ext2" jdbcType="VARCHAR" property="ext2" />
|
||||||
<result column="ext3" jdbcType="VARCHAR" property="ext3" />
|
<result column="ext3" jdbcType="VARCHAR" property="ext3" />
|
||||||
@@ -28,12 +29,12 @@
|
|||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
<!--@mbg.generated-->
|
<!--@mbg.generated-->
|
||||||
id, create_time, update_time, is_deleted, service, `no`, `name`, sort, `level`, parent,
|
id, create_time, update_time, is_deleted, service, `no`, `name`, sort, `level`, parent,
|
||||||
remark, is_open, `type`, link, platform, version, `source`, ext1, ext2, ext3
|
remark, is_open, `type`, link, platform, version, `source`, deps, ext1, ext2, ext3
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<insert id="batchInsert">
|
<insert id="batchInsert">
|
||||||
insert into core_role_authority(id, create_time, update_time, is_deleted, service, no, name, level, parent,
|
insert into core_role_authority(id, create_time, update_time, is_deleted, service, no, name, level, parent,
|
||||||
type, platform, is_open, version, source)
|
type, platform, is_open, version, source, deps)
|
||||||
values
|
values
|
||||||
<foreach collection="list" item="item" separator=",">
|
<foreach collection="list" item="item" separator=",">
|
||||||
(#{item.id}, now(), now(), 0,
|
(#{item.id}, now(), now(), 0,
|
||||||
@@ -43,7 +44,7 @@
|
|||||||
#{item.level},
|
#{item.level},
|
||||||
#{item.parent},
|
#{item.parent},
|
||||||
#{item.type},
|
#{item.type},
|
||||||
#{item.platform}, 1, #{item.version}, #{item.source})
|
#{item.platform}, 1, #{item.version}, #{item.source}, #{item.deps})
|
||||||
</foreach>
|
</foreach>
|
||||||
|
|
||||||
on duplicate key update update_time=now(),
|
on duplicate key update update_time=now(),
|
||||||
@@ -53,6 +54,7 @@
|
|||||||
type=values(type),
|
type=values(type),
|
||||||
platform=values(platform),
|
platform=values(platform),
|
||||||
source=values(source),
|
source=values(source),
|
||||||
|
deps=values(deps),
|
||||||
version=values(version)
|
version=values(version)
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
|||||||
@@ -10,19 +10,20 @@
|
|||||||
<result column="is_deleted" jdbcType="INTEGER" property="isDeleted" />
|
<result column="is_deleted" jdbcType="INTEGER" property="isDeleted" />
|
||||||
<result column="group_id" jdbcType="VARCHAR" property="groupId" />
|
<result column="group_id" jdbcType="VARCHAR" property="groupId" />
|
||||||
<result column="menu_id" jdbcType="VARCHAR" property="menuId" />
|
<result column="menu_id" jdbcType="VARCHAR" property="menuId" />
|
||||||
|
<result column="type" jdbcType="VARCHAR" property="type" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
<!--@mbg.generated-->
|
<!--@mbg.generated-->
|
||||||
id, create_time, update_time, is_deleted, group_id, menu_id
|
id, create_time, update_time, is_deleted, group_id, menu_id, `type`
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<insert id="batchInsert">
|
<insert id="batchInsert">
|
||||||
insert into core_role_group_rx(id, create_time, update_time, is_deleted, group_id, menu_id)
|
insert into core_role_group_rx(id, create_time, update_time, is_deleted, group_id, menu_id)
|
||||||
values
|
values
|
||||||
<foreach collection="list" separator="," item="item">
|
<foreach collection="list" item="item" separator=",">
|
||||||
(uuid(), now(), now(), 0,
|
(uuid(), now(), now(), 0,
|
||||||
#{item.groupId},
|
#{item.groupId},
|
||||||
#{item.menuId})
|
#{item.menuId})
|
||||||
</foreach>
|
</foreach>
|
||||||
</insert>
|
</insert>
|
||||||
</mapper>
|
</mapper>
|
||||||
Reference in New Issue
Block a user