#I636K1 全局搜索优化
This commit is contained in:
160
zyplayer-doc-ui/wiki-ui/package-lock.json
generated
160
zyplayer-doc-ui/wiki-ui/package-lock.json
generated
@@ -1880,6 +1880,44 @@
|
||||
"integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==",
|
||||
"dev": true
|
||||
},
|
||||
"ansi-styles": {
|
||||
"version": "4.3.0",
|
||||
"resolved": "https://registry.npmmirror.com/ansi-styles/-/ansi-styles-4.3.0.tgz",
|
||||
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"color-convert": "^2.0.1"
|
||||
}
|
||||
},
|
||||
"chalk": {
|
||||
"version": "4.1.2",
|
||||
"resolved": "https://registry.npmmirror.com/chalk/-/chalk-4.1.2.tgz",
|
||||
"integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"ansi-styles": "^4.1.0",
|
||||
"supports-color": "^7.1.0"
|
||||
}
|
||||
},
|
||||
"color-convert": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmmirror.com/color-convert/-/color-convert-2.0.1.tgz",
|
||||
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"color-name": "~1.1.4"
|
||||
}
|
||||
},
|
||||
"color-name": {
|
||||
"version": "1.1.4",
|
||||
"resolved": "https://registry.npmmirror.com/color-name/-/color-name-1.1.4.tgz",
|
||||
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"debug": {
|
||||
"version": "4.3.3",
|
||||
"resolved": "https://registry.npmmirror.com/debug/download/debug-4.3.3.tgz",
|
||||
@@ -1889,6 +1927,25 @@
|
||||
"ms": "2.1.2"
|
||||
}
|
||||
},
|
||||
"has-flag": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmmirror.com/has-flag/-/has-flag-4.0.0.tgz",
|
||||
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"loader-utils": {
|
||||
"version": "2.0.4",
|
||||
"resolved": "https://registry.npmmirror.com/loader-utils/-/loader-utils-2.0.4.tgz",
|
||||
"integrity": "sha512-xXqpXoINfFhgua9xiqD8fPFHgkoq1mmmpE92WlDbm9rNRd/EbRb+Gqf908T2DMfuHjjJlksiK2RbHVOdD/MqSw==",
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"big.js": "^5.2.2",
|
||||
"emojis-list": "^3.0.0",
|
||||
"json5": "^2.1.2"
|
||||
}
|
||||
},
|
||||
"ms": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmmirror.com/ms/download/ms-2.1.2.tgz",
|
||||
@@ -1903,6 +1960,28 @@
|
||||
"requires": {
|
||||
"minipass": "^3.1.1"
|
||||
}
|
||||
},
|
||||
"supports-color": {
|
||||
"version": "7.2.0",
|
||||
"resolved": "https://registry.npmmirror.com/supports-color/-/supports-color-7.2.0.tgz",
|
||||
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"has-flag": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"vue-loader-v16": {
|
||||
"version": "npm:vue-loader@16.8.3",
|
||||
"resolved": "https://registry.npmmirror.com/vue-loader/-/vue-loader-16.8.3.tgz",
|
||||
"integrity": "sha512-7vKN45IxsKxe5GcVCbc2qFU5aWzyiLrYJyUuMz4BQLKctCj/fmCa0w6fGiiQ2cLFetNcek1ppGJQDCup0c1hpA==",
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"chalk": "^4.1.0",
|
||||
"hash-sum": "^2.0.0",
|
||||
"loader-utils": "^2.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -11791,87 +11870,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"vue-loader-v16": {
|
||||
"version": "npm:vue-loader@16.8.3",
|
||||
"resolved": "https://registry.npmmirror.com/vue-loader/download/vue-loader-16.8.3.tgz",
|
||||
"integrity": "sha512-7vKN45IxsKxe5GcVCbc2qFU5aWzyiLrYJyUuMz4BQLKctCj/fmCa0w6fGiiQ2cLFetNcek1ppGJQDCup0c1hpA==",
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"chalk": "^4.1.0",
|
||||
"hash-sum": "^2.0.0",
|
||||
"loader-utils": "^2.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"ansi-styles": {
|
||||
"version": "4.3.0",
|
||||
"resolved": "https://registry.npmmirror.com/ansi-styles/download/ansi-styles-4.3.0.tgz",
|
||||
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"color-convert": "^2.0.1"
|
||||
}
|
||||
},
|
||||
"chalk": {
|
||||
"version": "4.1.2",
|
||||
"resolved": "https://registry.npmmirror.com/chalk/download/chalk-4.1.2.tgz",
|
||||
"integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"ansi-styles": "^4.1.0",
|
||||
"supports-color": "^7.1.0"
|
||||
}
|
||||
},
|
||||
"color-convert": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmmirror.com/color-convert/download/color-convert-2.0.1.tgz",
|
||||
"integrity": "sha1-ctOmjVmMm9s68q0ehPIdiWq9TeM=",
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"color-name": "~1.1.4"
|
||||
}
|
||||
},
|
||||
"color-name": {
|
||||
"version": "1.1.4",
|
||||
"resolved": "https://registry.npmmirror.com/color-name/download/color-name-1.1.4.tgz",
|
||||
"integrity": "sha1-wqCah6y95pVD3m9j+jmVyCbFNqI=",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"has-flag": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmmirror.com/has-flag/download/has-flag-4.0.0.tgz",
|
||||
"integrity": "sha1-lEdx/ZyByBJlxNaUGGDaBrtZR5s=",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"loader-utils": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmmirror.com/loader-utils/download/loader-utils-2.0.2.tgz",
|
||||
"integrity": "sha1-1uO0+4GHByGuTghoqxHdY4NowSk=",
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"big.js": "^5.2.2",
|
||||
"emojis-list": "^3.0.0",
|
||||
"json5": "^2.1.2"
|
||||
}
|
||||
},
|
||||
"supports-color": {
|
||||
"version": "7.2.0",
|
||||
"resolved": "https://registry.npmmirror.com/supports-color/download/supports-color-7.2.0.tgz",
|
||||
"integrity": "sha1-G33NyzK4E4gBs+R4umpRyqiWSNo=",
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"has-flag": "^4.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"vue-router": {
|
||||
"version": "3.5.3",
|
||||
"resolved": "https://registry.npmmirror.com/vue-router/download/vue-router-3.5.3.tgz",
|
||||
|
||||
@@ -17,9 +17,22 @@
|
||||
<div align="center">
|
||||
<el-button v-on:click="createWiki" icon="el-icon-plus" style="width: 100%;">创建文档</el-button>
|
||||
</div>
|
||||
<el-input v-model="searchKeywords" @input="searchByKeywords" @keyup.enter.native="searchByKeywords" placeholder="搜索文档" style="margin: 10px 0;">
|
||||
<el-button slot="append" icon="el-icon-search" v-on:click="searchByKeywordsNewPage"></el-button>
|
||||
</el-input>
|
||||
<el-autocomplete
|
||||
style="width: 100%;margin: 10px 0;" popper-class="search-autocomplete"
|
||||
v-model="searchKeywords"
|
||||
:fetch-suggestions="doSearchByKeywords"
|
||||
placeholder="在当前空间搜索"
|
||||
@select="handleSearchKeywordsSelect"
|
||||
>
|
||||
<template slot-scope="{ item }">
|
||||
<div class="search-option-item">
|
||||
<div class="title">
|
||||
<span v-html="item.pageTitle || '-'"></span>
|
||||
</div>
|
||||
<span class="content" v-html="item.previewContent || '-'"></span>
|
||||
</div>
|
||||
</template>
|
||||
</el-autocomplete>
|
||||
<div style="overflow: auto; padding-bottom: 30px;">
|
||||
<el-tree :props="defaultProps" :data="wikiPageList" @node-click="handleNodeClick"
|
||||
@node-expand="handleNodeExpand" draggable @node-drop="handlePageDrop"
|
||||
@@ -96,13 +109,13 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import userApi from '../../common/api/user'
|
||||
import pageApi from '../../common/api/page'
|
||||
import CreateSpace from '../space/CreateSpace'
|
||||
import RightResize from './RightResize.vue'
|
||||
import aboutDialog from "../../views/common/AboutDialog";
|
||||
import userApi from '../../common/api/user'
|
||||
import pageApi from '../../common/api/page'
|
||||
import CreateSpace from '../space/CreateSpace'
|
||||
import RightResize from './RightResize.vue'
|
||||
import aboutDialog from "../../views/common/AboutDialog";
|
||||
|
||||
export default {
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
leftCollapse: true,
|
||||
@@ -176,6 +189,20 @@
|
||||
changeWikiPageExpandedKeys(pageId) {
|
||||
// 展开没有触发子节点的加载,如果去加载子节点有还找不到当前的node,暂不展开
|
||||
// this.wikiPageExpandedKeys = [pageId];
|
||||
},
|
||||
doSearchByKeywords(queryString, callback) {
|
||||
if (!queryString || !queryString.trim()) {
|
||||
callback([]);
|
||||
return;
|
||||
}
|
||||
pageApi.pageNews({spaceId: this.choiceSpace, keywords: queryString}).then(json => {
|
||||
let spacePageNews = json.data || [];
|
||||
callback(spacePageNews);
|
||||
});
|
||||
},
|
||||
handleSearchKeywordsSelect(item) {
|
||||
this.searchKeywords = '';
|
||||
this.$router.push({path: '/page/show', query: {pageId: item.pageId}});
|
||||
},
|
||||
searchByKeywords() {
|
||||
this.$refs.wikiPageTree.filter(this.searchKeywords);
|
||||
@@ -305,32 +332,9 @@
|
||||
});
|
||||
},
|
||||
doGetPageList(parentId, node) {
|
||||
let param = {spaceId: this.choiceSpace, parentId: parentId || 0};
|
||||
if (this.nowSpaceShow.treeLazyLoad === 0) {
|
||||
param.parentId = null;
|
||||
}
|
||||
let param = {spaceId: this.choiceSpace};
|
||||
pageApi.pageList(param).then(json => {
|
||||
let result = json.data || [];
|
||||
let treeData = [];
|
||||
if (this.nowSpaceShow.treeLazyLoad === 0) {
|
||||
treeData = result;
|
||||
} else {
|
||||
for (let i = 0; i < result.length; i++) {
|
||||
let item = result[i];
|
||||
item.parentId = item.parentId || 0;
|
||||
item.children = [{name: '加载中...', needLoad: true}];// 初始化一个对象,点击展开时重新查询加载
|
||||
treeData.push(item);
|
||||
}
|
||||
}
|
||||
if (parentId > 0) {
|
||||
node.children = treeData;
|
||||
} else {
|
||||
this.wikiPageList = treeData;
|
||||
}
|
||||
}).catch(() => {
|
||||
if (parentId > 0) {
|
||||
node.children = [];
|
||||
}
|
||||
this.wikiPageList = json.data || [];
|
||||
});
|
||||
},
|
||||
userSettingDropdown(command) {
|
||||
@@ -401,4 +405,24 @@
|
||||
.head-icon{margin-right: 15px; font-size: 16px;cursor: pointer;color: #fff;}
|
||||
.header-user-message .page-info-box{text-align: right;margin-top: 10px;}
|
||||
.upgrade-info{max-height: 150px;overflow-y: auto;word-break: break-all; white-space: pre-wrap; line-height: 26px;}
|
||||
.search-option-item {
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.search-option-item .title {
|
||||
font-weight: bold;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.search-option-item .content {
|
||||
font-size: 12px;
|
||||
color: #888;
|
||||
}
|
||||
.search-autocomplete {
|
||||
width: 600px !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
|
||||
@@ -12,9 +12,6 @@
|
||||
<el-form-item label="空间开放:">
|
||||
<el-switch v-model="newSpaceForm.openDoc" inactive-text="需要登录" :inactive-value="0" active-text="开放访问" :active-value="1"></el-switch>
|
||||
</el-form-item>
|
||||
<el-form-item label="目录加载:">
|
||||
<el-switch v-model="newSpaceForm.treeLazyLoad" inactive-text="预先加载" :inactive-value="0" active-text="延迟加载" :active-value="1"></el-switch>
|
||||
</el-form-item>
|
||||
<el-form-item label="空间类型:">
|
||||
<el-select v-model="newSpaceForm.type" filterable placeholder="选择类型" style="width: 100%;">
|
||||
<el-option :key="1" label="公共空间" :value="1">
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
<a target="_blank" href="https://github.com/alibaba/fastjson">Fastjson</a>、
|
||||
<a target="_blank" href="https://alibaba-easyexcel.github.io">Easy Excel</a>、
|
||||
<a target="_blank" href="https://swagger.io">Swagger</a>、
|
||||
<a target="_blank" href="https://dubbo.io">Dubbo</a>、
|
||||
<a target="_blank" href="http://www.eclipse.org/jgit">JGit</a>、...
|
||||
</div>
|
||||
<el-divider content-position="left">前端</el-divider>
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
<template>
|
||||
<div style="padding: 10px;" class="home-vue">
|
||||
<div style="max-width: 800px;margin: 0 auto;">
|
||||
<el-select v-model="searchParam.newsType" v-on:change="getSpacePageNews" placeholder="请选择查看方式" style="float: right;z-index: 1;">
|
||||
<el-option :label="item.val" :value="item.key" :key="item.key" v-for="item in newsTypesArr"></el-option>
|
||||
</el-select>
|
||||
<el-tabs value="first">
|
||||
<el-tab-pane :label="newsTypesMap[searchParam.newsType]" name="first">
|
||||
<div v-if="spacePageNews.length <= 0" class="empty-news">暂无数据</div>
|
||||
@@ -23,18 +20,6 @@
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
<div class="page-info-box">
|
||||
<el-pagination
|
||||
@size-change="handleSizeChange"
|
||||
@current-change="handleCurrentChange"
|
||||
:page-sizes="[20, 50, 100]"
|
||||
:page-size="20"
|
||||
:current-page="searchParam.pageNum"
|
||||
layout="prev, pager, next, jumper, sizes, total"
|
||||
:total="totalCount"
|
||||
>
|
||||
</el-pagination>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -72,7 +57,6 @@
|
||||
getSpacePageNews() {
|
||||
pageApi.pageNews(this.searchParam).then(json => {
|
||||
this.spacePageNews = json.data || [];
|
||||
this.totalCount = json.total;
|
||||
});
|
||||
},
|
||||
handleSizeChange(val) {
|
||||
|
||||
@@ -2,9 +2,6 @@ package com.zyplayer.doc.wiki.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.github.dozermapper.core.Mapper;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.zyplayer.doc.core.json.DocResponseJson;
|
||||
import com.zyplayer.doc.core.json.ResponseJson;
|
||||
import com.zyplayer.doc.data.repository.manage.entity.WikiPage;
|
||||
@@ -53,8 +50,6 @@ public class WikiOpenApiController {
|
||||
WikiPageFileService wikiPageFileService;
|
||||
@Resource
|
||||
WikiPageContentMapper wikiPageContentMapper;
|
||||
@Resource
|
||||
Mapper mapper;
|
||||
|
||||
@PostMapping("/space/info")
|
||||
public ResponseJson<WikiSpace> spaceInfo(String space) {
|
||||
@@ -77,9 +72,7 @@ public class WikiOpenApiController {
|
||||
}
|
||||
// 分页查询
|
||||
param.setSpaceIds(Collections.singletonList(wikiSpace.getId()));
|
||||
PageHelper.startPage(param.getPageNum(), param.getPageSize(), true);
|
||||
List<SpaceNewsVo> spaceNewsVoList = wikiPageContentMapper.getNewsList(param);
|
||||
PageInfo<SpaceNewsVo> pageListPageInfo = new PageInfo<>(spaceNewsVoList);
|
||||
if (CollectionUtils.isNotEmpty(spaceNewsVoList)) {
|
||||
spaceNewsVoList.forEach(val -> {
|
||||
val.setSpace(wikiSpace.getUuid());
|
||||
@@ -101,7 +94,7 @@ public class WikiOpenApiController {
|
||||
val.setPageTitle(pageTitle);
|
||||
});
|
||||
}
|
||||
return DocResponseJson.ok(pageListPageInfo);
|
||||
return DocResponseJson.ok(spaceNewsVoList);
|
||||
}
|
||||
|
||||
@PostMapping("/page/list")
|
||||
@@ -117,10 +110,10 @@ public class WikiOpenApiController {
|
||||
if (CollectionUtils.isEmpty(wikiPageList)) {
|
||||
return DocResponseJson.ok();
|
||||
}
|
||||
Map<Long, List<WikiPageVo>> listMap = wikiPageList.stream().map(val -> mapper.map(val, WikiPageVo.class)).collect(Collectors.groupingBy(WikiPageVo::getParentId));
|
||||
Map<Long, List<WikiPageVo>> listMap = wikiPageList.stream().map(WikiPageVo::new).collect(Collectors.groupingBy(WikiPageVo::getParentId));
|
||||
List<WikiPageVo> nodePageList = listMap.get(0L);
|
||||
if (CollectionUtils.isNotEmpty(nodePageList)) {
|
||||
nodePageList = nodePageList.stream().sorted(Comparator.comparingInt(WikiPage::getSeqNo)).collect(Collectors.toList());
|
||||
nodePageList = nodePageList.stream().sorted(Comparator.comparingInt(WikiPageVo::getSeqNo)).collect(Collectors.toList());
|
||||
this.setChildren(listMap, nodePageList);
|
||||
}
|
||||
return DocResponseJson.ok(nodePageList);
|
||||
@@ -169,7 +162,7 @@ public class WikiOpenApiController {
|
||||
for (WikiPageVo page : nodePageList) {
|
||||
List<WikiPageVo> wikiPageVos = listMap.get(page.getId());
|
||||
if (CollectionUtils.isNotEmpty(wikiPageVos)) {
|
||||
wikiPageVos = wikiPageVos.stream().sorted(Comparator.comparingInt(WikiPage::getSeqNo)).collect(Collectors.toList());
|
||||
wikiPageVos = wikiPageVos.stream().sorted(Comparator.comparingInt(WikiPageVo::getSeqNo)).collect(Collectors.toList());
|
||||
page.setChildren(wikiPageVos);
|
||||
this.setChildren(listMap, wikiPageVos);
|
||||
}
|
||||
|
||||
@@ -2,8 +2,6 @@ package com.zyplayer.doc.wiki.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.zyplayer.doc.core.annotation.AuthMan;
|
||||
import com.zyplayer.doc.core.exception.ConfirmException;
|
||||
import com.zyplayer.doc.core.json.DocResponseJson;
|
||||
@@ -27,9 +25,7 @@ import com.zyplayer.doc.wiki.service.common.WikiPageAuthService;
|
||||
import com.zyplayer.doc.wiki.service.git.GitService;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import com.github.dozermapper.core.Mapper;
|
||||
import org.apache.poi.poifs.filesystem.DirectoryEntry;
|
||||
import org.apache.poi.poifs.filesystem.DocumentEntry;
|
||||
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -41,7 +37,6 @@ import javax.annotation.Resource;
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -78,8 +73,6 @@ public class WikiPageController {
|
||||
UserMessageService userMessageService;
|
||||
@Resource
|
||||
GitService gitService;
|
||||
@Resource
|
||||
Mapper mapper;
|
||||
|
||||
@PostMapping("/list")
|
||||
public ResponseJson<List<WikiPageVo>> list(WikiPage wikiPage) {
|
||||
@@ -92,22 +85,13 @@ public class WikiPageController {
|
||||
UpdateWrapper<WikiPage> wrapper = new UpdateWrapper<>();
|
||||
wrapper.eq("del_flag", 0);
|
||||
wrapper.eq("space_id", wikiPage.getSpaceId());
|
||||
wrapper.eq(wikiPage.getParentId() != null, "parent_id", wikiPage.getParentId());
|
||||
List<WikiPage> wikiPageList = wikiPageService.list(wrapper);
|
||||
Map<Long, List<WikiPageVo>> listMap = wikiPageList.stream().map(val -> mapper.map(val, WikiPageVo.class)).collect(Collectors.groupingBy(WikiPageVo::getParentId));
|
||||
List<WikiPageVo> nodePageList;
|
||||
if (wikiPage.getParentId() == null) {
|
||||
nodePageList = listMap.get(0L);
|
||||
Map<Long, List<WikiPageVo>> listMap = wikiPageList.stream().map(WikiPageVo::new).collect(Collectors.groupingBy(WikiPageVo::getParentId));
|
||||
List<WikiPageVo> nodePageList = listMap.get(0L);
|
||||
if (CollectionUtils.isNotEmpty(nodePageList)) {
|
||||
nodePageList = nodePageList.stream().sorted(Comparator.comparingInt(WikiPage::getSeqNo)).collect(Collectors.toList());
|
||||
nodePageList = nodePageList.stream().sorted(Comparator.comparingInt(WikiPageVo::getSeqNo)).collect(Collectors.toList());
|
||||
this.setChildren(listMap, nodePageList, "");
|
||||
}
|
||||
} else {
|
||||
nodePageList = listMap.get(wikiPage.getParentId());
|
||||
if (CollectionUtils.isNotEmpty(nodePageList)) {
|
||||
nodePageList = nodePageList.stream().sorted(Comparator.comparingInt(WikiPage::getSeqNo)).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
return DocResponseJson.ok(nodePageList);
|
||||
}
|
||||
|
||||
@@ -253,6 +237,7 @@ public class WikiPageController {
|
||||
UserMessage userMessage = userMessageService.createUserMessage(currentUser, wikiPageSel.getId(), wikiPageSel.getName(), DocSysType.WIKI, UserMsgType.WIKI_PAGE_UPDATE);
|
||||
userMessageService.addWikiMessage(userMessage);
|
||||
} else {
|
||||
Long parentId = Optional.ofNullable(wikiPage.getParentId()).orElse(0L);
|
||||
WikiSpace wikiSpaceSel = wikiSpaceService.getById(wikiPage.getSpaceId());
|
||||
if (wikiSpaceSel == null) {
|
||||
return DocResponseJson.warn("未找到指定的空间!");
|
||||
@@ -265,20 +250,22 @@ public class WikiPageController {
|
||||
if (SpaceType.isOthersPersonal(wikiSpaceSel.getType(), currentUser.getUserId(), wikiSpaceSel.getCreateUserId())) {
|
||||
return DocResponseJson.warn("您没有权限新增该空间的文章!");
|
||||
}
|
||||
if (wikiPage.getParentId() != null && wikiPage.getParentId() > 0) {
|
||||
WikiPage wikiPageParent = wikiPageService.getById(wikiPage.getParentId());
|
||||
if (parentId> 0) {
|
||||
WikiPage wikiPageParent = wikiPageService.getById(parentId);
|
||||
if (!Objects.equals(wikiPage.getSpaceId(), wikiPageParent.getSpaceId())) {
|
||||
return DocResponseJson.warn("当前空间和父页面的空间不一致,请重新选择父页面!");
|
||||
}
|
||||
}
|
||||
Integer lastSeq = wikiPageMapper.getLastSeq(wikiPage.getParentId());
|
||||
lastSeq = Optional.ofNullable(lastSeq).orElse(0);
|
||||
Integer lastSeq = wikiPageMapper.getLastSeq(wikiPage.getSpaceId(), parentId);
|
||||
lastSeq = Optional.ofNullable(lastSeq).orElse(99999);
|
||||
wikiPage.setSeqNo(lastSeq + 1);
|
||||
wikiPage.setCreateTime(new Date());
|
||||
wikiPage.setUpdateTime(new Date());
|
||||
wikiPage.setCreateUserId(currentUser.getUserId());
|
||||
wikiPage.setCreateUserName(currentUser.getUsername());
|
||||
wikiPageService.save(wikiPage);
|
||||
// 重置当前分支的所有节点seq值
|
||||
wikiPageMapper.updateChildrenSeq(wikiPage.getSpaceId(), parentId);
|
||||
// 详情
|
||||
pageContent.setPageId(wikiPage.getId());
|
||||
pageContent.setCreateTime(new Date());
|
||||
@@ -385,11 +372,9 @@ public class WikiPageController {
|
||||
param.setKeywords("%" + keywords + "%");
|
||||
}
|
||||
// 分页查询
|
||||
PageHelper.startPage(param.getPageNum(), param.getPageSize(), true);
|
||||
List<SpaceNewsVo> spaceNewsVoList = wikiPageContentMapper.getNewsList(param);
|
||||
PageInfo<SpaceNewsVo> pageListPageInfo = new PageInfo<>(spaceNewsVoList);
|
||||
if (spaceNewsVoList == null || spaceNewsVoList.isEmpty()) {
|
||||
return DocResponseJson.ok(pageListPageInfo);
|
||||
return DocResponseJson.ok();
|
||||
}
|
||||
spaceNewsVoList.forEach(val -> {
|
||||
val.setSpaceName(wikiSpaceMap.get(val.getSpaceId()).getName());
|
||||
@@ -409,7 +394,7 @@ public class WikiPageController {
|
||||
}
|
||||
val.setPageTitle(pageTitle);
|
||||
});
|
||||
return DocResponseJson.ok(pageListPageInfo);
|
||||
return DocResponseJson.ok(spaceNewsVoList);
|
||||
}
|
||||
|
||||
private Map<Long, WikiSpace> getCanVisitWikiSpace(Long spaceId) {
|
||||
@@ -440,7 +425,7 @@ public class WikiPageController {
|
||||
page.setPath(nowPath);
|
||||
List<WikiPageVo> wikiPageVos = listMap.get(page.getId());
|
||||
if (CollectionUtils.isNotEmpty(wikiPageVos)) {
|
||||
wikiPageVos = wikiPageVos.stream().sorted(Comparator.comparingInt(WikiPage::getSeqNo)).collect(Collectors.toList());
|
||||
wikiPageVos = wikiPageVos.stream().sorted(Comparator.comparingInt(WikiPageVo::getSeqNo)).collect(Collectors.toList());
|
||||
page.setChildren(wikiPageVos);
|
||||
this.setChildren(listMap, wikiPageVos, nowPath);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ import com.zyplayer.doc.wiki.controller.vo.UserSpaceAuthVo;
|
||||
import com.zyplayer.doc.wiki.controller.vo.WikiSpaceVo;
|
||||
import com.zyplayer.doc.wiki.framework.consts.WikiAuthType;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import com.github.dozermapper.core.Mapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@@ -54,8 +53,6 @@ public class WikiSpaceController {
|
||||
WikiSpaceFavoriteService wikiSpaceFavoriteService;
|
||||
@Resource
|
||||
UserSettingService userSettingService;
|
||||
@Resource
|
||||
Mapper mapper;
|
||||
|
||||
@PostMapping("/list")
|
||||
public ResponseJson<List<WikiSpaceVo>> list(WikiSpace wikiSpace, Integer ignoreFavorite) {
|
||||
@@ -65,7 +62,7 @@ public class WikiSpaceController {
|
||||
wrapper.eq(wikiSpace.getId() != null, "id", wikiSpace.getId());
|
||||
wrapper.and(con -> con.and(conSub -> conSub.eq("type", 3).eq("create_user_id", currentUser.getUserId())).or().in("type", 1, 2));
|
||||
List<WikiSpace> spaceList = wikiSpaceService.list(wrapper);
|
||||
List<WikiSpaceVo> spaceVoList = spaceList.stream().map(item -> mapper.map(item, WikiSpaceVo.class)).collect(Collectors.toList());
|
||||
List<WikiSpaceVo> spaceVoList = spaceList.stream().map(WikiSpaceVo::new).collect(Collectors.toList());
|
||||
// 收藏
|
||||
QueryWrapper<WikiSpaceFavorite> favoriteWrapper = new QueryWrapper<>();
|
||||
favoriteWrapper.eq("user_id", currentUser.getUserId());
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.zyplayer.doc.wiki.controller.vo;
|
||||
|
||||
import com.zyplayer.doc.data.repository.manage.entity.WikiPage;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -10,16 +11,260 @@ import java.util.List;
|
||||
* @author 暮光:城中城
|
||||
* @since 2019-03-11
|
||||
*/
|
||||
public class WikiPageVo extends WikiPage {
|
||||
public class WikiPageVo {
|
||||
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 空间ID
|
||||
*/
|
||||
private Long spaceId;
|
||||
|
||||
/**
|
||||
* 名字
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 父ID
|
||||
*/
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 节点类型 0=有子节点 1=终节点
|
||||
*/
|
||||
private Integer nodeType;
|
||||
|
||||
/**
|
||||
* 赞的数量
|
||||
*/
|
||||
private Integer zanNum;
|
||||
|
||||
/**
|
||||
* 编辑类型 0=可编辑 1=不允许编辑
|
||||
*/
|
||||
private Integer editType;
|
||||
|
||||
/**
|
||||
* 是否收藏 0=否 1=是
|
||||
*/
|
||||
private Integer favorite;
|
||||
|
||||
/**
|
||||
* 创建人ID
|
||||
*/
|
||||
private Long createUserId;
|
||||
|
||||
/**
|
||||
* 创建人名字
|
||||
*/
|
||||
private String createUserName;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 修改人ID
|
||||
*/
|
||||
private Long updateUserId;
|
||||
|
||||
/**
|
||||
* 修改人名字
|
||||
*/
|
||||
private String updateUserName;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 0=有效 1=删除
|
||||
*/
|
||||
private Integer delFlag;
|
||||
|
||||
/**
|
||||
* 阅读数
|
||||
*/
|
||||
private Integer viewNum;
|
||||
|
||||
/**
|
||||
* 顺序
|
||||
*/
|
||||
private Integer seqNo;
|
||||
|
||||
/**
|
||||
* 编辑框类型 1=HTML 2=Markdown
|
||||
*/
|
||||
private Integer editorType;
|
||||
|
||||
private String path;
|
||||
private List<WikiPageVo> children;
|
||||
|
||||
public List<WikiPageVo> getChildren() {
|
||||
return children;
|
||||
public WikiPageVo(WikiPage wikiPage) {
|
||||
this.id = wikiPage.getId();
|
||||
this.spaceId = wikiPage.getSpaceId();
|
||||
this.name = wikiPage.getName();
|
||||
this.parentId = wikiPage.getParentId();
|
||||
this.nodeType = wikiPage.getNodeType();
|
||||
this.zanNum = wikiPage.getZanNum();
|
||||
this.editType = wikiPage.getEditType();
|
||||
this.createUserId = wikiPage.getCreateUserId();
|
||||
this.createUserName = wikiPage.getCreateUserName();
|
||||
this.createTime = wikiPage.getCreateTime();
|
||||
this.updateUserId = wikiPage.getUpdateUserId();
|
||||
this.updateUserName = wikiPage.getUpdateUserName();
|
||||
this.updateTime = wikiPage.getUpdateTime();
|
||||
this.delFlag = wikiPage.getDelFlag();
|
||||
this.viewNum = wikiPage.getViewNum();
|
||||
this.seqNo = wikiPage.getSeqNo();
|
||||
this.editorType = wikiPage.getEditorType();
|
||||
}
|
||||
|
||||
public void setChildren(List<WikiPageVo> children) {
|
||||
this.children = children;
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public Long getParentId() {
|
||||
return parentId;
|
||||
}
|
||||
|
||||
public void setParentId(Long parentId) {
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
public Integer getNodeType() {
|
||||
return nodeType;
|
||||
}
|
||||
|
||||
public void setNodeType(Integer nodeType) {
|
||||
this.nodeType = nodeType;
|
||||
}
|
||||
|
||||
public Integer getZanNum() {
|
||||
return zanNum;
|
||||
}
|
||||
|
||||
public void setZanNum(Integer zanNum) {
|
||||
this.zanNum = zanNum;
|
||||
}
|
||||
|
||||
public Integer getEditType() {
|
||||
return editType;
|
||||
}
|
||||
|
||||
public void setEditType(Integer editType) {
|
||||
this.editType = editType;
|
||||
}
|
||||
|
||||
public Integer getFavorite() {
|
||||
return favorite;
|
||||
}
|
||||
|
||||
public void setFavorite(Integer favorite) {
|
||||
this.favorite = favorite;
|
||||
}
|
||||
|
||||
public Long getCreateUserId() {
|
||||
return createUserId;
|
||||
}
|
||||
|
||||
public void setCreateUserId(Long createUserId) {
|
||||
this.createUserId = createUserId;
|
||||
}
|
||||
|
||||
public String getCreateUserName() {
|
||||
return createUserName;
|
||||
}
|
||||
|
||||
public void setCreateUserName(String createUserName) {
|
||||
this.createUserName = createUserName;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public Long getUpdateUserId() {
|
||||
return updateUserId;
|
||||
}
|
||||
|
||||
public void setUpdateUserId(Long updateUserId) {
|
||||
this.updateUserId = updateUserId;
|
||||
}
|
||||
|
||||
public String getUpdateUserName() {
|
||||
return updateUserName;
|
||||
}
|
||||
|
||||
public void setUpdateUserName(String updateUserName) {
|
||||
this.updateUserName = updateUserName;
|
||||
}
|
||||
|
||||
public Date getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(Date updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
public Integer getDelFlag() {
|
||||
return delFlag;
|
||||
}
|
||||
|
||||
public void setDelFlag(Integer delFlag) {
|
||||
this.delFlag = delFlag;
|
||||
}
|
||||
|
||||
public Integer getViewNum() {
|
||||
return viewNum;
|
||||
}
|
||||
|
||||
public void setViewNum(Integer viewNum) {
|
||||
this.viewNum = viewNum;
|
||||
}
|
||||
|
||||
public Integer getSeqNo() {
|
||||
return seqNo;
|
||||
}
|
||||
|
||||
public void setSeqNo(Integer seqNo) {
|
||||
this.seqNo = seqNo;
|
||||
}
|
||||
|
||||
public Integer getEditorType() {
|
||||
return editorType;
|
||||
}
|
||||
|
||||
public void setEditorType(Integer editorType) {
|
||||
this.editorType = editorType;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
@@ -29,4 +274,12 @@ public class WikiPageVo extends WikiPage {
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public List<WikiPageVo> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<WikiPageVo> children) {
|
||||
this.children = children;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,16 +2,154 @@ package com.zyplayer.doc.wiki.controller.vo;
|
||||
|
||||
import com.zyplayer.doc.data.repository.manage.entity.WikiSpace;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* wiki空间信息
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-02-09
|
||||
*/
|
||||
public class WikiSpaceVo extends WikiSpace {
|
||||
public class WikiSpaceVo {
|
||||
|
||||
/**
|
||||
* 主键自增ID
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 空间名
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 空间类型 1=公开 2=个人
|
||||
*/
|
||||
private Integer type;
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String spaceExplain;
|
||||
/**
|
||||
* 目录延迟加载 0=否 1=是
|
||||
*/
|
||||
private Integer treeLazyLoad;
|
||||
/**
|
||||
* 是否是开放文档 0=否 1=是
|
||||
*/
|
||||
private Integer openDoc;
|
||||
/**
|
||||
* 唯一UUID
|
||||
*/
|
||||
private String uuid;
|
||||
/**
|
||||
* 创建人ID
|
||||
*/
|
||||
private Long createUserId;
|
||||
/**
|
||||
* 创建人名字
|
||||
*/
|
||||
private String createUserName;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Integer favorite;
|
||||
|
||||
public WikiSpaceVo(WikiSpace space) {
|
||||
this.id = space.getId();
|
||||
this.name = space.getName();
|
||||
this.type = space.getType();
|
||||
this.spaceExplain = space.getSpaceExplain();
|
||||
this.treeLazyLoad = space.getTreeLazyLoad();
|
||||
this.openDoc = space.getOpenDoc();
|
||||
this.uuid = space.getUuid();
|
||||
this.createUserId = space.getCreateUserId();
|
||||
this.createUserName = space.getCreateUserName();
|
||||
this.createTime = space.getCreateTime();
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Integer getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(Integer type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getSpaceExplain() {
|
||||
return spaceExplain;
|
||||
}
|
||||
|
||||
public void setSpaceExplain(String spaceExplain) {
|
||||
this.spaceExplain = spaceExplain;
|
||||
}
|
||||
|
||||
public Integer getTreeLazyLoad() {
|
||||
return treeLazyLoad;
|
||||
}
|
||||
|
||||
public void setTreeLazyLoad(Integer treeLazyLoad) {
|
||||
this.treeLazyLoad = treeLazyLoad;
|
||||
}
|
||||
|
||||
public Integer getOpenDoc() {
|
||||
return openDoc;
|
||||
}
|
||||
|
||||
public void setOpenDoc(Integer openDoc) {
|
||||
this.openDoc = openDoc;
|
||||
}
|
||||
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public Long getCreateUserId() {
|
||||
return createUserId;
|
||||
}
|
||||
|
||||
public void setCreateUserId(Long createUserId) {
|
||||
this.createUserId = createUserId;
|
||||
}
|
||||
|
||||
public String getCreateUserName() {
|
||||
return createUserName;
|
||||
}
|
||||
|
||||
public void setCreateUserName(String createUserName) {
|
||||
this.createUserName = createUserName;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public Integer getFavorite() {
|
||||
return favorite;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.zyplayer.doc.wiki.framework.config;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.zyplayer.doc.data.config.security.DocUserUtil;
|
||||
import com.zyplayer.doc.data.repository.manage.entity.WikiPageHistory;
|
||||
import com.zyplayer.doc.data.service.manage.WikiPageHistoryService;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.eclipse.jgit.api.Git;
|
||||
import org.eclipse.jgit.api.Status;
|
||||
import org.eclipse.jgit.internal.storage.file.FileRepository;
|
||||
|
||||
Reference in New Issue
Block a user