<?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.ruoyi.system.mapper.PostCollectionsMapper">

    <resultMap type="PostCollections" id="PostCollectionsResult">
        <result property="id"    column="id"    />
        <result property="systemId"    column="system_id"    />
        <result property="issuerId"    column="issuer_id"    />
        <result property="name"    column="name"    />
        <result property="startTime"    column="start_time"    />
        <result property="endTime"    column="end_time"    />
        <result property="status"    column="status"    />
        <result property="collectionsNumber"    column="collections_number"    />
        <result property="collectionsStory"    column="collections_story"    />
        <result property="image"    column="image"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="createUser"    column="create_user"    />
        <result property="updateUser"    column="update_user"    />
        <result property="delFlag"    column="del_flag"    />
    </resultMap>

    <sql id="selectPostCollectionsVo">
        select id, system_id, issuer_id, name, start_time, end_time, status, collections_number, collections_story, image, create_time, update_time, create_user, update_user, del_flag from post_collections
    </sql>

    <select id="selectPostCollectionsList" parameterType="PostCollections" resultMap="PostCollectionsResult">
        <include refid="selectPostCollectionsVo"/>
        <where>
            <if test="systemId != null "> and system_id = #{systemId}</if>
            <if test="issuerId != null "> and issuer_id = #{issuerId}</if>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="startTime != null "> and start_time = #{startTime}</if>
            <if test="endTime != null "> and end_time = #{endTime}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
            <if test="collectionsNumber != null "> and collections_number = #{collectionsNumber}</if>
            <if test="collectionsStory != null  and collectionsStory != ''"> and collections_story = #{collectionsStory}</if>
            <if test="image != null  and image != ''"> and image = #{image}</if>
            <if test="createUser != null  and createUser != ''"> and create_user = #{createUser}</if>
            <if test="updateUser != null  and updateUser != ''"> and update_user = #{updateUser}</if>
        </where>
    </select>

    <select id="selectPostCollectionsById" parameterType="Long" resultMap="PostCollectionsResult">
        <include refid="selectPostCollectionsVo"/>
        where id = #{id}
    </select>

    <insert id="insertPostCollections" parameterType="PostCollections" useGeneratedKeys="true" keyProperty="id">
        insert into post_collections
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="systemId != null">system_id,</if>
            <if test="issuerId != null">issuer_id,</if>
            <if test="name != null">name,</if>
            <if test="startTime != null">start_time,</if>
            <if test="endTime != null">end_time,</if>
            <if test="status != null">status,</if>
            <if test="collectionsNumber != null">collections_number,</if>
            <if test="collectionsStory != null">collections_story,</if>
            <if test="image != null">image,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="createUser != null">create_user,</if>
            <if test="updateUser != null">update_user,</if>
            <if test="delFlag != null">del_flag,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="systemId != null">#{systemId},</if>
            <if test="issuerId != null">#{issuerId},</if>
            <if test="name != null">#{name},</if>
            <if test="startTime != null">#{startTime},</if>
            <if test="endTime != null">#{endTime},</if>
            <if test="status != null">#{status},</if>
            <if test="collectionsNumber != null">#{collectionsNumber},</if>
            <if test="collectionsStory != null">#{collectionsStory},</if>
            <if test="image != null">#{image},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="createUser != null">#{createUser},</if>
            <if test="updateUser != null">#{updateUser},</if>
            <if test="delFlag != null">#{delFlag},</if>
        </trim>
    </insert>

    <update id="updatePostCollections" parameterType="PostCollections">
        update post_collections
        <trim prefix="SET" suffixOverrides=",">
            <if test="systemId != null">system_id = #{systemId},</if>
            <if test="issuerId != null">issuer_id = #{issuerId},</if>
            <if test="name != null">name = #{name},</if>
            <if test="startTime != null">start_time = #{startTime},</if>
            <if test="endTime != null">end_time = #{endTime},</if>
            <if test="status != null">status = #{status},</if>
            <if test="collectionsNumber != null">collections_number = #{collectionsNumber},</if>
            <if test="collectionsStory != null">collections_story = #{collectionsStory},</if>
            <if test="image != null">image = #{image},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="createUser != null">create_user = #{createUser},</if>
            <if test="updateUser != null">update_user = #{updateUser},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deletePostCollectionsById" parameterType="Long">
        delete from post_collections where id = #{id}
    </delete>

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