Update 更新帖子
(ctx context.Context, post domain.Post)
| 67 | |
| 68 | // Update 更新帖子 |
| 69 | func (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 更新帖子状态 |
| 88 | func (p *postRepository) UpdateStatus(ctx context.Context, postId uint, uid int64, status uint8) error { |
nothing calls this directly
no test coverage detected