InformationSharingMapper.xml 3.96 KB
<?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.trash.information_sharing.mapper.InformationSharingMapper">
    
    <resultMap type="InformationSharing" id="InformationSharingResult">
        <result property="id"    column="id"    />
        <result property="dataHeader"    column="data_header"    />
        <result property="retrieveDepartment"    column="retrieve_department"    />
        <result property="retrieveTime"    column="retrieve_time"    />
        <result property="retrieveContent"    column="retrieve_content"    />
        <result property="attachmentLink"    column="attachment_link"    />
        <result property="informationLink"    column="information_link"    />
    </resultMap>

    <sql id="selectInformationSharingVo">
        select id, data_header, retrieve_department, retrieve_time, retrieve_content, attachment_link, information_link from information_sharing
    </sql>

    <select id="selectInformationSharingList" parameterType="InformationSharing" resultMap="InformationSharingResult">
        <include refid="selectInformationSharingVo"/>
        <where>  
            <if test="dataHeader != null  and dataHeader != ''"> and data_header like concat('%', #{dataHeader}, '%')</if>
            <if test="retrieveDepartment != null  and retrieveDepartment != ''"> and retrieve_department like concat('%', #{retrieveDepartment}, '%')</if>
        </where>
    </select>
    
    <select id="selectInformationSharingById" parameterType="Long" resultMap="InformationSharingResult">
        <include refid="selectInformationSharingVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertInformationSharing" parameterType="InformationSharing" useGeneratedKeys="true" keyProperty="id">
        insert into information_sharing
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="dataHeader != null">data_header,</if>
            <if test="retrieveDepartment != null">retrieve_department,</if>
            <if test="retrieveTime != null">retrieve_time,</if>
            <if test="retrieveContent != null">retrieve_content,</if>
            <if test="attachmentLink != null">attachment_link,</if>
            <if test="informationLink != null">information_link,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="dataHeader != null">#{dataHeader},</if>
            <if test="retrieveDepartment != null">#{retrieveDepartment},</if>
            <if test="retrieveTime != null">#{retrieveTime},</if>
            <if test="retrieveContent != null">#{retrieveContent},</if>
            <if test="attachmentLink != null">#{attachmentLink},</if>
            <if test="informationLink != null">#{informationLink},</if>
         </trim>
    </insert>

    <update id="updateInformationSharing" parameterType="InformationSharing">
        update information_sharing
        <trim prefix="SET" suffixOverrides=",">
            <if test="dataHeader != null">data_header = #{dataHeader},</if>
            <if test="retrieveDepartment != null">retrieve_department = #{retrieveDepartment},</if>
            <if test="retrieveTime != null">retrieve_time = #{retrieveTime},</if>
            <if test="retrieveContent != null">retrieve_content = #{retrieveContent},</if>
            <if test="attachmentLink != null">attachment_link = #{attachmentLink},</if>
            <if test="informationLink != null">information_link = #{informationLink},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteInformationSharingById" parameterType="Long">
        delete from information_sharing where id = #{id}
    </delete>

    <delete id="deleteInformationSharingByIds" parameterType="String">
        delete from information_sharing where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    
</mapper>