fix: comment public flag

This commit is contained in:
王性驊 2025-05-02 01:04:39 +08:00
parent 283d196f6b
commit 0010f216f3
2 changed files with 10 additions and 3 deletions

View File

@ -32,6 +32,7 @@ type CommentDocs struct {
ParentCommentID string `json:"parent_comment_id"` // 父留言 id 沒有就空白
Message string `json:"message"` // 留言內容
Replies []*CommentDocs `json:"replies"` // 子留言
IsVisitable bool `json:"is_visitable"` // 留言是否可見
UpdatedAt int64 `json:"updated_at"` // 更新時間
CreatedAt int64 `json:"created_at"` // 建立時間
}

View File

@ -4,6 +4,7 @@ import (
"context"
"encoding/base64"
"fmt"
"google.golang.org/protobuf/proto"
"code.30cm.net/digimon/app-cloudep-comment-server/pkg/domain"
"code.30cm.net/digimon/app-cloudep-comment-server/pkg/domain/comment"
@ -89,6 +90,7 @@ func (use *CommentUseCase) GetCommentItem(ctx context.Context, id string) (*usec
ReferenceID: byID.ReferenceID,
ParentCommentID: byID.ParentCommentID,
Message: byID.Message,
IsVisitable: byID.IsVisitable,
UpdatedAt: byID.UpdatedAt,
CreatedAt: byID.CreatedAt,
}, nil
@ -140,6 +142,7 @@ func (use *CommentUseCase) ListComment(ctx context.Context, req usecase.ListComm
ReferenceID: req.ReferenceID,
IsVisitable: req.IsVisitable,
})
if err != nil {
return nil, 0, errs.DatabaseErrorWithScopeL(
code.CloudEPComment,
@ -173,6 +176,7 @@ func (use *CommentUseCase) ListComment(ctx context.Context, req usecase.ListComm
Message: decodedMessage,
UpdatedAt: item.UpdatedAt,
CreatedAt: item.CreatedAt,
IsVisitable: item.IsVisitable,
Replies: replyMap[item.ID.Hex()],
})
}
@ -190,6 +194,7 @@ func (use *CommentUseCase) buildReplies(ctx context.Context, parentComments []*e
ParentID: &id,
PageSize: 20,
PageIndex: 1, // 可調整分頁大小
IsVisitable: proto.Bool(item.IsVisitable),
})
if err != nil {
continue
@ -207,6 +212,7 @@ func (use *CommentUseCase) buildReplies(ctx context.Context, parentComments []*e
UID: sub.UID,
ReferenceID: sub.ReferenceID,
ParentCommentID: sub.ParentCommentID,
IsVisitable: sub.IsVisitable,
Message: decodedMessage,
UpdatedAt: sub.UpdatedAt,
CreatedAt: sub.CreatedAt,