From a4ae842a4acf7a7ff32d39e4e7893b9c8c39aa65 Mon Sep 17 00:00:00 2001 From: wenyu441069198 <14186472+wenyu441069198@user.noreply.gitee.com> Date: Tue, 6 Aug 2024 09:49:54 +0800 Subject: [PATCH] =?UTF-8?q?=E8=82=96=E6=B5=B7=E5=8D=97=E8=AE=BF=E9=97=AE?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E6=8E=A5=E5=8F=A3=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/umsAdmin/ReportController.java | 4 ++-- .../impl/report/ReportServiceImpl.java | 20 ++++++++++++------- .../backend/service/report/ReportService.java | 2 +- 3 files changed, 16 insertions(+), 10 deletions(-) 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(); }