From efe48afa15c9ce1e91bcc75f04d6cbce1ac5195d Mon Sep 17 00:00:00 2001 From: "rong.liu" Date: Tue, 29 Nov 2022 18:07:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=97=E8=A1=A8=E6=8E=92=E5=BA=8F=E3=80=81?= =?UTF-8?q?=E5=85=A8=E5=B1=80=E6=90=9C=E7=B4=A2=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iasf/controller/SysContentController.java | 14 +++++++ .../huoran/iasf/mapper/SysContentMapper.java | 2 + .../iasf/mapper/xml/SysContentMapper.xml | 39 +++++++++++++++---- .../iasf/service/SysContentService.java | 8 ++++ .../service/impl/SysColumnServiceImpl.java | 20 +--------- .../service/impl/SysContentServiceImpl.java | 18 +++++++++ 6 files changed, 74 insertions(+), 27 deletions(-) diff --git a/src/main/java/com/huoran/iasf/controller/SysContentController.java b/src/main/java/com/huoran/iasf/controller/SysContentController.java index 99f94a0..8088d22 100644 --- a/src/main/java/com/huoran/iasf/controller/SysContentController.java +++ b/src/main/java/com/huoran/iasf/controller/SysContentController.java @@ -159,5 +159,19 @@ public class SysContentController { } + + @PostMapping("/hotContent") + @ApiOperation(value = "热点内容", response = SysContent.class) + public R hotContent(@ApiParam(name = "siteId", value = "站点id", required = true) @RequestParam Integer siteId) { + return R.success(service.hotContent(siteId)); + + } + + @PostMapping("/siteSearchArticles") + @ApiOperation(value = "站点搜索文章", response = SysContent.class) + public R siteSearchArticles(@RequestBody PageContentReqVO req) { + return service.siteSearchArticles(req); + + } } diff --git a/src/main/java/com/huoran/iasf/mapper/SysContentMapper.java b/src/main/java/com/huoran/iasf/mapper/SysContentMapper.java index bdb0e15..1cd243f 100644 --- a/src/main/java/com/huoran/iasf/mapper/SysContentMapper.java +++ b/src/main/java/com/huoran/iasf/mapper/SysContentMapper.java @@ -26,4 +26,6 @@ public interface SysContentMapper extends BaseMapper { IPage getPublishedArticles(Page page, @Param("req") PageContentReqVO req); List useTheColumnToGetTagsForTheFullArticle(String ids); + + IPage siteSearchArticles(Page page, @Param("req") PageContentReqVO req); } \ No newline at end of file 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 735cf60..ab2b11c 100644 --- a/src/main/java/com/huoran/iasf/mapper/xml/SysContentMapper.xml +++ b/src/main/java/com/huoran/iasf/mapper/xml/SysContentMapper.xml @@ -88,16 +88,26 @@ - - and unix_timestamp(activity_start_time) = ]]> unix_timestamp(NOW()) - + + + + and unix_timestamp(activity_start_time) = ]]> unix_timestamp(NOW()) + ORDER BY t.activity_start_time asc + + + + and unix_timestamp(activity_start_time) unix_timestamp(NOW()) + ORDER BY t.activity_start_time desc + + + + + ORDER BY + t.create_time DESC + + - - and unix_timestamp(activity_start_time) unix_timestamp(NOW()) - - ORDER BY - t.create_time DESC + \ No newline at end of file diff --git a/src/main/java/com/huoran/iasf/service/SysContentService.java b/src/main/java/com/huoran/iasf/service/SysContentService.java index 2f21d10..ccc5615 100644 --- a/src/main/java/com/huoran/iasf/service/SysContentService.java +++ b/src/main/java/com/huoran/iasf/service/SysContentService.java @@ -1,9 +1,13 @@ package com.huoran.iasf.service; + import com.huoran.iasf.common.utils.R; import com.huoran.iasf.entity.SysContent; import com.baomidou.mybatisplus.extension.service.IService; import com.huoran.iasf.vo.req.ContentHeavyTitleReqVO; import com.huoran.iasf.vo.req.PageContentReqVO; +import org.springframework.web.bind.annotation.RequestBody; + +import java.util.List; /** * @描述:文章管理 service接口 @@ -28,4 +32,8 @@ public interface SysContentService extends IService { //统计浏览 Integer statisticsOfPageViews(Integer id); + List hotContent(Integer sideId); + + R siteSearchArticles(PageContentReqVO req); + } \ No newline at end of file diff --git a/src/main/java/com/huoran/iasf/service/impl/SysColumnServiceImpl.java b/src/main/java/com/huoran/iasf/service/impl/SysColumnServiceImpl.java index eaa9361..b8b3ab2 100644 --- a/src/main/java/com/huoran/iasf/service/impl/SysColumnServiceImpl.java +++ b/src/main/java/com/huoran/iasf/service/impl/SysColumnServiceImpl.java @@ -138,25 +138,7 @@ public class SysColumnServiceImpl extends ServiceImpl getsTheSubColumn = baseMapper.getsTheSubColumn(pid, ids); - //用来保存父节点 - List rootColumn = new ArrayList<>(); - //用来保存子节点 - List childList = new ArrayList<>(); - //遍历所有栏目,将所有栏目的父栏目id为0的栏目放入父节点集合中 - for (SysColumn column1 : getsTheSubColumn) { - Integer parentId = column1.getFatherId(); - if (parentId == 0) { - rootColumn.add(column1); - } - } - for (SysColumn sysColumn : rootColumn) { - Integer theColumnId = sysColumn.getId(); - //调用工具类获取子节点 - childList = getChildren(theColumnId, getsTheSubColumn); - sysColumn.setChildren(childList); - } - - return R.success(rootColumn); + return R.success( buildTree(getsTheSubColumn,pid)); //return R.success(baseMapper.getsTheSubColumn(parentId, ids)); 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 f6368a7..cb268d4 100644 --- a/src/main/java/com/huoran/iasf/service/impl/SysContentServiceImpl.java +++ b/src/main/java/com/huoran/iasf/service/impl/SysContentServiceImpl.java @@ -105,6 +105,24 @@ public class SysContentServiceImpl extends ServiceImpl hotContent(Integer siteId) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("deleted", Constant.DATA_NOT_DELETED); + queryWrapper.eq("site_id", siteId); + queryWrapper.last(" ORDER BY total_browsing desc LIMIT 0,5"); + + List contentList = baseMapper.selectList(queryWrapper); + return contentList; + } + + @Override + public R siteSearchArticles(PageContentReqVO reqVO) { + Page page = new Page(reqVO.getPageNum(), reqVO.getPageSize()); + IPage pageList = baseMapper.siteSearchArticles(page, reqVO); + return R.success(pageList); + } + }