feat: add cover image functionality for articles
- Implemented `resolveApiURL` function to handle various URL formats. - Updated `ArticleDetail` and `UpdateArticleRequest` interfaces to include `cover_asset_url`. - Enhanced `ArticleEditorView` to manage cover image uploads, including a new `CoverPickerModal` component. - Added cover image requirements logic in `cover-requirements.ts` to enforce platform-specific cover image rules. - Modified backend services to handle cover image uploads and validations, including checks for required cover images for specific platforms. - Improved error handling for cover image requirements during article publishing.
This commit is contained in:
@@ -456,6 +456,9 @@ func (s *MediaService) CreatePublishBatch(ctx context.Context, articleID int64,
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if publishBatchRequiresCover(accountSeeds) && strings.TrimSpace(pointerStringValue(req.CoverAssetURL)) == "" {
|
||||
return nil, response.ErrBadRequest(40044, "publish_cover_required", "baijiahao publishing requires a cover image")
|
||||
}
|
||||
|
||||
var publishBatchID int64
|
||||
if err := tx.QueryRow(ctx, `
|
||||
@@ -529,6 +532,22 @@ func (s *MediaService) CreatePublishBatch(ctx context.Context, articleID int64,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func publishBatchRequiresCover(accounts []platformAccountSeed) bool {
|
||||
for _, account := range accounts {
|
||||
if strings.TrimSpace(account.PlatformID) == "baijiahao" {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func pointerStringValue(value *string) string {
|
||||
if value == nil {
|
||||
return ""
|
||||
}
|
||||
return *value
|
||||
}
|
||||
|
||||
func (s *MediaService) ListArticlePublishRecords(ctx context.Context, articleID int64) ([]PublishRecordResponse, error) {
|
||||
actor := auth.MustActor(ctx)
|
||||
return s.listArticlePublishRecords(ctx, actor.TenantID, articleID)
|
||||
|
||||
Reference in New Issue
Block a user