<?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.party.mapper.PartyBuildingNewsMapper">
    
    <resultMap type="PartyBuildingNews" id="PartyBuildingNewsResult">
        <result property="id"    column="id"    />
        <result property="title"    column="title"    />
        <result property="pictureUrl"    column="picture_url"    />
        <result property="content"    column="content"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateBy"    column="update_by"    />
    </resultMap>

    <sql id="selectPartyBuildingNewsVo">
        select id, title, picture_url, content, create_time, update_time, create_by, update_by from party_building_news
    </sql>

    <select id="selectPartyBuildingNewsList" parameterType="com.ruoyi.party.domain.vo.PartyBuildingNewsVO" resultMap="PartyBuildingNewsResult">
        <include refid="selectPartyBuildingNewsVo"/>
        <where>  
            <if test="title != null  and title != ''"> and title like  concat('%', #{title}, '%')</if>
            <if test="pictureUrl != null  and pictureUrl != ''"> and picture_url = #{pictureUrl}</if>
            <if test="content != null  and content != ''"> and content = #{content}</if>
            <if test="publishTime != null  and publishTime != ''"> and create_time like concat('%',#{publishTime},'%')</if>
        </where>
    </select>
    
    <select id="selectPartyBuildingNewsById" parameterType="Long" resultMap="PartyBuildingNewsResult">
        <include refid="selectPartyBuildingNewsVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertPartyBuildingNews" parameterType="PartyBuildingNews">
        insert into party_building_news
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="title != null">title,</if>
            <if test="pictureUrl != null">picture_url,</if>
            <if test="content != null">content,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateBy != null">update_by,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="title != null">#{title},</if>
            <if test="pictureUrl != null">#{pictureUrl},</if>
            <if test="content != null">#{content},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateBy != null">#{updateBy},</if>
         </trim>
    </insert>

    <update id="updatePartyBuildingNews" parameterType="PartyBuildingNews">
        update party_building_news
        <trim prefix="SET" suffixOverrides=",">
            <if test="title != null">title = #{title},</if>
            <if test="pictureUrl != null">picture_url = #{pictureUrl},</if>
            <if test="content != null">content = #{content},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deletePartyBuildingNewsById" parameterType="Long">
        delete from party_building_news where id = #{id}
    </delete>

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