feat: implement new structure
This commit is contained in:
36
backend/app/http/v1/dto/auth.go
Normal file
36
backend/app/http/v1/dto/auth.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package dto
|
||||
|
||||
import "quyun/v2/pkg/consts"
|
||||
|
||||
type SendOTPForm struct {
|
||||
Phone string `json:"phone"`
|
||||
}
|
||||
|
||||
type LoginForm struct {
|
||||
Phone string `json:"phone"`
|
||||
OTP string `json:"otp"`
|
||||
}
|
||||
|
||||
type LoginResponse struct {
|
||||
Token string `json:"token"`
|
||||
User *User `json:"user"`
|
||||
}
|
||||
|
||||
type User struct {
|
||||
ID string `json:"id"`
|
||||
Phone string `json:"phone"`
|
||||
Nickname string `json:"nickname"`
|
||||
Avatar string `json:"avatar"`
|
||||
Gender consts.Gender `json:"gender"`
|
||||
Bio string `json:"bio"`
|
||||
Birthday string `json:"birthday"` // YYYY-MM-DD
|
||||
Location *Location `json:"location"`
|
||||
Balance float64 `json:"balance"`
|
||||
Points int64 `json:"points"`
|
||||
IsRealNameVerified bool `json:"isRealNameVerified"`
|
||||
}
|
||||
|
||||
type Location struct {
|
||||
Province string `json:"province"`
|
||||
City string `json:"city"`
|
||||
}
|
||||
9
backend/app/http/v1/dto/common.go
Normal file
9
backend/app/http/v1/dto/common.go
Normal file
@@ -0,0 +1,9 @@
|
||||
package dto
|
||||
|
||||
type UploadResult struct {
|
||||
ID string `json:"id"`
|
||||
URL string `json:"url"`
|
||||
Filename string `json:"filename"`
|
||||
Size int64 `json:"size"`
|
||||
MimeType string `json:"mimeType"`
|
||||
}
|
||||
84
backend/app/http/v1/dto/content.go
Normal file
84
backend/app/http/v1/dto/content.go
Normal file
@@ -0,0 +1,84 @@
|
||||
package dto
|
||||
|
||||
import "quyun/v2/app/requests"
|
||||
|
||||
type ContentItem struct {
|
||||
ID string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Cover string `json:"cover"`
|
||||
Genre string `json:"genre"`
|
||||
Type string `json:"type"` // video, audio, article
|
||||
Price float64 `json:"price"`
|
||||
AuthorID string `json:"authorId"`
|
||||
AuthorName string `json:"authorName"`
|
||||
AuthorAvatar string `json:"authorAvatar"`
|
||||
Views int `json:"views"`
|
||||
Likes int `json:"likes"`
|
||||
IsPurchased bool `json:"isPurchased"`
|
||||
}
|
||||
|
||||
type ContentDetail struct {
|
||||
ContentItem
|
||||
Description string `json:"description"`
|
||||
Body string `json:"body"`
|
||||
MediaUrls []MediaURL `json:"mediaUrls"`
|
||||
Meta Meta `json:"meta"`
|
||||
IsLiked bool `json:"isLiked"`
|
||||
IsFavorited bool `json:"isFavorited"`
|
||||
}
|
||||
|
||||
type MediaURL struct {
|
||||
Type string `json:"type"`
|
||||
URL string `json:"url"`
|
||||
Duration int `json:"duration"`
|
||||
}
|
||||
|
||||
type Meta struct {
|
||||
Role string `json:"role"`
|
||||
Key string `json:"key"`
|
||||
Beat string `json:"beat"`
|
||||
}
|
||||
|
||||
type Comment struct {
|
||||
ID string `json:"id"`
|
||||
Content string `json:"content"`
|
||||
UserID string `json:"userId"`
|
||||
UserNickname string `json:"userNickname"`
|
||||
UserAvatar string `json:"userAvatar"`
|
||||
CreateTime string `json:"createTime"`
|
||||
Likes int `json:"likes"`
|
||||
IsLiked bool `json:"isLiked"`
|
||||
ReplyTo string `json:"replyTo"`
|
||||
}
|
||||
|
||||
type CommentListResponse struct {
|
||||
Data []Comment `json:"data"`
|
||||
Pagination requests.Pagination `json:"pagination"`
|
||||
}
|
||||
|
||||
type CommentCreateForm struct {
|
||||
Content string `json:"content"`
|
||||
ReplyTo string `json:"replyTo"`
|
||||
}
|
||||
|
||||
type ContentListResponse struct {
|
||||
Data []ContentItem `json:"data"`
|
||||
Pagination requests.Pagination `json:"pagination"`
|
||||
}
|
||||
|
||||
type Topic struct {
|
||||
ID string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Cover string `json:"cover"`
|
||||
Tag string `json:"tag"`
|
||||
Count int `json:"count"`
|
||||
}
|
||||
|
||||
type ContentPrice struct {
|
||||
Currency string `json:"currency"`
|
||||
PriceAmount float64 `json:"priceAmount"`
|
||||
DiscountType string `json:"discountType"`
|
||||
DiscountValue float64 `json:"discountValue"`
|
||||
DiscountStartAt string `json:"discountStartAt"`
|
||||
DiscountEndAt string `json:"discountEndAt"`
|
||||
}
|
||||
77
backend/app/http/v1/dto/creator.go
Normal file
77
backend/app/http/v1/dto/creator.go
Normal file
@@ -0,0 +1,77 @@
|
||||
package dto
|
||||
|
||||
type ApplyForm struct {
|
||||
Name string `json:"name"`
|
||||
Bio string `json:"bio"`
|
||||
Avatar string `json:"avatar"`
|
||||
}
|
||||
|
||||
type DashboardStats struct {
|
||||
TotalFollowers IntStatItem `json:"totalFollowers"`
|
||||
TotalRevenue FloatStatItem `json:"totalRevenue"`
|
||||
PendingRefunds int `json:"pendingRefunds"`
|
||||
NewMessages int `json:"newMessages"`
|
||||
}
|
||||
|
||||
type IntStatItem struct {
|
||||
Value int `json:"value"`
|
||||
Trend float64 `json:"trend"`
|
||||
}
|
||||
|
||||
type FloatStatItem struct {
|
||||
Value float64 `json:"value"`
|
||||
Trend float64 `json:"trend"`
|
||||
}
|
||||
|
||||
type ContentCreateForm struct {
|
||||
Title string `json:"title"`
|
||||
Genre string `json:"genre"`
|
||||
Price float64 `json:"price"`
|
||||
MediaIDs []string `json:"mediaIds"`
|
||||
}
|
||||
|
||||
type ContentUpdateForm struct {
|
||||
Title string `json:"title"`
|
||||
Genre string `json:"genre"`
|
||||
Price float64 `json:"price"`
|
||||
MediaIDs []string `json:"mediaIds"`
|
||||
}
|
||||
|
||||
type RefundForm struct {
|
||||
Action string `json:"action"` // accept, reject
|
||||
Reason string `json:"reason"`
|
||||
}
|
||||
|
||||
type Settings struct {
|
||||
Name string `json:"name"`
|
||||
Bio string `json:"bio"`
|
||||
Avatar string `json:"avatar"`
|
||||
Cover string `json:"cover"`
|
||||
Description string `json:"description"`
|
||||
}
|
||||
|
||||
type PayoutAccount struct {
|
||||
ID string `json:"id"`
|
||||
Type string `json:"type"` // bank, alipay
|
||||
Name string `json:"name"`
|
||||
Account string `json:"account"`
|
||||
Realname string `json:"realname"`
|
||||
}
|
||||
|
||||
type WithdrawForm struct {
|
||||
Amount float64 `json:"amount"`
|
||||
Method string `json:"method"` // wallet, external
|
||||
AccountID string `json:"accountId"`
|
||||
}
|
||||
|
||||
// Re-export or Wrap
|
||||
// Since ContentItem and Order are in the same package 'dto',
|
||||
// we don't need type aliases unless we want to rename them.
|
||||
// If creator.go uses them, it can use dto.ContentItem directly.
|
||||
// But creator.go is in `v1` (package v1) and imports `dto`.
|
||||
// So it uses `dto.ContentItem`.
|
||||
// So we don't need aliases here if the original types are in this package.
|
||||
|
||||
// However, if the originals were in `content/dto` and `user/dto` and we moved them to `v1/dto` (this package),
|
||||
// then we just have them defined in `content.go` (dto) and `user.go` (dto).
|
||||
// So aliases are not needed if they are in the same package.
|
||||
23
backend/app/http/v1/dto/order.go
Normal file
23
backend/app/http/v1/dto/order.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package dto
|
||||
|
||||
type OrderCreateForm struct {
|
||||
ContentID string `json:"contentId"`
|
||||
Sku string `json:"sku"`
|
||||
Quantity int `json:"quantity"`
|
||||
}
|
||||
|
||||
type OrderCreateResponse struct {
|
||||
OrderID string `json:"orderId"`
|
||||
}
|
||||
|
||||
type OrderPayForm struct {
|
||||
Method string `json:"method"` // wechat, alipay, balance
|
||||
}
|
||||
|
||||
type OrderPayResponse struct {
|
||||
PayParams string `json:"payParams"`
|
||||
}
|
||||
|
||||
type OrderStatusResponse struct {
|
||||
Status string `json:"status"` // unpaid, paid, completed
|
||||
}
|
||||
202
backend/app/http/v1/dto/super.go
Normal file
202
backend/app/http/v1/dto/super.go
Normal file
@@ -0,0 +1,202 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"quyun/v2/pkg/consts"
|
||||
)
|
||||
|
||||
// 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 *ContentItem `json:"content"`
|
||||
StatusDescription string `json:"status_description"`
|
||||
VisibilityDescription string `json:"visibility_description"`
|
||||
Tenant *SuperContentTenantLite `json:"tenant"`
|
||||
Owner *SuperUserLite `json:"owner"`
|
||||
Price *ContentPrice `json:"price"` // Reuse or define specific price struct
|
||||
}
|
||||
|
||||
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"`
|
||||
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"`
|
||||
}
|
||||
|
||||
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 *ContentItem `json:"content"`
|
||||
Owner *AdminContentOwnerLite `json:"owner"`
|
||||
Price *ContentPrice `json:"price"`
|
||||
StatusDescription string `json:"status_description"`
|
||||
VisibilityDescription string `json:"visibility_description"`
|
||||
}
|
||||
|
||||
type AdminContentOwnerLite struct {
|
||||
ID int64 `json:"id"`
|
||||
Username string `json:"username"`
|
||||
Roles []consts.Role `json:"roles"`
|
||||
Status consts.UserStatus `json:"status"`
|
||||
}
|
||||
19
backend/app/http/v1/dto/tenant.go
Normal file
19
backend/app/http/v1/dto/tenant.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package dto
|
||||
|
||||
type TenantProfile struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Avatar string `json:"avatar"`
|
||||
Cover string `json:"cover"`
|
||||
Bio string `json:"bio"`
|
||||
Description string `json:"description"`
|
||||
CertType string `json:"certType"` // personal, enterprise
|
||||
Stats Stats `json:"stats"`
|
||||
IsFollowing bool `json:"isFollowing"`
|
||||
}
|
||||
|
||||
type Stats struct {
|
||||
Followers int `json:"followers"`
|
||||
Contents int `json:"contents"`
|
||||
Likes int `json:"likes"`
|
||||
}
|
||||
62
backend/app/http/v1/dto/user.go
Normal file
62
backend/app/http/v1/dto/user.go
Normal file
@@ -0,0 +1,62 @@
|
||||
package dto
|
||||
|
||||
import "quyun/v2/pkg/consts"
|
||||
|
||||
type UserUpdate struct {
|
||||
Nickname string `json:"nickname"`
|
||||
Avatar string `json:"avatar"`
|
||||
Gender consts.Gender `json:"gender"`
|
||||
Bio string `json:"bio"`
|
||||
Birthday string `json:"birthday"`
|
||||
Location *Location `json:"location"`
|
||||
}
|
||||
|
||||
type RealNameForm struct {
|
||||
Realname string `json:"realname"`
|
||||
IDCard string `json:"idCard"`
|
||||
}
|
||||
|
||||
type WalletResponse struct {
|
||||
Balance float64 `json:"balance"`
|
||||
Transactions []Transaction `json:"transactions"`
|
||||
}
|
||||
|
||||
type Transaction struct {
|
||||
ID string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Amount float64 `json:"amount"`
|
||||
Type string `json:"type"` // income, expense
|
||||
Date string `json:"date"`
|
||||
}
|
||||
|
||||
type RechargeForm struct {
|
||||
Amount float64 `json:"amount"`
|
||||
Method string `json:"method"` // wechat, alipay
|
||||
}
|
||||
|
||||
type RechargeResponse struct {
|
||||
PayParams string `json:"payParams"`
|
||||
OrderID string `json:"orderId"`
|
||||
}
|
||||
|
||||
type Order struct {
|
||||
ID string `json:"id"`
|
||||
CreateTime string `json:"createTime"`
|
||||
PayTime string `json:"payTime"`
|
||||
Status string `json:"status"`
|
||||
Amount float64 `json:"amount"`
|
||||
Quantity int `json:"quantity"`
|
||||
Items []ContentItem `json:"items"`
|
||||
TenantID string `json:"tenantId"`
|
||||
TenantName string `json:"tenantName"`
|
||||
IsVirtual bool `json:"isVirtual"`
|
||||
}
|
||||
|
||||
type Notification struct {
|
||||
ID string `json:"id"`
|
||||
Type string `json:"type"`
|
||||
Title string `json:"title"`
|
||||
Content string `json:"content"`
|
||||
Read bool `json:"read"`
|
||||
Time string `json:"time"`
|
||||
}
|
||||
Reference in New Issue
Block a user