fix: scope creator contents and bind uploads

This commit is contained in:
2026-01-12 15:33:39 +08:00
parent 16d13a2ab1
commit 4022a776a6
4 changed files with 69 additions and 15 deletions

View File

@@ -11,6 +11,8 @@ type ContentListFilter struct {
Genre *string `query:"genre"`
// TenantID 租户ID筛选内容所属店铺
TenantID *int64 `query:"tenant_id"`
// AuthorID 作者用户ID筛选用于筛选创作者作品
AuthorID *int64 `query:"author_id"`
// Sort 排序规则latest/hot/price_asc
Sort *string `query:"sort"`
// IsPinned 置顶内容筛选true 仅返回置顶)。

View File

@@ -21,7 +21,7 @@ type Tenant struct{}
// @Tags TenantPublic
// @Accept json
// @Produce json
// @Param id path int64 true "Tenant ID"
// @Param id path int64 true "Creator User ID"
// @Param page query int false "Page"
// @Param limit query int false "Limit"
// @Success 200 {object} requests.Pager
@@ -29,13 +29,13 @@ type Tenant struct{}
// @Bind filter query
func (t *Tenant) ListContents(ctx fiber.Ctx, id int64, filter *dto.ContentListFilter) (*requests.Pager, error) {
tenantID := getTenantID(ctx)
if tenantID > 0 && id != tenantID {
return nil, errorx.ErrForbidden.WithMsg("租户不匹配")
}
if filter == nil {
filter = &dto.ContentListFilter{}
}
filter.TenantID = &tenantID
if tenantID > 0 {
filter.TenantID = &tenantID
}
filter.AuthorID = &id
return services.Content.List(ctx, tenantID, filter)
}