--------去掉对es的支持和依赖,默认去掉对hive的包依赖,maven依赖关系优化,页面位置调整,增加build.bat的支持,支持jar直接启动,去掉历史遗留的无用前端代码,依赖的maven包升级--------
This commit is contained in:
@@ -2,6 +2,7 @@ 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;
|
||||
@@ -21,7 +22,6 @@ import com.zyplayer.doc.wiki.controller.vo.WikiPageContentVo;
|
||||
import com.zyplayer.doc.wiki.controller.vo.WikiPageVo;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.dozer.Mapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
||||
@@ -88,11 +88,6 @@ public class WikiPageAuthController {
|
||||
UserAuth userAuth = this.createUserAuth(pageId, currentUser.getUserId(), authVo.getUserId(), authId);
|
||||
userAuthList.add(userAuth);
|
||||
}
|
||||
if (Objects.equals(authVo.getCommentPage(), 1)) {
|
||||
Long authId = authInfoMap.get(WikiAuthType.COMMENT_PAGE.getName());
|
||||
UserAuth userAuth = this.createUserAuth(pageId, currentUser.getUserId(), authVo.getUserId(), authId);
|
||||
userAuthList.add(userAuth);
|
||||
}
|
||||
if (Objects.equals(authVo.getDeletePage(), 1)) {
|
||||
Long authId = authInfoMap.get(WikiAuthType.DELETE_PAGE.getName());
|
||||
UserAuth userAuth = this.createUserAuth(pageId, currentUser.getUserId(), authVo.getUserId(), authId);
|
||||
@@ -160,7 +155,6 @@ public class WikiPageAuthController {
|
||||
Set<String> authNameSet = value.stream().map(auth -> authInfoMap.get(auth.getAuthId())).collect(Collectors.toSet());
|
||||
UserPageAuthVo authVo = new UserPageAuthVo();
|
||||
authVo.setEditPage(this.haveAuth(authNameSet, WikiAuthType.EDIT_PAGE));
|
||||
authVo.setCommentPage(this.haveAuth(authNameSet, WikiAuthType.COMMENT_PAGE));
|
||||
authVo.setDeletePage(this.haveAuth(authNameSet, WikiAuthType.DELETE_PAGE));
|
||||
authVo.setPageFileUpload(this.haveAuth(authNameSet, WikiAuthType.PAGE_FILE_UPLOAD));
|
||||
authVo.setPageFileDelete(this.haveAuth(authNameSet, WikiAuthType.PAGE_FILE_DELETE));
|
||||
|
||||
@@ -18,7 +18,6 @@ import com.zyplayer.doc.data.service.manage.WikiPageService;
|
||||
import com.zyplayer.doc.data.service.manage.WikiSpaceService;
|
||||
import com.zyplayer.doc.wiki.controller.vo.WikiPageCommentVo;
|
||||
import com.zyplayer.doc.wiki.framework.consts.SpaceType;
|
||||
import org.dozer.Mapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@@ -28,9 +27,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 文档控制器
|
||||
@@ -52,8 +49,6 @@ public class WikiPageCommentController {
|
||||
WikiPageService wikiPageService;
|
||||
@Resource
|
||||
UserMessageService userMessageService;
|
||||
@Resource
|
||||
Mapper mapper;
|
||||
|
||||
@PostMapping("/list")
|
||||
public ResponseJson<List<WikiPageCommentVo>> list(WikiPageComment pageComment) {
|
||||
|
||||
@@ -17,9 +17,6 @@ import com.zyplayer.doc.data.repository.manage.param.SearchByEsParam;
|
||||
import com.zyplayer.doc.data.repository.manage.vo.SpaceNewsVo;
|
||||
import com.zyplayer.doc.data.repository.support.consts.UserMsgSysType;
|
||||
import com.zyplayer.doc.data.repository.support.consts.UserMsgType;
|
||||
import com.zyplayer.doc.data.service.elasticsearch.entity.EsWikiPage;
|
||||
import com.zyplayer.doc.data.service.elasticsearch.service.EsWikiPageService;
|
||||
import com.zyplayer.doc.data.service.elasticsearch.support.EsPage;
|
||||
import com.zyplayer.doc.data.service.manage.*;
|
||||
import com.zyplayer.doc.data.utils.CachePrefix;
|
||||
import com.zyplayer.doc.data.utils.CacheUtil;
|
||||
@@ -30,12 +27,9 @@ 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 org.dozer.Mapper;
|
||||
import org.elasticsearch.index.query.BoolQueryBuilder;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
import com.github.dozermapper.core.Mapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
@@ -78,8 +72,6 @@ public class WikiPageController {
|
||||
GitService gitService;
|
||||
@Resource
|
||||
Mapper mapper;
|
||||
@Autowired(required = false)
|
||||
EsWikiPageService esWikiPageService;
|
||||
|
||||
@PostMapping("/list")
|
||||
public ResponseJson<List<WikiPageVo>> list(WikiPage wikiPage) {
|
||||
@@ -289,16 +281,6 @@ public class WikiPageController {
|
||||
UserMessage userMessage = userMessageService.createUserMessage(currentUser, wikiPage.getId(), wikiPage.getName(), UserMsgSysType.WIKI, UserMsgType.WIKI_PAGE_CREATE);
|
||||
userMessageService.addWikiMessage(userMessage);
|
||||
}
|
||||
// 保存到es
|
||||
if (esWikiPageService.isOpen()) {
|
||||
WikiPage wikiPageSel = wikiPageService.getById(wikiPage.getId());
|
||||
EsWikiPage esWikiPage = mapper.map(wikiPageSel, EsWikiPage.class);
|
||||
esWikiPage.setContent(content);
|
||||
esWikiPage.setPreview(preview);
|
||||
esWikiPageService.upsert(esWikiPage);
|
||||
} else {
|
||||
logger.warn("未开启elasticsearch服务,建议开启");
|
||||
}
|
||||
try {
|
||||
// 提交历史版本记录
|
||||
gitService.commitAndAddHistory(wikiPage.getId(), content);
|
||||
@@ -337,50 +319,8 @@ public class WikiPageController {
|
||||
|
||||
@PostMapping("/searchByEs")
|
||||
public ResponseJson<Object> searchByEs(SearchByEsParam param) {
|
||||
if (esWikiPageService.isOpen()) {
|
||||
Map<Long, WikiSpace> wikiSpaceMap = this.getCanVisitWikiSpace(param.getSpaceId());
|
||||
if (wikiSpaceMap.isEmpty()) {
|
||||
return DocResponseJson.ok();
|
||||
}
|
||||
String[] fields = {
|
||||
"id", "preview", "createTime", "updateTime", "createUserId", "createUserName",
|
||||
"updateUserId", "updateUserName", "spaceId", "name", "zanNum", "viewNum",
|
||||
};
|
||||
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
|
||||
if (StringUtils.isNotBlank(param.getKeywords())) {
|
||||
boolQueryBuilder.must(QueryBuilders.multiMatchQuery(param.getKeywords(), "name", "preview"));
|
||||
}
|
||||
boolQueryBuilder.must(QueryBuilders.termQuery("delFlag", "0"));
|
||||
boolQueryBuilder.must(QueryBuilders.termsQuery("spaceId", wikiSpaceMap.keySet().toArray()));
|
||||
EsPage<EsWikiPage> wikiPageEsPage = esWikiPageService.getDataByQuery(boolQueryBuilder, fields, param.getStartIndex(), param.getPageSize());
|
||||
if (wikiPageEsPage == null || wikiPageEsPage.getTotal() == null) {
|
||||
return DocResponseJson.ok();
|
||||
}
|
||||
// 组装数据
|
||||
List<EsWikiPage> esWikiPageList = wikiPageEsPage.getData();
|
||||
List<SpaceNewsVo> pageVoList = new LinkedList<>();
|
||||
esWikiPageList.forEach(val -> {
|
||||
String preview = val.getPreview();
|
||||
if (preview != null && preview.length() > 200) {
|
||||
preview = preview.substring(0, 200);
|
||||
}
|
||||
SpaceNewsVo spaceNewsVo = mapper.map(val, SpaceNewsVo.class);
|
||||
spaceNewsVo.setSpaceName(wikiSpaceMap.get(val.getSpaceId()).getName());
|
||||
spaceNewsVo.setPreviewContent(preview);
|
||||
spaceNewsVo.setPageTitle(val.getName());
|
||||
spaceNewsVo.setPageId(val.getId());
|
||||
pageVoList.add(spaceNewsVo);
|
||||
});
|
||||
// 组装数据返回
|
||||
PageInfo<SpaceNewsVo> pageInfo = new PageInfo<>();
|
||||
pageInfo.setTotal(wikiPageEsPage.getTotal());
|
||||
pageInfo.setList(pageVoList);
|
||||
return DocResponseJson.ok(pageInfo);
|
||||
} else {
|
||||
logger.warn("未开启elasticsearch服务,使用数据库查询匹配,建议开启");
|
||||
param.setNewsType(1);
|
||||
return this.news(param);
|
||||
}
|
||||
param.setNewsType(1);
|
||||
return this.news(param);
|
||||
}
|
||||
|
||||
@PostMapping("/news")
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.zyplayer.doc.wiki.controller;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import com.zyplayer.doc.core.annotation.AuthMan;
|
||||
import com.zyplayer.doc.core.json.DocResponseJson;
|
||||
@@ -158,7 +159,7 @@ public class WikiPageFileController {
|
||||
if (!newFile.exists() && !newFile.mkdirs()) {
|
||||
return DocResponseJson.warn("创建文件夹失败");
|
||||
}
|
||||
String simpleUUID = RandomUtil.simpleUUID();
|
||||
String simpleUUID = IdUtil.simpleUUID();
|
||||
path += simpleUUID + fileSuffix;
|
||||
newFile = new File(path);
|
||||
try {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.zyplayer.doc.wiki.controller;
|
||||
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
@@ -23,7 +23,7 @@ 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 org.dozer.Mapper;
|
||||
import com.github.dozermapper.core.Mapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@@ -104,7 +104,7 @@ public class WikiSpaceController {
|
||||
wikiSpace.setEditType(null);
|
||||
wikiSpaceService.updateById(wikiSpace);
|
||||
} else {
|
||||
wikiSpace.setUuid(RandomUtil.simpleUUID());
|
||||
wikiSpace.setUuid(IdUtil.simpleUUID());
|
||||
wikiSpace.setCreateTime(new Date());
|
||||
wikiSpace.setCreateUserId(currentUser.getUserId());
|
||||
wikiSpace.setCreateUserName(currentUser.getUsername());
|
||||
@@ -188,7 +188,6 @@ public class WikiSpaceController {
|
||||
for (UserSpaceAuthVo authVo : authVoList) {
|
||||
List<UserGroupAuth> userAuthList = new LinkedList<>();
|
||||
this.createUserAuth(userAuthList, authVo.getEditPage(), spaceId, WikiAuthType.EDIT_PAGE, authVo.getGroupId());
|
||||
this.createUserAuth(userAuthList, authVo.getCommentPage(), spaceId, WikiAuthType.COMMENT_PAGE, authVo.getGroupId());
|
||||
this.createUserAuth(userAuthList, authVo.getDeletePage(), spaceId, WikiAuthType.DELETE_PAGE, authVo.getGroupId());
|
||||
this.createUserAuth(userAuthList, authVo.getPageFileUpload(), spaceId, WikiAuthType.PAGE_FILE_UPLOAD, authVo.getGroupId());
|
||||
this.createUserAuth(userAuthList, authVo.getPageFileDelete(), spaceId, WikiAuthType.PAGE_FILE_DELETE, authVo.getGroupId());
|
||||
@@ -224,7 +223,6 @@ public class WikiSpaceController {
|
||||
Set<Integer> authNameSet = value.stream().map(UserGroupAuth::getAuthType).collect(Collectors.toSet());
|
||||
UserSpaceAuthVo authVo = new UserSpaceAuthVo();
|
||||
authVo.setEditPage(this.haveAuth(authNameSet, WikiAuthType.EDIT_PAGE));
|
||||
authVo.setCommentPage(this.haveAuth(authNameSet, WikiAuthType.COMMENT_PAGE));
|
||||
authVo.setDeletePage(this.haveAuth(authNameSet, WikiAuthType.DELETE_PAGE));
|
||||
authVo.setPageFileUpload(this.haveAuth(authNameSet, WikiAuthType.PAGE_FILE_UPLOAD));
|
||||
authVo.setPageFileDelete(this.haveAuth(authNameSet, WikiAuthType.PAGE_FILE_DELETE));
|
||||
|
||||
Reference in New Issue
Block a user