Create 创建帖子
(ctx context.Context, post domain.Post)
| 52 | |
| 53 | // Create 创建帖子 |
| 54 | func (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 更新帖子 |
| 69 | func (p *postRepository) Update(ctx context.Context, post domain.Post) error { |
nothing calls this directly
no test coverage detected