fix: scope creator contents and bind uploads
This commit is contained in:
@@ -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 仅返回置顶)。
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user