se-modules/se-system/src/main/java/com/se/system/controller/IndexController.java
@@ -41,8 +41,12 @@ // PV反映了网站用户访问的网页数量,是衡量网站流量的重要指标之一 @Log(title = "PV统计", businessType = BusinessType.OTHER) @GetMapping("/pvCount") public Map<String, Object> pvCount() { public Map<String, Object> pvCount(Integer day) { if (null == day || day < 1) day = 15; if (day > 365) day = 365; Map<String, Object> map = new HashMap<>(); map.put("pvCount", indexService.pvCount(day)); return map; } @@ -52,8 +56,12 @@ // 如果更换了IP后但不清除cookies,再访问相同网站,该网站的统计中UV数是不变的。 @Log(title = "UV统计", businessType = BusinessType.OTHER) @GetMapping("/uvCount") public Map<String, Object> uvCount() { public Map<String, Object> uvCount(Integer day) { if (null == day || day < 1) day = 15; if (day > 365) day = 365; Map<String, Object> map = new HashMap<>(); map.put("uvCount", indexService.uvCount(day)); return map; } se-modules/se-system/src/main/java/com/se/system/mapper/IndexMapper.java
@@ -16,4 +16,8 @@ //@MapKey("username") public List<Map<String, Object>> userCountList(@Param("createTime") String createTime, @Param("amount") Integer amount); public int uvCount(@Param("createTime") String createTime); public int pvCount(String createTime); } se-modules/se-system/src/main/java/com/se/system/service/IndexService.java
@@ -35,4 +35,16 @@ return indexMapper.userCountList(createTime, amount); } public int uvCount(int day) { String createTime = getCreateTime(day); return indexMapper.uvCount(createTime); } public Object pvCount(Integer day) { String createTime = getCreateTime(day); return indexMapper.pvCount(createTime); } } se-modules/se-system/src/main/resources/mapper/system/IndexMapper.xml
@@ -15,4 +15,16 @@ order by count desc limit ${amount}; </select> <select id="uvCount" resultType="java.lang.Integer"> select count(distinct user_name, ipaddr, date_format(access_time, '%Y%m%d')) count from sys_logininfor where access_time >= #{createTime}; </select> <select id="pvCount" resultType="java.lang.Integer"> select count(*) from sys_oper_log where oper_url = '/index/addAccessLog' and oper_time >= #{createTime}; </select> </mapper>