<?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.business.mapper.BusinessSurveyMapper">
    
    <resultMap type="BusinessSurvey" id="BusinessSurveyResult">
        <result property="id"    column="id"    />
        <result property="title"    column="title"    />
        <result property="context"    column="context"    />
        <result property="tempId"    column="temp_id"    />
        <result property="open"    column="open"    />
        <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="deleted"    column="deleted"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectBusinessSurveyVo">
        select id, title, context, temp_id, open, create_by, create_time, update_by, update_time, deleted, remark from business_survey
    </sql>

    <select id="selectBusinessSurveyList" parameterType="BusinessSurvey" resultMap="BusinessSurveyResult">
        <include refid="selectBusinessSurveyVo"/>
        <where>  
            <if test="title != null  and title != ''"> and title = #{title}</if>
            <if test="context != null  and context != ''"> and context = #{context}</if>
            <if test="tempId != null "> and temp_id = #{tempId}</if>
            <if test="open != null  and open != ''"> and open = #{open}</if>
        </where>
    </select>
    
    <select id="selectBusinessSurveyById" parameterType="Long" resultMap="BusinessSurveyResult">
        <include refid="selectBusinessSurveyVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertBusinessSurvey" parameterType="BusinessSurvey" useGeneratedKeys="true" keyProperty="id">
        insert into business_survey
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="title != null">title,</if>
            <if test="context != null">context,</if>
            <if test="tempId != null">temp_id,</if>
            <if test="open != null">open,</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="deleted != null">deleted,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="title != null">#{title},</if>
            <if test="context != null">#{context},</if>
            <if test="tempId != null">#{tempId},</if>
            <if test="open != null">#{open},</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="deleted != null">#{deleted},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateBusinessSurvey" parameterType="BusinessSurvey">
        update business_survey
        <trim prefix="SET" suffixOverrides=",">
            <if test="title != null">title = #{title},</if>
            <if test="context != null">context = #{context},</if>
            <if test="tempId != null">temp_id = #{tempId},</if>
            <if test="open != null">open = #{open},</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="deleted != null">deleted = #{deleted},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteBusinessSurveyById" parameterType="Long">
        delete from business_survey where id = #{id}
    </delete>

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