serv\web- 日志
This commit is contained in:
@@ -90,6 +90,37 @@
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<!-- 权限过滤条件(基于dept_path的高效继承) -->
|
||||
<sql id="Permission_Filter">
|
||||
INNER JOIN tb_resource_permission rp ON ct.task_id = rp.resource_id
|
||||
AND rp.resource_type = 7
|
||||
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>
|
||||
|
||||
<!-- 插入任务 -->
|
||||
<insert id="insertTask">
|
||||
INSERT INTO tb_crontab_task
|
||||
@@ -168,27 +199,69 @@
|
||||
|
||||
<!-- 根据过滤条件查询任务列表 -->
|
||||
<select id="selectTaskList" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_crontab_task
|
||||
<include refid="Filter_Where_Clause" />
|
||||
ORDER BY create_time DESC
|
||||
SELECT DISTINCT ct.*
|
||||
FROM tb_crontab_task ct
|
||||
<include refid="Permission_Filter" />
|
||||
WHERE ct.deleted = 0
|
||||
<if test="filter != null">
|
||||
<if test="filter.ID != null and filter.ID != ''">
|
||||
AND ct.id = #{filter.ID}
|
||||
</if>
|
||||
<if test="filter.taskId != null and filter.taskId != ''">
|
||||
AND ct.task_id = #{filter.taskId}
|
||||
</if>
|
||||
<if test="filter.taskName != null and filter.taskName != ''">
|
||||
AND ct.task_name LIKE CONCAT('%', #{filter.taskName}, '%')
|
||||
</if>
|
||||
<if test="filter.taskGroup != null and filter.taskGroup != ''">
|
||||
AND ct.task_group = #{filter.taskGroup}
|
||||
</if>
|
||||
<if test="filter.status != null">
|
||||
AND ct.status = #{filter.status}
|
||||
</if>
|
||||
</if>
|
||||
ORDER BY ct.create_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 分页查询任务列表 -->
|
||||
<select id="selectTaskPage" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_crontab_task
|
||||
<include refid="Filter_Where_Clause" />
|
||||
ORDER BY create_time DESC
|
||||
SELECT DISTINCT ct.*
|
||||
FROM tb_crontab_task ct
|
||||
<include refid="Permission_Filter" />
|
||||
WHERE ct.deleted = 0
|
||||
<if test="filter != null">
|
||||
<if test="filter.ID != null and filter.ID != ''">
|
||||
AND ct.id = #{filter.ID}
|
||||
</if>
|
||||
<if test="filter.taskId != null and filter.taskId != ''">
|
||||
AND ct.task_id = #{filter.taskId}
|
||||
</if>
|
||||
<if test="filter.taskName != null and filter.taskName != ''">
|
||||
AND ct.task_name LIKE CONCAT('%', #{filter.taskName}, '%')
|
||||
</if>
|
||||
<if test="filter.taskGroup != null and filter.taskGroup != ''">
|
||||
AND ct.task_group = #{filter.taskGroup}
|
||||
</if>
|
||||
<if test="filter.status != null">
|
||||
AND ct.status = #{filter.status}
|
||||
</if>
|
||||
</if>
|
||||
ORDER BY ct.create_time DESC
|
||||
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.offset}
|
||||
</select>
|
||||
|
||||
<!-- 查询所有运行中的任务 -->
|
||||
<!-- 查询所有运行中的任务(包含权限过滤) -->
|
||||
<select id="selectRunningTasks" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
SELECT DISTINCT ct.*
|
||||
FROM tb_crontab_task ct
|
||||
<include refid="Permission_Filter" />
|
||||
WHERE ct.status = 1 AND ct.deleted = 0
|
||||
ORDER BY ct.create_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 查询所有运行中的任务(系统级,不含权限过滤,用于系统初始化) -->
|
||||
<select id="selectAllRunningTasks" resultMap="BaseResultMap">
|
||||
SELECT *
|
||||
FROM tb_crontab_task
|
||||
WHERE status = 1 AND deleted = 0
|
||||
ORDER BY create_time DESC
|
||||
@@ -214,9 +287,27 @@
|
||||
</select>
|
||||
|
||||
<!-- countSelectTask -->
|
||||
|
||||
<select id="countSelectTask">
|
||||
SELECT COUNT(1) FROM tb_crontab_task
|
||||
<include refid="Filter_Where_Clause" />
|
||||
<select id="countSelectTask" resultType="int">
|
||||
SELECT COUNT(DISTINCT ct.id)
|
||||
FROM tb_crontab_task ct
|
||||
<include refid="Permission_Filter" />
|
||||
WHERE ct.deleted = 0
|
||||
<if test="filter != null">
|
||||
<if test="filter.ID != null and filter.ID != ''">
|
||||
AND ct.id = #{filter.ID}
|
||||
</if>
|
||||
<if test="filter.taskId != null and filter.taskId != ''">
|
||||
AND ct.task_id = #{filter.taskId}
|
||||
</if>
|
||||
<if test="filter.taskName != null and filter.taskName != ''">
|
||||
AND ct.task_name LIKE CONCAT('%', #{filter.taskName}, '%')
|
||||
</if>
|
||||
<if test="filter.taskGroup != null and filter.taskGroup != ''">
|
||||
AND ct.task_group = #{filter.taskGroup}
|
||||
</if>
|
||||
<if test="filter.status != null">
|
||||
AND ct.status = #{filter.status}
|
||||
</if>
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user