serv\web- 多租户修改
This commit is contained in:
@@ -69,21 +69,83 @@
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<!-- selectBanners -->
|
||||
<!-- 权限过滤条件(基于dept_path的高效继承) -->
|
||||
<sql id="Permission_Filter">
|
||||
INNER JOIN tb_resource_permission rp ON b.banner_id = rp.resource_id
|
||||
AND rp.resource_type = 8
|
||||
AND rp.deleted = 0
|
||||
AND rp.can_read = 1
|
||||
AND (
|
||||
-- 全局权限:所有用户可访问
|
||||
(rp.dept_id IS NULL AND rp.role_id IS NULL)
|
||||
<if test="userDeptRoles != null and userDeptRoles.size() > 0">
|
||||
OR EXISTS (
|
||||
SELECT 1
|
||||
FROM (
|
||||
<foreach collection="userDeptRoles" item="udr" separator=" UNION ALL ">
|
||||
SELECT #{udr.deptID} AS dept_id, #{udr.deptPath} AS dept_path, #{udr.roleID} AS role_id
|
||||
</foreach>
|
||||
) user_roles
|
||||
LEFT JOIN tb_sys_dept perm_dept ON perm_dept.dept_id = rp.dept_id AND perm_dept.deleted = 0
|
||||
WHERE
|
||||
-- 部门级权限:当前部门或父部门(通过dept_path判断继承关系)
|
||||
(rp.role_id IS NULL AND rp.dept_id IS NOT NULL
|
||||
AND user_roles.dept_path LIKE CONCAT(perm_dept.dept_path, '%'))
|
||||
-- 角色级权限:跨部门的角色权限
|
||||
OR (rp.dept_id IS NULL AND rp.role_id = user_roles.role_id)
|
||||
-- 精确权限:特定部门的特定角色
|
||||
OR (rp.dept_id = user_roles.dept_id AND rp.role_id = user_roles.role_id)
|
||||
)
|
||||
</if>
|
||||
)
|
||||
</sql>
|
||||
|
||||
<!-- selectBanners - 添加权限过滤 -->
|
||||
<select id="selectBanners" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM tb_banner
|
||||
<include refid="Where_Clause"/>
|
||||
ORDER BY order_num ASC, create_time DESC
|
||||
SELECT DISTINCT b.*
|
||||
FROM tb_banner b
|
||||
<include refid="Permission_Filter"/>
|
||||
WHERE b.deleted = 0
|
||||
<if test="filter.bannerID != null and filter.bannerID != ''">
|
||||
AND b.banner_id = #{filter.bannerID}
|
||||
</if>
|
||||
<if test="filter.title != null and filter.title != ''">
|
||||
AND b.title LIKE CONCAT('%', #{filter.title}, '%')
|
||||
</if>
|
||||
<if test="filter.linkType != null">
|
||||
AND b.link_type = #{filter.linkType}
|
||||
</if>
|
||||
<if test="filter.linkID != null and filter.linkID != ''">
|
||||
AND b.link_id = #{filter.linkID}
|
||||
</if>
|
||||
<if test="filter.status != null">
|
||||
AND b.status = #{filter.status}
|
||||
</if>
|
||||
ORDER BY b.order_num ASC, b.create_time DESC
|
||||
</select>
|
||||
|
||||
<!-- selectBannersLimit - 添加权限过滤 -->
|
||||
<select id="selectBannersLimit" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM tb_banner
|
||||
<include refid="Filter_Clause"/>
|
||||
ORDER BY order_num ASC, create_time DESC
|
||||
SELECT DISTINCT b.*
|
||||
FROM tb_banner b
|
||||
<include refid="Permission_Filter"/>
|
||||
WHERE b.deleted = 0
|
||||
<if test="filter.bannerID != null and filter.bannerID != ''">
|
||||
AND b.banner_id = #{filter.bannerID}
|
||||
</if>
|
||||
<if test="filter.title != null and filter.title != ''">
|
||||
AND b.title LIKE CONCAT('%', #{filter.title}, '%')
|
||||
</if>
|
||||
<if test="filter.linkType != null">
|
||||
AND b.link_type = #{filter.linkType}
|
||||
</if>
|
||||
<if test="filter.linkID != null and filter.linkID != ''">
|
||||
AND b.link_id = #{filter.linkID}
|
||||
</if>
|
||||
<if test="filter.status != null">
|
||||
AND b.status = #{filter.status}
|
||||
</if>
|
||||
ORDER BY b.order_num ASC, b.create_time DESC
|
||||
LIMIT #{limit}
|
||||
</select>
|
||||
|
||||
@@ -218,20 +280,56 @@
|
||||
</delete>
|
||||
|
||||
<!-- 分页查询Banner -->
|
||||
<!-- selectBannersPage - 添加权限过滤 -->
|
||||
<select id="selectBannersPage" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_banner
|
||||
<include refid="Filter_Clause" />
|
||||
ORDER BY order_num ASC, create_time DESC
|
||||
SELECT DISTINCT b.*
|
||||
FROM tb_banner b
|
||||
<include refid="Permission_Filter"/>
|
||||
WHERE b.deleted = 0
|
||||
<if test="filter != null">
|
||||
<if test="filter.bannerID != null and filter.bannerID != ''">
|
||||
AND b.banner_id = #{filter.bannerID}
|
||||
</if>
|
||||
<if test="filter.title != null and filter.title != ''">
|
||||
AND b.title LIKE CONCAT('%', #{filter.title}, '%')
|
||||
</if>
|
||||
<if test="filter.linkType != null">
|
||||
AND b.link_type = #{filter.linkType}
|
||||
</if>
|
||||
<if test="filter.linkID != null and filter.linkID != ''">
|
||||
AND b.link_id = #{filter.linkID}
|
||||
</if>
|
||||
<if test="filter.status != null">
|
||||
AND b.status = #{filter.status}
|
||||
</if>
|
||||
</if>
|
||||
ORDER BY b.order_num ASC, b.create_time DESC
|
||||
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.offset}
|
||||
</select>
|
||||
|
||||
<!-- 统计Banner总数 -->
|
||||
<!-- 统计Banner总数 - 添加权限过滤 -->
|
||||
<select id="countBanners" resultType="long">
|
||||
SELECT COUNT(1)
|
||||
FROM tb_banner
|
||||
<include refid="Filter_Clause" />
|
||||
SELECT COUNT(DISTINCT b.id)
|
||||
FROM tb_banner b
|
||||
<include refid="Permission_Filter"/>
|
||||
WHERE b.deleted = 0
|
||||
<if test="filter != null">
|
||||
<if test="filter.bannerID != null and filter.bannerID != ''">
|
||||
AND b.banner_id = #{filter.bannerID}
|
||||
</if>
|
||||
<if test="filter.title != null and filter.title != ''">
|
||||
AND b.title LIKE CONCAT('%', #{filter.title}, '%')
|
||||
</if>
|
||||
<if test="filter.linkType != null">
|
||||
AND b.link_type = #{filter.linkType}
|
||||
</if>
|
||||
<if test="filter.linkID != null and filter.linkID != ''">
|
||||
AND b.link_id = #{filter.linkID}
|
||||
</if>
|
||||
<if test="filter.status != null">
|
||||
AND b.status = #{filter.status}
|
||||
</if>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user