312 lines
12 KiB
Go
312 lines
12 KiB
Go
package dto
|
||
|
||
import (
|
||
v1_dto "quyun/v2/app/http/v1/dto"
|
||
"quyun/v2/app/requests"
|
||
"quyun/v2/pkg/consts"
|
||
)
|
||
|
||
// Filters
|
||
type UserListFilter struct {
|
||
requests.Pagination
|
||
Username *string `query:"username"`
|
||
}
|
||
|
||
type TenantListFilter struct {
|
||
requests.Pagination
|
||
Name *string `query:"name"`
|
||
}
|
||
|
||
type SuperContentListFilter struct {
|
||
requests.Pagination
|
||
// ID 内容ID,精确匹配。
|
||
ID *int64 `query:"id"`
|
||
// TenantID 租户ID,精确匹配。
|
||
TenantID *int64 `query:"tenant_id"`
|
||
// TenantCode 租户编码,模糊匹配。
|
||
TenantCode *string `query:"tenant_code"`
|
||
// TenantName 租户名称,模糊匹配。
|
||
TenantName *string `query:"tenant_name"`
|
||
// UserID 作者用户ID,精确匹配。
|
||
UserID *int64 `query:"user_id"`
|
||
// Username 作者用户名/昵称,模糊匹配。
|
||
Username *string `query:"username"`
|
||
// Keyword 标题或摘要关键字,模糊匹配。
|
||
Keyword *string `query:"keyword"`
|
||
// Status 内容状态过滤。
|
||
Status *consts.ContentStatus `query:"status"`
|
||
// Visibility 内容可见性过滤。
|
||
Visibility *consts.ContentVisibility `query:"visibility"`
|
||
// PublishedAtFrom 发布时间起始(RFC3339)。
|
||
PublishedAtFrom *string `query:"published_at_from"`
|
||
// PublishedAtTo 发布时间结束(RFC3339)。
|
||
PublishedAtTo *string `query:"published_at_to"`
|
||
// CreatedAtFrom 创建时间起始(RFC3339)。
|
||
CreatedAtFrom *string `query:"created_at_from"`
|
||
// CreatedAtTo 创建时间结束(RFC3339)。
|
||
CreatedAtTo *string `query:"created_at_to"`
|
||
// PriceAmountMin 价格下限(分)。
|
||
PriceAmountMin *int64 `query:"price_amount_min"`
|
||
// PriceAmountMax 价格上限(分)。
|
||
PriceAmountMax *int64 `query:"price_amount_max"`
|
||
// Asc 升序字段(id/title/published_at/created_at 等)。
|
||
Asc *string `query:"asc"`
|
||
// Desc 降序字段(id/title/published_at/created_at 等)。
|
||
Desc *string `query:"desc"`
|
||
}
|
||
|
||
type SuperOrderListFilter struct {
|
||
requests.Pagination
|
||
// ID 订单ID,精确匹配。
|
||
ID *int64 `query:"id"`
|
||
// TenantID 租户ID,精确匹配。
|
||
TenantID *int64 `query:"tenant_id"`
|
||
// TenantCode 租户编码,模糊匹配。
|
||
TenantCode *string `query:"tenant_code"`
|
||
// TenantName 租户名称,模糊匹配。
|
||
TenantName *string `query:"tenant_name"`
|
||
// UserID 买家用户ID,精确匹配。
|
||
UserID *int64 `query:"user_id"`
|
||
// Username 买家用户名/昵称,模糊匹配。
|
||
Username *string `query:"username"`
|
||
// ContentID 内容ID,精确匹配。
|
||
ContentID *int64 `query:"content_id"`
|
||
// ContentTitle 内容标题关键字,模糊匹配。
|
||
ContentTitle *string `query:"content_title"`
|
||
// Type 订单类型过滤。
|
||
Type *consts.OrderType `query:"type"`
|
||
// Status 订单状态过滤。
|
||
Status *consts.OrderStatus `query:"status"`
|
||
// CreatedAtFrom 创建时间起始(RFC3339)。
|
||
CreatedAtFrom *string `query:"created_at_from"`
|
||
// CreatedAtTo 创建时间结束(RFC3339)。
|
||
CreatedAtTo *string `query:"created_at_to"`
|
||
// PaidAtFrom 支付时间起始(RFC3339)。
|
||
PaidAtFrom *string `query:"paid_at_from"`
|
||
// PaidAtTo 支付时间结束(RFC3339)。
|
||
PaidAtTo *string `query:"paid_at_to"`
|
||
// AmountPaidMin 实付金额下限(分)。
|
||
AmountPaidMin *int64 `query:"amount_paid_min"`
|
||
// AmountPaidMax 实付金额上限(分)。
|
||
AmountPaidMax *int64 `query:"amount_paid_max"`
|
||
// Asc 升序字段(id/created_at/paid_at/amount_paid 等)。
|
||
Asc *string `query:"asc"`
|
||
// Desc 降序字段(id/created_at/paid_at/amount_paid 等)。
|
||
Desc *string `query:"desc"`
|
||
}
|
||
|
||
// SuperUserLite 用于平台用户列表的轻量级用户信息
|
||
type SuperUserLite struct {
|
||
ID int64 `json:"id"`
|
||
Username string `json:"username"`
|
||
Roles []consts.Role `json:"roles"`
|
||
Status consts.UserStatus `json:"status"`
|
||
StatusDescription string `json:"status_description"`
|
||
VerifiedAt string `json:"verified_at"`
|
||
CreatedAt string `json:"created_at"`
|
||
UpdatedAt string `json:"updated_at"`
|
||
}
|
||
|
||
type UserItem struct {
|
||
SuperUserLite
|
||
Balance int64 `json:"balance"`
|
||
BalanceFrozen int64 `json:"balance_frozen"`
|
||
OwnedTenantCount int64 `json:"owned_tenant_count"`
|
||
JoinedTenantCount int64 `json:"joined_tenant_count"`
|
||
}
|
||
|
||
type UserStatistics struct {
|
||
Status consts.UserStatus `json:"status"`
|
||
StatusDescription string `json:"status_description"`
|
||
Count int64 `json:"count"`
|
||
}
|
||
|
||
type UserStatusUpdateForm struct {
|
||
Status consts.UserStatus `json:"status" validate:"required"`
|
||
}
|
||
|
||
type UserRolesUpdateForm struct {
|
||
Roles []consts.Role `json:"roles" validate:"required,min=1"`
|
||
}
|
||
|
||
type UserTenantItem struct {
|
||
TenantID int64 `json:"tenant_id"`
|
||
TenantStatus consts.TenantStatus `json:"tenant_status"`
|
||
TenantStatusDescription string `json:"tenant_status_description"`
|
||
Name string `json:"name"`
|
||
Code string `json:"code"`
|
||
Owner *TenantOwnerUserLite `json:"owner"`
|
||
Role []consts.TenantUserRole `json:"role"`
|
||
MemberStatus consts.UserStatus `json:"member_status"`
|
||
MemberStatusDescription string `json:"member_status_description"`
|
||
JoinedAt string `json:"joined_at"`
|
||
ExpiredAt string `json:"expired_at"`
|
||
}
|
||
|
||
// Tenant Related
|
||
type TenantCreateForm struct {
|
||
Name string `json:"name" validate:"required,max=128"`
|
||
Code string `json:"code" validate:"required,max=64"`
|
||
AdminUserID int64 `json:"admin_user_id" validate:"required"`
|
||
Duration int `json:"duration" validate:"required,oneof=7 30 90 180 365"`
|
||
}
|
||
|
||
type TenantItem struct {
|
||
ID int64 `json:"id"`
|
||
UUID string `json:"uuid"`
|
||
Code string `json:"code"`
|
||
Name string `json:"name"`
|
||
Status consts.TenantStatus `json:"status"`
|
||
StatusDescription string `json:"status_description"`
|
||
Config []int `json:"config"` // Replace with actual config struct if needed
|
||
Owner *TenantOwnerUserLite `json:"owner"`
|
||
AdminUsers []*TenantAdminUserLite `json:"admin_users"`
|
||
UserCount int64 `json:"user_count"`
|
||
IncomeAmountPaidSum int64 `json:"income_amount_paid_sum"`
|
||
ExpiredAt string `json:"expired_at"`
|
||
CreatedAt string `json:"created_at"`
|
||
UpdatedAt string `json:"updated_at"`
|
||
UserID int64 `json:"user_id"`
|
||
Users []*SuperUserLite `json:"users"`
|
||
}
|
||
|
||
type TenantOwnerUserLite struct {
|
||
ID int64 `json:"id"`
|
||
Username string `json:"username"`
|
||
}
|
||
|
||
type TenantAdminUserLite struct {
|
||
ID int64 `json:"id"`
|
||
Username string `json:"username"`
|
||
}
|
||
|
||
type TenantExpireUpdateForm struct {
|
||
Duration int `json:"duration" validate:"required,oneof=7 30 90 180 365"`
|
||
}
|
||
|
||
type TenantStatusUpdateForm struct {
|
||
Status consts.TenantStatus `json:"status" validate:"required"`
|
||
}
|
||
|
||
type SuperTenantContentItem struct {
|
||
Content *v1_dto.ContentItem `json:"content"`
|
||
StatusDescription string `json:"status_description"`
|
||
VisibilityDescription string `json:"visibility_description"`
|
||
Tenant *SuperContentTenantLite `json:"tenant"`
|
||
Owner *SuperUserLite `json:"owner"`
|
||
Price *v1_dto.ContentPrice `json:"price"`
|
||
}
|
||
|
||
type SuperContentTenantLite struct {
|
||
ID int64 `json:"id"`
|
||
Code string `json:"code"`
|
||
Name string `json:"name"`
|
||
}
|
||
|
||
type SuperTenantContentStatusUpdateForm struct {
|
||
Status consts.ContentStatus `json:"status" validate:"required,oneof=unpublished blocked"`
|
||
}
|
||
|
||
type SuperTenantUserItem struct {
|
||
User *SuperUserLite `json:"user"`
|
||
TenantUser *TenantUser `json:"tenant_user"`
|
||
}
|
||
|
||
type TenantUser struct {
|
||
ID int64 `json:"id"`
|
||
TenantID int64 `json:"tenant_id"`
|
||
UserID int64 `json:"user_id"`
|
||
Role []consts.TenantUserRole `json:"role"`
|
||
Status consts.UserStatus `json:"status"`
|
||
CreatedAt string `json:"created_at"`
|
||
UpdatedAt string `json:"updated_at"`
|
||
}
|
||
|
||
// Order Related
|
||
type SuperOrderItem struct {
|
||
ID int64 `json:"id"`
|
||
Type consts.OrderType `json:"type"`
|
||
Status consts.OrderStatus `json:"status"`
|
||
StatusDescription string `json:"status_description"`
|
||
Currency consts.Currency `json:"currency"`
|
||
AmountOriginal int64 `json:"amount_original"`
|
||
AmountDiscount int64 `json:"amount_discount"`
|
||
AmountPaid int64 `json:"amount_paid"`
|
||
Tenant *OrderTenantLite `json:"tenant"`
|
||
Buyer *OrderBuyerLite `json:"buyer"`
|
||
// Snapshot 订单快照,包含下单时的关键参数与定价信息,便于审计回溯。
|
||
Snapshot any `json:"snapshot"`
|
||
// Items 订单明细行,用于展示具体内容与金额拆分。
|
||
Items []SuperOrderItemLine `json:"items"`
|
||
PaidAt string `json:"paid_at"`
|
||
RefundedAt string `json:"refunded_at"`
|
||
CreatedAt string `json:"created_at"`
|
||
UpdatedAt string `json:"updated_at"`
|
||
}
|
||
|
||
type OrderTenantLite struct {
|
||
ID int64 `json:"id"`
|
||
Code string `json:"code"`
|
||
Name string `json:"name"`
|
||
}
|
||
|
||
type OrderBuyerLite struct {
|
||
ID int64 `json:"id"`
|
||
Username string `json:"username"`
|
||
}
|
||
|
||
// SuperOrderItemLine 表示订单明细行。
|
||
type SuperOrderItemLine struct {
|
||
// ID 订单明细ID。
|
||
ID int64 `json:"id"`
|
||
// ContentID 购买的内容ID。
|
||
ContentID int64 `json:"content_id"`
|
||
// AmountPaid 该明细实付金额(分)。
|
||
AmountPaid int64 `json:"amount_paid"`
|
||
// Snapshot 明细快照,用于展示内容标题等历史信息。
|
||
Snapshot any `json:"snapshot"`
|
||
}
|
||
|
||
type OrderStatisticsResponse struct {
|
||
TotalCount int64 `json:"total_count"`
|
||
TotalAmountPaidSum int64 `json:"total_amount_paid_sum"`
|
||
ByStatus []OrderStatisticsRow `json:"by_status"`
|
||
}
|
||
|
||
type OrderStatisticsRow struct {
|
||
Status consts.OrderStatus `json:"status"`
|
||
StatusDescription string `json:"status_description"`
|
||
Count int64 `json:"count"`
|
||
AmountPaidSum int64 `json:"amount_paid_sum"`
|
||
}
|
||
|
||
type SuperOrderDetail struct {
|
||
Order *SuperOrderItem `json:"order"` // Using SuperOrderItem as base, extend if needed
|
||
Tenant *OrderTenantLite `json:"tenant"`
|
||
Buyer *OrderBuyerLite `json:"buyer"`
|
||
}
|
||
|
||
type SuperOrderRefundForm struct {
|
||
Force bool `json:"force"`
|
||
Reason string `json:"reason"`
|
||
IdempotencyKey string `json:"idempotency_key"`
|
||
}
|
||
|
||
// AdminContentItem for super admin view
|
||
type AdminContentItem struct {
|
||
Content *v1_dto.ContentItem `json:"content"`
|
||
Owner *AdminContentOwnerLite `json:"owner"`
|
||
Price *v1_dto.ContentPrice `json:"price"`
|
||
StatusDescription string `json:"status_description"`
|
||
VisibilityDescription string `json:"visibility_description"`
|
||
// Tenant 内容所属租户信息,用于超管列表展示与跳转。
|
||
Tenant *SuperContentTenantLite `json:"tenant"`
|
||
}
|
||
|
||
type AdminContentOwnerLite struct {
|
||
ID int64 `json:"id"`
|
||
Username string `json:"username"`
|
||
Roles []consts.Role `json:"roles"`
|
||
Status consts.UserStatus `json:"status"`
|
||
}
|