#I1KMTP 增加删除评论功能
This commit is contained in:
@@ -52,6 +52,9 @@ export default {
|
||||
},
|
||||
updatePageComment: data => {
|
||||
return request({url: '/zyplayer-doc-wiki/page/comment/update', method: 'post', data: Qs.stringify(data)});
|
||||
},
|
||||
deletePageComment: data => {
|
||||
return request({url: '/zyplayer-doc-wiki/page/comment/delete', method: 'post', data: Qs.stringify(data)});
|
||||
},
|
||||
pageZanList: data => {
|
||||
return request({url: '/zyplayer-doc-wiki/page/zan/list', method: 'post', data: Qs.stringify(data)});
|
||||
|
||||
@@ -67,6 +67,7 @@
|
||||
{{comment.createUserName}}
|
||||
<span style="color: #888;font-size: 13px;padding-left: 10px;">{{comment.createTime}}</span>
|
||||
<span style="color: #888;font-size: 13px;margin-left: 10px;cursor: pointer;" @click="recommentUser(comment.id, index)">回复</span>
|
||||
<span style="color: #888;font-size: 13px;margin-left: 10px;cursor: pointer;" @click="deleteComment(comment.id)" v-if="canDeleteComment(comment)">删除</span>
|
||||
</div>
|
||||
<pre style="padding: 10px 0 0 55px;">{{comment.content}}</pre>
|
||||
<div v-for="(commentSub,indexSub) in comment.commentList" :key="commentSub.id" :data-id="commentSub.id" :data-index="indexSub" style="border-bottom: 1px solid #eee;padding: 10px;margin-left: 40px;">
|
||||
@@ -76,6 +77,7 @@
|
||||
<div style="padding-left: 55px;">
|
||||
{{commentSub.createUserName}}
|
||||
<span style="color: #888;font-size: 13px;padding-left: 10px;">{{commentSub.createTime}}</span>
|
||||
<span style="color: #888;font-size: 13px;margin-left: 10px;cursor: pointer;" @click="deleteComment(commentSub.id)" v-if="canDeleteComment(commentSub)">删除</span>
|
||||
</div>
|
||||
<pre style="padding: 10px 0 0 55px;">{{commentSub.content}}</pre>
|
||||
</div>
|
||||
@@ -146,6 +148,7 @@
|
||||
wikiPage: {},
|
||||
pageContent: {},
|
||||
pageFileList: [],
|
||||
selfUserId: 0,
|
||||
uploadFileList: [],
|
||||
uploadFormData: {pageId: 0},
|
||||
zanUserDialogVisible: false,
|
||||
@@ -274,6 +277,7 @@
|
||||
this.wikiPage = wikiPage;
|
||||
this.pageContent = json.data.pageContent || {};
|
||||
this.pageFileList = json.data.fileList || [];
|
||||
this.selfUserId = json.data.selfUserId || 0;
|
||||
this.uploadFormData = {pageId: this.wikiPage.id};
|
||||
this.parentPath.spaceId = wikiPage.spaceId;
|
||||
// 修改标题
|
||||
@@ -321,6 +325,21 @@
|
||||
recommentUser(id, index) {
|
||||
this.recommentInfo = {id: id, index: index, placeholder: '回复' + (index + 1) + '楼'};
|
||||
},
|
||||
canDeleteComment(row) {
|
||||
return this.selfUserId == row.createUserId || this.wikiPage.createUserId == this.selfUserId;
|
||||
},
|
||||
deleteComment(id) {
|
||||
this.$confirm('确定要除删此评论吗?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
pageApi.deletePageComment({id: id}).then(() => {
|
||||
this.$message.success("删除成功!");
|
||||
this.loadCommentList(this.parentPath.pageId);
|
||||
});
|
||||
});
|
||||
},
|
||||
cancelCommentUser() {
|
||||
this.recommentInfo = {};
|
||||
},
|
||||
@@ -337,7 +356,7 @@
|
||||
var data = json.data;
|
||||
data.color = this.getUserHeadBgColor(data.createUserId);
|
||||
this.commentTextInput = "";
|
||||
this.commentList.push(data);
|
||||
this.loadCommentList(this.parentPath.pageId);
|
||||
});
|
||||
},
|
||||
uploadFileError(err) {
|
||||
|
||||
@@ -25,6 +25,7 @@ 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;
|
||||
|
||||
/**
|
||||
@@ -58,6 +59,7 @@ public class WikiPageCommentController {
|
||||
return DocResponseJson.warn("您没有查看该空间的评论权!");
|
||||
}
|
||||
UpdateWrapper<WikiPageComment> wrapper = new UpdateWrapper<>();
|
||||
wrapper.eq("del_flag", 0);
|
||||
wrapper.eq("page_id", pageComment.getPageId());
|
||||
wrapper.eq(pageComment.getParentId() != null, "parent_id", pageComment.getParentId());
|
||||
List<WikiPageComment> authList = wikiPageCommentService.list(wrapper);
|
||||
@@ -71,19 +73,39 @@ public class WikiPageCommentController {
|
||||
return DocResponseJson.ok(commentList);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
public ResponseJson<Object> delete(Long id) {
|
||||
WikiPageComment pageCommentSel = wikiPageCommentService.getById(id);
|
||||
DocUserDetails currentUser = DocUserUtil.getCurrentUser();
|
||||
if (!Objects.equals(pageCommentSel.getCreateUserId(), currentUser.getUserId())) {
|
||||
WikiPage wikiPageSel = wikiPageService.getById(pageCommentSel.getPageId());
|
||||
if (!Objects.equals(currentUser.getUserId(), wikiPageSel.getCreateUserId())) {
|
||||
return DocResponseJson.warn("只有评论人或页面创建人才有权限删除此评论!");
|
||||
}
|
||||
}
|
||||
WikiPageComment pageComment = new WikiPageComment();
|
||||
pageComment.setId(id);
|
||||
pageComment.setDelFlag(1);
|
||||
wikiPageCommentService.updateById(pageComment);
|
||||
return DocResponseJson.ok();
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
public ResponseJson<Object> update(WikiPageComment pageComment) {
|
||||
DocUserDetails currentUser = DocUserUtil.getCurrentUser();
|
||||
Long id = pageComment.getId();
|
||||
Long pageId;
|
||||
if (id != null && id > 0) {
|
||||
WikiPageComment pageCommentSel = wikiPageCommentService.getById(id);
|
||||
if (!Objects.equals(pageCommentSel.getCreateUserId(), currentUser.getUserId())) {
|
||||
return DocResponseJson.warn("只能修改自己的评论!");
|
||||
}
|
||||
pageId = pageCommentSel.getPageId();
|
||||
} else if (pageComment.getPageId() != null) {
|
||||
pageId = pageComment.getPageId();
|
||||
} else {
|
||||
return DocResponseJson.warn("需指定所属页面!");
|
||||
}
|
||||
DocUserDetails currentUser = DocUserUtil.getCurrentUser();
|
||||
WikiPage wikiPageSel = wikiPageService.getById(pageId);
|
||||
WikiSpace wikiSpaceSel = wikiSpaceService.getById(wikiPageSel.getSpaceId());
|
||||
// 私人空间
|
||||
@@ -98,6 +120,7 @@ public class WikiPageCommentController {
|
||||
// }
|
||||
// }
|
||||
if (id != null && id > 0) {
|
||||
pageComment.setDelFlag(0);
|
||||
wikiPageCommentService.updateById(pageComment);
|
||||
} else {
|
||||
pageComment.setCreateTime(new Date());
|
||||
|
||||
@@ -132,6 +132,7 @@ public class WikiPageController {
|
||||
vo.setPageContent(pageContent);
|
||||
vo.setFileList(pageFiles);
|
||||
vo.setSelfZan((pageZan != null) ? 1 : 0);
|
||||
vo.setSelfUserId(currentUser.getUserId());
|
||||
// 高并发下会有覆盖问题,但不重要~
|
||||
Integer viewNum = Optional.ofNullable(wikiPageSel.getViewNum()).orElse(0);
|
||||
WikiPage wikiPageUp = new WikiPage();
|
||||
|
||||
@@ -11,6 +11,7 @@ public class WikiPageContentVo {
|
||||
private WikiPageContent pageContent;
|
||||
private List<WikiPageFile> fileList;
|
||||
private Integer selfZan;
|
||||
private Long selfUserId;
|
||||
|
||||
public WikiPage getWikiPage() {
|
||||
return wikiPage;
|
||||
@@ -43,4 +44,12 @@ public class WikiPageContentVo {
|
||||
public void setSelfZan(Integer selfZan) {
|
||||
this.selfZan = selfZan;
|
||||
}
|
||||
|
||||
public Long getSelfUserId() {
|
||||
return selfUserId;
|
||||
}
|
||||
|
||||
public void setSelfUserId(Long selfUserId) {
|
||||
this.selfUserId = selfUserId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ public class SpaceType {
|
||||
public static final Integer personalSpace = 2;
|
||||
public static final Integer privateSpace = 3;
|
||||
|
||||
public static boolean isPublic(Integer type){
|
||||
public static boolean isPublic(Integer type) {
|
||||
return Objects.equals(type, publicSpace);
|
||||
}
|
||||
|
||||
@@ -15,19 +15,19 @@ public class SpaceType {
|
||||
return Objects.equals(type, personalSpace);
|
||||
}
|
||||
|
||||
public static boolean isOthersPersonal(Integer type, Long loginUserId, Long spaceUserId){
|
||||
public static boolean isOthersPersonal(Integer type, Long loginUserId, Long spaceUserId) {
|
||||
return Objects.equals(type, personalSpace) && !Objects.equals(loginUserId, spaceUserId);
|
||||
}
|
||||
|
||||
public static boolean isPrivate(Integer type){
|
||||
public static boolean isPrivate(Integer type) {
|
||||
return Objects.equals(type, privateSpace);
|
||||
}
|
||||
|
||||
public static boolean isSelfPrivate(Integer type, Long loginUserId, Long spaceUserId){
|
||||
public static boolean isSelfPrivate(Integer type, Long loginUserId, Long spaceUserId) {
|
||||
return Objects.equals(type, privateSpace) && Objects.equals(loginUserId, spaceUserId);
|
||||
}
|
||||
|
||||
public static boolean isOthersPrivate(Integer type, Long loginUserId, Long spaceUserId){
|
||||
public static boolean isOthersPrivate(Integer type, Long loginUserId, Long spaceUserId) {
|
||||
return Objects.equals(type, privateSpace) && !Objects.equals(loginUserId, spaceUserId);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user