serv-mapper和.xml 基本增删改
This commit is contained in:
@@ -49,4 +49,170 @@
|
||||
ORDER BY create_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 根据关联ID查询关联信息 -->
|
||||
<select id="selectByRelationId" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_task_user
|
||||
WHERE id = #{relationId}
|
||||
</select>
|
||||
|
||||
<!-- 根据任务ID查询用户关联列表 -->
|
||||
<select id="selectByTaskId" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_task_user
|
||||
WHERE task_id = #{taskId}
|
||||
ORDER BY create_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 根据用户ID查询任务关联列表 -->
|
||||
<select id="selectByUserId" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_task_user
|
||||
WHERE user_id = #{userId}
|
||||
ORDER BY create_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 根据任务ID和用户ID查询关联信息 -->
|
||||
<select id="selectByTaskIdAndUserId" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_task_user
|
||||
WHERE task_id = #{taskId} AND user_id = #{userId}
|
||||
</select>
|
||||
|
||||
<!-- 根据状态查询任务用户关联列表 -->
|
||||
<select id="selectByStatus" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_task_user
|
||||
WHERE status = #{status}
|
||||
ORDER BY create_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 根据用户ID和状态查询任务关联列表 -->
|
||||
<select id="selectByUserIdAndStatus" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_task_user
|
||||
WHERE user_id = #{userId} AND status = #{status}
|
||||
ORDER BY create_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 检查任务用户关联是否存在 -->
|
||||
<select id="countByTaskIdAndUserId" resultType="int">
|
||||
SELECT COUNT(1)
|
||||
FROM tb_task_user
|
||||
WHERE task_id = #{taskId} AND user_id = #{userId}
|
||||
<if test="excludeId != null and excludeId != ''">
|
||||
AND id != #{excludeId}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 插入任务用户关联 -->
|
||||
<insert id="insertTaskUser" parameterType="org.xyzh.common.dto.study.TbTaskUser">
|
||||
INSERT INTO tb_task_user (
|
||||
id, task_id, user_id, dept_id, status, progress, complete_time,
|
||||
creator, create_time, update_time
|
||||
) VALUES (
|
||||
#{id}, #{taskID}, #{userID}, #{deptID}, #{status}, #{progress}, #{completeTime},
|
||||
#{creator}, #{createTime}, #{updateTime}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<!-- 更新任务用户关联 -->
|
||||
<update id="updateTaskUser" parameterType="org.xyzh.common.dto.study.TbTaskUser">
|
||||
UPDATE tb_task_user
|
||||
<set>
|
||||
<if test="taskID != null and taskID != ''">
|
||||
task_id = #{taskID},
|
||||
</if>
|
||||
<if test="userID != null and userID != ''">
|
||||
user_id = #{userID},
|
||||
</if>
|
||||
<if test="deptID != null and deptID != ''">
|
||||
dept_id = #{deptID},
|
||||
</if>
|
||||
<if test="status != null">
|
||||
status = #{status},
|
||||
</if>
|
||||
<if test="progress != null">
|
||||
progress = #{progress},
|
||||
</if>
|
||||
<if test="completeTime != null">
|
||||
complete_time = #{completeTime},
|
||||
</if>
|
||||
<if test="creator != null and creator != ''">
|
||||
creator = #{creator},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
create_time = #{createTime},
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
update_time = #{updateTime},
|
||||
</if>
|
||||
</set>
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<!-- 删除任务用户关联 -->
|
||||
<delete id="deleteTaskUser" parameterType="org.xyzh.common.dto.study.TbTaskUser">
|
||||
DELETE FROM tb_task_user
|
||||
WHERE id = #{id}
|
||||
</delete>
|
||||
|
||||
<!-- 批量插入任务用户关联 -->
|
||||
<insert id="batchInsertTaskUsers" parameterType="java.util.List">
|
||||
INSERT INTO tb_task_user (
|
||||
id, task_id, user_id, dept_id, status, progress, complete_time,
|
||||
creator, create_time, update_time
|
||||
) VALUES
|
||||
<foreach collection="taskUserList" item="item" separator=",">
|
||||
(
|
||||
#{item.id}, #{item.taskID}, #{item.userID}, #{item.deptID}, #{item.status},
|
||||
#{item.progress}, #{item.completeTime}, #{item.creator}, #{item.createTime}, #{item.updateTime}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<!-- 批量删除任务用户关联 -->
|
||||
<delete id="batchDeleteTaskUsers">
|
||||
DELETE FROM tb_task_user
|
||||
WHERE id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<!-- 根据任务ID批量删除用户关联 -->
|
||||
<delete id="deleteByTaskId">
|
||||
DELETE FROM tb_task_user
|
||||
WHERE task_id = #{taskId}
|
||||
</delete>
|
||||
|
||||
<!-- 根据用户ID批量删除任务关联 -->
|
||||
<delete id="deleteByUserId">
|
||||
DELETE FROM tb_task_user
|
||||
WHERE user_id = #{userId}
|
||||
</delete>
|
||||
|
||||
<!-- 分页查询任务用户关联 -->
|
||||
<select id="selectTaskUsersPage" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_task_user
|
||||
<include refid="Where_Clause" />
|
||||
ORDER BY create_time DESC
|
||||
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.pageNumber}
|
||||
</select>
|
||||
|
||||
<!-- 统计任务用户关联总数 -->
|
||||
<select id="countTaskUsers" resultType="long">
|
||||
SELECT COUNT(1)
|
||||
FROM tb_task_user
|
||||
<include refid="Where_Clause" />
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user