<?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.tb_purchaser.TbPurchaserMapper">




	<!-- ================================== 查询相关 ================================== -->
	<!-- select id, name, legal_person, id_card, contact, business_license, bank_no, bank_name, bank_account, duty_paragraph, address_ids, address, judge_status, judge_content, judge_time, register_time, person_id, create_time, create_by, create_name, update_time, update_by, update_name, delete_status from tb_purchaser  -->

	<!-- 通用映射：自动模式 -->
	<resultMap id="model" autoMapping="true" type="com.pj.tb_purchaser.TbPurchaser"></resultMap>

	<!-- 公共查询sql片段 -->
	<sql id="select_sql">
		select *
		from tb_purchaser
	</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 like concat('%', #{name}, '%') </if>
			<if test=' this.has("legalPerson") '> and legal_person like concat('%', #{legalPerson}, '%') </if>
			<if test=' this.has("idCard") '> and id_card = #{idCard} </if>
			<if test=' this.has("contact") '> and contact = #{contact} </if>
			<if test=' this.has("bankNo") '> and bank_no = #{bankNo} </if>
			<if test=' this.has("bankName") '> and bank_name = #{bankName} </if>
			<if test=' this.has("bankAccount") '> and bank_account = #{bankAccount} </if>
			<if test=' this.has("dutyParagraph") '> and duty_paragraph = #{dutyParagraph} </if>
			<if test=' this.has("addressIds") '> and address_ids = #{addressIds} </if>
			<if test=' this.has("address") '> and address = #{address} </if>
			<if test=' this.has("judgeStatus") '> and judge_status = #{judgeStatus} </if>
			<if test=' this.has("judgeContent") '> and judge_content = #{judgeContent} </if>
			<if test=' this.has("personId") '> and person_id = #{personId} </if>
			<if test=' this.has("createTime") '> and create_time = #{createTime} </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("updateTime") '> and update_time = #{updateTime} </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("type") '> and type = #{type} </if>
			<if test=' this.has("businessName") '> and business_name like concat('%', #{businessName}, '%') </if>
			<if test=' this.has("email") '> and email = #{email} </if>
		</where>
		order by
		<choose>
			<when test='sortType == 1'> id desc </when>
			<when test='sortType == 2'> name desc </when>
			<when test='sortType == 3'> legal_person desc </when>
			<when test='sortType == 4'> id_card desc </when>
			<when test='sortType == 5'> contact desc </when>
			<when test='sortType == 6'> bank_no desc </when>
			<when test='sortType == 7'> bank_name desc </when>
			<when test='sortType == 8'> bank_account desc </when>
			<when test='sortType == 9'> duty_paragraph desc </when>
			<when test='sortType == 10'> address_ids desc </when>
			<when test='sortType == 11'> address desc </when>
			<when test='sortType == 12'> judge_status desc </when>
			<when test='sortType == 13'> judge_content desc </when>
			<when test='sortType == 14'> judge_time desc </when>
			<when test='sortType == 15'> register_time desc </when>
			<when test='sortType == 16'> person_id desc </when>
			<when test='sortType == 17'> create_time desc </when>
			<when test='sortType == 18'> create_by desc </when>
			<when test='sortType == 19'> create_name desc </when>
			<when test='sortType == 20'> update_time desc </when>
			<when test='sortType == 21'> update_by desc </when>
			<when test='sortType == 22'> update_name desc </when>
			<when test='sortType == 23'> delete_status desc </when>
			<otherwise> id desc </otherwise>
		</choose>
	</select>










</mapper>
