<?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.njzscloud.supervisory.biz.mapper.BizTruckMapper">
    <resultMap id="SearchTruckResultMap" autoMapping="true" type="com.njzscloud.supervisory.biz.pojo.result.SearchTruckResult">
        <result property="truckLicenseDate" column="truck_license_date" typeHandler="com.njzscloud.common.mp.support.handler.j.JsonTypeHandler"/>
        <result property="qualificationDate" column="qualification_date" typeHandler="com.njzscloud.common.mp.support.handler.j.JsonTypeHandler"/>
        <result property="truckLicense" column="truck_license" typeHandler="com.njzscloud.common.mp.support.handler.j.JsonTypeHandler"/>
        <result property="qualification" column="qualification" typeHandler="com.njzscloud.common.mp.support.handler.j.JsonTypeHandler"/>
    </resultMap>
    <select id="paging" resultMap="SearchTruckResultMap">
        SELECT
        a.id,
        a.company_id,
        b.company_name,
        b.uscc,
        a.license_plate,
        a.truck_license,
        a.vn_code,
        a.qualification,
        a.carrying_capacity,
        a.tare_weight,
        a.audit_status,
        a.audit_memo,
        a.creator_id,
        a.modifier_id,
        a.create_time,
        a.modify_time,
        a.truck_license_date,
        a.qualification_date,
        a.deleted,
        a.busy,
        a.gps,
        a.picture,
        a.truck_category,
        a.disabled
        FROM biz_truck a
        INNER JOIN biz_company b ON b.id = a.company_id
        <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''">
            ${ew.customSqlSegment}
        </if>
        ORDER BY a.modify_time DESC
    </select>

    <select id="selectDetailById" resultMap="SearchTruckResultMap">
        SELECT
            a.id,
            a.company_id,
            b.company_name,
            b.uscc,
            a.license_plate,
            a.truck_license,
            a.vn_code,
            a.qualification,
            a.carrying_capacity,
            a.tare_weight,
            a.audit_status,
            a.audit_memo,
            a.creator_id,
            a.modifier_id,
            a.create_time,
            a.modify_time,
            a.truck_license_date,
            a.qualification_date,
            a.deleted,
            a.gps,
            a.picture,
            a.truck_category,
            a.disabled
        FROM biz_truck a
        INNER JOIN biz_company b ON b.id = a.company_id AND b.deleted = 0
        WHERE a.id = #{id} AND a.deleted = 0
    </select>
</mapper>
