<?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_shop.TbShopMapper">




	<!-- ================================== 查询相关 ================================== -->
	<!-- select id, enterprise_id, create_by, create_name, update_name, create_time, update_by, update_time, trade_area_id, trade_area_name, address, address_ids, name, no, area, status, remark, enterprise_name, delete_status from tb_shop  -->

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

	<!-- 公共查询sql片段 -->
	<sql id="select_sql">
		select *
		from tb_shop
	</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("enterpriseId") '> and enterprise_id = #{enterpriseId} </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("updateName") '> and update_name = #{updateName} </if>
			<if test=' this.has("updateBy") '> and update_by = #{updateBy} </if>
			<if test=' this.has("tradeAreaId") '> and trade_area_id = #{tradeAreaId} </if>
			<if test=' this.has("tradeAreaName") '> and trade_area_name = #{tradeAreaName} </if>
			<if test=' this.has("address") '> and address = #{address} </if>
			<if test=' this.has("addressIds") '> and address_ids = #{addressIds} </if>
			<if test=' this.has("shopName") '> and shop_name like concat('%',#{shopName},'%') </if>
			<if test=' this.has("shopNo") '> and shop_no = #{shopNo} </if>
			<if test=' this.has("area") '> and area = #{area} </if>
			<if test=' this.has("status") '> and status = #{status} </if>
			<if test=' this.has("remark") '> and remark = #{remark} </if>
			<if test=' this.has("enterpriseName") '> and enterprise_name like cancat('%',#{enterpriseName},'%')  </if>
			<if test=' this.has("ownerName") '> and owner_name like concat('%',#{ownerName},'%')  </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'> enterprise_id desc </when>
			<when test='sortType == 3'> create_by desc </when>
			<when test='sortType == 4'> create_name desc </when>
			<when test='sortType == 5'> update_name desc </when>
			<when test='sortType == 6'> create_time desc </when>
			<when test='sortType == 7'> update_by desc </when>
			<when test='sortType == 8'> update_time desc </when>
			<when test='sortType == 9'> trade_area_id desc </when>
			<when test='sortType == 10'> trade_area_name desc </when>
			<when test='sortType == 11'> address desc </when>
			<when test='sortType == 12'> address_ids desc </when>
			<when test='sortType == 13'> name desc </when>
			<when test='sortType == 14'> no desc </when>
			<when test='sortType == 15'> area desc </when>
			<when test='sortType == 16'> status desc </when>
			<when test='sortType == 17'> remark desc </when>
			<when test='sortType == 18'> enterprise_name desc </when>
			<otherwise> id desc </otherwise>
		</choose>
	</select>

</mapper>
