<?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.TjElevatorParaDetailMapper">
    
    <resultMap type="TjElevatorParaDetail" id="TjElevatorParaDetailResult">
        <result property="id"    column="id"    />
        <result property="elevatorId"    column="elevator_id"    />
        <result property="paraCode"    column="para_code"    />
        <result property="paraValue"    column="para_value"    />
        <result property="paraCategory"    column="para_category"    />
        <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>

    <sql id="selectTjElevatorParaDetailVo">
        select id, elevator_id, para_code, para_value, para_category, del_flag, create_time, create_by, update_time, update_by, remark from tj_elevator_para_detail
    </sql>

    <select id="selectTjElevatorParaDetailList" parameterType="TjElevatorParaDetail" resultMap="TjElevatorParaDetailResult">
        <include refid="selectTjElevatorParaDetailVo"/>
        <where>  
            <if test="elevatorId != null "> and elevator_id = #{elevatorId}</if>
            <if test="paraCode != null  and paraCode != ''"> and para_code = #{paraCode}</if>
            <if test="paraValue != null  and paraValue != ''"> and para_value = #{paraValue}</if>
            <if test="paraCategory != null  and paraCategory != ''"> and para_category = #{paraCategory}</if>
        </where>
    </select>
    
    <select id="selectTjElevatorParaDetailById" parameterType="Long" resultMap="TjElevatorParaDetailResult">
        <include refid="selectTjElevatorParaDetailVo"/>
        where id = #{id}
    </select>

    <select id="selectByElevatorIds" resultType="com.ruoyi.project.business.domain.TjElevatorParaDetail">
        <include refid="selectTjElevatorParaDetailVo"/>
        where elevator_id in
        <foreach collection="elevatorIds" item="elevatorId" open="(" separator="," close=")">
            #{elevatorId}
        </foreach>
    </select>

    <insert id="insertTjElevatorParaDetail" parameterType="TjElevatorParaDetail" useGeneratedKeys="true" keyProperty="id">
        insert into tj_elevator_para_detail
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="elevatorId != null">elevator_id,</if>
            <if test="paraCode != null and paraCode != ''">para_code,</if>
            <if test="paraValue != null">para_value,</if>
            <if test="paraCategory != null">para_category,</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="elevatorId != null">#{elevatorId},</if>
            <if test="paraCode != null and paraCode != ''">#{paraCode},</if>
            <if test="paraValue != null">#{paraValue},</if>
            <if test="paraCategory != null">#{paraCategory},</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>

    <insert id="batchInsertTjElevatorParaDetail">
        insert into tj_elevator_para_detail
        (elevator_id,
         para_code,
         para_value,
         para_category,
         del_flag,
         create_time,
         create_by,
         update_time,
         update_by,
         remark)
        values
        <foreach collection="list" item="item" index="index" separator=",">
            (#{item.elevatorId},
             #{item.paraCode},
             #{item.paraValue},
             #{item.paraCategory},
             #{item.delFlag},
             #{item.createTime},
             #{item.createBy},
             #{item.updateTime},
             #{item.updateBy},
             #{item.remark})
        </foreach>
    </insert>

    <update id="updateTjElevatorParaDetail" parameterType="TjElevatorParaDetail">
        update tj_elevator_para_detail
        <trim prefix="SET" suffixOverrides=",">
            <if test="elevatorId != null">elevator_id = #{elevatorId},</if>
            <if test="paraCode != null and paraCode != ''">para_code = #{paraCode},</if>
            <if test="paraValue != null">para_value = #{paraValue},</if>
            <if test="paraCategory != null">para_category = #{paraCategory},</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="deleteTjElevatorParaDetailById" parameterType="Long">
        delete from tj_elevator_para_detail where id = #{id}
    </delete>

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