feat: 接入计划广场后端主链路
This commit is contained in:
@@ -4,13 +4,10 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
forumcontracts "github.com/LoveLosita/smartflow/backend/shared/contracts/taskclassforum"
|
||||
forumdao "github.com/LoveLosita/smartflow/backend/services/taskclassforum/dao"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// ErrNotImplemented 表示 RPC 骨架已接线,但对应业务用例还在后续步骤实现。
|
||||
var ErrNotImplemented = errors.New("taskclassforum service method not implemented")
|
||||
|
||||
// TaskClassSnapshotPort 是计划广场读取和写入 TaskClass 的端口。
|
||||
//
|
||||
// 职责边界:
|
||||
@@ -71,12 +68,14 @@ type Options struct {
|
||||
// 3. 不拥有 TaskClass 原表,只通过 TaskClassSnapshotPort 读取和创建副本。
|
||||
type Service struct {
|
||||
db *gorm.DB
|
||||
forumDAO *forumdao.ForumDAO
|
||||
taskClassPort TaskClassSnapshotPort
|
||||
}
|
||||
|
||||
func New(opts Options) *Service {
|
||||
return &Service{
|
||||
db: opts.DB,
|
||||
forumDAO: forumdao.NewForumDAO(opts.DB),
|
||||
taskClassPort: opts.TaskClassPort,
|
||||
}
|
||||
}
|
||||
@@ -93,87 +92,3 @@ func (s *Service) Ready() error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ListPosts 是计划列表用例占位,第三步实现真实查询。
|
||||
func (s *Service) ListPosts(ctx context.Context, actorUserID uint64, page int, pageSize int, sort string, keyword string, tag string) ([]forumcontracts.ForumPostBrief, forumcontracts.PageResult, error) {
|
||||
_ = ctx
|
||||
_ = actorUserID
|
||||
_ = page
|
||||
_ = pageSize
|
||||
_ = sort
|
||||
_ = keyword
|
||||
_ = tag
|
||||
return nil, forumcontracts.PageResult{}, ErrNotImplemented
|
||||
}
|
||||
|
||||
// ListTags 是标签列表用例占位,第三步实现真实聚合查询。
|
||||
func (s *Service) ListTags(ctx context.Context, actorUserID uint64, limit int) ([]forumcontracts.ForumTagItem, error) {
|
||||
_ = ctx
|
||||
_ = actorUserID
|
||||
_ = limit
|
||||
return nil, ErrNotImplemented
|
||||
}
|
||||
|
||||
// CreatePost 是发布计划用例占位,第三步会通过 TaskClassSnapshotPort 读取旧计划快照。
|
||||
func (s *Service) CreatePost(ctx context.Context, req forumcontracts.CreateForumPostRequest) (*forumcontracts.ForumPostBrief, error) {
|
||||
_ = ctx
|
||||
_ = req
|
||||
return nil, ErrNotImplemented
|
||||
}
|
||||
|
||||
// GetPost 是计划详情用例占位,第三步实现帖子和模板快照读取。
|
||||
func (s *Service) GetPost(ctx context.Context, actorUserID uint64, postID uint64) (*forumcontracts.ForumPostDetail, error) {
|
||||
_ = ctx
|
||||
_ = actorUserID
|
||||
_ = postID
|
||||
return nil, ErrNotImplemented
|
||||
}
|
||||
|
||||
// LikePost 是点赞用例占位,第三步实现唯一约束和计数更新。
|
||||
func (s *Service) LikePost(ctx context.Context, actorUserID uint64, postID uint64) (forumcontracts.ForumPostCounters, forumcontracts.ForumPostViewerState, error) {
|
||||
_ = ctx
|
||||
_ = actorUserID
|
||||
_ = postID
|
||||
return forumcontracts.ForumPostCounters{}, forumcontracts.ForumPostViewerState{}, ErrNotImplemented
|
||||
}
|
||||
|
||||
// UnlikePost 是取消点赞用例占位,第三步实现幂等撤销。
|
||||
func (s *Service) UnlikePost(ctx context.Context, actorUserID uint64, postID uint64) (forumcontracts.ForumPostCounters, forumcontracts.ForumPostViewerState, error) {
|
||||
_ = ctx
|
||||
_ = actorUserID
|
||||
_ = postID
|
||||
return forumcontracts.ForumPostCounters{}, forumcontracts.ForumPostViewerState{}, ErrNotImplemented
|
||||
}
|
||||
|
||||
// ListComments 是评论树查询用例占位,第三步实现根评论分页和服务层组树。
|
||||
func (s *Service) ListComments(ctx context.Context, actorUserID uint64, postID uint64, page int, pageSize int, sort string) ([]forumcontracts.ForumCommentNode, forumcontracts.PageResult, error) {
|
||||
_ = ctx
|
||||
_ = actorUserID
|
||||
_ = postID
|
||||
_ = page
|
||||
_ = pageSize
|
||||
_ = sort
|
||||
return nil, forumcontracts.PageResult{}, ErrNotImplemented
|
||||
}
|
||||
|
||||
// CreateComment 是发表评论或回复用例占位,第三步实现父子评论校验和幂等。
|
||||
func (s *Service) CreateComment(ctx context.Context, req forumcontracts.CreateForumCommentRequest) (*forumcontracts.ForumCommentNode, error) {
|
||||
_ = ctx
|
||||
_ = req
|
||||
return nil, ErrNotImplemented
|
||||
}
|
||||
|
||||
// DeleteComment 是删除自己评论用例占位,第三步实现软删除和权限判断。
|
||||
func (s *Service) DeleteComment(ctx context.Context, actorUserID uint64, commentID uint64) (*forumcontracts.DeleteForumCommentResult, error) {
|
||||
_ = ctx
|
||||
_ = actorUserID
|
||||
_ = commentID
|
||||
return nil, ErrNotImplemented
|
||||
}
|
||||
|
||||
// ImportPost 是一键导入用例占位,第三步会保证同一用户同一帖子只导入一次。
|
||||
func (s *Service) ImportPost(ctx context.Context, req forumcontracts.ImportForumPostRequest) (*forumcontracts.ImportForumPostResult, error) {
|
||||
_ = ctx
|
||||
_ = req
|
||||
return nil, ErrNotImplemented
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user