<?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_login_log.AppUserLoginLogMapper">




	<!-- ================================== 查询相关 ================================== -->
	<!-- select id, usre_id, login_time, login_ip, device_mode, app_version from app_user_login_log  -->
	
	<!-- 通用映射：自动模式 -->
	<resultMap id="model" autoMapping="true" type="com.pj.project.app_user_login_log.AppUserLoginLog"></resultMap>
	
	<!-- 公共查询sql片段 -->
	<sql id="select_sql">
		select * 
		from app_user_login_log 
	</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("userName") '> and user_name like concat('%', #{userName}, '%') </if>
			<if test=' this.has("loginIp") '> and login_ip = #{loginIp} </if>
			<if test=' this.has("deviceMode") '> and device_mode = #{deviceMode} </if>
			<if test=' this.has("appVersion") '> and app_version = #{appVersion} </if>
		</where>
		order by
		<choose>
			<when test='sortType == 1'> id desc </when>
			<when test='sortType == 2'> usre_id desc </when>
			<when test='sortType == 3'> login_time desc </when>
			<when test='sortType == 4'> login_ip desc </when>
			<when test='sortType == 5'> device_mode desc </when>
			<when test='sortType == 6'> app_version desc </when>
			<otherwise> id desc </otherwise>
		</choose>
	</select>
	
	
	
	
	
	
	
	
	

</mapper>
