<?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.postCheck.mapper.PostHighlightsMapper">

    <resultMap type="PostHighlights" id="PostHighlightsResult">
        <result property="id"    column="id"    />
        <result property="highlightsType"    column="highlights_type"    />
        <result property="highlights"    column="highlights"    />
        <result property="remark"    column="remark"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createTime"    column="create_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="createUserId"    column="create_user_id"    />
        <result property="problemAttribute"    column="problem_attribute"    />
    </resultMap>

    <sql id="selectPostHighlightsVo">
        select id, highlights_type, problem_attribute,highlights, remark, del_flag, create_time, create_by, update_time, update_by, create_user_id from post_highlights
    </sql>

    <select id="selectPostHighlightsList" parameterType="PostHighlights" resultMap="PostHighlightsResult">
        <include refid="selectPostHighlightsVo"/>
        <where>
            <if test="highlightsType != null "> and highlights_type = #{highlightsType}</if>
            <if test="problemAttribute != null"> and problem_attribute = #{problemAttribute}</if>
            <if test="highlights != null  and highlights != ''"> and highlights = #{highlights}</if>
            <if test="createUserId != null "> and create_user_id = #{createUserId}</if>
        </where>
    </select>

    <select id="selectPostHighlightsById" parameterType="Long" resultMap="PostHighlightsResult">
        <include refid="selectPostHighlightsVo"/>
        where id = #{id}
    </select>

    <insert id="insertPostHighlights" parameterType="PostHighlights">
        insert into post_highlights
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="highlightsType != null">highlights_type,</if>
            <if test="highlights != null and highlights != ''">highlights,</if>
            <if test="remark != null">remark,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createBy != null and createBy != ''">create_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="updateBy != null and updateBy != ''">update_by,</if>
            <if test="createUserId != null">create_user_id,</if>
            <if test="problemAttribute != null">problem_attribute,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="highlightsType != null">#{highlightsType},</if>
            <if test="highlights != null and highlights != ''">#{highlights},</if>
            <if test="remark != null">#{remark},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null and createBy != ''">#{createBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="updateBy != null and updateBy != ''">#{updateBy},</if>
            <if test="createUserId != null">#{createUserId},</if>
            <if test="problemAttribute != null">#{problemAttribute},</if>
        </trim>
    </insert>

    <update id="updatePostHighlights" parameterType="PostHighlights">
        update post_highlights
        <trim prefix="SET" suffixOverrides=",">
            <if test="highlightsType != null">highlights_type = #{highlightsType},</if>
            <if test="highlights != null and highlights != ''">highlights = #{highlights},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <!--
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
            -->
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
            <if test="createUserId != null">create_user_id = #{createUserId},</if>
            <if test="problemAttribute != null">problem_attribute = #{problemAttribute},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deletePostHighlightsById" parameterType="Long">
        delete from post_highlights where id = #{id}
    </delete>

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