Helius
2021-09-16 4d80b819948366cb0754369b1bea5e0e83cf6af1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?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="cc.mrbird.febs.monitor.mapper.LoginLogMapper">
    <select id="findTotalVisitCount" resultType="long">
        select count(1) from t_login_log
    </select>
 
    <select id="findTodayVisitCount" resultType="long">
        SELECT count(1) FROM t_login_log WHERE login_time between CURDATE() and DATE_ADD(CURDATE(), INTERVAL 1 DAY)
    </select>
 
    <select id="findTodayIp" resultType="long">
        SELECT count(DISTINCT(ip)) FROM t_login_log WHERE login_time between CURDATE() and DATE_ADD(CURDATE(), INTERVAL 1 DAY)
    </select>
 
    <select id="findLastSevenDaysVisitCount" resultType="map" parameterType="string">
        select
        date_format(l.login_time, '%m-%d') days,
        count(1) count
        from
        (
        select
        *
        from
        t_login_log
        where
        date_sub(curdate(), interval 10 day) &lt;= date(login_time)
        ) as l where 1 = 1
        <if test="username != null and username != ''">
            and l.username = #{username}
        </if>
        group by
        days
    </select>
</mapper>