MCPcopy Create free account
hub / github.com/GoSimplicity/LinkMe / Collect

Method Collect

internal/service/interactive.go:64–80  ·  view source on GitHub ↗

Collect 处理收藏逻辑

(ctx context.Context, postId uint, uid int64)

Source from the content-addressed store, hash-verified

62
63// Collect 处理收藏逻辑
64func (i *interactiveService) Collect(ctx context.Context, postId uint, uid int64) error {
65 if postId == 0 || uid <= 0 {
66 return errors.New("invalid parameters")
67 }
68
69 collected, err := i.repo.Collected(ctx, postId, uid)
70 if err != nil && !errors.Is(err, dao.ErrRecordNotFound) {
71 i.l.Error("收藏状态查询失败", zap.Error(err), zap.Uint("postId", postId), zap.Int64("uid", uid))
72 return err
73 }
74
75 if collected {
76 return errors.New("已收藏")
77 }
78
79 return i.repo.IncrCollectionItem(ctx, postId, uid)
80}
81
82// CancelCollect 处理取消收藏逻辑
83func (i *interactiveService) CancelCollect(ctx context.Context, postId uint, uid int64) error {

Callers

nothing calls this directly

Calls 2

CollectedMethod · 0.65
IncrCollectionItemMethod · 0.65

Tested by

no test coverage detected