<?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_address.TbPurchaserAddressMapper">




	<!-- ================================== 查询相关 ================================== -->
	<!-- select id, owner, province, city, town, street, building_no, address_name, post_num from tb_purchaser_address  -->
	
	<!-- 通用映射：自动模式 -->
	<resultMap id="model" autoMapping="true" type="com.pj.tb_purchaser_address.TbPurchaserAddress"></resultMap>
	
	<!-- 公共查询sql片段 -->
	<sql id="select_sql">
		select * 
		from tb_purchaser_address 
	</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("userId") '> and user_id = #{userId} </if>
		</where>
		order by
		<choose>
			<when test='sortType == 1'> id desc </when>
			<when test='sortType == 2'> owner desc </when>
			<when test='sortType == 3'> province desc </when>
			<when test='sortType == 4'> city desc </when>
			<when test='sortType == 5'> town desc </when>
			<when test='sortType == 6'> street desc </when>
			<when test='sortType == 7'> building_no desc </when>
			<when test='sortType == 8'> address_name desc </when>
			<when test='sortType == 9'> post_num desc </when>
			<otherwise> id desc </otherwise>
		</choose>
	</select>
	
	
	
	
	
	
	
	
	

</mapper>
