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

Method GetPost

internal/repository/post.go:268–280  ·  view source on GitHub ↗

GetPost 获取帖子

(ctx context.Context, postId uint)

Source from the content-addressed store, hash-verified

266
267// GetPost 获取帖子
268func (p *postRepository) GetPost(ctx context.Context, postId uint) (domain.Post, error) {
269 dp, err := p.dao.GetPost(ctx, postId)
270 if err != nil {
271 p.l.Error("获取帖子失败", zap.Error(err), zap.Uint("post_id", postId))
272 return domain.Post{}, fmt.Errorf("获取帖子失败: %w", err)
273 }
274
275 if err := p.cache.Set(ctx, fmt.Sprint(postId), change.ToDomainPost(dp)); err != nil {
276 p.l.Error("设置帖子缓存失败", zap.Error(err), zap.Uint("post_id", postId))
277 }
278
279 return change.ToDomainPost(dp), nil
280}
281
282// ListAllPosts 获取所有帖子
283func (p *postRepository) ListAllPosts(ctx context.Context, pagination domain.Pagination) ([]domain.Post, error) {

Callers

nothing calls this directly

Calls 3

ToDomainPostFunction · 0.92
GetPostMethod · 0.65
SetMethod · 0.65

Tested by

no test coverage detected