同一个页面只能一个人编辑
This commit is contained in:
@@ -49,6 +49,11 @@ public class DocUserDetails {
|
|||||||
this.authorities = authorities;
|
this.authorities = authorities;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DocUserDetails(Long userId, String username) {
|
||||||
|
this.userId = userId;
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
public DocUserDetails(Long userId, String username, String password, boolean enabled) {
|
public DocUserDetails(Long userId, String username, String password, boolean enabled) {
|
||||||
super();
|
super();
|
||||||
this.userId = userId;
|
this.userId = userId;
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import java.util.Date;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @author 暮光:城中城
|
* @author 暮光:城中城
|
||||||
@@ -99,6 +99,16 @@ public class WikiPage implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private Integer seqNo;
|
private Integer seqNo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当前正在编辑的用户ID
|
||||||
|
*/
|
||||||
|
private Integer nowEditUserId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当前正在编辑的用户名
|
||||||
|
*/
|
||||||
|
private Integer nowEditUserName;
|
||||||
|
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
@@ -211,7 +221,23 @@ public class WikiPage implements Serializable {
|
|||||||
public void setSeqNo(Integer seqNo) {
|
public void setSeqNo(Integer seqNo) {
|
||||||
this.seqNo = seqNo;
|
this.seqNo = seqNo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getNowEditUserId() {
|
||||||
|
return nowEditUserId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNowEditUserId(Integer nowEditUserId) {
|
||||||
|
this.nowEditUserId = nowEditUserId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getNowEditUserName() {
|
||||||
|
return nowEditUserName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNowEditUserName(Integer nowEditUserName) {
|
||||||
|
this.nowEditUserName = nowEditUserName;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "WikiPage{" +
|
return "WikiPage{" +
|
||||||
|
|||||||
@@ -21,7 +21,17 @@ UPDATE wiki_page SET seq_no=id WHERE del_flag=0;
|
|||||||
ALTER TABLE `wiki_page_content` ADD COLUMN `preview` varchar(1024) NULL COMMENT '预览内容';
|
ALTER TABLE `wiki_page_content` ADD COLUMN `preview` varchar(1024) NULL COMMENT '预览内容';
|
||||||
ALTER TABLE `wiki_page_file` ADD COLUMN `download_num` int NOT NULL DEFAULT 0 COMMENT '下载次数';
|
ALTER TABLE `wiki_page_file` ADD COLUMN `download_num` int NOT NULL DEFAULT 0 COMMENT '下载次数';
|
||||||
|
|
||||||
|
CREATE TABLE `wiki_page_history` (
|
||||||
|
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键自增ID',
|
||||||
|
`page_id` bigint(20) DEFAULT NULL COMMENT '页面ID',
|
||||||
|
`content` mediumtext COMMENT '本次文章内容',
|
||||||
|
`create_user_id` bigint(20) DEFAULT NULL COMMENT '创建人ID',
|
||||||
|
`create_user_name` varchar(20) DEFAULT NULL COMMENT '创建人名字',
|
||||||
|
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||||
|
`del_flag` tinyint(4) NOT NULL DEFAULT '0' COMMENT '删除标记 0=正常 1=已删除',
|
||||||
|
PRIMARY KEY (`id`) USING BTREE,
|
||||||
|
KEY `idx_page_id` (`page_id`) USING BTREE COMMENT '页面ID索引'
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -308,6 +318,18 @@ CREATE TABLE `zyplayer_storage` (
|
|||||||
UNIQUE INDEX `key`(`doc_key`) USING BTREE COMMENT 'key唯一索引'
|
UNIQUE INDEX `key`(`doc_key`) USING BTREE COMMENT 'key唯一索引'
|
||||||
) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '存储网页上相关的数据' ROW_FORMAT = Compact;
|
) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '存储网页上相关的数据' ROW_FORMAT = Compact;
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `wiki_page_history`;
|
||||||
|
CREATE TABLE `wiki_page_history` (
|
||||||
|
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键自增ID',
|
||||||
|
`page_id` bigint(20) DEFAULT NULL COMMENT '页面ID',
|
||||||
|
`content` mediumtext COMMENT '本次文章内容',
|
||||||
|
`create_user_id` bigint(20) DEFAULT NULL COMMENT '创建人ID',
|
||||||
|
`create_user_name` varchar(20) DEFAULT NULL COMMENT '创建人名字',
|
||||||
|
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||||
|
`del_flag` tinyint(4) NOT NULL DEFAULT '0' COMMENT '删除标记 0=正常 1=已删除',
|
||||||
|
PRIMARY KEY (`id`) USING BTREE,
|
||||||
|
KEY `idx_page_id` (`page_id`) USING BTREE COMMENT '页面ID索引'
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Records of zyplayer_storage
|
-- Records of zyplayer_storage
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ var URL = {
|
|||||||
pageDetail: '/zyplayer-doc-wiki/page/detail',
|
pageDetail: '/zyplayer-doc-wiki/page/detail',
|
||||||
pageDelete: '/zyplayer-doc-wiki/page/delete',
|
pageDelete: '/zyplayer-doc-wiki/page/delete',
|
||||||
pageNews: '/zyplayer-doc-wiki/page/news',
|
pageNews: '/zyplayer-doc-wiki/page/news',
|
||||||
|
pageLock: '/zyplayer-doc-wiki/page/lock',
|
||||||
|
pageUnlock: '/zyplayer-doc-wiki/page/unlock',
|
||||||
spaceList: '/zyplayer-doc-wiki/space/list',
|
spaceList: '/zyplayer-doc-wiki/space/list',
|
||||||
updateSpace: '/zyplayer-doc-wiki/space/update',
|
updateSpace: '/zyplayer-doc-wiki/space/update',
|
||||||
getPageUserAuthList: '/zyplayer-doc-wiki/page/auth/list',
|
getPageUserAuthList: '/zyplayer-doc-wiki/page/auth/list',
|
||||||
|
|||||||
@@ -52,6 +52,27 @@ export default {
|
|||||||
this.validateResult(res);
|
this.validateResult(res);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
postNonCheck: function (url, param, callback) {
|
||||||
|
param = param || {};
|
||||||
|
param.accessToken = this.getAccessToken();
|
||||||
|
global.vue.axios({
|
||||||
|
method: "post",
|
||||||
|
url: url,
|
||||||
|
headers: {'Content-type': 'application/x-www-form-urlencoded'},
|
||||||
|
data: Qs.stringify(param),
|
||||||
|
withCredentials: true,
|
||||||
|
}).then((res) => {
|
||||||
|
console.log("ok", res);
|
||||||
|
if (typeof callback == 'function') {
|
||||||
|
callback(res.data);
|
||||||
|
}
|
||||||
|
}).catch((res) => {
|
||||||
|
console.log("error", res);
|
||||||
|
if (typeof callback == 'function') {
|
||||||
|
callback(res.data);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* 返回不为空的字符串,为空返回def
|
* 返回不为空的字符串,为空返回def
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -23,6 +23,13 @@
|
|||||||
import global from '../../common/config/global'
|
import global from '../../common/config/global'
|
||||||
import WangEditor from 'wangeditor'
|
import WangEditor from 'wangeditor'
|
||||||
|
|
||||||
|
window.onunload = function () {
|
||||||
|
app.unlockPage();
|
||||||
|
};
|
||||||
|
window.onbeforeunload = function () {
|
||||||
|
app.unlockPage();
|
||||||
|
};
|
||||||
|
|
||||||
var app;
|
var app;
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
@@ -32,8 +39,12 @@
|
|||||||
newPageTitle: "",
|
newPageTitle: "",
|
||||||
parentPath: {},
|
parentPath: {},
|
||||||
wikiPage: {},
|
wikiPage: {},
|
||||||
|
isUnlock: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
destroyed: function () {
|
||||||
|
this.unlockPage();
|
||||||
|
},
|
||||||
beforeRouteUpdate(to, from, next) {
|
beforeRouteUpdate(to, from, next) {
|
||||||
this.initQueryParam(to);
|
this.initQueryParam(to);
|
||||||
next();
|
next();
|
||||||
@@ -47,12 +58,22 @@
|
|||||||
changeToRootPath() {
|
changeToRootPath() {
|
||||||
app.parentPath = {spaceId: this.parentPath.spaceId};
|
app.parentPath = {spaceId: this.parentPath.spaceId};
|
||||||
},
|
},
|
||||||
|
unlockPage() {
|
||||||
|
// 防止各种事件重复调这个接口,只需要调一次就好了
|
||||||
|
if (this.isUnlock) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.isUnlock = true;
|
||||||
|
var param = {pageId: app.parentPath.pageId};
|
||||||
|
this.common.post(this.apilist1.pageUnlock, param, function (json) {});
|
||||||
|
},
|
||||||
createWikiCancel() {
|
createWikiCancel() {
|
||||||
this.$confirm('确定要取消编辑吗?您编辑的内容将不会被保存哦~', '提示', {
|
this.$confirm('确定要取消编辑吗?您编辑的内容将不会被保存哦~', '提示', {
|
||||||
confirmButtonText: '确定',
|
confirmButtonText: '确定',
|
||||||
cancelButtonText: '继续编辑',
|
cancelButtonText: '继续编辑',
|
||||||
type: 'warning'
|
type: 'warning'
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
|
app.unlockPage();
|
||||||
app.$router.back();
|
app.$router.back();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -114,6 +135,17 @@
|
|||||||
} else {
|
} else {
|
||||||
this.cleanPage();
|
this.cleanPage();
|
||||||
}
|
}
|
||||||
|
var param = {pageId: app.parentPath.pageId};
|
||||||
|
this.common.postNonCheck(this.apilist1.pageLock, param, function (json) {
|
||||||
|
if (json.errCode !== 200) {
|
||||||
|
app.$alert(json.errMsg || '未知错误', '错误', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
callback: () => {
|
||||||
|
app.$router.back();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
initEditor() {
|
initEditor() {
|
||||||
this.editor = new WangEditor('#newPageContentDiv');
|
this.editor = new WangEditor('#newPageContentDiv');
|
||||||
|
|||||||
@@ -183,7 +183,10 @@
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
editWiki() {
|
editWiki() {
|
||||||
this.$router.push({path: '/page/edit', query: this.parentPath});
|
var param = {pageId: app.parentPath.pageId};
|
||||||
|
this.common.post(this.apilist1.pageLock, param, function (json) {
|
||||||
|
app.$router.push({path: '/page/edit', query: app.parentPath});
|
||||||
|
});
|
||||||
},
|
},
|
||||||
getSearchUserList(query) {
|
getSearchUserList(query) {
|
||||||
if (query == '') {
|
if (query == '') {
|
||||||
@@ -320,6 +323,10 @@
|
|||||||
this.recommentInfo = {};
|
this.recommentInfo = {};
|
||||||
},
|
},
|
||||||
submitPageComment() {
|
submitPageComment() {
|
||||||
|
if (app.commentTextInput.length <= 0) {
|
||||||
|
toast.error("请输入评论内容");
|
||||||
|
return;
|
||||||
|
}
|
||||||
var param = {
|
var param = {
|
||||||
pageId: app.wikiPage.id, content: app.commentTextInput,
|
pageId: app.wikiPage.id, content: app.commentTextInput,
|
||||||
parentId: app.recommentInfo.id
|
parentId: app.recommentInfo.id
|
||||||
@@ -332,7 +339,7 @@
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
uploadFileError(err) {
|
uploadFileError(err) {
|
||||||
toast.success("上传失败," + err);
|
toast.error("上传失败," + err);
|
||||||
},
|
},
|
||||||
uploadFileSuccess(response) {
|
uploadFileSuccess(response) {
|
||||||
this.common.validateResult({data: response}, function () {
|
this.common.validateResult({data: response}, function () {
|
||||||
|
|||||||
@@ -12,12 +12,14 @@ import com.zyplayer.doc.data.config.security.DocUserUtil;
|
|||||||
import com.zyplayer.doc.data.repository.manage.entity.*;
|
import com.zyplayer.doc.data.repository.manage.entity.*;
|
||||||
import com.zyplayer.doc.data.repository.manage.mapper.WikiPageMapper;
|
import com.zyplayer.doc.data.repository.manage.mapper.WikiPageMapper;
|
||||||
import com.zyplayer.doc.data.service.manage.*;
|
import com.zyplayer.doc.data.service.manage.*;
|
||||||
|
import com.zyplayer.doc.data.utils.CacheUtil;
|
||||||
import com.zyplayer.doc.wiki.controller.param.SpaceNewsParam;
|
import com.zyplayer.doc.wiki.controller.param.SpaceNewsParam;
|
||||||
import com.zyplayer.doc.wiki.controller.vo.SpaceNewsVo;
|
import com.zyplayer.doc.wiki.controller.vo.SpaceNewsVo;
|
||||||
import com.zyplayer.doc.wiki.controller.vo.WikiPageContentVo;
|
import com.zyplayer.doc.wiki.controller.vo.WikiPageContentVo;
|
||||||
import com.zyplayer.doc.wiki.controller.vo.WikiPageVo;
|
import com.zyplayer.doc.wiki.controller.vo.WikiPageVo;
|
||||||
import com.zyplayer.doc.wiki.framework.consts.SpaceType;
|
import com.zyplayer.doc.wiki.framework.consts.SpaceType;
|
||||||
import com.zyplayer.doc.wiki.framework.consts.WikiAuthType;
|
import com.zyplayer.doc.wiki.framework.consts.WikiAuthType;
|
||||||
|
import com.zyplayer.doc.wiki.framework.consts.WikiCachePrefix;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.dozer.Mapper;
|
import org.dozer.Mapper;
|
||||||
@@ -253,6 +255,33 @@ public class WikiPageController {
|
|||||||
return DocResponseJson.ok(wikiPage);
|
return DocResponseJson.ok(wikiPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/unlock")
|
||||||
|
public ResponseJson<Object> unlock(Long pageId) {
|
||||||
|
String lockKey = WikiCachePrefix.WIKI_LOCK_PAGE + pageId;
|
||||||
|
DocUserDetails pageLockUser = CacheUtil.get(lockKey);
|
||||||
|
if (pageLockUser != null) {
|
||||||
|
DocUserDetails currentUser = DocUserUtil.getCurrentUser();
|
||||||
|
if (Objects.equals(pageLockUser.getUserId(), currentUser.getUserId())) {
|
||||||
|
CacheUtil.remove(lockKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return DocResponseJson.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/lock")
|
||||||
|
public ResponseJson<Object> editLock(Long pageId) {
|
||||||
|
DocUserDetails currentUser = DocUserUtil.getCurrentUser();
|
||||||
|
String lockKey = WikiCachePrefix.WIKI_LOCK_PAGE + pageId;
|
||||||
|
DocUserDetails pageLockUser = CacheUtil.get(lockKey);
|
||||||
|
if (pageLockUser != null) {
|
||||||
|
if (!Objects.equals(pageLockUser.getUserId(), currentUser.getUserId())) {
|
||||||
|
return DocResponseJson.warn("当前页面正在被:" + pageLockUser.getUsername() + " 编辑");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CacheUtil.put(lockKey, new DocUserDetails(currentUser.getUserId(), currentUser.getUsername()));
|
||||||
|
return DocResponseJson.ok();
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping("/news")
|
@PostMapping("/news")
|
||||||
public ResponseJson<Object> news(SpaceNewsParam param) {
|
public ResponseJson<Object> news(SpaceNewsParam param) {
|
||||||
DocUserDetails currentUser = DocUserUtil.getCurrentUser();
|
DocUserDetails currentUser = DocUserUtil.getCurrentUser();
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package com.zyplayer.doc.wiki.framework.consts;
|
||||||
|
|
||||||
|
public class WikiCachePrefix {
|
||||||
|
public static final String WIKI_LOCK_PAGE = "WIKI_LOCK_PAGE_";
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user