From d787ed305860335e8cda32707e8ec94bd9389052 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=91=E6=9D=B0?= Date: Wed, 26 Dec 2018 11:18:13 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AB=99=E7=82=B9=E7=BB=9F=E8=AE=A1=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../monitor/config/VisitsInitialization.java | 18 ++++++++++++++++++ .../service/impl/VisitsServiceImpl.java | 3 --- src/main/resources/logback.xml | 16 +--------------- 3 files changed, 19 insertions(+), 18 deletions(-) create mode 100644 src/main/java/me/zhengjie/monitor/config/VisitsInitialization.java diff --git a/src/main/java/me/zhengjie/monitor/config/VisitsInitialization.java b/src/main/java/me/zhengjie/monitor/config/VisitsInitialization.java new file mode 100644 index 000000000..8ae173325 --- /dev/null +++ b/src/main/java/me/zhengjie/monitor/config/VisitsInitialization.java @@ -0,0 +1,18 @@ +package me.zhengjie.monitor.config; + +import lombok.extern.slf4j.Slf4j; +import me.zhengjie.monitor.service.VisitsService; +import org.springframework.context.annotation.Configuration; + +/** + * 初始化站点统计 + */ +@Slf4j +@Configuration +public class VisitsInitialization { + + public VisitsInitialization(VisitsService visitsService){ + log.info("--------------- 初始化站点统计,如果存在今日统计则跳过 ---------------"); + visitsService.save(); + } +} diff --git a/src/main/java/me/zhengjie/monitor/service/impl/VisitsServiceImpl.java b/src/main/java/me/zhengjie/monitor/service/impl/VisitsServiceImpl.java index a281030f8..e7e66e18b 100644 --- a/src/main/java/me/zhengjie/monitor/service/impl/VisitsServiceImpl.java +++ b/src/main/java/me/zhengjie/monitor/service/impl/VisitsServiceImpl.java @@ -48,9 +48,6 @@ public void save() { @Override public void count(HttpServletRequest request) { - - // 部署到线上后,可将save()删除 - save(); LocalDate localDate = LocalDate.now(); Visits visits = visitsRepository.findByDate(localDate.toString()); visits.setPvCounts(visits.getPvCounts()+1); diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml index fa856a813..a882a2b04 100644 --- a/src/main/resources/logback.xml +++ b/src/main/resources/logback.xml @@ -1,7 +1,6 @@ - elune - + elAdmin @@ -14,22 +13,9 @@ - - - - - - - - - - - - -