StaDataMapper.xml 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.pj.project.sta_data.StaDataMapper">
  4. <!-- 返回统计数据 -->
  5. <select id="getStaData" resultType="somap">
  6. select
  7. (select count(*) from sys_user) as sys_user_count,
  8. (select count(*) from sys_user where to_days(create_time) = to_days(now())) as sys_user_today_count,
  9. (select count(*) from sys_login_log) as sys_login_log_count,
  10. (select count(*) from sys_login_log where to_days(create_time) = to_days(now())) as sys_login_log_today_count,
  11. (select count(*) from sys_client) as sys_client_count,
  12. (select count(*) from sp_apilog) as sp_apilog_count
  13. </select>
  14. <!-- 获取指定年份每月登录量 -->
  15. <select id="getUserLoginSta" resultType="somap">
  16. select
  17. DATE_FORMAT( create_time, '%m' ) as m,
  18. count(*) as count
  19. from sys_login_log
  20. where DATE_FORMAT( create_time, '%Y' ) = #{year}
  21. group by m
  22. </select>
  23. <!-- 指定月份每日用户登录量 -->
  24. <select id="getUserLoginStaByMonth" resultType="somap">
  25. select
  26. DATE_FORMAT( create_time, '%d' ) as d,
  27. count(*) as count
  28. from sys_login_log
  29. where DATE_FORMAT( create_time, '%Y-%m' ) = #{yearMonth}
  30. group by d
  31. </select>
  32. <!-- 查询总登录数据,按照url分组 -->
  33. <select id="getUserLoginStaByUrlGroup" resultType="somap">
  34. select
  35. client_domain as name,
  36. count(1) as value
  37. from sys_login_log
  38. group by client_domain
  39. </select>
  40. <!-- 查询总登录数据,按照client分组 -->
  41. <select id="getUserLoginStaByClientGroup" resultType="somap">
  42. select
  43. concat(
  44. ifnull( (select name from sys_client where id = sys_login_log.client_id), '未知') ,
  45. ' - ',
  46. client_domain
  47. ) as name,
  48. count(1) as count
  49. from sys_login_log
  50. group by name
  51. </select>
  52. <!-- 获取指定年份每月注册量 -->
  53. <select id="getUserRegSta" resultType="somap">
  54. select
  55. DATE_FORMAT( create_time, '%m' ) as m,
  56. count(*) as count
  57. from sys_user
  58. where DATE_FORMAT( create_time, '%Y' ) = #{year}
  59. group by m
  60. </select>
  61. <!-- 指定时间段的用户登录数据 -->
  62. <select id="getLoginData" resultType="somap">
  63. select
  64. date_format(create_time, #{dateFormat} ) as names,
  65. count(*) as count
  66. from sys_login_log
  67. where create_time > #{startTime}
  68. and create_time &lt; #{endTime}
  69. group by names
  70. </select>
  71. <!-- 指定时间段的用户注册数据 -->
  72. <select id="getRegData" resultType="somap">
  73. select
  74. date_format(create_time, #{dateFormat} ) as names,
  75. count(*) as count
  76. from sys_user
  77. where create_time > #{startTime}
  78. and create_time &lt; #{endTime}
  79. group by names
  80. </select>
  81. </mapper>