<?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.easyproject.service.mapper.operate.OperateHotQuestionsMapper">
    
    <resultMap type="OperateHotQuestions" id="OperateHotQuestionsResult">
        <result property="id"    column="id"    />
        <result property="questionContent"    column="question_content"    />
        <result property="sort"    column="sort"    />
        <result property="status"    column="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="selectOperateHotQuestionsVo">
        select id, question_content, sort, status, create_by, create_time, update_by, update_time, remark from operate_hot_questions
    </sql>

    <select id="selectOperateHotQuestionsList" parameterType="OperateHotQuestions" resultMap="OperateHotQuestionsResult">
        <include refid="selectOperateHotQuestionsVo"/>
        <where>  
            <if test="questionContent != null  and questionContent != ''"> and question_content like concat('%', #{questionContent}, '%')</if>
            <if test="status != null "> and status = #{status}</if>
            <if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''"> and create_time between #{params.beginCreateTime} and #{params.endCreateTime}</if>
        </where>
        order by sort asc
    </select>
    
    <select id="selectOperateHotQuestionsById" parameterType="Long" resultMap="OperateHotQuestionsResult">
        <include refid="selectOperateHotQuestionsVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertOperateHotQuestions" parameterType="OperateHotQuestions" useGeneratedKeys="true" keyProperty="id">
        insert into operate_hot_questions
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="questionContent != null and questionContent != ''">question_content,</if>
            <if test="sort != null">sort,</if>
            <if test="status != null">status,</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="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="questionContent != null and questionContent != ''">#{questionContent},</if>
            <if test="sort != null">#{sort},</if>
            <if test="status != null">#{status},</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="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateOperateHotQuestions" parameterType="OperateHotQuestions">
        update operate_hot_questions
        <trim prefix="SET" suffixOverrides=",">
            <if test="questionContent != null and questionContent != ''">question_content = #{questionContent},</if>
            <if test="sort != null">sort = #{sort},</if>
            <if test="status != null">status = #{status},</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="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteOperateHotQuestionsById" parameterType="Long">
        delete from operate_hot_questions where id = #{id}
    </delete>

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