肖海南访问记录接口修改

master
wenyu441069198 4 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")
@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();
}

@ -59,13 +59,19 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> 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<Report> 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;
}

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

Loading…
Cancel
Save