<?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.TpParaLibraryMapper">
    
    <resultMap type="com.ruoyi.project.business.domain.TpParaLibrary" id="TpParaLibraryResult">
        <result property="id"    column="id"    />
        <result property="paraCode"    column="para_code"    />
        <result property="paraName"    column="para_name"    />
        <result property="paraNameUS"    column="para_nameUS"    />
        <result property="paraNameRU"    column="para_nameRU"    />
        <result property="paraNameES"    column="para_nameES"    />
        <result property="paraCategory"    column="para_category"    />
        <result property="inputType"    column="input_type"    />
        <result property="sortNumber"    column="sort_number"    />
        <result property="elevatorType"    column="elevator_type"    />
        <result property="isQuotation"    column="is_quotation"    />
        <result property="isCivil"    column="is_civil"    />
        <result property="isCalc"    column="is_calc"    />
        <result property="status"    column="status"    />
        <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"    />
    </resultMap>

    <resultMap type="com.ruoyi.project.business.domain.TpParaLibrary" id="TpParaLibraryResult2"  extends="TpParaLibraryResult">
        <result property="paraCategoryK"    column="para_category_k"    />
        <result property="inputTypeK"    column="input_type_k"    />
        <result property="elevatorTypeK"    column="elevator_type_k"    />
        <result property="statusK"    column="status_k"    />
        <result property="isQuotationK"    column="is_quotation_k"    />
        <result property="isCivilK"    column="is_civil_k"    />
        <result property="isCalcK"    column="is_calc_k"    />
    </resultMap>

    <resultMap type="com.ruoyi.project.business.domain.vo.paramSelectItem.TpParaLibraryVo" id="TpParaLibraryItemResult">
        <result property="id"    column="id"    />
        <result property="paraCode"    column="para_code"    />
        <result property="paraName"    column="para_name"    />
        <result property="paraCategory"    column="para_category"    />
        <result property="inputType"    column="input_type"    />
        <collection property="items" ofType="com.ruoyi.project.business.domain.TpParaSelectItem">
            <result property="id"    column="item_id"    />
            <result property="paraId"    column="para_id"    />
            <result property="value"    column="value"    />
            <result property="label"    column="label"    />
        </collection>
    </resultMap>

    <resultMap type="com.ruoyi.common.importExcel.excel.tempInfo.ParaLibraryExcel" id="ParaLibraryExcel">
        <result property="id"    column="id"    />
        <result property="paraCode"    column="para_code"    />
        <result property="paraName"    column="para_name"    />
        <result property="paraNameUS"    column="para_nameUS"    />
        <result property="paraNameRU"    column="para_nameRU"    />
        <result property="paraNameES"    column="para_nameES"    />
        <result property="paraCategory"    column="para_category"    />
        <result property="inputType"    column="input_type"    />
        <result property="sortNumber"    column="sort_number"    />
        <result property="elevatorType"    column="elevator_type"    />
        <result property="isQuotation"    column="is_quotation"    />
        <result property="isCivil"    column="is_civil"    />
        <result property="isCalc"    column="is_calc"    />
        <result property="status"    column="status"    />
        <collection property="selectVOS" ofType="com.ruoyi.common.importExcel.excel.tempInfo.ParaSelectExcel">
            <result property="value"    column="value"    />
            <result property="label"    column="label"    />
            <result property="labelUS"    column="labelUS"    />
            <result property="labelRU"    column="labelRU"    />
            <result property="labelES"    column="labelES"    />
            <result property="paraCode"    column="item_code"    />
            <result property="prarSource"    column="prar_source"    />
            <result property="remark"    column="remark"    />
        </collection>
    </resultMap>
    <resultMap type="com.ruoyi.common.importExcel.excel.tempInfo.ParaLibraryExportHelper" id="ParaLibraryExcelHelper">

        <result property="paraCode"    column="para_code"    />
        <result property="paraName"    column="para_name"    />
        <result property="paraNameUS"    column="para_nameUS"    />
        <result property="paraNameRU"    column="para_nameRU"    />
        <result property="paraNameES"    column="para_nameES"    />
        <result property="paraCategory"    column="para_category"    />
        <result property="inputType"    column="input_type"    />

        <result property="elevatorType"    column="elevator_type"    />
        <result property="isQuotation"    column="is_quotation"    />
        <result property="isCivil"    column="is_civil"    />
        <result property="isCalc"    column="is_calc"    />

            <result property="value"    column="value"    />
            <result property="label"    column="label"    />
            <result property="labelUS"    column="labelUS"    />
            <result property="labelRU"    column="labelRU"    />
            <result property="labelES"    column="labelES"    />
        <result property="itemCode"    column="item_code"    />
        <result property="prarSource"    column="prar_source"    />
        <result property="remark"    column="remark"    />
    </resultMap>
    <sql id="selectExoprt">
           SELECT
        t1.para_code,
        t1.para_name,
        t1.para_nameUS,
        t1.para_nameRU,
        t1.para_nameES,
        t1.para_category,
        t1.input_type,
        t1.sort_number,
        t1.elevator_type,
        t1.is_quotation,
        t1.is_civil,
        t1.is_calc,
        t2.value,
        t2.label,
        t2.labelUS,
        t2.labelRU,
        t2.labelES,
        t2.para_code as item_code,
        t2.prar_source,
        t2.remark
        FROM
        tp_para_library  t1
        left join tp_para_select_item t2 on t2.para_id = t1.id and t2.del_flag = '0'
    </sql>
    <sql id="selectExportFromModel">
           SELECT
        t1.para_code,
        t1.para_name,
        t1.para_nameUS,
        t1.para_nameRU,
        t1.para_nameES,
        t1.para_category,
        t1.input_type,
        t1.sort_number,
        t1.elevator_type,
        t1.is_quotation,
        t1.is_civil,
        t1.is_calc,
        t2.value,
        t2.label,
        t2.labelUS,
        t2.labelRU,
        t2.labelES,
         t2.para_code as item_code,
        t2.prar_source,
        t2.remark
        FROM
        tp_elevator_model elv
        left join tp_area_elevator_model_para para on para.elevator_model_id = elv.id and  para.del_flag = '0'
        left join tp_area_para_select_item item on item.elevator_model_id = elv.id and para.para_id = item.para_id and item.del_flag = '0'
        left join tp_para_library  t1 on  t1.id = para.para_id
        left join tp_para_select_item t2 on t2.id = item.para_select_item_id and t1.id = t2.para_id
    </sql>
    <sql id="selectTpParaLibraryVo">
        SELECT
            id,
            para_code,
            para_name,
            para_nameUS,
            para_nameRU,
            para_nameES,
            para_category,
            input_type,
            sort_number,
            elevator_type,
            is_quotation,
            is_civil,
            is_calc,
            STATUS,
            del_flag,
            create_time,
            create_by,
            update_time,
            update_by,
            remark
        FROM
            tp_para_library
    </sql>

    <sql id="selectTpParaLibraryVo2">
        SELECT
            t1.id,
            t1.para_code,
            t1.para_name,
            t1.para_nameUS,
            t1.para_nameRU,
            t1.para_nameES,
            t1.para_category,
            t1.input_type,
            t1.sort_number,
            t1.elevator_type,
            t1.is_quotation,
            t1.is_civil,
            t1.is_calc,
            t1.STATUS,
            t1.update_time,
            CASE #{language}
                WHEN 'english' THEN
                    t2.dict_labelUS
                WHEN 'russia' THEN
                    t2.dict_labelRU
                WHEN 'spanish' THEN
                    t2.dict_labelES ELSE t2.dict_label
                END AS para_category_k,
            CASE #{language}
                WHEN 'english' THEN
                    t3.dict_labelUS
                WHEN 'russia' THEN
                    t3.dict_labelRU
                WHEN 'spanish' THEN
                    t3.dict_labelES ELSE t3.dict_label
                END AS input_type_k,
            CASE #{language}
                WHEN 'english' THEN
                    t4.dict_labelUS
                WHEN 'russia' THEN
                    t4.dict_labelRU
                WHEN 'spanish' THEN
                    t4.dict_labelES ELSE t4.dict_label
                END AS elevator_type_k,
            CASE #{language}
                WHEN 'english' THEN
                    t5.dict_labelUS
                WHEN 'russia' THEN
                    t5.dict_labelRU
                WHEN 'spanish' THEN
                    t5.dict_labelES ELSE t5.dict_label
                END AS status_k,
            CASE #{language}
                WHEN 'english' THEN
                t6.dict_labelUS
                WHEN 'russia' THEN
                t6.dict_labelRU
                WHEN 'spanish' THEN
                t6.dict_labelES ELSE t6.dict_label
                END AS is_quotation_k,
            CASE #{language}
                WHEN 'english' THEN
                t7.dict_labelUS
                WHEN 'russia' THEN
                t7.dict_labelRU
                WHEN 'spanish' THEN
                t7.dict_labelES ELSE t7.dict_label
                END AS is_civil_k,
            CASE #{language}
                WHEN 'english' THEN
                t8.dict_labelUS
                WHEN 'russia' THEN
                t8.dict_labelRU
                WHEN 'spanish' THEN
                t8.dict_labelES ELSE t8.dict_label
                END AS is_calc_k
        FROM
            tp_para_library  t1
                LEFT JOIN sys_dict_data AS t2 ON t2.dict_type = 'para_category'
                AND t1.para_category = t2.dict_value
                LEFT JOIN sys_dict_data AS t3 ON t3.dict_type = 'input_type'
                AND t1.input_type = t3.dict_value
                LEFT JOIN sys_dict_data AS t4 ON t4.dict_type = 'elevator_type'
                AND t1.elevator_type = t4.dict_value
                LEFT JOIN sys_dict_data AS t5 ON t5.dict_type = 'status_switch'
                AND t1.STATUS = t5.dict_value
                LEFT JOIN sys_dict_data AS t6 ON t6.dict_type = 'crm_yes_no'
                AND t1.is_quotation = t6.dict_value
                LEFT JOIN sys_dict_data AS t7 ON t7.dict_type = 'crm_yes_no'
                AND t1.is_civil = t7.dict_value
                LEFT JOIN sys_dict_data AS t8 ON t8.dict_type = 'crm_yes_no'
                AND t1.is_calc = t8.dict_value
    </sql>

    <select id="selectTpParaLibraryList" parameterType="TpParaLibrary" resultMap="TpParaLibraryResult2">
        <include refid="selectTpParaLibraryVo2"/>
        <where>
            AND t1.del_flag = '0'
            <if test="paraCode != null  and paraCode != ''"> and t1.para_code like concat('%', #{paraCode}, '%')</if>
            <if test="paraName != null  and paraName != ''"> and t1.para_name like concat('%', #{paraName}, '%')</if>
            <if test="paraNameUS != null  and paraNameUS != ''"> and t1.para_nameUS like concat('%', #{paraNameUS}, '%')</if>
            <if test="paraNameRU != null  and paraNameRU != ''"> and t1.para_nameRU like concat('%', #{paraNameRU}, '%')</if>
            <if test="paraNameES != null  and paraNameES != ''"> and t1.para_nameES like concat('%', #{paraNameES}, '%')</if>
            <if test="ids != null  and ids.size() > 0">
                and t1.id in
                <foreach item="item" collection="ids" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="paraCategoryArray != null  and paraCategoryArray.length > 0">
                and t1.para_category in
                <foreach item="item" collection="paraCategoryArray" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="inputTypeArray != null  and inputTypeArray.length > 0">
                and t1.input_type in
                <foreach item="item" collection="inputTypeArray" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="elevatorTypeArray != null  and elevatorTypeArray.length > 0">
                and t1.elevator_type in
                <foreach item="item" collection="elevatorTypeArray" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="sortNumber != null "> and t1.sort_number = #{sortNumber}</if>
            <if test="status != null  and status != ''"> and t1.status = #{status}</if>
            <if test="isQuotation != null  and isQuotation != ''"> and t1.is_quotation = #{isQuotation}</if>
            <if test="isCivil != null  and isCivil != ''"> and t1.is_civil = #{isCivil}</if>
            <if test="isCalc != null  and isCalc != ''"> and t1.is_calc = #{isCalc}</if>
        </where>
    </select>
    
    <select id="selectTpParaLibraryById" parameterType="Long" resultMap="TpParaLibraryResult">
        <include refid="selectTpParaLibraryVo"/>
        where id = #{id}
    </select>

    <select id="selectTpParaLibraryListExport" parameterType="TpParaLibrary" resultMap="ParaLibraryExcelHelper">
        <include refid="selectExoprt"/>
        <where>
            t1.del_flag = '0'
            <if test="paraCode != null  and paraCode != ''"> and t1.para_code like concat('%', #{paraCode}, '%')</if>
            <if test="paraName != null  and paraName != ''"> and t1.para_name like concat('%', #{paraName}, '%')</if>
            <if test="paraNameUS != null  and paraNameUS != ''"> and t1.para_nameUS like concat('%', #{paraNameUS}, '%')</if>
            <if test="paraNameRU != null  and paraNameRU != ''"> and t1.para_nameRU like concat('%', #{paraNameRU}, '%')</if>
            <if test="paraNameES != null  and paraNameES != ''"> and t1.para_nameES like concat('%', #{paraNameES}, '%')</if>
            <if test="ids != null  and ids.size() > 0">
                and t1.id in
                <foreach item="item" collection="ids" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="paraCategoryArray != null  and paraCategoryArray.length > 0">
                and t1.para_category in
                <foreach item="item" collection="paraCategoryArray" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="inputTypeArray != null  and inputTypeArray.length > 0">
                and t1.input_type in
                <foreach item="item" collection="inputTypeArray" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="elevatorTypeArray != null  and elevatorTypeArray.length > 0">
                and t1.elevator_type in
                <foreach item="item" collection="elevatorTypeArray" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="status != null  and status != ''"> and t1.status = #{status}</if>
            <if test="isQuotation != null  and isQuotation != ''"> and t1.is_quotation = #{isQuotation}</if>
            <if test="isCivil != null  and isCivil != ''"> and t1.is_civil = #{isCivil}</if>
            <if test="isCalc != null  and isCalc != ''"> and t1.is_calc = #{isCalc}</if>
        </where>
        order by t1.sort_number, t2.sort_number
    </select>

    <select id="selectModelExport" parameterType="com.ruoyi.project.business.domain.TpAreaParaSelectItem" resultMap="ParaLibraryExcelHelper">
        <include refid="selectExportFromModel"/>
        <where>
            elv.del_flag = '0'
            <if test="elevatorModelId != null "> and elv.id = #{elevatorModelId}</if>
            <if test="paraCode != null  and paraCode != ''"> and t1.para_code like concat('%', #{paraCode}, '%')</if>
        </where>
        order by t1.sort_number, t2.sort_number
    </select>

    <select id="selectTpParaLibraryListExport2" parameterType="TpParaLibrary" resultMap="ParaLibraryExcel">
        <include refid="selectExoprt"/>
        <where>
            t1.del_flag = '0'
            <if test="paraCode != null  and paraCode != ''"> and t1.para_code like concat('%', #{paraCode}, '%')</if>
            <if test="paraName != null  and paraName != ''"> and t1.para_name like concat('%', #{paraName}, '%')</if>
            <if test="paraNameUS != null  and paraNameUS != ''"> and t1.para_nameUS like concat('%', #{paraNameUS}, '%')</if>
            <if test="paraNameRU != null  and paraNameRU != ''"> and t1.para_nameRU like concat('%', #{paraNameRU}, '%')</if>
            <if test="paraNameES != null  and paraNameES != ''"> and t1.para_nameES like concat('%', #{paraNameES}, '%')</if>
            <if test="ids != null  and ids.size() > 0">
                and t1.id in
                <foreach item="item" collection="ids" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="paraCategoryArray != null  and paraCategoryArray.length > 0">
                and t1.para_category in
                <foreach item="item" collection="paraCategoryArray" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="inputTypeArray != null  and inputTypeArray.length > 0">
                and t1.input_type in
                <foreach item="item" collection="inputTypeArray" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="elevatorTypeArray != null  and elevatorTypeArray.length > 0">
                and t1.elevator_type in
                <foreach item="item" collection="elevatorTypeArray" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="status != null  and status != ''"> and t1.status = #{status}</if>
            <if test="isQuotation != null  and isQuotation != ''"> and t1.is_quotation = #{isQuotation}</if>
            <if test="isCivil != null  and isCivil != ''"> and t1.is_civil = #{isCivil}</if>
            <if test="isCalc != null  and isCalc != ''"> and t1.is_calc = #{isCalc}</if>
        </where>
        order by t1.para_category,t1.sort_number, t2.sort_number
    </select>

    <select id="selectModelExport2" parameterType="com.ruoyi.project.business.domain.TpAreaParaSelectItem" resultMap="ParaLibraryExcel">
        <include refid="selectExportFromModel"/>
        <where>
            elv.del_flag = '0'
            <if test="elevatorModelId != null "> and elv.id = #{elevatorModelId}</if>
            <if test="paraCode != null  and paraCode != ''"> and t1.para_code like concat('%', #{paraCode}, '%')</if>
        </where>
        order by t1.para_category,t1.sort_number, t2.sort_number
    </select>


    <select id="checkParaChangeAllowed" resultType="int">
        SELECT
            COUNT(*)
        FROM
            tp_para_library t1
                INNER JOIN tp_area_elevator_model_para t2  on t1.para_code = t2.para_code
        WHERE t1.id = #{id}
    </select>

    <select id="selectTpParaLibraryByParabarId" parameterType="Long" resultMap="TpParaLibraryResult">
        SELECT T3.*
        FROM tp_para_library T3
        where T3.para_code in (select distinct para_code from tp_parabar_detail_value where parabar_id = #{parabarId})

    </select>
        
    <insert id="insertTpParaLibrary" parameterType="TpParaLibrary" useGeneratedKeys="true" keyProperty="id">
        insert into tp_para_library
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="paraCode != null">para_code,</if>
            <if test="paraName != null">para_name,</if>
            <if test="paraNameUS != null">para_nameUS,</if>
            <if test="paraNameRU != null">para_nameRU,</if>
            <if test="paraNameES != null">para_nameES,</if>
            <if test="paraCategory != null">para_category,</if>
            <if test="inputType != null">input_type,</if>
            <if test="sortNumber != null">sort_number,</if>
            <if test="elevatorType != null">elevator_type,</if>
            <if test="isQuotation != null">is_quotation,</if>
            <if test="isCivil != null">is_civil,</if>
            <if test="isCalc != null">is_calc,</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>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="paraCode != null">#{paraCode},</if>
            <if test="paraName != null">#{paraName},</if>
            <if test="paraNameUS != null">#{paraNameUS},</if>
            <if test="paraNameRU != null">#{paraNameRU},</if>
            <if test="paraNameES != null">#{paraNameES},</if>
            <if test="paraCategory != null">#{paraCategory},</if>
            <if test="inputType != null">#{inputType},</if>
            <if test="sortNumber != null">#{sortNumber},</if>
            <if test="elevatorType != null">#{elevatorType},</if>
            <if test="isQuotation != null">#{isQuotation},</if>
            <if test="isCivil != null">#{isCivil},</if>
            <if test="isCalc != null">#{isCalc},</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>
         </trim>
    </insert>

    <update id="updateTpParaLibrary" parameterType="TpParaLibrary">
        update tp_para_library
        <trim prefix="SET" suffixOverrides=",">
            <if test="paraCode != null">para_code = #{paraCode},</if>
            <if test="paraName != null">para_name = #{paraName},</if>
            <if test="paraNameUS != null">para_nameUS = #{paraNameUS},</if>
            <if test="paraNameRU != null">para_nameRU = #{paraNameRU},</if>
            <if test="paraNameES != null">para_nameES = #{paraNameES},</if>
            <if test="paraCategory != null">para_category = #{paraCategory},</if>
            <if test="inputType != null">input_type = #{inputType},</if>
            <if test="sortNumber != null">sort_number = #{sortNumber},</if>
            <if test="elevatorType != null">elevator_type = #{elevatorType},</if>
            <if test="isQuotation != null">is_quotation = #{isQuotation},</if>
            <if test="isCivil != null">is_civil = #{isCivil},</if>
            <if test="isCalc != null">is_calc = #{isCalc},</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>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTpParaLibraryById" parameterType="Long">
        delete from tp_para_library where id = #{id}
        update tp_para_library set del_flag = 1 where id = #{id}
    </delete>

    <delete id="deleteTpParaLibraryByIds" parameterType="String">
        update tp_para_library set del_flag = 1 where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>

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

    <insert id="InsertBySQL" parameterType="java.util.List"   useGeneratedKeys="true"
            keyProperty="id">
        insert into tp_para_library (
        para_code,
        para_name,
        para_nameUS,
        para_nameRU,
        para_nameES,
        para_category,
        input_type,
        sort_number,
        elevator_type,
        status,
        is_quotation,
        is_civil,
        is_calc,
        create_time,
        create_by,
        remark
        )values
        <foreach collection="list" item="item" index="index" separator=",">
            (
            #{item.paraCode},
            #{item.paraName},
            #{item.paraNameUS},
            #{item.paraNameRU},
            #{item.paraNameES},
            #{item.paraCategory},
            #{item.inputType},

            #{item.sortNumber},
            #{item.elevatorType},
            #{item.status},
            #{item.isQuotation},
            #{item.isCivil},
            #{item.isCalc},
            #{item.createTime},
            #{item.createBy},
            #{item.remark}
            )
        </foreach>
    </insert>

    <select id="getMaxSort" parameterType="java.lang.String" resultType="java.lang.Long">
        select ifnull(Max(sort_number), 0) from tp_para_library
        where del_flag = '0'
    </select>


    <select id="selectTpParaLibraryWithItem" parameterType="com.ruoyi.project.business.domain.TpParaLibrary" resultMap="TpParaLibraryItemResult">
        select
        lib.id,
        lib.para_code,
        lib.para_category,
        lib.input_type,
        sel.id as item_id,
        sel.para_id,
        sel.value,
        sel.label
        from tp_para_library lib
        left join tp_para_select_item sel on lib.id = sel.para_id and sel.del_flag = 0
        <where>
            lib.del_flag = 0
            <if test="id != null "> and para_id = #{id}</if>
            <if test="paraCode != null "> and lib.para_code = #{paraCode}</if>
            <if test="elevatorType != null "> and lib.elevator_type = #{elevatorType}</if>
        </where>
    </select>
</mapper>