<?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_car_record.TbCarRecordMapper">




	<!-- ================================== 查询相关 ================================== -->
	<!-- select id, trade_area_id, trade_area_name, driver_id, enterprise_id, order_id, vehicle_id, goods_name, goods_img, goods_weight, shop_name, enterprise_name, enterprise_phone, remark, create_by, create_name, create_time, delete_status from tb_car_record  -->
	
	<!-- 通用映射：自动模式 -->
	<resultMap id="model" autoMapping="true" type="com.pj.project.tb_car_record.TbCarRecord"></resultMap>
	
	<!-- 公共查询sql片段 -->
	<sql id="select_sql">
		select * 
		from tb_car_record 
	</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("tradeAreaId") '> and trade_area_id = #{tradeAreaId} </if>
			<if test=' this.has("driverResult") '> and driver_result = #{driverResult} </if>
			<if test=' this.has("tradeAreaName") '> and trade_area_name = #{tradeAreaName} </if>
			<if test=' this.has("vehicleType") '> and vehicle_type = #{vehicleType} </if>
			<if test=' this.has("vehicleModel") '> and vehicle_model = #{vehicleModel} </if>
			<if test=' this.has("driverId") '> and driver_id = #{driverId} </if>
			<if test=' this.has("enterpriseId") '> and enterprise_id = #{enterpriseId} </if>
			<if test=' this.has("orderId") '> and order_id = #{orderId} </if>
			<if test=' this.has("vehicleId") '> and vehicle_id = #{vehicleId} </if>
			<if test=' this.has("goodsName") '> and goods_name = #{goodsName} </if>
			<if test=' this.has("goodsImg") '> and goods_img = #{goodsImg} </if>
			<if test=' this.has("goodsWeight") '> and goods_weight = #{goodsWeight} </if>
			<if test=' this.has("shopName") '> and shop_name = #{shopName} </if>
			<if test=' this.has("enterpriseName") '> and enterprise_name = #{enterpriseName} </if>
			<if test=' this.has("enterprisePhone") '> and enterprise_phone = #{enterprisePhone} </if>
			<if test=' this.has("remark") '> and remark = #{remark} </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("createTime") '> and create_time = #{createTime} </if>
			<if test=' this.has("deleteStatus") '> and delete_status = #{deleteStatus} </if>
		</where>
		order by
		<choose>
			<when test='sortType == 1'> id desc </when>
			<when test='sortType == 2'> trade_area_id desc </when>
			<when test='sortType == 3'> trade_area_name desc </when>
			<when test='sortType == 4'> driver_id desc </when>
			<when test='sortType == 5'> enterprise_id desc </when>
			<when test='sortType == 6'> order_id desc </when>
			<when test='sortType == 7'> vehicle_id desc </when>
			<when test='sortType == 8'> goods_name desc </when>
			<when test='sortType == 9'> goods_img desc </when>
			<when test='sortType == 10'> goods_weight desc </when>
			<when test='sortType == 11'> shop_name desc </when>
			<when test='sortType == 12'> enterprise_name desc </when>
			<when test='sortType == 13'> enterprise_phone desc </when>
			<when test='sortType == 14'> remark desc </when>
			<when test='sortType == 15'> create_by desc </when>
			<when test='sortType == 16'> create_name desc </when>
			<when test='sortType == 17'> create_time desc </when>
			<when test='sortType == 18'> delete_status desc </when>
			<otherwise> id desc </otherwise>
		</choose>
	</select>
	
	
	
	
	
	
	
	
	

</mapper>
