Compare commits
2 Commits
Author | SHA1 | Date |
---|---|---|
|
0dcd5fcf11 | |
|
0010f216f3 |
|
@ -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"` // 建立時間
|
||||
}
|
||||
|
|
|
@ -25,6 +25,8 @@ type MockCommentRepository struct {
|
|||
isgomock struct{}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// MockCommentRepositoryMockRecorder is the mock recorder for MockCommentRepository.
|
||||
type MockCommentRepositoryMockRecorder struct {
|
||||
mock *MockCommentRepository
|
||||
|
|
|
@ -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,13 +90,17 @@ 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
|
||||
}
|
||||
|
||||
func (use *CommentUseCase) UpdateCommentMessage(ctx context.Context, id string, message string, isVisitable bool) error {
|
||||
err := use.Comment.UpdateCommentMessage(ctx, id, message, isVisitable)
|
||||
snappyContent := snappy.Encode(nil, []byte(message))
|
||||
msg := base64.StdEncoding.EncodeToString(snappyContent)
|
||||
|
||||
err := use.Comment.UpdateCommentMessage(ctx, id, msg, isVisitable)
|
||||
if err != nil {
|
||||
return errs.DatabaseErrorWithScopeL(
|
||||
code.CloudEPComment,
|
||||
|
@ -140,6 +145,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 +179,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 +197,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 +215,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,
|
||||
|
|
Loading…
Reference in New Issue