<?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.BusinessTemplatePropMapper">
    
    <resultMap type="BusinessTemplateProp" id="BusinessTemplatePropResult">
        <result property="id"    column="id"    />
        <result property="title"    column="title"    />
        <result property="compType"    column="comp_type"    />
        <result property="fieldName"    column="field_name"    />
        <result property="placPrompt"    column="plac_prompt"    />
        <result property="defaultValue"    column="default_value"    />
        <result property="optionalValue"    column="optional_value"    />
        <result property="open"    column="open"    />
        <result property="tempId"    column="temp_id"    />
        <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="selectBusinessTemplatePropVo">
        select id, title, comp_type, field_name, plac_prompt, default_value, optional_value, open, temp_id, create_by, create_time, update_by, update_time, deleted, remark from business_template_prop
    </sql>

    <select id="selectBusinessTemplatePropList" parameterType="BusinessTemplateProp" resultMap="BusinessTemplatePropResult">
        <include refid="selectBusinessTemplatePropVo"/>
        <where>  
            <if test="title != null  and title != ''"> and title = #{title}</if>
            <if test="compType != null  and compType != ''"> and comp_type = #{compType}</if>
            <if test="fieldName != null  and fieldName != ''"> and field_name like concat('%', #{fieldName}, '%')</if>
            <if test="placPrompt != null  and placPrompt != ''"> and plac_prompt = #{placPrompt}</if>
            <if test="defaultValue != null  and defaultValue != ''"> and default_value = #{defaultValue}</if>
            <if test="optionalValue != null  and optionalValue != ''"> and optional_value = #{optionalValue}</if>
            <if test="open != null  and open != ''"> and open = #{open}</if>
            <if test="tempId != null "> and temp_id = #{tempId}</if>
        </where>
    </select>
    
    <select id="selectBusinessTemplatePropById" parameterType="Long" resultMap="BusinessTemplatePropResult">
        <include refid="selectBusinessTemplatePropVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertBusinessTemplateProp" parameterType="BusinessTemplateProp" useGeneratedKeys="true" keyProperty="id">
        insert into business_template_prop
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="title != null and title != ''">title,</if>
            <if test="compType != null and compType != ''">comp_type,</if>
            <if test="fieldName != null and fieldName != ''">field_name,</if>
            <if test="placPrompt != null">plac_prompt,</if>
            <if test="defaultValue != null">default_value,</if>
            <if test="optionalValue != null">optional_value,</if>
            <if test="open != null">open,</if>
            <if test="tempId != null">temp_id,</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 and title != ''">#{title},</if>
            <if test="compType != null and compType != ''">#{compType},</if>
            <if test="fieldName != null and fieldName != ''">#{fieldName},</if>
            <if test="placPrompt != null">#{placPrompt},</if>
            <if test="defaultValue != null">#{defaultValue},</if>
            <if test="optionalValue != null">#{optionalValue},</if>
            <if test="open != null">#{open},</if>
            <if test="tempId != null">#{tempId},</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="updateBusinessTemplateProp" parameterType="BusinessTemplateProp">
        update business_template_prop
        <trim prefix="SET" suffixOverrides=",">
            <if test="title != null and title != ''">title = #{title},</if>
            <if test="compType != null and compType != ''">comp_type = #{compType},</if>
            <if test="fieldName != null and fieldName != ''">field_name = #{fieldName},</if>
            <if test="placPrompt != null">plac_prompt = #{placPrompt},</if>
            <if test="defaultValue != null">default_value = #{defaultValue},</if>
            <if test="optionalValue != null">optional_value = #{optionalValue},</if>
            <if test="open != null">open = #{open},</if>
            <if test="tempId != null">temp_id = #{tempId},</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="deleteBusinessTemplatePropById" parameterType="Long">
        delete from business_template_prop where id = #{id}
    </delete>

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