<?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.pj.project.tb_vehicle.TbVehicleMapper">




	<!-- ================================== 查询相关 ================================== -->
	<!-- select id, vehicle_plate, owner, vehicle_type, parent_id, vehicle_size, vehicle_model, vehicle_load, vehicle_weight, create_by, create_name, create_time, update_by, update_name, update_time, delete_status, audit_status, audit_by, nopass_reason, audit_time from tb_vehicle  -->
	
	<!-- 通用映射：自动模式 -->
	<resultMap id="model" autoMapping="true" type="com.pj.project.tb_vehicle.TbVehicle"></resultMap>
	
	<!-- 公共查询sql片段 -->
	<sql id="select_sql">
		select * 
		from tb_vehicle 
	</sql>

	
	<!-- 查集合 - 根据条件（参数为空时代表忽略指定条件） [G] -->
	<select id="getList" resultMap="model">
		<include refid="select_sql"></include>
		<where>
			<if test=' this.has("id") '> and id = #{id} </if>
			<if test=' this.has("vehiclePlate") '> and vehicle_plate = #{vehiclePlate} </if>
			<if test=' this.has("owner") '> and owner = #{owner} </if>
			<if test=' this.has("vehicleType") '> and vehicle_type = #{vehicleType} </if>
			<if test=' this.has("parentId") '> and parent_id = #{parentId} </if>
			<if test=' this.has("vehicleSize") '> and vehicle_size = #{vehicleSize} </if>
			<if test=' this.has("vehicleModel") '> and vehicle_model = #{vehicleModel} </if>
			<if test=' this.has("vehicleLoad") '> and vehicle_load = #{vehicleLoad} </if>
			<if test=' this.has("vehicleWeight") '> and vehicle_weight = #{vehicleWeight} </if>
			<if test=' this.has("createBy") '> and create_by = #{createBy} </if>
			<if test=' this.has("createName") '> and create_name = #{createName} </if>
			<if test=' this.has("updateBy") '> and update_by = #{updateBy} </if>
			<if test=' this.has("updateName") '> and update_name = #{updateName} </if>
			<if test=' this.has("deleteStatus") '> and delete_status = #{deleteStatus} </if>
			<if test=' this.has("auditStatus") '> and audit_status = #{auditStatus} </if>
			<if test=' this.has("auditBy") '> and audit_by = #{auditBy} </if>
			<if test=' this.has("nopassReason") '> and nopass_reason = #{nopassReason} </if>
			<if test=' this.has("auditTime") '> and audit_time = #{auditTime} </if>
		</where>
		order by
		<choose>
			<when test='sortType == 1'> id desc </when>
			<when test='sortType == 2'> vehicle_plate desc </when>
			<when test='sortType == 3'> owner desc </when>
			<when test='sortType == 4'> vehicle_type desc </when>
			<when test='sortType == 5'> parent_id desc </when>
			<when test='sortType == 6'> vehicle_size desc </when>
			<when test='sortType == 7'> vehicle_model desc </when>
			<when test='sortType == 8'> vehicle_load desc </when>
			<when test='sortType == 9'> vehicle_weight desc </when>
			<when test='sortType == 10'> create_by desc </when>
			<when test='sortType == 11'> create_name desc </when>
			<when test='sortType == 12'> create_time desc </when>
			<when test='sortType == 13'> update_by desc </when>
			<when test='sortType == 14'> update_name desc </when>
			<when test='sortType == 15'> update_time desc </when>
			<when test='sortType == 16'> audit_status desc </when>
			<when test='sortType == 17'> audit_by desc </when>
			<when test='sortType == 18'> nopass_reason desc </when>
			<when test='sortType == 19'> audit_time desc </when>
			<otherwise> id desc </otherwise>
		</choose>
	</select>
	
	
	
	
	
	
	
	
	

</mapper>
