文件记录-权限系统整体重构

This commit is contained in:
YBP
2026-03-11 14:25:29 +08:00
parent 5e907c9fd4
commit 6f0889a022
23 changed files with 424 additions and 567 deletions

View File

@@ -2,34 +2,9 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zt.plat.module.qms.resource.record.dal.mapper.RecordCategoryMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
<!-- <resultMap id="cateGoryAndPermissionDResMap" type="CateGoryAndPermissionDO">-->
<select id="checkUserAdminPermission" resultType="boolean">
SELECT COUNT(*) > 0
FROM t_rcd_ctgr rc
INNER JOIN t_rcd_perm rp ON rc.id = rp.src_id
WHERE rc.id = #{categoryId} and rp.perm = '管理员'
AND ( <!-- 检查用户是否有指定分类的管理员权限 -->
<!-- </resultMap>-->
( rp.tgt_id = #{userId} AND rp.tgt_tp = '用户')
OR
(rp.tgt_tp = '部门' AND rp.tgt_id IN
<foreach collection="userDepts" item="deptId" open="(" separator="," close=")">
#{deptId}
</foreach>
)
OR
(rp.tgt_tp = '角色' AND rp.tgt_id IN
<foreach collection="userRoles" item="roleId" open="(" separator="," close=")">
#{roleId}
</foreach>
)
)
</select>
</mapper>

View File

@@ -9,4 +9,31 @@
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
<!-- 分类权限查询(查询管理员,以及处管理员以外满足条件的权限)-->
<select id="selectPermissionList" resultType="com.zt.plat.module.qms.resource.record.dal.dataobject.recordpermission.RecordPermissionDO">
SELECT rp.*
FROM t_rcd_ctgr rc
INNER JOIN t_rcd_perm rp ON rc.id = rp.src_id
WHERE rp.deleted = 0 and rc.deleted = 0 AND rc.id = #{categoryId}
<if test="permission != null">
and rp.perm = #{permission} <!--'管理员'-->
</if>
AND ( <!-- 检查用户是否有指定分类的管理员权限 -->
( rp.tgt_id = #{userId} AND rp.tgt_tp = '用户')
OR
(rp.tgt_tp = '部门' AND rp.tgt_id IN
<foreach collection="userDepts" item="deptId" open="(" separator="," close=")">
#{deptId}
</foreach>
)
OR
(rp.tgt_tp = '角色' AND rp.tgt_id IN
<foreach collection="userRoles" item="roleId" open="(" separator="," close=")">
#{roleId}
</foreach>
)
)
</select>
</mapper>

View File

@@ -124,4 +124,60 @@
</where>
ORDER BY trr.CREATE_TIME ASC
</select>
<!-- 记录权限查询 SRC_ID = 记录Id 通过 记录Id 过滤查询重复数据-->
<select id="selectRecordPermissionList" resultType="com.zt.plat.module.qms.resource.record.dal.dataobject.recordrecord.RecordRecordDO">
SELECT DISTINCT trr.ID, trr.CTGR_ID AS categoryId, trr.CD AS code, trr.BSN_TP AS businessType,
trr.FORM_KY AS formKey, trr.NAME, trr.VER AS version,trr.CRNT_FLG AS currentFlag,
trr.MKE_DT AS makeDate,
trr.CNF_FLG AS confidentialFlag,
trr.CNF_LVL AS confidentialLevel,
trr.CNF_WY AS confidentialWay,
trr.CNF_KY AS confidentialKey,
trr.PMNT AS permanently,
trr.SBM_FLG AS submitFlag,
trr.RCD_STS AS recordStatus,
trr.EXPR_DT AS expirationDate,
trr.EFCT_DT AS effectiveDate,
trr.EXPR_STS AS expirationStatus,
trr.CNL_FLG AS cancelFlag,
trr.FORM_DAT AS formData,
trr.DAT_COLT_ID AS dataCollectionId,
trr.SRC_URL AS sourceUrl, apl.*
FROM T_RCD_RCD trr
LEFT JOIN T_RCD_PERM trp ON trp.SRC_ID = trr.ID
-- TODO 关联申请表
LEFT JOIN
(
SELECT applyId, documentId, flowInstanceId, businessStatus
FROM (SELECT trad.APL_ID as applyId,
trad.DOC_ID as documentId,
-- trad.TGT_ID as targetId,
tra.FLW_INSC_ID as flowInstanceId,
tra.BSN_STS as businessStatus,
ROW_NUMBER() OVER (PARTITION BY trad.APL_ID ORDER BY trad.APL_ID) AS rn
FROM T_RCD_APL_DTL trad
INNER JOIN T_RCD_APL tra ON tra.ID = trad.APL_ID) t
WHERE rn = 1
) as apl
ON apl.documentId = trr.ID
WHERE trp.SRC_TP = '记录'
AND trp.PERM = '可查看'
AND trr.CTGR_ID = #{pageReqVO.categoryId}
<if test="pageReqVO.code != null and pageReqVO.code != ''">
AND trr.CD = #{pageReqVO.code}
</if>
<if test="pageReqVO.name != null and pageReqVO.name != ''">
AND trr.NAME LIKE CONCAT('%', #{pageReqVO.name}, '%')
</if>
AND (
( trp.tgt_id = #{userId} AND trp.tgt_tp = '用户')
OR
(trp.tgt_tp = '部门' AND trp.tgt_id IN
<foreach collection="userDepts" item="deptId" open="(" separator="," close=")">
#{deptId}
</foreach>
)
)
</select>
</mapper>