增加了elasticsearch全局搜索和文章内搜索

This commit is contained in:
暮光:城中城
2019-07-11 23:36:30 +08:00
parent 9a50db6b5d
commit a081443c91
21 changed files with 1132 additions and 131 deletions

View File

@@ -69,6 +69,16 @@ public class WikiPageContent implements Serializable {
*/
private String preview;
/**
* 空间ID
*/
private Long spaceId;
/**
* 名字
*/
private String name;
public Long getId() {
return id;
}
@@ -155,4 +165,20 @@ public class WikiPageContent implements Serializable {
public void setPreview(String preview) {
this.preview = preview;
}
public Long getSpaceId() {
return spaceId;
}
public void setSpaceId(Long spaceId) {
this.spaceId = spaceId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}

View File

@@ -2,6 +2,10 @@ package com.zyplayer.doc.data.repository.manage.mapper;
import com.zyplayer.doc.data.repository.manage.entity.WikiPageContent;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zyplayer.doc.data.repository.manage.param.SearchByEsParam;
import com.zyplayer.doc.data.repository.manage.vo.SpaceNewsVo;
import java.util.List;
/**
* <p>
@@ -12,5 +16,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
* @since 2019-02-24
*/
public interface WikiPageContentMapper extends BaseMapper<WikiPageContent> {
List<SpaceNewsVo> getNewsList(SearchByEsParam param);
}

View File

@@ -0,0 +1,64 @@
package com.zyplayer.doc.data.repository.manage.param;
import java.util.List;
public class SearchByEsParam {
private Long spaceId;
private String keywords;
private Integer pageNum;
private Integer pageSize;
private Integer newsType;
private List<Long> spaceIds;
public Integer getPageNum() {
return pageNum;
}
public void setPageNum(Integer pageNum) {
this.pageNum = pageNum;
}
public Integer getPageSize() {
return pageSize;
}
public Integer getStartIndex() {
return (pageNum - 1) * pageSize;
}
public void setPageSize(Integer pageSize) {
this.pageSize = pageSize;
}
public Long getSpaceId() {
return spaceId;
}
public void setSpaceId(Long spaceId) {
this.spaceId = spaceId;
}
public String getKeywords() {
return keywords;
}
public void setKeywords(String keywords) {
this.keywords = keywords;
}
public Integer getNewsType() {
return newsType;
}
public void setNewsType(Integer newsType) {
this.newsType = newsType;
}
public List<Long> getSpaceIds() {
return spaceIds;
}
public void setSpaceIds(List<Long> spaceIds) {
this.spaceIds = spaceIds;
}
}

View File

@@ -0,0 +1,106 @@
package com.zyplayer.doc.data.repository.manage.vo;
import java.util.Date;
public class SpaceNewsVo {
private Long spaceId;
private Long pageId;
private Integer zanNum;
private Integer viewNum;
private String createUserName;
private String updateUserName;
private Date createTime;
private Date updateTime;
private String spaceName;
private String pageTitle;
private String previewContent;
public Long getPageId() {
return pageId;
}
public void setPageId(Long pageId) {
this.pageId = pageId;
}
public Integer getZanNum() {
return zanNum;
}
public void setZanNum(Integer zanNum) {
this.zanNum = zanNum;
}
public Integer getViewNum() {
return viewNum;
}
public void setViewNum(Integer viewNum) {
this.viewNum = viewNum;
}
public String getCreateUserName() {
return createUserName;
}
public void setCreateUserName(String createUserName) {
this.createUserName = createUserName;
}
public String getUpdateUserName() {
return updateUserName;
}
public void setUpdateUserName(String updateUserName) {
this.updateUserName = updateUserName;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public String getSpaceName() {
return spaceName;
}
public void setSpaceName(String spaceName) {
this.spaceName = spaceName;
}
public String getPageTitle() {
return pageTitle;
}
public void setPageTitle(String pageTitle) {
this.pageTitle = pageTitle;
}
public String getPreviewContent() {
return previewContent;
}
public void setPreviewContent(String previewContent) {
this.previewContent = previewContent;
}
public Long getSpaceId() {
return spaceId;
}
public void setSpaceId(Long spaceId) {
this.spaceId = spaceId;
}
}

View File

@@ -1,5 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zyplayer.doc.data.repository.manage.mapper.WikiPageContentMapper">
<select id="getNewsList" resultType="com.zyplayer.doc.data.repository.manage.vo.SpaceNewsVo">
select a.space_id as spaceId, a.id as pageId, a.zan_num as zanNum, a.view_num as viewNum,
a.create_user_name as createUserName, a.update_user_name as updateUserName, a.create_time as createTime,
a.update_time as updateTime, a.name as pageTitle, b.preview as previewContent
from wiki_page a
join wiki_page_content b on b.page_id = a.id
where a.del_flag = 0
<if test="keywords != null and keywords != ''">
and (
a.name like #{keywords} or b.preview like #{keywords}
)
</if>
<if test="spaceIds != null and spaceIds.size > 0">
and a.space_id in
<foreach collection="spaceIds" open="(" close=")" item="item" separator=",">#{item}</foreach>
</if>
<if test="newsType == 1">order by a.update_time desc</if>
<if test="newsType == 2">order by a.create_time desc</if>
<if test="newsType == 3">order by a.view_num desc</if>
<if test="newsType == 4">order by a.zan_num desc</if>
<if test="newsType == 5">order by a.view_num+a.zan_num desc</if>
</select>
</mapper>