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

Method Update

internal/repository/post.go:69–85  ·  view source on GitHub ↗

Update 更新帖子

(ctx context.Context, post domain.Post)

Source from the content-addressed store, hash-verified

67
68// Update 更新帖子
69func (p *postRepository) Update(ctx context.Context, post domain.Post) error {
70 oldStatus := post.Status
71 post.Status = domain.Draft
72
73 if err := p.dao.Update(ctx, change.FromDomainPost(post)); err != nil {
74 p.l.Error("更新帖子失败", zap.Error(err), zap.Uint("post_id", post.ID))
75 return fmt.Errorf("更新帖子失败: %w", err)
76 }
77
78 if oldStatus == domain.Published {
79 p.refreshCache(job.RefreshTypeAll, "*", post.ID)
80 return nil
81 }
82
83 p.refreshCache(job.RefreshTypeNormal, "*", post.ID)
84 return nil
85}
86
87// UpdateStatus 更新帖子状态
88func (p *postRepository) UpdateStatus(ctx context.Context, postId uint, uid int64, status uint8) error {

Callers

nothing calls this directly

Calls 3

refreshCacheMethod · 0.95
FromDomainPostFunction · 0.92
UpdateMethod · 0.65

Tested by

no test coverage detected