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