<?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.project.business.mapper.TpAreaOptionalParaMapper">
    
    <resultMap type="com.ruoyi.project.business.domain.TpAreaOptionalPara" id="TpAreaOptionalParaResult">
        <result property="id"    column="id"    />
        <result property="elevatorModelId"    column="elevator_model_id"    />
        <result property="markupKey"    column="markup_key"    />
        <result property="markupName"    column="markup_name"    />
        <result property="paraCode"    column="para_code"    />
        <result property="relatedParaCode1"    column="related_para_code1"    />
        <result property="relatedParaCode2"    column="related_para_code2"    />
        <result property="relatedParaCode3"    column="related_para_code3"    />
        <result property="relatedParaCode4"    column="related_para_code4"    />
        <result property="relatedParaCode5"    column="related_para_code5"    />
        <result property="relatedParaCode6"    column="related_para_code6"    />
        <result property="relatedParaCode7"    column="related_para_code7"    />
        <result property="relatedParaCode8"    column="related_para_code8"    />
        <result property="relatedParaCode9"    column="related_para_code9"    />
        <result property="relatedParaCode10"    column="related_para_code10"    />
        <result property="status"    column="status"    />
        <result property="sortIndex"    column="sort_index"    />
        <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="remark"    column="remark"    />
        <result property="exportParaCodes"    column="export_para_codes"    />
    </resultMap>

    <sql id="selectTpAreaOptionalParaVo">
        select id, elevator_model_id, markup_key, markup_name, para_code, related_para_code1, related_para_code2, related_para_code3, related_para_code4, related_para_code5, related_para_code6, related_para_code7, related_para_code8, related_para_code9, related_para_code10, status, del_flag, create_time, create_by, update_time, update_by, remark, sort_index, export_para_codes from tp_area_optional_para
    </sql>

    <select id="selectTpAreaOptionalParaList" parameterType="com.ruoyi.project.business.domain.TpAreaOptionalPara" resultMap="TpAreaOptionalParaResult">
        <include refid="selectTpAreaOptionalParaVo"/>
        <where>  
            <if test="elevatorModelId != null "> and elevator_model_id = #{elevatorModelId}</if>
            <if test="markupKey != null  and markupKey != ''"> and markup_key = #{markupKey}</if>
            <if test="markupName != null  and markupName != ''"> and markup_name like concat('%', #{markupName}, '%')</if>
            <if test="paraCode != null  and paraCode != ''"> and para_code = #{paraCode}</if>
            <if test="relatedParaCode1 != null  and relatedParaCode1 != ''"> and related_para_code1 = #{relatedParaCode1}</if>
            <if test="relatedParaCode2 != null  and relatedParaCode2 != ''"> and related_para_code2 = #{relatedParaCode2}</if>
            <if test="relatedParaCode3 != null  and relatedParaCode3 != ''"> and related_para_code3 = #{relatedParaCode3}</if>
            <if test="relatedParaCode4 != null  and relatedParaCode4 != ''"> and related_para_code4 = #{relatedParaCode4}</if>
            <if test="relatedParaCode5 != null  and relatedParaCode5 != ''"> and related_para_code5 = #{relatedParaCode5}</if>
            <if test="relatedParaCode6 != null  and relatedParaCode6 != ''"> and related_para_code6 = #{relatedParaCode6}</if>
            <if test="relatedParaCode7 != null  and relatedParaCode7 != ''"> and related_para_code7 = #{relatedParaCode7}</if>
            <if test="relatedParaCode8 != null  and relatedParaCode8 != ''"> and related_para_code8 = #{relatedParaCode8}</if>
            <if test="relatedParaCode9 != null  and relatedParaCode9 != ''"> and related_para_code9 = #{relatedParaCode9}</if>
            <if test="relatedParaCode10 != null  and relatedParaCode10 != ''"> and related_para_code10 = #{relatedParaCode10}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
            <if test="exportParaCodes != null  and exportParaCodes != ''"> and export_para_codes = #{exportParaCodes}</if>
        </where>
        order by ISNULL(sort_index), sort_index asc
    </select>
    
    <select id="selectTpAreaOptionalParaById" parameterType="Long" resultMap="TpAreaOptionalParaResult">
        <include refid="selectTpAreaOptionalParaVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTpAreaOptionalPara" parameterType="com.ruoyi.project.business.domain.TpAreaOptionalPara" useGeneratedKeys="true" keyProperty="id">
        insert into tp_area_optional_para
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="elevatorModelId != null">elevator_model_id,</if>
            <if test="markupKey != null">markup_key,</if>
            <if test="markupName != null">markup_name,</if>
            <if test="paraCode != null">para_code,</if>
            <if test="relatedParaCode1 != null">related_para_code1,</if>
            <if test="relatedParaCode2 != null">related_para_code2,</if>
            <if test="relatedParaCode3 != null">related_para_code3,</if>
            <if test="relatedParaCode4 != null">related_para_code4,</if>
            <if test="relatedParaCode5 != null">related_para_code5,</if>
            <if test="relatedParaCode6 != null">related_para_code6,</if>
            <if test="relatedParaCode7 != null">related_para_code7,</if>
            <if test="relatedParaCode8 != null">related_para_code8,</if>
            <if test="relatedParaCode9 != null">related_para_code9,</if>
            <if test="relatedParaCode10 != null">related_para_code10,</if>
            <if test="status != null">status,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="remark != null">remark,</if>
            <if test="sortIndex != null">sort_index,</if>
            <if test="exportParaCodes != null">export_para_codes,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="elevatorModelId != null">#{elevatorModelId},</if>
            <if test="markupKey != null">#{markupKey},</if>
            <if test="markupName != null">#{markupName},</if>
            <if test="paraCode != null">#{paraCode},</if>
            <if test="relatedParaCode1 != null">#{relatedParaCode1},</if>
            <if test="relatedParaCode2 != null">#{relatedParaCode2},</if>
            <if test="relatedParaCode3 != null">#{relatedParaCode3},</if>
            <if test="relatedParaCode4 != null">#{relatedParaCode4},</if>
            <if test="relatedParaCode5 != null">#{relatedParaCode5},</if>
            <if test="relatedParaCode6 != null">#{relatedParaCode6},</if>
            <if test="relatedParaCode7 != null">#{relatedParaCode7},</if>
            <if test="relatedParaCode8 != null">#{relatedParaCode8},</if>
            <if test="relatedParaCode9 != null">#{relatedParaCode9},</if>
            <if test="relatedParaCode10 != null">#{relatedParaCode10},</if>
            <if test="status != null">#{status},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="remark != null">#{remark},</if>
            <if test="sortIndex != null">#{sortIndex},</if>
            <if test="exportParaCodes != null">#{exportParaCodes},</if>
         </trim>
    </insert>

    <update id="updateTpAreaOptionalPara" parameterType="com.ruoyi.project.business.domain.TpAreaOptionalPara">
        update tp_area_optional_para
        <trim prefix="SET" suffixOverrides=",">
            <if test="elevatorModelId != null">elevator_model_id = #{elevatorModelId},</if>
            <if test="markupKey != null">markup_key = #{markupKey},</if>
            <if test="markupName != null">markup_name = #{markupName},</if>
            <if test="paraCode != null">para_code = #{paraCode},</if>
            <if test="relatedParaCode1 != null">related_para_code1 = #{relatedParaCode1},</if>
            <if test="relatedParaCode2 != null">related_para_code2 = #{relatedParaCode2},</if>
            <if test="relatedParaCode3 != null">related_para_code3 = #{relatedParaCode3},</if>
            <if test="relatedParaCode4 != null">related_para_code4 = #{relatedParaCode4},</if>
            <if test="relatedParaCode5 != null">related_para_code5 = #{relatedParaCode5},</if>
            <if test="relatedParaCode6 != null">related_para_code6 = #{relatedParaCode6},</if>
            <if test="relatedParaCode7 != null">related_para_code7 = #{relatedParaCode7},</if>
            <if test="relatedParaCode8 != null">related_para_code8 = #{relatedParaCode8},</if>
            <if test="relatedParaCode9 != null">related_para_code9 = #{relatedParaCode9},</if>
            <if test="relatedParaCode10 != null">related_para_code10 = #{relatedParaCode10},</if>
            <if test="status != null">status = #{status},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="sortIndex != null">sort_index = #{sortIndex},</if>
            <if test="exportParaCodes != null">export_para_codes = #{exportParaCodes},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTpAreaOptionalParaById" parameterType="Long">
        delete from tp_area_optional_para where id = #{id}
    </delete>

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