<?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.tofly.gpsboot.mapper.car.CarBaseinfoMapper">

    <resultMap id="carBaseinfoMap" type="com.tofly.pojo.car.CarBaseinfo">
        <id property="id" column="ID"/>
        <result property="speedLimit" column="SPEED_LIMIT"/>
        <result property="departmentId" column="DEPARTMENT_ID"/>
        <result property="carNumber" column="CAR_NUMBER"/>
        <result property="carStatas" column="CAR_STATAS"/>
        <result property="carType" column="CAR_TYPE"/>
        <result property="manager" column="MANAGER"/>
        <result property="createTime" column="CREATE_TIME"/>
        <result property="createUser" column="CREATE_USER"/>
        <result property="carPic" column="CAR_PIC"/>
        <result property="delFlag" column="DEL_FLAG"/>
        <result property="delTime" column="DEL_TIME"/>
        <result property="state" column="STATE" />
        <result property="isBind" column="IS_BIND" />
        <result property="snowflakeId" column="SNOWFLAKE_ID" />
        <result property="brandModel" column="BRAND_MODEL" />
        <result property="isDomestic" column="IS_DOMESTIC" />
        <result property="frameNumber" column="FRAME_NUMBER" />
        <result property="powerType" column="POWER_TYPE" />
        <result property="exhaustVolume" column="EXHAUST_VOLUME" />
        <result property="registerDate" column="REGISTER_DATE" />
        <result property="nature" column="NATURE" />
        <result property="remark" column="REMARK" />
        <result property="status" column="STATUS"/>
        <association property="stateName" column="STATE" select="getStateName"/>
        <association property="managerName" column="MANAGER" select="com.tofly.gpsboot.mapper.plan.HydrantrecordMapper.getRealName"/>
        <association property="departmentName" column="DEPARTMENT_ID" select="getdepartmentName"/>
        <association property="carTypeName" column="CAR_TYPE" select="getcarTypeName"/>
        <association property="createUserName" column="CREATE_USER"
                     select="com.tofly.gpsboot.mapper.plan.HydrantrecordMapper.getRealName"/>
        <association property="filePathList" column="CAR_PIC" select="com.tofly.gpsboot.mapper.plan.HydrantrecordMapper.getFilePathList"/>
    </resultMap>


    <select id="getStateName" resultType="java.lang.Object">
        SELECT
            (CASE #{state} WHEN '0' THEN '在用' WHEN '1' THEN '停用' WHEN '2' THEN '报废' END) AS stateName
        FROM DUAL
    </select>
    <select id="getdepartmentName" resultType="java.lang.Object">
      select name as departmentName from tf_smpn_department_x where id = #{departmentId}
    </select>
    <select id="getcarTypeName" resultType="java.lang.Object">
      select name as carTypeName from TF_CAR_TYPE where id = #{carType}
    </select>
    <select id="getCommonCarInfo" resultType="String">
        select notes from tf_smpn_code_x where key = 'common_vehicle' and notes is not null
    </select>

</mapper>
