肖海南访问记录接口修改

master
wenyu441069198 6 months ago
parent 2bd2968cc6
commit a4ae842a4a
  1. 4
      src/main/java/com/teaching/backend/controller/umsAdmin/ReportController.java
  2. 20
      src/main/java/com/teaching/backend/service/impl/report/ReportServiceImpl.java
  3. 2
      src/main/java/com/teaching/backend/service/report/ReportService.java

@ -35,9 +35,9 @@ public class ReportController {
*/ */
@PostMapping("/receptionBrowse") @PostMapping("/receptionBrowse")
@ApiOperation("接收每日浏览量") @ApiOperation("接收每日浏览量")
public CommonResult receptionBrowse(@RequestBody ReportDTO reportDTO){ public CommonResult receptionBrowse(){
boolean receptionBrowse = reportService.getReceptionBrowse(reportDTO); boolean receptionBrowse = reportService.getReceptionBrowse();
if (receptionBrowse == false){ if (receptionBrowse == false){
return CommonResult.failed(); return CommonResult.failed();
} }

@ -59,13 +59,19 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
} }
@Override @Override
public boolean getReceptionBrowse(ReportDTO reportDTO) { public boolean getReceptionBrowse() {
if (reportDTO.getCreateTime() == null || reportDTO.getPageView() == null){ //查询今日有无记录
return false; List<Report> list = lambdaQuery().eq(Report::getCreateTime, LocalDate.now()).list();
}
boolean todayBrowse = reportMapper.addTodayBrowse(reportDTO); if (list.size() > 0){
if (todayBrowse == false){ //有,给记录加一
return false; 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; return true;
} }

@ -17,5 +17,5 @@ public interface ReportService extends IService<Report> {
* 接收每日浏览量 * 接收每日浏览量
* @return * @return
*/ */
boolean getReceptionBrowse(ReportDTO reportDTO); boolean getReceptionBrowse();
} }

Loading…
Cancel
Save