列表排序、全局搜索功能

master
rong.liu 2 years ago
parent 1444047b94
commit efe48afa15
  1. 14
      src/main/java/com/huoran/iasf/controller/SysContentController.java
  2. 2
      src/main/java/com/huoran/iasf/mapper/SysContentMapper.java
  3. 39
      src/main/java/com/huoran/iasf/mapper/xml/SysContentMapper.xml
  4. 8
      src/main/java/com/huoran/iasf/service/SysContentService.java
  5. 20
      src/main/java/com/huoran/iasf/service/impl/SysColumnServiceImpl.java
  6. 18
      src/main/java/com/huoran/iasf/service/impl/SysContentServiceImpl.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);
}
}

@ -26,4 +26,6 @@ public interface SysContentMapper extends BaseMapper<SysContent> {
IPage<PageContentRespVO> getPublishedArticles(Page<PageContentRespVO> page, @Param("req") PageContentReqVO req);
List<SysContentClassification> useTheColumnToGetTagsForTheFullArticle(String ids);
IPage<SysContent> siteSearchArticles(Page<SysContent> page, @Param("req") PageContentReqVO req);
}

@ -88,16 +88,26 @@
</if>
<if test="req.convokeType == 1">
and unix_timestamp(activity_start_time) <![CDATA[ >= ]]> unix_timestamp(NOW())
</if>
<choose>
<when test="req.convokeType !=null">
<if test="req.convokeType == 1">
and unix_timestamp(activity_start_time) <![CDATA[ >= ]]> unix_timestamp(NOW())
ORDER BY t.activity_start_time asc
</if>
<if test="req.convokeType == 2">
and unix_timestamp(activity_start_time) <![CDATA[ <= ]]> unix_timestamp(NOW())
ORDER BY t.activity_start_time desc
</if>
</when>
<otherwise>
ORDER BY
t.create_time DESC
</otherwise>
</choose>
<if test="req.convokeType == 2">
and unix_timestamp(activity_start_time) <![CDATA[ <= ]]> unix_timestamp(NOW())
</if>
ORDER BY
t.create_time DESC
</select>
<select id="useTheColumnToGetTagsForTheFullArticle" resultType="com.huoran.iasf.entity.SysContentClassification">
@ -114,6 +124,19 @@
AND FIND_IN_SET(s.column_id, #{ids}))
)
</select>
<select id="siteSearchArticles" resultType="com.huoran.iasf.entity.SysContent">
SELECT
c.*
FROM
sys_content c
WHERE
deleted = 1
AND site_id = 1
<if test="req.title != null and req.title != ''">
AND title LIKE
CONCAT('%',#{req.title},'%')
</if>
</select>
</mapper>

@ -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<SysContent> {
//统计浏览
Integer statisticsOfPageViews(Integer id);
List<SysContent> hotContent(Integer sideId);
R siteSearchArticles(PageContentReqVO req);
}

@ -138,25 +138,7 @@ public class SysColumnServiceImpl extends ServiceImpl<SysColumnMapper, SysColumn
public R getsTheSubColumn(Integer pid, String ids) {
List<SysColumn> getsTheSubColumn = baseMapper.getsTheSubColumn(pid, ids);
//用来保存父节点
List<SysColumn> rootColumn = new ArrayList<>();
//用来保存子节点
List<SysColumn> 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));

@ -105,6 +105,24 @@ public class SysContentServiceImpl extends ServiceImpl<SysContentMapper, SysCont
return Integer.valueOf(returnValue);
}
@Override
public List<SysContent> hotContent(Integer siteId) {
QueryWrapper<SysContent> 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<SysContent> contentList = baseMapper.selectList(queryWrapper);
return contentList;
}
@Override
public R siteSearchArticles(PageContentReqVO reqVO) {
Page<SysContent> page = new Page<SysContent>(reqVO.getPageNum(), reqVO.getPageSize());
IPage<SysContent> pageList = baseMapper.siteSearchArticles(page, reqVO);
return R.success(pageList);
}
}

Loading…
Cancel
Save