<?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.playlet.system.mapper.PlayletPublicDetailMapper">

    <resultMap type="PlayletPublicDetail" id="PlayletPublicDetailResult">
        <result property="id"    column="id"    />
        <result property="publicId"    column="public_id"    />
        <result property="itemId"    column="item_id"    />
        <result property="detailTag"    column="detail_tag"    />
        <result property="readCount"    column="read_count"    />
        <result property="transmitCount"    column="transmit_count"    />
        <result property="content"    column="content"    />
        <result property="address"    column="address"    />
        <result property="starCount"    column="star_count"    />
        <result property="type" column="type" />
        <result property="itemOne"    column="item_one"    />
        <result property="itemTwo"    column="item_two"    />
        <result property="itemThree"    column="item_three"    />
        <result property="itemFour"    column="item_four"    />
        <result property="itemFive"    column="item_five"    />
        <result property="itemSix"    column="item_six"    />
        <result property="itemSeven"    column="item_seven"    />
        <result property="itemEight"    column="item_eight"    />
        <result property="itemNine"    column="item_nine"    />
        <result property="itemTen"    column="item_ten"    />
        <result property="title"    column="title"    />
        <result property="authorAlias" column="author_alias"/>
        <result property="imgUrl"    column="img_url"    />
        <result property="headUrl"    column="head_url"    />
        <result property="topStatus"    column="top_status"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectPlayletPublicDetailVo">
        select id, public_id, item_id, head_url, read_count,star_count,
               item_one,item_two,item_three,item_four,item_five,top_status,
               item_six,item_seven,item_eight,item_nine,item_ten,
               title,type,author_alias,img_url, content, create_by, create_time,
               update_by, update_time, detail_tag, remark, address, transmit_count from playlet_public_detail
    </sql>

    <sql id="selectPlayletPublicDetailVoNoContent">
        select id, public_id, item_id, head_url, read_count,star_count,
               item_one,item_two,item_three,item_four,item_five,top_status,
               item_six,item_seven,item_eight,item_nine,item_ten,
               title,type,author_alias,img_url, create_by, create_time,
               update_by, update_time, detail_tag, remark, address, transmit_count from playlet_public_detail
    </sql>

    <select id="selectPlayletPublicDetailList" parameterType="PlayletPublicDetail" resultMap="PlayletPublicDetailResult">
        <include refid="selectPlayletPublicDetailVoNoContent"/>
        <where>
            <if test="publicId != null "> and public_id = #{publicId}</if>
            <if test="publicIds != null and publicIds.size() > 0">
                and public_id in
                <foreach item="item" collection="publicIds" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="type != null "> and type = #{type}</if>
            <if test="readCount != null "> and read_count = #{readCount}</if>
            <if test="topStatus != null "> and top_status = #{topStatus}</if>
            <if test="content != null  and content != ''"> and content = #{content}</if>
        </where>
        order by create_time desc
    </select>

    <select id="selectPlayletPublicDetailById" parameterType="Long" resultMap="PlayletPublicDetailResult">
        <include refid="selectPlayletPublicDetailVo"/>
        where id = #{id}
    </select>

    <insert id="insertPlayletPublicDetail" parameterType="PlayletPublicDetail" useGeneratedKeys="true" keyProperty="id">
        insert into playlet_public_detail
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="publicId != null">public_id,</if>
            <if test="itemId != null">item_id,</if>
            <if test="readCount != null">read_count,</if>
            <if test="transmitCount != null">transmit_count,</if>
            <if test="content != null">content,</if>
            <if test="address != null">address,</if>
            <if test="title != null">title,</if>
            <if test="type != null">type,</if>
            <if test="authorAlias != null">author_alias,</if>
            <if test="starCount != null">star_count,</if>
            <if test="itemOne != null">item_one,</if>
            <if test="itemTwo != null">item_two,</if>
            <if test="itemThree != null">item_three,</if>
            <if test="itemFour != null">item_four,</if>
            <if test="itemFive != null">item_five,</if>
            <if test="itemSix != null">item_six,</if>
            <if test="itemSeven != null">item_seven,</if>
            <if test="itemEight != null">item_eight,</if>
            <if test="itemNine != null">item_nine,</if>
            <if test="itemTen != null">item_ten,</if>
            <if test="imgUrl != null">img_url,</if>
            <if test="headUrl != null">head_url,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="detailTag != null">detail_tag,</if>
            <if test="remark != null">remark,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="publicId != null">#{publicId},</if>
            <if test="itemId != null">#{itemId},</if>
            <if test="readCount != null">#{readCount},</if>
            <if test="transmitCount != null">#{transmitCount},</if>
            <if test="content != null">#{content},</if>
            <if test="address != null">#{address},</if>
            <if test="title != null">#{title},</if>
            <if test="type != null">#{type},</if>
            <if test="authorAlias != null">#{authorAlias},</if>
            <if test="starCount != null">#{starCount},</if>
            <if test="itemOne != null">#{itemOne},</if>
            <if test="itemTwo != null">#{itemTwo},</if>
            <if test="itemThree != null">#{itemThree},</if>
            <if test="itemFour != null">#{itemFour},</if>
            <if test="itemFive != null">#{itemFive},</if>
            <if test="itemSix != null">#{itemSix},</if>
            <if test="itemSeven != null">#{itemSeven},</if>
            <if test="itemEight != null">#{itemEight},</if>
            <if test="itemNine != null">#{itemNine},</if>
            <if test="itemTen != null">#{itemTen},</if>
            <if test="imgUrl != null">#{imgUrl},</if>
            <if test="headUrl != null">#{headUrl},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="detailTag != null">#{detailTag},</if>
            <if test="remark != null">#{remark},</if>
        </trim>
    </insert>

    <update id="updatePlayletPublicDetail" parameterType="PlayletPublicDetail">
        update playlet_public_detail
        <trim prefix="SET" suffixOverrides=",">
            <if test="publicId != null">public_id = #{publicId},</if>
            <if test="itemId != null">#{itemId},</if>
            <if test="readCount != null">read_count = #{readCount},</if>
            <if test="transmitCount != null">transmit_count = #{transmitCount},</if>
            <if test="content != null">content = #{content},</if>
            <if test="address != null">address = #{address},</if>
            <if test="title != null">title = #{title},</if>
            <if test="type != null">type = #{type},</if>
            <if test="authorAlias != null">author_alias = #{authorAlias},</if>
            <if test="starCount != null">star_count = #{starCount},</if>
            <if test="itemOne != null">item_one = #{itemOne},</if>
            <if test="itemTwo != null">item_two = #{itemTwo},</if>
            <if test="itemThree != null">item_three = #{itemThree},</if>
            <if test="itemFour != null">item_four = #{itemFour},</if>
            <if test="itemFive != null">item_five = #{itemFive},</if>
            <if test="itemSix != null">item_six = #{itemSix},</if>
            <if test="itemSeven != null">item_seven = #{itemSeven},</if>
            <if test="itemEight != null">item_eight = #{itemEight},</if>
            <if test="itemNine != null">item_nine = #{itemNine},</if>
            <if test="itemTen != null">item_ten = #{itemTen},</if>
            <if test="imgUrl != null">img_url = #{imgUrl},</if>
            <if test="headUrl != null">head_url = #{headUrl},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="detailTag != null">detail_tag = #{detailTag},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deletePlayletPublicDetailById" parameterType="Long">
        delete from playlet_public_detail where id = #{id}
    </delete>

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

</mapper>