<?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.TpParabarRelatedModelMapper">
    
    <resultMap type="TpParabarRelatedModel" id="TpParabarRelatedModelResult">
        <result property="id"    column="id"    />
        <result property="parabarId"    column="parabar_id"    />
        <result property="elevatorModelId"    column="elevator_model_id"    />
        <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="selectTpParabarRelatedModelVo">
        select id, parabar_id, elevator_model_id, del_flag, create_time, create_by, update_time, update_by, remark from tp_parabar_related_model
    </sql>

    <select id="selectTpParabarRelatedModelList" parameterType="TpParabarRelatedModel" resultMap="TpParabarRelatedModelResult">
        <include refid="selectTpParabarRelatedModelVo"/>
        <where>  
            <if test="parabarId != null "> and parabar_id = #{parabarId}</if>
            <if test="elevatorModelId != null "> and elevator_model_id = #{elevatorModelId}</if>
        </where>
    </select>
    
    <select id="selectTpParabarRelatedModelById" parameterType="Long" resultMap="TpParabarRelatedModelResult">
        <include refid="selectTpParabarRelatedModelVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTpParabarRelatedModel" parameterType="TpParabarRelatedModel" useGeneratedKeys="true" keyProperty="id">
        insert into tp_parabar_related_model
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="parabarId != null">parabar_id,</if>
            <if test="elevatorModelId != null">elevator_model_id,</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="parabarId != null">#{parabarId},</if>
            <if test="elevatorModelId != null">#{elevatorModelId},</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="updateTpParabarRelatedModel" parameterType="TpParabarRelatedModel">
        update tp_parabar_related_model
        <trim prefix="SET" suffixOverrides=",">
            <if test="parabarId != null">parabar_id = #{parabarId},</if>
            <if test="elevatorModelId != null">elevator_model_id = #{elevatorModelId},</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="deleteTpParabarRelatedModelById" parameterType="Long">
        delete from tp_parabar_related_model where id = #{id}
    </delete>

    <delete id="deleteTpParabarRelatedModelByParabarId" parameterType="Long">
        delete from tp_parabar_related_model where parabar_id = #{parabarId}
    </delete>

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

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