feat: scope articles by brand
This commit is contained in:
@@ -78,7 +78,11 @@ func (s *ArticleSelectionOptimizeService) ValidateRequest(
|
||||
}
|
||||
|
||||
actor := auth.MustActor(ctx)
|
||||
return s.ensureArticleEditable(ctx, articleID, actor.TenantID)
|
||||
brandID, err := requireCurrentBrandID(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return s.ensureArticleEditable(ctx, articleID, actor.TenantID, brandID)
|
||||
}
|
||||
|
||||
func (s *ArticleSelectionOptimizeService) OptimizeSelection(
|
||||
@@ -154,15 +158,17 @@ func (s *ArticleSelectionOptimizeService) ensureArticleEditable(
|
||||
ctx context.Context,
|
||||
articleID int64,
|
||||
tenantID int64,
|
||||
brandID int64,
|
||||
) error {
|
||||
var generateStatus string
|
||||
err := s.pool.QueryRow(
|
||||
ctx,
|
||||
`SELECT generate_status
|
||||
FROM articles
|
||||
WHERE id = $1 AND tenant_id = $2 AND deleted_at IS NULL`,
|
||||
WHERE id = $1 AND tenant_id = $2 AND brand_id = $3 AND deleted_at IS NULL`,
|
||||
articleID,
|
||||
tenantID,
|
||||
brandID,
|
||||
).Scan(&generateStatus)
|
||||
if err != nil {
|
||||
if err == pgx.ErrNoRows {
|
||||
|
||||
Reference in New Issue
Block a user