123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- <?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.sta_data.StaDataMapper">
- <!-- 返回统计数据 -->
- <select id="getStaData" resultType="somap">
- select
- (select count(*) from sys_user) as sys_user_count,
- (select count(*) from sys_user where to_days(create_time) = to_days(now())) as sys_user_today_count,
- (select count(*) from sys_login_log) as sys_login_log_count,
- (select count(*) from sys_login_log where to_days(create_time) = to_days(now())) as sys_login_log_today_count,
- (select count(*) from sys_client) as sys_client_count,
- (select count(*) from sp_apilog) as sp_apilog_count
- </select>
- <!-- 获取指定年份每月登录量 -->
- <select id="getUserLoginSta" resultType="somap">
- select
- DATE_FORMAT( create_time, '%m' ) as m,
- count(*) as count
- from sys_login_log
- where DATE_FORMAT( create_time, '%Y' ) = #{year}
- group by m
- </select>
-
- <!-- 指定月份每日用户登录量 -->
- <select id="getUserLoginStaByMonth" resultType="somap">
- select
- DATE_FORMAT( create_time, '%d' ) as d,
- count(*) as count
- from sys_login_log
- where DATE_FORMAT( create_time, '%Y-%m' ) = #{yearMonth}
- group by d
- </select>
-
- <!-- 查询总登录数据,按照url分组 -->
- <select id="getUserLoginStaByUrlGroup" resultType="somap">
- select
- client_domain as name,
- count(1) as value
- from sys_login_log
- group by client_domain
- </select>
-
- <!-- 查询总登录数据,按照client分组 -->
- <select id="getUserLoginStaByClientGroup" resultType="somap">
- select
- concat(
- ifnull( (select name from sys_client where id = sys_login_log.client_id), '未知') ,
- ' - ',
- client_domain
- ) as name,
- count(1) as count
- from sys_login_log
- group by name
- </select>
-
- <!-- 获取指定年份每月注册量 -->
- <select id="getUserRegSta" resultType="somap">
- select
- DATE_FORMAT( create_time, '%m' ) as m,
- count(*) as count
- from sys_user
- where DATE_FORMAT( create_time, '%Y' ) = #{year}
- group by m
- </select>
-
- <!-- 指定时间段的用户登录数据 -->
- <select id="getLoginData" resultType="somap">
- select
- date_format(create_time, #{dateFormat} ) as names,
- count(*) as count
- from sys_login_log
- where create_time > #{startTime}
- and create_time < #{endTime}
- group by names
- </select>
-
- <!-- 指定时间段的用户注册数据 -->
- <select id="getRegData" resultType="somap">
- select
- date_format(create_time, #{dateFormat} ) as names,
- count(*) as count
- from sys_user
- where create_time > #{startTime}
- and create_time < #{endTime}
- group by names
- </select>
-
- </mapper>
|