diff --git a/src/main/java/com/teaching/backend/controller/umsAdmin/ReportController.java b/src/main/java/com/teaching/backend/controller/umsAdmin/ReportController.java index 15b86c9..06deea1 100644 --- a/src/main/java/com/teaching/backend/controller/umsAdmin/ReportController.java +++ b/src/main/java/com/teaching/backend/controller/umsAdmin/ReportController.java @@ -35,9 +35,9 @@ public class ReportController { */ @PostMapping("/receptionBrowse") @ApiOperation("接收每日浏览量") - public CommonResult receptionBrowse(@RequestBody ReportDTO reportDTO){ + public CommonResult receptionBrowse(){ - boolean receptionBrowse = reportService.getReceptionBrowse(reportDTO); + boolean receptionBrowse = reportService.getReceptionBrowse(); if (receptionBrowse == false){ return CommonResult.failed(); } diff --git a/src/main/java/com/teaching/backend/service/impl/report/ReportServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/report/ReportServiceImpl.java index 3cabf56..e3ee1a3 100644 --- a/src/main/java/com/teaching/backend/service/impl/report/ReportServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/report/ReportServiceImpl.java @@ -59,13 +59,19 @@ public class ReportServiceImpl extends ServiceImpl impleme } @Override - public boolean getReceptionBrowse(ReportDTO reportDTO) { - if (reportDTO.getCreateTime() == null || reportDTO.getPageView() == null){ - return false; - } - boolean todayBrowse = reportMapper.addTodayBrowse(reportDTO); - if (todayBrowse == false){ - return false; + public boolean getReceptionBrowse() { + //查询今日有无记录 + List list = lambdaQuery().eq(Report::getCreateTime, LocalDate.now()).list(); + + if (list.size() > 0){ + //有,给记录加一 + update().setSql("page_view = page_view + 1").eq("create_time",LocalDate.now()).update(); + }else { + //无,创建一个记录 + Report report = new Report(); + report.setCreateTime(LocalDate.now()); + report.setPageView("1"); + save(report); } return true; } diff --git a/src/main/java/com/teaching/backend/service/report/ReportService.java b/src/main/java/com/teaching/backend/service/report/ReportService.java index 5fbe678..74c1fcc 100644 --- a/src/main/java/com/teaching/backend/service/report/ReportService.java +++ b/src/main/java/com/teaching/backend/service/report/ReportService.java @@ -17,5 +17,5 @@ public interface ReportService extends IService { * 接收每日浏览量 * @return */ - boolean getReceptionBrowse(ReportDTO reportDTO); + boolean getReceptionBrowse(); }