This commit is contained in:
2025-12-18 09:54:29 +08:00
parent 1eef314e98
commit 650ada9cc6
25 changed files with 3929 additions and 43 deletions

View File

@@ -0,0 +1,43 @@
package dto
import (
"quyun/v2/app/requests"
"quyun/v2/database/models"
)
type ContentListFilter struct {
// Pagination controls paging parameters (page/limit).
requests.Pagination `json:",inline" query:",inline"`
// Keyword filters by title keyword (LIKE).
Keyword *string `json:"keyword,omitempty" query:"keyword"`
}
// ContentItem is a list item with price snapshot and access indicator for current user.
type ContentItem struct {
// Content is the content entity.
Content *models.Content `json:"content,omitempty"`
// Price is the current price settings for the content (may be nil if not set).
Price *models.ContentPrice `json:"price,omitempty"`
// HasAccess indicates whether current user can access main assets (free/owner/purchased).
HasAccess bool `json:"has_access"`
}
// ContentDetail is the detail payload with price snapshot and access indicator for current user.
type ContentDetail struct {
// Content is the content entity.
Content *models.Content `json:"content,omitempty"`
// Price is the current price settings for the content (may be nil if not set).
Price *models.ContentPrice `json:"price,omitempty"`
// HasAccess indicates whether current user can access main assets (free/owner/purchased).
HasAccess bool `json:"has_access"`
}
// ContentAssetsResponse returns assets for either preview or main role.
type ContentAssetsResponse struct {
// Content is the content entity.
Content *models.Content `json:"content,omitempty"`
// Assets is the list of media assets for the requested role (preview/main).
Assets []*models.MediaAsset `json:"assets,omitempty"`
// PreviewSeconds indicates the max preview duration (only meaningful for preview response).
PreviewSeconds int32 `json:"preview_seconds,omitempty"`
}

View File

@@ -0,0 +1,58 @@
package dto
import (
"time"
"quyun/v2/pkg/consts"
)
type ContentCreateForm struct {
// Title is the content title.
Title string `json:"title,omitempty"`
// Description is the content description.
Description string `json:"description,omitempty"`
// Visibility controls who can view the content detail (main assets still require free/purchase).
Visibility consts.ContentVisibility `json:"visibility,omitempty"`
// PreviewSeconds controls preview duration (defaults to 60 when omitted).
PreviewSeconds *int32 `json:"preview_seconds,omitempty"`
}
// ContentUpdateForm updates mutable fields of a content.
type ContentUpdateForm struct {
// Title updates the title when provided.
Title *string `json:"title,omitempty"`
// Description updates the description when provided.
Description *string `json:"description,omitempty"`
// Visibility updates the visibility when provided.
Visibility *consts.ContentVisibility `json:"visibility,omitempty"`
// Status updates the content status when provided (e.g. publish/unpublish).
Status *consts.ContentStatus `json:"status,omitempty"`
// PreviewSeconds updates preview duration when provided (must be > 0).
PreviewSeconds *int32 `json:"preview_seconds,omitempty"`
}
// ContentPriceUpsertForm upserts pricing and discount settings for a content.
type ContentPriceUpsertForm struct {
// PriceAmount is the base price in cents (CNY 分).
PriceAmount int64 `json:"price_amount,omitempty"`
// Currency is fixed to CNY for now.
Currency consts.Currency `json:"currency,omitempty"`
// DiscountType defines the discount algorithm (none/percent/amount).
DiscountType consts.DiscountType `json:"discount_type,omitempty"`
// DiscountValue is interpreted based on DiscountType.
DiscountValue int64 `json:"discount_value,omitempty"`
// DiscountStartAt enables discount from this time (optional).
DiscountStartAt *time.Time `json:"discount_start_at,omitempty"`
// DiscountEndAt disables discount after this time (optional).
DiscountEndAt *time.Time `json:"discount_end_at,omitempty"`
}
// ContentAssetAttachForm attaches a media asset to a content with a role and sort order.
type ContentAssetAttachForm struct {
// AssetID is the media asset id to attach.
AssetID int64 `json:"asset_id,omitempty"`
// Role indicates how this asset is used (main/cover/preview).
Role consts.ContentAssetRole `json:"role,omitempty"`
// Sort controls ordering under the same role.
Sort int32 `json:"sort,omitempty"`
}

View File

@@ -2,8 +2,12 @@ package dto
import "quyun/v2/database/models"
// MeResponse returns the resolved tenant context for the current request.
type MeResponse struct {
Tenant *models.Tenant `json:"tenant,omitempty"`
User *models.User `json:"user,omitempty"`
// Tenant is the resolved tenant by `tenant_code`.
Tenant *models.Tenant `json:"tenant,omitempty"`
// User is the authenticated user derived from JWT `user_id`.
User *models.User `json:"user,omitempty"`
// TenantUser is the membership record of the authenticated user within the tenant.
TenantUser *models.TenantUser `json:"tenant_user,omitempty"`
}