<?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.ytpm.dao.AppUserLoginMapper">
    <select id="getLastLoginInfo" resultType="com.ytpm.app.model.YtAppUserLoginRecord">
        select
            record_id, user_id, app_id, login_time, phone_brand, phone_model, login_ip, communication_operator, ip_addr
        from yt_app_user_login_record
        where user_id = #{userId} and app_id = #{appId}
        order by login_time desc limit 1
    </select>
    <select id="getIpRepeatCount" resultType="java.lang.Integer">
        select
            count(distinct login_ip)
        from yt_app_user_login_record
        where
            app_id = #{appId}
            and user_id not in (#{userId})
            and login_ip = #{loginIp}
    </select>
    <select id="getDeviceCount" resultType="java.lang.Integer">
        select
            count(distinct phone_model)
        from yt_app_user_login_record
        where
            app_id = #{appId}
            and user_id not in (#{userId})
            and phone_model = #{phoneModel}
    </select>
</mapper>