|
@@ -20,7 +20,6 @@ export class CommentService {
|
|
|
|
|
|
|
|
|
|
|
|
|
async findAll(req: PageRequest<Comment>): Promise<Pagination<Comment>> {
|
|
async findAll(req: PageRequest<Comment>): Promise<Pagination<Comment>> {
|
|
|
-
|
|
|
|
|
const query = await this.commentRepository.createQueryBuilder()
|
|
const query = await this.commentRepository.createQueryBuilder()
|
|
|
.where('comment.isDel = false')
|
|
.where('comment.isDel = false')
|
|
|
|
|
|
|
@@ -54,9 +53,14 @@ export class CommentService {
|
|
|
items.forEach(comment => {
|
|
items.forEach(comment => {
|
|
|
if (!Boolean(comment.rootCommentId)) {
|
|
if (!Boolean(comment.rootCommentId)) {
|
|
|
rootMap.set(comment.id, comment)
|
|
rootMap.set(comment.id, comment)
|
|
|
- } else {
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ items.forEach(comment => {
|
|
|
|
|
+ console.log(rootMap)
|
|
|
|
|
+ if (Boolean(comment.rootCommentId)) {
|
|
|
const root = rootMap.get(comment.rootCommentId)
|
|
const root = rootMap.get(comment.rootCommentId)
|
|
|
- if (Boolean(root.childList)) {
|
|
|
|
|
|
|
+ if (root.hasOwnProperty('childList')) {
|
|
|
root.childList.push(comment)
|
|
root.childList.push(comment)
|
|
|
} else {
|
|
} else {
|
|
|
const childList: Comment[] = []
|
|
const childList: Comment[] = []
|
|
@@ -66,8 +70,8 @@ export class CommentService {
|
|
|
rootMap.set(root.id, root)
|
|
rootMap.set(root.id, root)
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
- const newItems = Array.from(rootMap.values());
|
|
|
|
|
|
|
|
|
|
|
|
+ const newItems = Array.from(rootMap.values());
|
|
|
const result: Pagination<Comment> = {
|
|
const result: Pagination<Comment> = {
|
|
|
items: newItems,
|
|
items: newItems,
|
|
|
meta
|
|
meta
|