肖海南浏览小修改

master
wenyu441069198 4 months ago
parent 6329dec57d
commit e7c9fcbd07
  1. 11
      src/main/java/com/teaching/backend/service/impl/report/ReportServiceImpl.java

@ -11,6 +11,7 @@ import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -24,7 +25,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
@Override @Override
public BrowseReportVO getBrowseStatistics() { public BrowseReportVO getBrowseStatistics() {
//存放访问的前一天至前七天的每天对应的日期 //存放访问的前一天至前七天的每天对应的日期
List<LocalDate> dateList = new ArrayList<>(); List<String> dateList = new ArrayList<>();
//存放这个月访问的前一天至前七天的每天对应的浏览量 //存放这个月访问的前一天至前七天的每天对应的浏览量
List<String> ThisMonthBrowseList = new ArrayList<>(); List<String> ThisMonthBrowseList = new ArrayList<>();
//存放上个月访问的前一天至前七天的每天对应的浏览量 //存放上个月访问的前一天至前七天的每天对应的浏览量
@ -36,7 +37,9 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
// 获取前七天的日期 // 获取前七天的日期
for (int i = 1; i <= 7; i++) { for (int i = 1; i <= 7; i++) {
LocalDate day = end.minusDays(i); LocalDate day = end.minusDays(i);
dateList.add(day); // 定义一个仅包含月日的格式化器
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM-dd");
dateList.add(day.format(formatter));
//查询今天对应的浏览量 //查询今天对应的浏览量
String browse = reportMapper.getBrowseByTime(day); String browse = reportMapper.getBrowseByTime(day);
@ -47,6 +50,8 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
LocalDate lastMonth = lastMonthToday.minusDays(i); LocalDate lastMonth = lastMonthToday.minusDays(i);
//查询上个月的今天对应的浏览量 //查询上个月的今天对应的浏览量
String lastMonthBrowse = reportMapper.getBrowseByTime(lastMonth); String lastMonthBrowse = reportMapper.getBrowseByTime(lastMonth);
LastMonthBrowseList.add(lastMonthBrowse); LastMonthBrowseList.add(lastMonthBrowse);
} }
@ -62,7 +67,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
public boolean getReceptionBrowse() { public boolean getReceptionBrowse() {
//查询今日有无记录 //查询今日有无记录
List<Report> list = lambdaQuery().eq(Report::getCreateTime, LocalDate.now()).list(); List<Report> list = lambdaQuery().eq(Report::getCreateTime, LocalDate.now()).list();
if (list.size() > 0){ if (list.size() > 0){
//有,给记录加一 //有,给记录加一
update().setSql("page_view = page_view + 1").eq("create_time",LocalDate.now()).update(); update().setSql("page_view = page_view + 1").eq("create_time",LocalDate.now()).update();

Loading…
Cancel
Save