feat: 添加内容创建表单状态字段,优化内容保存和发布逻辑
This commit is contained in:
@@ -201,6 +201,10 @@ func (s *creator) CreateContent(ctx context.Context, userID int64, form *creator
|
||||
uid := userID
|
||||
|
||||
return models.Q.Transaction(func(tx *models.Query) error {
|
||||
status := consts.ContentStatusPublished
|
||||
if form.Status != "" {
|
||||
status = consts.ContentStatus(form.Status)
|
||||
}
|
||||
// 1. Create Content
|
||||
content := &models.Content{
|
||||
TenantID: tid,
|
||||
@@ -208,7 +212,7 @@ func (s *creator) CreateContent(ctx context.Context, userID int64, form *creator
|
||||
Title: form.Title,
|
||||
Genre: form.Genre,
|
||||
Key: form.Key,
|
||||
Status: consts.ContentStatusPublished,
|
||||
Status: status,
|
||||
}
|
||||
if err := tx.Content.WithContext(ctx).Create(content); err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user