From 1444047b949653d403920e208a8613a26fea92bc Mon Sep 17 00:00:00 2001 From: "rong.liu" Date: Mon, 28 Nov 2022 18:23:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E7=AB=A0=E6=B5=8F=E8=A7=88=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E5=8A=9F=E8=83=BD=E4=BB=A5=E5=8F=8A=E5=90=84=E4=B8=AA?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E5=9B=9E=E6=98=BE=E7=BB=9F=E8=AE=A1=E6=95=B0?= =?UTF-8?q?=E9=87=8F=E7=9A=84=E5=80=BC=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iasf/controller/SysContentController.java | 11 +++++++- .../iasf/mapper/xml/SysContentMapper.xml | 4 +-- .../iasf/service/SysContentService.java | 4 +++ .../service/impl/SysContentServiceImpl.java | 28 ++++++++++++++++--- 4 files changed, 40 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/huoran/iasf/controller/SysContentController.java b/src/main/java/com/huoran/iasf/controller/SysContentController.java index d44a2f1..99f94a0 100644 --- a/src/main/java/com/huoran/iasf/controller/SysContentController.java +++ b/src/main/java/com/huoran/iasf/controller/SysContentController.java @@ -16,6 +16,7 @@ import io.swagger.annotations.*; import com.huoran.iasf.common.utils.R; import org.apache.ibatis.annotations.Update; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; @@ -49,8 +50,9 @@ public class SysContentController { public SysContentFileService fileService; + @PostMapping("/pagingQuery") - @ApiOperation(value = "分页查询", response = PageContentRespVO.class) + @ApiOperation(value = "分页查询文章列表", response = PageContentRespVO.class) public R pagingQuery(@RequestBody @Valid @ApiParam(name = "分页查询参数", value = "传入json格式", required = true) PageContentReqVO sysContent) { return service.articlePaginationList(sysContent); } @@ -150,5 +152,12 @@ public class SysContentController { return ret ? R.success() : R.fail("禁用/启用失败"); } + @PostMapping("/articlePreview") + @ApiOperation(value = "增加文章浏览量(点击一次算一次)", response = SysContent.class) + public R articlePreview(@ApiParam(name = "contentId", value = "文章id", required = true) @RequestParam Integer contentId) { + return R.success(service.statisticsOfPageViews(contentId)); + + } + } diff --git a/src/main/java/com/huoran/iasf/mapper/xml/SysContentMapper.xml b/src/main/java/com/huoran/iasf/mapper/xml/SysContentMapper.xml index 2a9c491..735cf60 100644 --- a/src/main/java/com/huoran/iasf/mapper/xml/SysContentMapper.xml +++ b/src/main/java/com/huoran/iasf/mapper/xml/SysContentMapper.xml @@ -88,11 +88,11 @@ - + and unix_timestamp(activity_start_time) = ]]> unix_timestamp(NOW()) - + and unix_timestamp(activity_start_time) unix_timestamp(NOW()) diff --git a/src/main/java/com/huoran/iasf/service/SysContentService.java b/src/main/java/com/huoran/iasf/service/SysContentService.java index 5513b0e..2f21d10 100644 --- a/src/main/java/com/huoran/iasf/service/SysContentService.java +++ b/src/main/java/com/huoran/iasf/service/SysContentService.java @@ -24,4 +24,8 @@ public interface SysContentService extends IService { R publishedEnabledArticles(); R getTheFullArticleByColumn(String ids); + + //统计浏览 + Integer statisticsOfPageViews(Integer id); + } \ No newline at end of file diff --git a/src/main/java/com/huoran/iasf/service/impl/SysContentServiceImpl.java b/src/main/java/com/huoran/iasf/service/impl/SysContentServiceImpl.java index 48c0e52..f6368a7 100644 --- a/src/main/java/com/huoran/iasf/service/impl/SysContentServiceImpl.java +++ b/src/main/java/com/huoran/iasf/service/impl/SysContentServiceImpl.java @@ -1,6 +1,7 @@ package com.huoran.iasf.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -12,6 +13,7 @@ import com.huoran.iasf.service.SysContentService; import com.huoran.iasf.vo.req.ContentHeavyTitleReqVO; import com.huoran.iasf.vo.req.PageContentReqVO; import com.huoran.iasf.vo.resp.PageContentRespVO; +import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Service; import org.springframework.beans.factory.annotation.Autowired; @@ -28,6 +30,9 @@ public class SysContentServiceImpl extends ServiceImpl queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("site_id", reqVO.getSiteId()); - queryWrapper.eq("is_release", Constant.ARTICLE_PUBLISHED).orderByDesc("create_time");*/ Page page = new Page(reqVO.getPageNum(), reqVO.getPageSize()); IPage pageList = baseMapper.getPublishedArticles(page, reqVO); return R.success(pageList); @@ -73,7 +75,6 @@ public class SysContentServiceImpl extends ServiceImpl sysContentList = mapper.selectList(queryWrapper); - return R.success(sysContentList); } @@ -83,7 +84,26 @@ public class SysContentServiceImpl extends ServiceImpl