<?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_driver.TbDriverMapper">




	<!-- ================================== 查询相关 ================================== -->
	<!-- select id, name, age, sex, phone, address, bank_code, bank_name, id_card, id_card_img, driving_license_id, driving_license_img, vehicle_driving_id, vehicle_driving_img, vehicle_img, register_time, is_lock, create_by, create_name, create_time, update_by, update_name, update_time, delete_status, audit_status, audit_by, audit_time, nopass_reason from tb_driver  -->
	
	<!-- 通用映射：自动模式 -->
	<resultMap id="model" autoMapping="true" type="com.pj.project.tb_driver.TbDriver"></resultMap>
	
	<!-- 公共查询sql片段 -->
	<sql id="select_sql">
		select * 
		from tb_driver 
	</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("name") '> and name = #{name} </if>
			<if test=' this.has("age") '> and age = #{age} </if>
			<if test=' this.has("sex") '> and sex = #{sex} </if>
			<if test=' this.has("phone") '> and phone = #{phone} </if>
			<if test=' this.has("address") '> and address = #{address} </if>
			<if test=' this.has("bankCode") '> and bank_code = #{bankCode} </if>
			<if test=' this.has("bankName") '> and bank_name = #{bankName} </if>
			<if test=' this.has("idCard") '> and id_card = #{idCard} </if>
			<if test=' this.has("drivingLicenseId") '> and driving_license_id = #{drivingLicenseId} </if>
			<if test=' this.has("vehicleDrivingId") '> and vehicle_driving_id = #{vehicleDrivingId} </if>
			<if test=' this.has("registerTime") '> and register_time = #{registerTime} </if>
			<if test=' this.has("isLock") '> and is_lock = #{isLock} </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("auditTime") '> and audit_time = #{auditTime} </if>
			<if test=' this.has("nopassReason") '> and nopass_reason = #{nopassReason} </if>
		</where>
		order by
		<choose>
			<when test='sortType == 1'> id desc </when>
			<when test='sortType == 2'> name desc </when>
			<when test='sortType == 3'> age desc </when>
			<when test='sortType == 4'> sex desc </when>
			<when test='sortType == 5'> phone desc </when>
			<when test='sortType == 6'> address desc </when>
			<when test='sortType == 7'> bank_code desc </when>
			<when test='sortType == 8'> bank_name desc </when>
			<when test='sortType == 9'> id_card desc </when>
			<when test='sortType == 10'> driving_license_id desc </when>
			<when test='sortType == 11'> vehicle_driving_id desc </when>
			<when test='sortType == 12'> register_time desc </when>
			<when test='sortType == 13'> is_lock desc </when>
			<when test='sortType == 14'> create_by desc </when>
			<when test='sortType == 15'> create_name desc </when>
			<when test='sortType == 16'> create_time desc </when>
			<when test='sortType == 17'> update_by desc </when>
			<when test='sortType == 18'> update_name desc </when>
			<when test='sortType == 19'> update_time desc </when>
			<when test='sortType == 20'> audit_status desc </when>
			<when test='sortType == 21'> audit_by desc </when>
			<when test='sortType == 22'> audit_time desc </when>
			<when test='sortType == 23'> nopass_reason desc </when>
			<otherwise> id desc </otherwise>
		</choose>
	</select>
	
	
	
	
	
	
	
	
	

</mapper>
