<?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.app_user.AppUserMapper">




	<!-- ================================== 查询相关 ================================== -->
	<!-- select id, phone, name, user_type, fk_id, status, auth, auth_time, login_count, last_login_time, create_time, update_by_id, update_by_name, update_time from app_user  -->
	
	<!-- 通用映射：自动模式 -->
	<resultMap id="model" autoMapping="true" type="com.pj.project.app_user.AppUser"></resultMap>
	
	<!-- 公共查询sql片段 -->
	<sql id="select_sql">
		select * 
		from app_user 
	</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("phone") '> and phone = #{phone} </if>
			<if test=' this.has("name") '> and name = #{name} </if>
			<if test=' this.has("userType") '> and user_type = #{userType} </if>
			<if test=' this.has("fkId") '> and fk_id = #{fkId} </if>
			<if test=' this.has("status") '> and status = #{status} </if>
			<if test=' this.has("auth") '> and auth = #{auth} </if>
			<if test=' this.has("authTime") '> and auth_time = #{authTime} </if>
			<if test=' this.has("loginCount") '> and login_count = #{loginCount} </if>
			<if test=' this.has("lastLoginTime") '> and last_login_time = #{lastLoginTime} </if>
			<if test=' this.has("updateById") '> and update_by_id = #{updateById} </if>
			<if test=' this.has("updateByName") '> and update_by_name = #{updateByName} </if>
		</where>
		order by
		<choose>
			<when test='sortType == 1'> id desc </when>
			<when test='sortType == 2'> phone desc </when>
			<when test='sortType == 3'> name desc </when>
			<when test='sortType == 4'> user_type desc </when>
			<when test='sortType == 5'> fk_id desc </when>
			<when test='sortType == 6'> status desc </when>
			<when test='sortType == 7'> auth desc </when>
			<when test='sortType == 8'> auth_time desc </when>
			<when test='sortType == 9'> login_count desc </when>
			<when test='sortType == 10'> last_login_time desc </when>
			<when test='sortType == 11'> create_time desc </when>
			<when test='sortType == 12'> update_by_id desc </when>
			<when test='sortType == 13'> update_by_name desc </when>
			<when test='sortType == 14'> update_time desc </when>
			<otherwise> id desc </otherwise>
		</choose>
	</select>
	
	
	
	
	
	
	
	
	

</mapper>
