|
|
@@ -0,0 +1,117 @@
|
|
|
+<?xml version="1.0" encoding="UTF-8" ?>
|
|
|
+<!DOCTYPE mapper
|
|
|
+ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
+ "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
|
+
|
|
|
+<mapper namespace="com.siwei.apply.mapper.ProjectAttachmentInfoMapper">
|
|
|
+
|
|
|
+ <!-- 结果映射 -->
|
|
|
+ <resultMap id="BaseResultMap" type="com.siwei.apply.domain.ProjectAttachmentInfo">
|
|
|
+ <id property="id" column="id"/>
|
|
|
+ <result property="projectId" column="project_id"/>
|
|
|
+ <result property="nodeId" column="node_id"/>
|
|
|
+ <result property="fileName" column="file_name"/>
|
|
|
+ <result property="filePath" column="file_path"/>
|
|
|
+ </resultMap>
|
|
|
+
|
|
|
+ <!-- 基础查询字段 -->
|
|
|
+ <sql id="Base_Column_List">
|
|
|
+ id, project_id, node_id, file_name, file_path
|
|
|
+ </sql>
|
|
|
+
|
|
|
+ <!-- 根据ID查询附件信息 -->
|
|
|
+ <select id="selectById" resultMap="BaseResultMap" parameterType="String">
|
|
|
+ SELECT
|
|
|
+ <include refid="Base_Column_List"/>
|
|
|
+ FROM t_project_attachment_info
|
|
|
+ WHERE id = #{id}
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 根据节点ID查询附件信息(只返回一条) -->
|
|
|
+ <select id="selectByNodeId" resultMap="BaseResultMap" parameterType="String">
|
|
|
+ SELECT
|
|
|
+ <include refid="Base_Column_List"/>
|
|
|
+ FROM t_project_attachment_info
|
|
|
+ WHERE node_id = #{nodeId}
|
|
|
+ LIMIT 1
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 根据项目ID查询附件信息(多条) -->
|
|
|
+ <select id="selectByProjectId" resultMap="BaseResultMap" parameterType="String">
|
|
|
+ SELECT
|
|
|
+ <include refid="Base_Column_List"/>
|
|
|
+ FROM t_project_attachment_info
|
|
|
+ WHERE project_id = #{projectId}
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 根据节点ID查询附件信息(多条) -->
|
|
|
+ <select id="selectByNodeIdList" resultMap="BaseResultMap" parameterType="List">
|
|
|
+ SELECT
|
|
|
+ <include refid="Base_Column_List"/>
|
|
|
+ FROM t_project_attachment_info
|
|
|
+ <where>
|
|
|
+ <if test="nodeIdList != null and nodeIdList.size() > 0">
|
|
|
+ AND node_id IN
|
|
|
+ <foreach collection="nodeIdList" item="id" open="(" separator="," close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 插入附件记录 -->
|
|
|
+ <insert id="insert" parameterType="com.siwei.apply.domain.ProjectAttachmentInfo">
|
|
|
+ INSERT INTO t_project_attachment_info (
|
|
|
+ id,
|
|
|
+ project_id,
|
|
|
+ node_id,
|
|
|
+ file_name,
|
|
|
+ file_path
|
|
|
+ ) VALUES (
|
|
|
+ #{id},
|
|
|
+ #{projectId},
|
|
|
+ #{nodeId},
|
|
|
+ #{fileName},
|
|
|
+ #{filePath}
|
|
|
+ )
|
|
|
+ </insert>
|
|
|
+
|
|
|
+ <!-- 根据节点ID更新附件记录(更新文件路径和名称) -->
|
|
|
+ <update id="update" parameterType="com.siwei.apply.domain.ProjectAttachmentInfo">
|
|
|
+ UPDATE t_project_attachment_info
|
|
|
+ SET file_name = #{fileName},
|
|
|
+ file_path = #{filePath}
|
|
|
+ WHERE node_id = #{nodeId}
|
|
|
+ </update>
|
|
|
+
|
|
|
+ <!-- 根据ID更新附件记录(可选字段更新) -->
|
|
|
+ <update id="updateById" parameterType="com.siwei.apply.domain.ProjectAttachmentInfo">
|
|
|
+ UPDATE t_project_attachment_info
|
|
|
+ <set>
|
|
|
+ <if test="projectId != null">project_id = #{projectId},</if>
|
|
|
+ <if test="nodeId != null">node_id = #{nodeId},</if>
|
|
|
+ <if test="fileName != null">file_name = #{fileName},</if>
|
|
|
+ <if test="filePath != null">file_path = #{filePath}</if>
|
|
|
+ </set>
|
|
|
+ WHERE id = #{id}
|
|
|
+ </update>
|
|
|
+
|
|
|
+ <!-- 根据节点ID删除附件记录 -->
|
|
|
+ <delete id="deleteByNodeId" parameterType="String">
|
|
|
+ DELETE FROM t_project_attachment_info WHERE node_id = #{nodeId}
|
|
|
+ </delete>
|
|
|
+
|
|
|
+ <!-- 根据节点ID删除且排除指定ID的记录 -->
|
|
|
+ <delete id="deleteByNodeIdAndIdNotEqual" parameterType="map">
|
|
|
+ DELETE FROM t_project_attachment_info
|
|
|
+ WHERE node_id = #{nodeId}
|
|
|
+ AND id != #{id}
|
|
|
+ </delete>
|
|
|
+
|
|
|
+ <!-- 根据项目ID删除附件记录 -->
|
|
|
+ <delete id="deleteByProjectId" parameterType="String">
|
|
|
+ DELETE FROM t_project_attachment_info WHERE project_id = #{projectId}
|
|
|
+ </delete>
|
|
|
+
|
|
|
+</mapper>
|
|
|
+
|