<?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.basetyre.mapper.BaseTyreMapper">
    
    <resultMap type="BaseTyre" id="BaseTyreResult">
        <result property="id"    column="id"    />
        <result property="tyreFacCode"    column="tyre_fac_code"    />
        <result property="companyCode"    column="company_code"    />
        <result property="carId"    column="car_id"    />
        <result property="carLicense"    column="car_license"    />
        <result property="tureCode"    column="ture_code"    />
        <result property="tureModel"    column="ture_model"    />
        <result property="tureModelId"    column="ture_model_id"    />
        <result property="tureBrandId"    column="ture_brand_id"    />
        <result property="tyreRfid"    column="tyre_rfid"    />
        <result property="tyrePosition"    column="tyre_position"    />
        <result property="sensorId"    column="sensor_id"    />
        <result property="currentTextureDepth"    column="current_texture_depth"    />
        <result property="state"    column="state"    />
        <result property="isDelete"    column="is_delete"    />
        <result property="createTime"    column="create_time"    />
        <result property="createId"    column="create_id"    />
        <result property="createBy"    column="create_by"    />
        <result property="createName"    column="create_name"    />
        <result property="modifyTime"    column="modify_time"    />
        <result property="modifyId"    column="modify_id"    />
        <result property="modifyBy"    column="modify_by"    />
        <result property="modifyName"    column="modify__name"    />
    </resultMap>

    <sql id="selectBaseTyreVo">
        select id, tyre_fac_code, company_code, car_id, car_license, ture_code, ture_model, ture_model_id, ture_brand_id, tyre_rfid, tyre_position, sensor_id, current_texture_depth, state, is_delete, create_time, create_id, create_by, create_name, modify_time, modify_id, modify_by, modify__name from base_tyre
    </sql>

    <select id="selectBaseTyreList" parameterType="BaseTyre" resultMap="BaseTyreResult">
        <include refid="selectBaseTyreVo"/>
        <where>  
            <if test="tyreFacCode != null  and tyreFacCode != ''"> and tyre_fac_code = #{tyreFacCode}</if>
            <if test="companyCode != null  and companyCode != ''"> and company_code = #{companyCode}</if>
            <if test="carId != null  and carId != ''"> and car_id = #{carId}</if>
            <if test="carLicense != null  and carLicense != ''"> and car_license = #{carLicense}</if>
            <if test="tureCode != null  and tureCode != ''"> and ture_code like concat('%', #{tureCode}, '%')</if>
            <if test="tureModel != null  and tureModel != ''"> and ture_model = #{tureModel}</if>
            <if test="tureModelId != null  and tureModelId != ''"> and ture_model_id = #{tureModelId}</if>
            <if test="tureBrandId != null  and tureBrandId != ''"> and ture_brand_id = #{tureBrandId}</if>
            <if test="tyreRfid != null  and tyreRfid != ''"> and tyre_rfid = #{tyreRfid}</if>
            <if test="tyrePosition != null  and tyrePosition != ''"> and tyre_position = #{tyrePosition}</if>
            <if test="sensorId != null  and sensorId != ''"> and sensor_id = #{sensorId}</if>
            <if test="currentTextureDepth != null "> and current_texture_depth = #{currentTextureDepth}</if>
            <if test="state != null "> and state = #{state}</if>
            <if test="isDelete != null "> and is_delete = #{isDelete}</if>
            <if test="createId != null  and createId != ''"> and create_id = #{createId}</if>
            <if test="createName != null  and createName != ''"> and create_name like concat('%', #{createName}, '%')</if>
            <if test="modifyTime != null "> and modify_time = #{modifyTime}</if>
            <if test="modifyId != null  and modifyId != ''"> and modify_id = #{modifyId}</if>
            <if test="modifyBy != null  and modifyBy != ''"> and modify_by = #{modifyBy}</if>
            <if test="modifyName != null  and modifyName != ''"> and modify__name like concat('%', #{modifyName}, '%')</if>
        </where>
    </select>
    
    <select id="selectBaseTyreById" parameterType="String" resultMap="BaseTyreResult">
        <include refid="selectBaseTyreVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertBaseTyre" parameterType="BaseTyre">
        insert into base_tyre
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="tyreFacCode != null">tyre_fac_code,</if>
            <if test="companyCode != null">company_code,</if>
            <if test="carId != null">car_id,</if>
            <if test="carLicense != null">car_license,</if>
            <if test="tureCode != null">ture_code,</if>
            <if test="tureModel != null">ture_model,</if>
            <if test="tureModelId != null">ture_model_id,</if>
            <if test="tureBrandId != null">ture_brand_id,</if>
            <if test="tyreRfid != null">tyre_rfid,</if>
            <if test="tyrePosition != null">tyre_position,</if>
            <if test="sensorId != null">sensor_id,</if>
            <if test="currentTextureDepth != null">current_texture_depth,</if>
            <if test="state != null">state,</if>
            <if test="isDelete != null">is_delete,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createId != null">create_id,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createName != null">create_name,</if>
            <if test="modifyTime != null">modify_time,</if>
            <if test="modifyId != null">modify_id,</if>
            <if test="modifyBy != null">modify_by,</if>
            <if test="modifyName != null">modify__name,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="tyreFacCode != null">#{tyreFacCode},</if>
            <if test="companyCode != null">#{companyCode},</if>
            <if test="carId != null">#{carId},</if>
            <if test="carLicense != null">#{carLicense},</if>
            <if test="tureCode != null">#{tureCode},</if>
            <if test="tureModel != null">#{tureModel},</if>
            <if test="tureModelId != null">#{tureModelId},</if>
            <if test="tureBrandId != null">#{tureBrandId},</if>
            <if test="tyreRfid != null">#{tyreRfid},</if>
            <if test="tyrePosition != null">#{tyrePosition},</if>
            <if test="sensorId != null">#{sensorId},</if>
            <if test="currentTextureDepth != null">#{currentTextureDepth},</if>
            <if test="state != null">#{state},</if>
            <if test="isDelete != null">#{isDelete},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createId != null">#{createId},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createName != null">#{createName},</if>
            <if test="modifyTime != null">#{modifyTime},</if>
            <if test="modifyId != null">#{modifyId},</if>
            <if test="modifyBy != null">#{modifyBy},</if>
            <if test="modifyName != null">#{modifyName},</if>
         </trim>
    </insert>

    <update id="updateBaseTyre" parameterType="BaseTyre">
        update base_tyre
        <trim prefix="SET" suffixOverrides=",">
            <if test="tyreFacCode != null">tyre_fac_code = #{tyreFacCode},</if>
            <if test="companyCode != null">company_code = #{companyCode},</if>
            <if test="carId != null">car_id = #{carId},</if>
            <if test="carLicense != null">car_license = #{carLicense},</if>
            <if test="tureCode != null">ture_code = #{tureCode},</if>
            <if test="tureModel != null">ture_model = #{tureModel},</if>
            <if test="tureModelId != null">ture_model_id = #{tureModelId},</if>
            <if test="tureBrandId != null">ture_brand_id = #{tureBrandId},</if>
            <if test="tyreRfid != null">tyre_rfid = #{tyreRfid},</if>
            <if test="tyrePosition != null">tyre_position = #{tyrePosition},</if>
            <if test="sensorId != null">sensor_id = #{sensorId},</if>
            <if test="currentTextureDepth != null">current_texture_depth = #{currentTextureDepth},</if>
            <if test="state != null">state = #{state},</if>
            <if test="isDelete != null">is_delete = #{isDelete},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createId != null">create_id = #{createId},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createName != null">create_name = #{createName},</if>
            <if test="modifyTime != null">modify_time = #{modifyTime},</if>
            <if test="modifyId != null">modify_id = #{modifyId},</if>
            <if test="modifyBy != null">modify_by = #{modifyBy},</if>
            <if test="modifyName != null">modify__name = #{modifyName},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteBaseTyreById" parameterType="String">
        delete from base_tyre where id = #{id}
    </delete>

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