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

Method Create

internal/repository/post.go:54–66  ·  view source on GitHub ↗

Create 创建帖子

(ctx context.Context, post domain.Post)

Source from the content-addressed store, hash-verified

52
53// Create 创建帖子
54func (p *postRepository) Create(ctx context.Context, post domain.Post) (uint, error) {
55 // 设置帖子的唯一标识符
56 post.Slug = uuid.New().String() + strconv.Itoa(int(post.ID))
57
58 id, err := p.dao.Insert(ctx, change.FromDomainPost(post))
59 if err != nil {
60 p.l.Error("创建帖子失败", zap.Error(err))
61 return 0, fmt.Errorf("创建帖子失败: %w", err)
62 }
63
64 p.refreshCache(job.RefreshTypeNormal, "*")
65 return id, nil
66}
67
68// Update 更新帖子
69func (p *postRepository) Update(ctx context.Context, post domain.Post) error {

Callers

nothing calls this directly

Calls 3

refreshCacheMethod · 0.95
FromDomainPostFunction · 0.92
InsertMethod · 0.65

Tested by

no test coverage detected