feat: implement new structure
This commit is contained in:
41
backend/app/http/v1/auth.go
Normal file
41
backend/app/http/v1/auth.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"quyun/v2/app/http/v1/dto"
|
||||
"quyun/v2/app/services"
|
||||
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
|
||||
// @provider
|
||||
type Auth struct{}
|
||||
|
||||
// SendOTP sends an OTP to the provided phone number.
|
||||
//
|
||||
// @Router /v1/auth/otp [post]
|
||||
// @Summary Send OTP
|
||||
// @Description Send OTP to phone number
|
||||
// @Tags Auth
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param form body dto.SendOTPForm true "Phone number"
|
||||
// @Success 200 {object} string "OTP sent"
|
||||
// @Bind form body
|
||||
func (a *Auth) SendOTP(ctx fiber.Ctx, form *dto.SendOTPForm) error {
|
||||
return services.User.SendOTP(ctx.Context(), form.Phone)
|
||||
}
|
||||
|
||||
// Login logs in or registers a user with OTP.
|
||||
//
|
||||
// @Router /v1/auth/login [post]
|
||||
// @Summary Login or Register with OTP
|
||||
// @Description Login or register user using phone number and OTP
|
||||
// @Tags Auth
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param form body dto.LoginForm true "Login form"
|
||||
// @Success 200 {object} dto.LoginResponse
|
||||
// @Bind form body
|
||||
func (a *Auth) Login(ctx fiber.Ctx, form *dto.LoginForm) (*dto.LoginResponse, error) {
|
||||
return services.User.LoginWithOTP(ctx.Context(), form.Phone, form.OTP)
|
||||
}
|
||||
34
backend/app/http/v1/common.go
Normal file
34
backend/app/http/v1/common.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"mime/multipart"
|
||||
|
||||
"quyun/v2/app/http/v1/dto"
|
||||
"quyun/v2/app/services"
|
||||
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
|
||||
// @provider
|
||||
type Common struct{}
|
||||
|
||||
// Upload file
|
||||
//
|
||||
// @Router /v1/upload [post]
|
||||
// @Summary Upload file
|
||||
// @Description Upload file
|
||||
// @Tags Common
|
||||
// @Accept multipart/form-data
|
||||
// @Produce json
|
||||
// @Param file formData file true "File"
|
||||
// @Param type formData string false "Type enum(image, video, audio)"
|
||||
// @Success 200 {object} dto.UploadResult
|
||||
// @Bind file file
|
||||
// @Bind typeArg body key(type)
|
||||
func (c *Common) Upload(ctx fiber.Ctx, file *multipart.FileHeader, typeArg *string) (*dto.UploadResult, error) {
|
||||
val := ""
|
||||
if typeArg != nil {
|
||||
val = *typeArg
|
||||
}
|
||||
return services.Common.Upload(ctx.Context(), file, val)
|
||||
}
|
||||
115
backend/app/http/v1/content.go
Normal file
115
backend/app/http/v1/content.go
Normal file
@@ -0,0 +1,115 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"quyun/v2/app/http/v1/dto"
|
||||
"quyun/v2/app/services"
|
||||
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
|
||||
// @provider
|
||||
type Content struct{}
|
||||
|
||||
// List contents (Explore / Search)
|
||||
//
|
||||
// @Router /v1/contents [get]
|
||||
// @Summary List contents
|
||||
// @Description List contents with filtering and pagination
|
||||
// @Tags Content
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param keyword query string false "Search keyword"
|
||||
// @Param genre query string false "Genre"
|
||||
// @Param tenantId query string false "Filter by creator"
|
||||
// @Param sort query string false "Sort order" Enums(latest, hot, price_asc)
|
||||
// @Param page query int false "Page number"
|
||||
// @Success 200 {object} dto.ContentListResponse
|
||||
// @Bind keyword query
|
||||
// @Bind genre query
|
||||
// @Bind tenantId query
|
||||
// @Bind sort query
|
||||
// @Bind page query
|
||||
func (c *Content) List(
|
||||
ctx fiber.Ctx,
|
||||
keyword, genre, tenantId, sort string,
|
||||
page int,
|
||||
) (*dto.ContentListResponse, error) {
|
||||
return services.Content.List(ctx.Context(), keyword, genre, tenantId, sort, page)
|
||||
}
|
||||
|
||||
// Get content detail
|
||||
//
|
||||
// @Router /v1/contents/:id [get]
|
||||
// @Summary Get content detail
|
||||
// @Description Get content detail by ID
|
||||
// @Tags Content
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "Content ID"
|
||||
// @Success 200 {object} dto.ContentDetail
|
||||
// @Bind id path
|
||||
func (c *Content) Get(ctx fiber.Ctx, id string) (*dto.ContentDetail, error) {
|
||||
return services.Content.Get(ctx.Context(), id)
|
||||
}
|
||||
|
||||
// Get comments for a content
|
||||
//
|
||||
// @Router /v1/contents/:id/comments [get]
|
||||
// @Summary Get comments
|
||||
// @Description Get comments for a content
|
||||
// @Tags Content
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "Content ID"
|
||||
// @Param page query int false "Page number"
|
||||
// @Success 200 {object} dto.CommentListResponse
|
||||
// @Bind id path
|
||||
// @Bind page query
|
||||
func (c *Content) ListComments(ctx fiber.Ctx, id string, page int) (*dto.CommentListResponse, error) {
|
||||
return services.Content.ListComments(ctx.Context(), id, page)
|
||||
}
|
||||
|
||||
// Post a comment
|
||||
//
|
||||
// @Router /v1/contents/:id/comments [post]
|
||||
// @Summary Post comment
|
||||
// @Description Post a comment to a content
|
||||
// @Tags Content
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "Content ID"
|
||||
// @Param form body dto.CommentCreateForm true "Comment form"
|
||||
// @Success 200 {string} string "Comment created"
|
||||
// @Bind id path
|
||||
// @Bind form body
|
||||
func (c *Content) CreateComment(ctx fiber.Ctx, id string, form *dto.CommentCreateForm) error {
|
||||
return services.Content.CreateComment(ctx.Context(), id, form)
|
||||
}
|
||||
|
||||
// Like a comment
|
||||
//
|
||||
// @Router /v1/comments/:id/like [post]
|
||||
// @Summary Like comment
|
||||
// @Description Like a comment
|
||||
// @Tags Content
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "Comment ID"
|
||||
// @Success 200 {string} string "Liked"
|
||||
// @Bind id path
|
||||
func (c *Content) LikeComment(ctx fiber.Ctx, id string) error {
|
||||
return services.Content.LikeComment(ctx.Context(), id)
|
||||
}
|
||||
|
||||
// List curated topics
|
||||
//
|
||||
// @Router /v1/topics [get]
|
||||
// @Summary List topics
|
||||
// @Description List curated topics
|
||||
// @Tags Content
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {array} dto.Topic
|
||||
func (c *Content) ListTopics(ctx fiber.Ctx) ([]dto.Topic, error) {
|
||||
return services.Content.ListTopics(ctx.Context())
|
||||
}
|
||||
225
backend/app/http/v1/creator.go
Normal file
225
backend/app/http/v1/creator.go
Normal file
@@ -0,0 +1,225 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"quyun/v2/app/http/v1/dto"
|
||||
"quyun/v2/app/services"
|
||||
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
|
||||
// @provider
|
||||
type Creator struct{}
|
||||
|
||||
// Apply to become a creator
|
||||
//
|
||||
// @Router /v1/creator/apply [post]
|
||||
// @Summary Apply creator
|
||||
// @Description Apply to become a creator
|
||||
// @Tags CreatorCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param form body dto.ApplyForm true "Apply form"
|
||||
// @Success 200 {string} string "Application submitted"
|
||||
// @Bind form body
|
||||
func (c *Creator) Apply(ctx fiber.Ctx, form *dto.ApplyForm) error {
|
||||
return services.Creator.Apply(ctx.Context(), form)
|
||||
}
|
||||
|
||||
// Get creator dashboard stats
|
||||
//
|
||||
// @Router /v1/creator/dashboard [get]
|
||||
// @Summary Dashboard stats
|
||||
// @Description Get creator dashboard stats
|
||||
// @Tags CreatorCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {object} dto.DashboardStats
|
||||
func (c *Creator) Dashboard(ctx fiber.Ctx) (*dto.DashboardStats, error) {
|
||||
return services.Creator.Dashboard(ctx.Context())
|
||||
}
|
||||
|
||||
// List creator contents
|
||||
//
|
||||
// @Router /v1/creator/contents [get]
|
||||
// @Summary List contents
|
||||
// @Description List creator contents
|
||||
// @Tags CreatorCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param status query string false "Status"
|
||||
// @Param genre query string false "Genre"
|
||||
// @Param keyword query string false "Keyword"
|
||||
// @Success 200 {array} dto.ContentItem
|
||||
// @Bind status query
|
||||
// @Bind genre query
|
||||
// @Bind keyword query
|
||||
func (c *Creator) ListContents(ctx fiber.Ctx, status, genre, keyword string) ([]dto.ContentItem, error) {
|
||||
return services.Creator.ListContents(ctx.Context(), status, genre, keyword)
|
||||
}
|
||||
|
||||
// Create/Publish content
|
||||
//
|
||||
// @Router /v1/creator/contents [post]
|
||||
// @Summary Create content
|
||||
// @Description Create/Publish content
|
||||
// @Tags CreatorCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param form body dto.ContentCreateForm true "Content form"
|
||||
// @Success 200 {string} string "Created"
|
||||
// @Bind form body
|
||||
func (c *Creator) CreateContent(ctx fiber.Ctx, form *dto.ContentCreateForm) error {
|
||||
return services.Creator.CreateContent(ctx.Context(), form)
|
||||
}
|
||||
|
||||
// Update content
|
||||
//
|
||||
// @Router /v1/creator/contents/:id [put]
|
||||
// @Summary Update content
|
||||
// @Description Update content
|
||||
// @Tags CreatorCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "Content ID"
|
||||
// @Param form body dto.ContentUpdateForm true "Update form"
|
||||
// @Success 200 {string} string "Updated"
|
||||
// @Bind id path
|
||||
// @Bind form body
|
||||
func (c *Creator) UpdateContent(ctx fiber.Ctx, id string, form *dto.ContentUpdateForm) error {
|
||||
return services.Creator.UpdateContent(ctx.Context(), id, form)
|
||||
}
|
||||
|
||||
// Delete content
|
||||
//
|
||||
// @Router /v1/creator/contents/:id [delete]
|
||||
// @Summary Delete content
|
||||
// @Description Delete content
|
||||
// @Tags CreatorCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "Content ID"
|
||||
// @Success 200 {string} string "Deleted"
|
||||
// @Bind id path
|
||||
func (c *Creator) DeleteContent(ctx fiber.Ctx, id string) error {
|
||||
return services.Creator.DeleteContent(ctx.Context(), id)
|
||||
}
|
||||
|
||||
// List sales orders
|
||||
//
|
||||
// @Router /v1/creator/orders [get]
|
||||
// @Summary List sales orders
|
||||
// @Description List sales orders
|
||||
// @Tags CreatorCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param status query string false "Status"
|
||||
// @Param keyword query string false "Keyword"
|
||||
// @Success 200 {array} dto.Order
|
||||
// @Bind status query
|
||||
// @Bind keyword query
|
||||
func (c *Creator) ListOrders(ctx fiber.Ctx, status, keyword string) ([]dto.Order, error) {
|
||||
return services.Creator.ListOrders(ctx.Context(), status, keyword)
|
||||
}
|
||||
|
||||
// Process refund
|
||||
//
|
||||
// @Router /v1/creator/orders/:id/refund [post]
|
||||
// @Summary Process refund
|
||||
// @Description Process refund
|
||||
// @Tags CreatorCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "Order ID"
|
||||
// @Param form body dto.RefundForm true "Refund form"
|
||||
// @Success 200 {string} string "Processed"
|
||||
// @Bind id path
|
||||
// @Bind form body
|
||||
func (c *Creator) Refund(ctx fiber.Ctx, id string, form *dto.RefundForm) error {
|
||||
return services.Creator.ProcessRefund(ctx.Context(), id, form)
|
||||
}
|
||||
|
||||
// Get channel settings
|
||||
//
|
||||
// @Router /v1/creator/settings [get]
|
||||
// @Summary Get settings
|
||||
// @Description Get channel settings
|
||||
// @Tags CreatorCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {object} dto.Settings
|
||||
func (c *Creator) GetSettings(ctx fiber.Ctx) (*dto.Settings, error) {
|
||||
return services.Creator.GetSettings(ctx.Context())
|
||||
}
|
||||
|
||||
// Update channel settings
|
||||
//
|
||||
// @Router /v1/creator/settings [put]
|
||||
// @Summary Update settings
|
||||
// @Description Update channel settings
|
||||
// @Tags CreatorCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param form body dto.Settings true "Settings form"
|
||||
// @Success 200 {string} string "Updated"
|
||||
// @Bind form body
|
||||
func (c *Creator) UpdateSettings(ctx fiber.Ctx, form *dto.Settings) error {
|
||||
return services.Creator.UpdateSettings(ctx.Context(), form)
|
||||
}
|
||||
|
||||
// List payout accounts
|
||||
//
|
||||
// @Router /v1/creator/payout-accounts [get]
|
||||
// @Summary List payout accounts
|
||||
// @Description List payout accounts
|
||||
// @Tags CreatorCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {array} dto.PayoutAccount
|
||||
func (c *Creator) ListPayoutAccounts(ctx fiber.Ctx) ([]dto.PayoutAccount, error) {
|
||||
return services.Creator.ListPayoutAccounts(ctx.Context())
|
||||
}
|
||||
|
||||
// Add payout account
|
||||
//
|
||||
// @Router /v1/creator/payout-accounts [post]
|
||||
// @Summary Add payout account
|
||||
// @Description Add payout account
|
||||
// @Tags CreatorCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param form body dto.PayoutAccount true "Account form"
|
||||
// @Success 200 {string} string "Added"
|
||||
// @Bind form body
|
||||
func (c *Creator) AddPayoutAccount(ctx fiber.Ctx, form *dto.PayoutAccount) error {
|
||||
return services.Creator.AddPayoutAccount(ctx.Context(), form)
|
||||
}
|
||||
|
||||
// Remove payout account
|
||||
//
|
||||
// @Router /v1/creator/payout-accounts [delete]
|
||||
// @Summary Remove payout account
|
||||
// @Description Remove payout account
|
||||
// @Tags CreatorCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id query string true "Account ID"
|
||||
// @Success 200 {string} string "Removed"
|
||||
// @Bind id query
|
||||
func (c *Creator) RemovePayoutAccount(ctx fiber.Ctx, id string) error {
|
||||
return services.Creator.RemovePayoutAccount(ctx.Context(), id)
|
||||
}
|
||||
|
||||
// Request withdrawal
|
||||
//
|
||||
// @Router /v1/creator/withdraw [post]
|
||||
// @Summary Request withdrawal
|
||||
// @Description Request withdrawal
|
||||
// @Tags CreatorCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param form body dto.WithdrawForm true "Withdraw form"
|
||||
// @Success 200 {string} string "Withdrawal requested"
|
||||
// @Bind form body
|
||||
func (c *Creator) Withdraw(ctx fiber.Ctx, form *dto.WithdrawForm) error {
|
||||
return services.Creator.Withdraw(ctx.Context(), form)
|
||||
}
|
||||
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"`
|
||||
}
|
||||
100
backend/app/http/v1/provider.gen.go
Executable file
100
backend/app/http/v1/provider.gen.go
Executable file
@@ -0,0 +1,100 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"quyun/v2/app/middlewares"
|
||||
|
||||
"go.ipao.vip/atom"
|
||||
"go.ipao.vip/atom/container"
|
||||
"go.ipao.vip/atom/contracts"
|
||||
"go.ipao.vip/atom/opt"
|
||||
)
|
||||
|
||||
func Provide(opts ...opt.Option) error {
|
||||
if err := container.Container.Provide(func() (*Auth, error) {
|
||||
obj := &Auth{}
|
||||
|
||||
return obj, nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := container.Container.Provide(func() (*Common, error) {
|
||||
obj := &Common{}
|
||||
|
||||
return obj, nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := container.Container.Provide(func() (*Content, error) {
|
||||
obj := &Content{}
|
||||
|
||||
return obj, nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := container.Container.Provide(func() (*Creator, error) {
|
||||
obj := &Creator{}
|
||||
|
||||
return obj, nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := container.Container.Provide(func(
|
||||
auth *Auth,
|
||||
common *Common,
|
||||
content *Content,
|
||||
creator *Creator,
|
||||
middlewares *middlewares.Middlewares,
|
||||
super *Super,
|
||||
tenant *Tenant,
|
||||
transaction *Transaction,
|
||||
user *User,
|
||||
) (contracts.HttpRoute, error) {
|
||||
obj := &Routes{
|
||||
auth: auth,
|
||||
common: common,
|
||||
content: content,
|
||||
creator: creator,
|
||||
middlewares: middlewares,
|
||||
super: super,
|
||||
tenant: tenant,
|
||||
transaction: transaction,
|
||||
user: user,
|
||||
}
|
||||
if err := obj.Prepare(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return obj, nil
|
||||
}, atom.GroupRoutes); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := container.Container.Provide(func() (*Super, error) {
|
||||
obj := &Super{}
|
||||
|
||||
return obj, nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := container.Container.Provide(func() (*Tenant, error) {
|
||||
obj := &Tenant{}
|
||||
|
||||
return obj, nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := container.Container.Provide(func() (*Transaction, error) {
|
||||
obj := &Transaction{}
|
||||
|
||||
return obj, nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := container.Container.Provide(func() (*User, error) {
|
||||
obj := &User{}
|
||||
|
||||
return obj, nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
394
backend/app/http/v1/routes.gen.go
Normal file
394
backend/app/http/v1/routes.gen.go
Normal file
@@ -0,0 +1,394 @@
|
||||
// Code generated by atomctl. DO NOT EDIT.
|
||||
|
||||
// Package v1 provides HTTP route definitions and registration
|
||||
// for the quyun/v2 application.
|
||||
package v1
|
||||
|
||||
import (
|
||||
"mime/multipart"
|
||||
"quyun/v2/app/http/v1/dto"
|
||||
"quyun/v2/app/middlewares"
|
||||
|
||||
"github.com/gofiber/fiber/v3"
|
||||
log "github.com/sirupsen/logrus"
|
||||
_ "go.ipao.vip/atom"
|
||||
_ "go.ipao.vip/atom/contracts"
|
||||
. "go.ipao.vip/atom/fen"
|
||||
)
|
||||
|
||||
// Routes implements the HttpRoute contract and provides route registration
|
||||
// for all controllers in the v1 module.
|
||||
//
|
||||
// @provider contracts.HttpRoute atom.GroupRoutes
|
||||
type Routes struct {
|
||||
log *log.Entry `inject:"false"`
|
||||
middlewares *middlewares.Middlewares
|
||||
// Controller instances
|
||||
auth *Auth
|
||||
common *Common
|
||||
content *Content
|
||||
creator *Creator
|
||||
super *Super
|
||||
tenant *Tenant
|
||||
transaction *Transaction
|
||||
user *User
|
||||
}
|
||||
|
||||
// Prepare initializes the routes provider with logging configuration.
|
||||
func (r *Routes) Prepare() error {
|
||||
r.log = log.WithField("module", "routes.v1")
|
||||
r.log.Info("Initializing routes module")
|
||||
return nil
|
||||
}
|
||||
|
||||
// Name returns the unique identifier for this routes provider.
|
||||
func (r *Routes) Name() string {
|
||||
return "v1"
|
||||
}
|
||||
|
||||
// Register registers all HTTP routes with the provided fiber router.
|
||||
// Each route is registered with its corresponding controller action and parameter bindings.
|
||||
func (r *Routes) Register(router fiber.Router) {
|
||||
// Register routes for controller: Auth
|
||||
r.log.Debugf("Registering route: Post /v1/auth/login -> auth.Login")
|
||||
router.Post("/v1/auth/login"[len(r.Path()):], DataFunc1(
|
||||
r.auth.Login,
|
||||
Body[dto.LoginForm]("form"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Post /v1/auth/otp -> auth.SendOTP")
|
||||
router.Post("/v1/auth/otp"[len(r.Path()):], Func1(
|
||||
r.auth.SendOTP,
|
||||
Body[dto.SendOTPForm]("form"),
|
||||
))
|
||||
// Register routes for controller: Common
|
||||
r.log.Debugf("Registering route: Post /v1/upload -> common.Upload")
|
||||
router.Post("/v1/upload"[len(r.Path()):], DataFunc2(
|
||||
r.common.Upload,
|
||||
File[multipart.FileHeader]("file"),
|
||||
Body[string]("type"),
|
||||
))
|
||||
// Register routes for controller: Content
|
||||
r.log.Debugf("Registering route: Get /v1/contents -> content.List")
|
||||
router.Get("/v1/contents"[len(r.Path()):], DataFunc5(
|
||||
r.content.List,
|
||||
QueryParam[string]("keyword"),
|
||||
QueryParam[string]("genre"),
|
||||
QueryParam[string]("tenantId"),
|
||||
QueryParam[string]("sort"),
|
||||
QueryParam[int]("page"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /v1/contents/:id -> content.Get")
|
||||
router.Get("/v1/contents/:id"[len(r.Path()):], DataFunc1(
|
||||
r.content.Get,
|
||||
PathParam[string]("id"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /v1/contents/:id/comments -> content.ListComments")
|
||||
router.Get("/v1/contents/:id/comments"[len(r.Path()):], DataFunc2(
|
||||
r.content.ListComments,
|
||||
PathParam[string]("id"),
|
||||
QueryParam[int]("page"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /v1/topics -> content.ListTopics")
|
||||
router.Get("/v1/topics"[len(r.Path()):], DataFunc0(
|
||||
r.content.ListTopics,
|
||||
))
|
||||
r.log.Debugf("Registering route: Post /v1/comments/:id/like -> content.LikeComment")
|
||||
router.Post("/v1/comments/:id/like"[len(r.Path()):], Func1(
|
||||
r.content.LikeComment,
|
||||
PathParam[string]("id"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Post /v1/contents/:id/comments -> content.CreateComment")
|
||||
router.Post("/v1/contents/:id/comments"[len(r.Path()):], Func2(
|
||||
r.content.CreateComment,
|
||||
PathParam[string]("id"),
|
||||
Body[dto.CommentCreateForm]("form"),
|
||||
))
|
||||
// Register routes for controller: Creator
|
||||
r.log.Debugf("Registering route: Delete /v1/creator/contents/:id -> creator.DeleteContent")
|
||||
router.Delete("/v1/creator/contents/:id"[len(r.Path()):], Func1(
|
||||
r.creator.DeleteContent,
|
||||
PathParam[string]("id"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Delete /v1/creator/payout-accounts -> creator.RemovePayoutAccount")
|
||||
router.Delete("/v1/creator/payout-accounts"[len(r.Path()):], Func1(
|
||||
r.creator.RemovePayoutAccount,
|
||||
QueryParam[string]("id"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /v1/creator/contents -> creator.ListContents")
|
||||
router.Get("/v1/creator/contents"[len(r.Path()):], DataFunc3(
|
||||
r.creator.ListContents,
|
||||
QueryParam[string]("status"),
|
||||
QueryParam[string]("genre"),
|
||||
QueryParam[string]("keyword"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /v1/creator/dashboard -> creator.Dashboard")
|
||||
router.Get("/v1/creator/dashboard"[len(r.Path()):], DataFunc0(
|
||||
r.creator.Dashboard,
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /v1/creator/orders -> creator.ListOrders")
|
||||
router.Get("/v1/creator/orders"[len(r.Path()):], DataFunc2(
|
||||
r.creator.ListOrders,
|
||||
QueryParam[string]("status"),
|
||||
QueryParam[string]("keyword"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /v1/creator/payout-accounts -> creator.ListPayoutAccounts")
|
||||
router.Get("/v1/creator/payout-accounts"[len(r.Path()):], DataFunc0(
|
||||
r.creator.ListPayoutAccounts,
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /v1/creator/settings -> creator.GetSettings")
|
||||
router.Get("/v1/creator/settings"[len(r.Path()):], DataFunc0(
|
||||
r.creator.GetSettings,
|
||||
))
|
||||
r.log.Debugf("Registering route: Post /v1/creator/apply -> creator.Apply")
|
||||
router.Post("/v1/creator/apply"[len(r.Path()):], Func1(
|
||||
r.creator.Apply,
|
||||
Body[dto.ApplyForm]("form"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Post /v1/creator/contents -> creator.CreateContent")
|
||||
router.Post("/v1/creator/contents"[len(r.Path()):], Func1(
|
||||
r.creator.CreateContent,
|
||||
Body[dto.ContentCreateForm]("form"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Post /v1/creator/orders/:id/refund -> creator.Refund")
|
||||
router.Post("/v1/creator/orders/:id/refund"[len(r.Path()):], Func2(
|
||||
r.creator.Refund,
|
||||
PathParam[string]("id"),
|
||||
Body[dto.RefundForm]("form"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Post /v1/creator/payout-accounts -> creator.AddPayoutAccount")
|
||||
router.Post("/v1/creator/payout-accounts"[len(r.Path()):], Func1(
|
||||
r.creator.AddPayoutAccount,
|
||||
Body[dto.PayoutAccount]("form"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Post /v1/creator/withdraw -> creator.Withdraw")
|
||||
router.Post("/v1/creator/withdraw"[len(r.Path()):], Func1(
|
||||
r.creator.Withdraw,
|
||||
Body[dto.WithdrawForm]("form"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Put /v1/creator/contents/:id -> creator.UpdateContent")
|
||||
router.Put("/v1/creator/contents/:id"[len(r.Path()):], Func2(
|
||||
r.creator.UpdateContent,
|
||||
PathParam[string]("id"),
|
||||
Body[dto.ContentUpdateForm]("form"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Put /v1/creator/settings -> creator.UpdateSettings")
|
||||
router.Put("/v1/creator/settings"[len(r.Path()):], Func1(
|
||||
r.creator.UpdateSettings,
|
||||
Body[dto.Settings]("form"),
|
||||
))
|
||||
// Register routes for controller: Super
|
||||
r.log.Debugf("Registering route: Get /v1/auth/token -> super.CheckToken")
|
||||
router.Get("/v1/auth/token"[len(r.Path()):], DataFunc0(
|
||||
r.super.CheckToken,
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /v1/contents -> super.ListContents")
|
||||
router.Get("/v1/contents"[len(r.Path()):], DataFunc2(
|
||||
r.super.ListContents,
|
||||
QueryParam[int]("page"),
|
||||
QueryParam[int]("limit"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /v1/orders -> super.ListOrders")
|
||||
router.Get("/v1/orders"[len(r.Path()):], DataFunc2(
|
||||
r.super.ListOrders,
|
||||
QueryParam[int]("page"),
|
||||
QueryParam[int]("limit"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /v1/orders/:id -> super.GetOrder")
|
||||
router.Get("/v1/orders/:id"[len(r.Path()):], DataFunc1(
|
||||
r.super.GetOrder,
|
||||
PathParam[int64]("id"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /v1/orders/statistics -> super.OrderStatistics")
|
||||
router.Get("/v1/orders/statistics"[len(r.Path()):], DataFunc0(
|
||||
r.super.OrderStatistics,
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /v1/tenants -> super.ListTenants")
|
||||
router.Get("/v1/tenants"[len(r.Path()):], DataFunc3(
|
||||
r.super.ListTenants,
|
||||
QueryParam[int]("page"),
|
||||
QueryParam[int]("limit"),
|
||||
QueryParam[string]("name"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /v1/tenants/:id -> super.GetTenant")
|
||||
router.Get("/v1/tenants/:id"[len(r.Path()):], DataFunc1(
|
||||
r.super.GetTenant,
|
||||
PathParam[int64]("id"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /v1/tenants/statuses -> super.TenantStatuses")
|
||||
router.Get("/v1/tenants/statuses"[len(r.Path()):], DataFunc0(
|
||||
r.super.TenantStatuses,
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /v1/users -> super.ListUsers")
|
||||
router.Get("/v1/users"[len(r.Path()):], DataFunc3(
|
||||
r.super.ListUsers,
|
||||
QueryParam[int]("page"),
|
||||
QueryParam[int]("limit"),
|
||||
QueryParam[string]("username"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /v1/users/:id -> super.GetUser")
|
||||
router.Get("/v1/users/:id"[len(r.Path()):], DataFunc1(
|
||||
r.super.GetUser,
|
||||
PathParam[int64]("id"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /v1/users/statistics -> super.UserStatistics")
|
||||
router.Get("/v1/users/statistics"[len(r.Path()):], DataFunc0(
|
||||
r.super.UserStatistics,
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /v1/users/statuses -> super.UserStatuses")
|
||||
router.Get("/v1/users/statuses"[len(r.Path()):], DataFunc0(
|
||||
r.super.UserStatuses,
|
||||
))
|
||||
r.log.Debugf("Registering route: Patch /v1/tenants/:id -> super.UpdateTenantExpire")
|
||||
router.Patch("/v1/tenants/:id"[len(r.Path()):], Func2(
|
||||
r.super.UpdateTenantExpire,
|
||||
PathParam[int64]("id"),
|
||||
Body[dto.TenantExpireUpdateForm]("form"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Patch /v1/tenants/:id/status -> super.UpdateTenantStatus")
|
||||
router.Patch("/v1/tenants/:id/status"[len(r.Path()):], Func2(
|
||||
r.super.UpdateTenantStatus,
|
||||
PathParam[int64]("id"),
|
||||
Body[dto.TenantStatusUpdateForm]("form"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Patch /v1/tenants/:tenantID/contents/:contentID/status -> super.UpdateContentStatus")
|
||||
router.Patch("/v1/tenants/:tenantID/contents/:contentID/status"[len(r.Path()):], Func3(
|
||||
r.super.UpdateContentStatus,
|
||||
PathParam[int64]("tenantID"),
|
||||
PathParam[int64]("contentID"),
|
||||
Body[dto.SuperTenantContentStatusUpdateForm]("form"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Patch /v1/users/:id/roles -> super.UpdateUserRoles")
|
||||
router.Patch("/v1/users/:id/roles"[len(r.Path()):], Func2(
|
||||
r.super.UpdateUserRoles,
|
||||
PathParam[int64]("id"),
|
||||
Body[dto.UserRolesUpdateForm]("form"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Patch /v1/users/:id/status -> super.UpdateUserStatus")
|
||||
router.Patch("/v1/users/:id/status"[len(r.Path()):], Func2(
|
||||
r.super.UpdateUserStatus,
|
||||
PathParam[int64]("id"),
|
||||
Body[dto.UserStatusUpdateForm]("form"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Post /v1/auth/login -> super.Login")
|
||||
router.Post("/v1/auth/login"[len(r.Path()):], DataFunc1(
|
||||
r.super.Login,
|
||||
Body[dto.LoginForm]("form"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Post /v1/orders/:id/refund -> super.RefundOrder")
|
||||
router.Post("/v1/orders/:id/refund"[len(r.Path()):], Func2(
|
||||
r.super.RefundOrder,
|
||||
PathParam[int64]("id"),
|
||||
Body[dto.SuperOrderRefundForm]("form"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Post /v1/tenants -> super.CreateTenant")
|
||||
router.Post("/v1/tenants"[len(r.Path()):], Func1(
|
||||
r.super.CreateTenant,
|
||||
Body[dto.TenantCreateForm]("form"),
|
||||
))
|
||||
// Register routes for controller: Tenant
|
||||
r.log.Debugf("Registering route: Delete /v1/tenants/:id/follow -> tenant.Unfollow")
|
||||
router.Delete("/v1/tenants/:id/follow"[len(r.Path()):], Func1(
|
||||
r.tenant.Unfollow,
|
||||
PathParam[string]("id"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /v1/tenants/:id -> tenant.Get")
|
||||
router.Get("/v1/tenants/:id"[len(r.Path()):], DataFunc1(
|
||||
r.tenant.Get,
|
||||
PathParam[string]("id"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Post /v1/tenants/:id/follow -> tenant.Follow")
|
||||
router.Post("/v1/tenants/:id/follow"[len(r.Path()):], Func1(
|
||||
r.tenant.Follow,
|
||||
PathParam[string]("id"),
|
||||
))
|
||||
// Register routes for controller: Transaction
|
||||
r.log.Debugf("Registering route: Get /v1/orders/:id/status -> transaction.Status")
|
||||
router.Get("/v1/orders/:id/status"[len(r.Path()):], DataFunc1(
|
||||
r.transaction.Status,
|
||||
PathParam[string]("id"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Post /v1/orders -> transaction.Create")
|
||||
router.Post("/v1/orders"[len(r.Path()):], DataFunc1(
|
||||
r.transaction.Create,
|
||||
Body[dto.OrderCreateForm]("form"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Post /v1/orders/:id/pay -> transaction.Pay")
|
||||
router.Post("/v1/orders/:id/pay"[len(r.Path()):], DataFunc2(
|
||||
r.transaction.Pay,
|
||||
PathParam[string]("id"),
|
||||
Body[dto.OrderPayForm]("form"),
|
||||
))
|
||||
// Register routes for controller: User
|
||||
r.log.Debugf("Registering route: Delete /v1/me/favorites/:contentId -> user.RemoveFavorite")
|
||||
router.Delete("/v1/me/favorites/:contentId"[len(r.Path()):], Func1(
|
||||
r.user.RemoveFavorite,
|
||||
PathParam[string]("contentId"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Delete /v1/me/likes/:contentId -> user.RemoveLike")
|
||||
router.Delete("/v1/me/likes/:contentId"[len(r.Path()):], Func1(
|
||||
r.user.RemoveLike,
|
||||
PathParam[string]("contentId"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /v1/me -> user.Me")
|
||||
router.Get("/v1/me"[len(r.Path()):], DataFunc0(
|
||||
r.user.Me,
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /v1/me/favorites -> user.Favorites")
|
||||
router.Get("/v1/me/favorites"[len(r.Path()):], DataFunc0(
|
||||
r.user.Favorites,
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /v1/me/library -> user.Library")
|
||||
router.Get("/v1/me/library"[len(r.Path()):], DataFunc0(
|
||||
r.user.Library,
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /v1/me/likes -> user.Likes")
|
||||
router.Get("/v1/me/likes"[len(r.Path()):], DataFunc0(
|
||||
r.user.Likes,
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /v1/me/notifications -> user.Notifications")
|
||||
router.Get("/v1/me/notifications"[len(r.Path()):], DataFunc1(
|
||||
r.user.Notifications,
|
||||
QueryParam[string]("type"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /v1/me/orders -> user.ListOrders")
|
||||
router.Get("/v1/me/orders"[len(r.Path()):], DataFunc1(
|
||||
r.user.ListOrders,
|
||||
QueryParam[string]("status"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /v1/me/orders/:id -> user.GetOrder")
|
||||
router.Get("/v1/me/orders/:id"[len(r.Path()):], DataFunc1(
|
||||
r.user.GetOrder,
|
||||
PathParam[string]("id"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /v1/me/wallet -> user.Wallet")
|
||||
router.Get("/v1/me/wallet"[len(r.Path()):], DataFunc0(
|
||||
r.user.Wallet,
|
||||
))
|
||||
r.log.Debugf("Registering route: Post /v1/me/favorites -> user.AddFavorite")
|
||||
router.Post("/v1/me/favorites"[len(r.Path()):], Func1(
|
||||
r.user.AddFavorite,
|
||||
QueryParam[string]("contentId"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Post /v1/me/likes -> user.AddLike")
|
||||
router.Post("/v1/me/likes"[len(r.Path()):], Func1(
|
||||
r.user.AddLike,
|
||||
QueryParam[string]("contentId"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Post /v1/me/realname -> user.RealName")
|
||||
router.Post("/v1/me/realname"[len(r.Path()):], Func1(
|
||||
r.user.RealName,
|
||||
Body[dto.RealNameForm]("form"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Post /v1/me/wallet/recharge -> user.Recharge")
|
||||
router.Post("/v1/me/wallet/recharge"[len(r.Path()):], DataFunc1(
|
||||
r.user.Recharge,
|
||||
Body[dto.RechargeForm]("form"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Put /v1/me -> user.Update")
|
||||
router.Put("/v1/me"[len(r.Path()):], Func1(
|
||||
r.user.Update,
|
||||
Body[dto.UserUpdate]("form"),
|
||||
))
|
||||
|
||||
r.log.Info("Successfully registered all routes")
|
||||
}
|
||||
9
backend/app/http/v1/routes.manual.go
Normal file
9
backend/app/http/v1/routes.manual.go
Normal file
@@ -0,0 +1,9 @@
|
||||
package v1
|
||||
|
||||
func (r *Routes) Path() string {
|
||||
return "/v1"
|
||||
}
|
||||
|
||||
func (r *Routes) Middlewares() []any {
|
||||
return []any{}
|
||||
}
|
||||
308
backend/app/http/v1/super.go
Normal file
308
backend/app/http/v1/super.go
Normal file
@@ -0,0 +1,308 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"quyun/v2/app/http/v1/dto"
|
||||
"quyun/v2/app/requests"
|
||||
"quyun/v2/app/services"
|
||||
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
|
||||
// @provider
|
||||
type Super struct{}
|
||||
|
||||
// Login
|
||||
//
|
||||
// @Router /v1/auth/login [post]
|
||||
// @Summary Login
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param form body dto.LoginForm true "Login form"
|
||||
// @Success 200 {object} dto.LoginResponse
|
||||
// @Bind form body
|
||||
func (s *Super) Login(ctx fiber.Ctx, form *dto.LoginForm) (*dto.LoginResponse, error) {
|
||||
return services.Super.Login(ctx.Context(), form)
|
||||
}
|
||||
|
||||
// Check Token
|
||||
//
|
||||
// @Router /v1/auth/token [get]
|
||||
// @Summary Check Token
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {object} dto.LoginResponse
|
||||
func (s *Super) CheckToken(ctx fiber.Ctx) (*dto.LoginResponse, error) {
|
||||
return services.Super.CheckToken(ctx.Context())
|
||||
}
|
||||
|
||||
// List Users
|
||||
//
|
||||
// @Router /v1/users [get]
|
||||
// @Summary User list
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param page query int false "Page"
|
||||
// @Param limit query int false "Limit"
|
||||
// @Param username query string false "Username"
|
||||
// @Success 200 {object} requests.Pager{items=[]dto.UserItem}
|
||||
// @Bind page query
|
||||
// @Bind limit query
|
||||
// @Bind username query
|
||||
func (s *Super) ListUsers(ctx fiber.Ctx, page, limit int, username string) (*requests.Pager, error) {
|
||||
return services.Super.ListUsers(ctx.Context(), page, limit, username)
|
||||
}
|
||||
|
||||
// Get User
|
||||
//
|
||||
// @Router /v1/users/:id [get]
|
||||
// @Summary Get User
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int64 true "ID"
|
||||
// @Success 200 {object} dto.UserItem
|
||||
// @Bind id path
|
||||
func (s *Super) GetUser(ctx fiber.Ctx, id int64) (*dto.UserItem, error) {
|
||||
return services.Super.GetUser(ctx.Context(), id)
|
||||
}
|
||||
|
||||
// Update User Status
|
||||
//
|
||||
// @Router /v1/users/:id/status [patch]
|
||||
// @Summary Update user status
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int64 true "ID"
|
||||
// @Param form body dto.UserStatusUpdateForm true "Form"
|
||||
// @Success 200
|
||||
// @Bind id path
|
||||
// @Bind form body
|
||||
func (s *Super) UpdateUserStatus(ctx fiber.Ctx, id int64, form *dto.UserStatusUpdateForm) error {
|
||||
return services.Super.UpdateUserStatus(ctx.Context(), id, form)
|
||||
}
|
||||
|
||||
// Update User Roles
|
||||
//
|
||||
// @Router /v1/users/:id/roles [patch]
|
||||
// @Summary Update user roles
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int64 true "ID"
|
||||
// @Param form body dto.UserRolesUpdateForm true "Form"
|
||||
// @Success 200
|
||||
// @Bind id path
|
||||
// @Bind form body
|
||||
func (s *Super) UpdateUserRoles(ctx fiber.Ctx, id int64, form *dto.UserRolesUpdateForm) error {
|
||||
return services.Super.UpdateUserRoles(ctx.Context(), id, form)
|
||||
}
|
||||
|
||||
// List Tenants
|
||||
//
|
||||
// @Router /v1/tenants [get]
|
||||
// @Summary Tenant list
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param page query int false "Page"
|
||||
// @Param limit query int false "Limit"
|
||||
// @Param name query string false "Name"
|
||||
// @Success 200 {object} requests.Pager{items=[]dto.TenantItem}
|
||||
// @Bind page query
|
||||
// @Bind limit query
|
||||
// @Bind name query
|
||||
func (s *Super) ListTenants(ctx fiber.Ctx, page, limit int, name string) (*requests.Pager, error) {
|
||||
return services.Super.ListTenants(ctx.Context(), page, limit, name)
|
||||
}
|
||||
|
||||
// Create Tenant
|
||||
//
|
||||
// @Router /v1/tenants [post]
|
||||
// @Summary Create Tenant
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param form body dto.TenantCreateForm true "Form"
|
||||
// @Success 200
|
||||
// @Bind form body
|
||||
func (s *Super) CreateTenant(ctx fiber.Ctx, form *dto.TenantCreateForm) error {
|
||||
return services.Super.CreateTenant(ctx.Context(), form)
|
||||
}
|
||||
|
||||
// Get Tenant
|
||||
//
|
||||
// @Router /v1/tenants/:id [get]
|
||||
// @Summary Get Tenant
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int64 true "ID"
|
||||
// @Success 200 {object} dto.TenantItem
|
||||
// @Bind id path
|
||||
func (s *Super) GetTenant(ctx fiber.Ctx, id int64) (*dto.TenantItem, error) {
|
||||
return services.Super.GetTenant(ctx.Context(), id)
|
||||
}
|
||||
|
||||
// Update Tenant Status
|
||||
//
|
||||
// @Router /v1/tenants/:id/status [patch]
|
||||
// @Summary Update Tenant Status
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int64 true "ID"
|
||||
// @Param form body dto.TenantStatusUpdateForm true "Form"
|
||||
// @Success 200
|
||||
// @Bind id path
|
||||
// @Bind form body
|
||||
func (s *Super) UpdateTenantStatus(ctx fiber.Ctx, id int64, form *dto.TenantStatusUpdateForm) error {
|
||||
return services.Super.UpdateTenantStatus(ctx.Context(), id, form)
|
||||
}
|
||||
|
||||
// Update Tenant Expire
|
||||
//
|
||||
// @Router /v1/tenants/:id [patch]
|
||||
// @Summary Update Tenant Expire
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int64 true "ID"
|
||||
// @Param form body dto.TenantExpireUpdateForm true "Form"
|
||||
// @Success 200
|
||||
// @Bind id path
|
||||
// @Bind form body
|
||||
func (s *Super) UpdateTenantExpire(ctx fiber.Ctx, id int64, form *dto.TenantExpireUpdateForm) error {
|
||||
return services.Super.UpdateTenantExpire(ctx.Context(), id, form)
|
||||
}
|
||||
|
||||
// List Contents
|
||||
//
|
||||
// @Router /v1/contents [get]
|
||||
// @Summary Content list
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param page query int false "Page"
|
||||
// @Param limit query int false "Limit"
|
||||
// @Success 200 {object} requests.Pager{items=[]dto.SuperTenantContentItem}
|
||||
// @Bind page query
|
||||
// @Bind limit query
|
||||
func (s *Super) ListContents(ctx fiber.Ctx, page, limit int) (*requests.Pager, error) {
|
||||
return services.Super.ListContents(ctx.Context(), page, limit)
|
||||
}
|
||||
|
||||
// Update Content Status
|
||||
//
|
||||
// @Router /v1/tenants/:tenantID/contents/:contentID/status [patch]
|
||||
// @Summary Update Content Status
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param tenantID path int64 true "TenantID"
|
||||
// @Param contentID path int64 true "ContentID"
|
||||
// @Param form body dto.SuperTenantContentStatusUpdateForm true "Form"
|
||||
// @Success 200
|
||||
// @Bind tenantID path
|
||||
// @Bind contentID path
|
||||
// @Bind form body
|
||||
func (s *Super) UpdateContentStatus(ctx fiber.Ctx, tenantID, contentID int64, form *dto.SuperTenantContentStatusUpdateForm) error {
|
||||
return services.Super.UpdateContentStatus(ctx.Context(), tenantID, contentID, form)
|
||||
}
|
||||
|
||||
// List Orders
|
||||
//
|
||||
// @Router /v1/orders [get]
|
||||
// @Summary Order list
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param page query int false "Page"
|
||||
// @Param limit query int false "Limit"
|
||||
// @Success 200 {object} requests.Pager{items=[]dto.SuperOrderItem}
|
||||
// @Bind page query
|
||||
// @Bind limit query
|
||||
func (s *Super) ListOrders(ctx fiber.Ctx, page, limit int) (*requests.Pager, error) {
|
||||
return services.Super.ListOrders(ctx.Context(), page, limit)
|
||||
}
|
||||
|
||||
// Get Order
|
||||
//
|
||||
// @Router /v1/orders/:id [get]
|
||||
// @Summary Get Order
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int64 true "ID"
|
||||
// @Success 200 {object} dto.SuperOrderDetail
|
||||
// @Bind id path
|
||||
func (s *Super) GetOrder(ctx fiber.Ctx, id int64) (*dto.SuperOrderDetail, error) {
|
||||
return services.Super.GetOrder(ctx.Context(), id)
|
||||
}
|
||||
|
||||
// Refund Order
|
||||
//
|
||||
// @Router /v1/orders/:id/refund [post]
|
||||
// @Summary Refund Order
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int64 true "ID"
|
||||
// @Param form body dto.SuperOrderRefundForm true "Form"
|
||||
// @Success 200
|
||||
// @Bind id path
|
||||
// @Bind form body
|
||||
func (s *Super) RefundOrder(ctx fiber.Ctx, id int64, form *dto.SuperOrderRefundForm) error {
|
||||
return services.Super.RefundOrder(ctx.Context(), id, form)
|
||||
}
|
||||
|
||||
// Order Statistics
|
||||
//
|
||||
// @Router /v1/orders/statistics [get]
|
||||
// @Summary Order Statistics
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {object} dto.OrderStatisticsResponse
|
||||
func (s *Super) OrderStatistics(ctx fiber.Ctx) (*dto.OrderStatisticsResponse, error) {
|
||||
return services.Super.OrderStatistics(ctx.Context())
|
||||
}
|
||||
|
||||
// User Statistics
|
||||
//
|
||||
// @Router /v1/users/statistics [get]
|
||||
// @Summary User Statistics
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {array} dto.UserStatistics
|
||||
func (s *Super) UserStatistics(ctx fiber.Ctx) ([]dto.UserStatistics, error) {
|
||||
return services.Super.UserStatistics(ctx.Context())
|
||||
}
|
||||
|
||||
// User Statuses
|
||||
//
|
||||
// @Router /v1/users/statuses [get]
|
||||
// @Summary User Statuses Enum
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {array} requests.KV
|
||||
func (s *Super) UserStatuses(ctx fiber.Ctx) ([]requests.KV, error) {
|
||||
return services.Super.UserStatuses(ctx.Context())
|
||||
}
|
||||
|
||||
// Tenant Statuses
|
||||
//
|
||||
// @Router /v1/tenants/statuses [get]
|
||||
// @Summary Tenant Statuses Enum
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {array} requests.KV
|
||||
func (s *Super) TenantStatuses(ctx fiber.Ctx) ([]requests.KV, error) {
|
||||
return services.Super.TenantStatuses(ctx.Context())
|
||||
}
|
||||
56
backend/app/http/v1/tenant.go
Normal file
56
backend/app/http/v1/tenant.go
Normal file
@@ -0,0 +1,56 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"quyun/v2/app/http/v1/dto"
|
||||
"quyun/v2/app/services"
|
||||
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
|
||||
// @provider
|
||||
type Tenant struct{}
|
||||
|
||||
// Get tenant public profile
|
||||
//
|
||||
// @Router /v1/tenants/:id [get]
|
||||
// @Summary Get tenant profile
|
||||
// @Description Get tenant public profile
|
||||
// @Tags TenantPublic
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "Tenant ID"
|
||||
// @Success 200 {object} dto.TenantProfile
|
||||
// @Bind id path
|
||||
func (t *Tenant) Get(ctx fiber.Ctx, id string) (*dto.TenantProfile, error) {
|
||||
return services.Tenant.GetPublicProfile(ctx.Context(), id)
|
||||
}
|
||||
|
||||
// Follow a tenant
|
||||
//
|
||||
// @Router /v1/tenants/:id/follow [post]
|
||||
// @Summary Follow tenant
|
||||
// @Description Follow a tenant
|
||||
// @Tags TenantPublic
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "Tenant ID"
|
||||
// @Success 200 {string} string "Followed"
|
||||
// @Bind id path
|
||||
func (t *Tenant) Follow(ctx fiber.Ctx, id string) error {
|
||||
return services.Tenant.Follow(ctx.Context(), id)
|
||||
}
|
||||
|
||||
// Unfollow a tenant
|
||||
//
|
||||
// @Router /v1/tenants/:id/follow [delete]
|
||||
// @Summary Unfollow tenant
|
||||
// @Description Unfollow a tenant
|
||||
// @Tags TenantPublic
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "Tenant ID"
|
||||
// @Success 200 {string} string "Unfollowed"
|
||||
// @Bind id path
|
||||
func (t *Tenant) Unfollow(ctx fiber.Ctx, id string) error {
|
||||
return services.Tenant.Unfollow(ctx.Context(), id)
|
||||
}
|
||||
58
backend/app/http/v1/transaction.go
Normal file
58
backend/app/http/v1/transaction.go
Normal file
@@ -0,0 +1,58 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"quyun/v2/app/http/v1/dto"
|
||||
"quyun/v2/app/services"
|
||||
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
|
||||
// @provider
|
||||
type Transaction struct{}
|
||||
|
||||
// Create Order
|
||||
//
|
||||
// @Router /v1/orders [post]
|
||||
// @Summary Create Order
|
||||
// @Description Create Order
|
||||
// @Tags Transaction
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param form body dto.OrderCreateForm true "Create form"
|
||||
// @Success 200 {object} dto.OrderCreateResponse
|
||||
// @Bind form body
|
||||
func (t *Transaction) Create(ctx fiber.Ctx, form *dto.OrderCreateForm) (*dto.OrderCreateResponse, error) {
|
||||
return services.Order.Create(ctx.Context(), form)
|
||||
}
|
||||
|
||||
// Pay for order
|
||||
//
|
||||
// @Router /v1/orders/:id/pay [post]
|
||||
// @Summary Pay for order
|
||||
// @Description Pay for order
|
||||
// @Tags Transaction
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "Order ID"
|
||||
// @Param form body dto.OrderPayForm true "Pay form"
|
||||
// @Success 200 {object} dto.OrderPayResponse
|
||||
// @Bind id path
|
||||
// @Bind form body
|
||||
func (t *Transaction) Pay(ctx fiber.Ctx, id string, form *dto.OrderPayForm) (*dto.OrderPayResponse, error) {
|
||||
return services.Order.Pay(ctx.Context(), id, form)
|
||||
}
|
||||
|
||||
// Check order payment status
|
||||
//
|
||||
// @Router /v1/orders/:id/status [get]
|
||||
// @Summary Check order status
|
||||
// @Description Check order payment status
|
||||
// @Tags Transaction
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "Order ID"
|
||||
// @Success 200 {object} dto.OrderStatusResponse
|
||||
// @Bind id path
|
||||
func (t *Transaction) Status(ctx fiber.Ctx, id string) (*dto.OrderStatusResponse, error) {
|
||||
return services.Order.Status(ctx.Context(), id)
|
||||
}
|
||||
227
backend/app/http/v1/user.go
Normal file
227
backend/app/http/v1/user.go
Normal file
@@ -0,0 +1,227 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"quyun/v2/app/http/v1/dto"
|
||||
auth_dto "quyun/v2/app/http/v1/dto"
|
||||
"quyun/v2/app/services"
|
||||
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
|
||||
// @provider
|
||||
type User struct{}
|
||||
|
||||
// Get current user profile
|
||||
//
|
||||
// @Router /v1/me [get]
|
||||
// @Summary Get user profile
|
||||
// @Description Get current user profile
|
||||
// @Tags UserCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {object} auth_dto.User
|
||||
func (u *User) Me(ctx fiber.Ctx) (*auth_dto.User, error) {
|
||||
return services.User.Me(ctx.Context())
|
||||
}
|
||||
|
||||
// Update user profile
|
||||
//
|
||||
// @Router /v1/me [put]
|
||||
// @Summary Update user profile
|
||||
// @Description Update user profile
|
||||
// @Tags UserCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param form body dto.UserUpdate true "Update form"
|
||||
// @Success 200 {string} string "Updated"
|
||||
// @Bind form body
|
||||
func (u *User) Update(ctx fiber.Ctx, form *dto.UserUpdate) error {
|
||||
return services.User.Update(ctx.Context(), form)
|
||||
}
|
||||
|
||||
// Submit real-name authentication
|
||||
//
|
||||
// @Router /v1/me/realname [post]
|
||||
// @Summary Realname auth
|
||||
// @Description Submit real-name authentication
|
||||
// @Tags UserCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param form body dto.RealNameForm true "Realname form"
|
||||
// @Success 200 {string} string "Submitted"
|
||||
// @Bind form body
|
||||
func (u *User) RealName(ctx fiber.Ctx, form *dto.RealNameForm) error {
|
||||
return services.User.RealName(ctx.Context(), form)
|
||||
}
|
||||
|
||||
// Get wallet balance and transactions
|
||||
//
|
||||
// @Router /v1/me/wallet [get]
|
||||
// @Summary Get wallet
|
||||
// @Description Get wallet balance and transactions
|
||||
// @Tags UserCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {object} dto.WalletResponse
|
||||
func (u *User) Wallet(ctx fiber.Ctx) (*dto.WalletResponse, error) {
|
||||
return services.Wallet.GetWallet(ctx.Context())
|
||||
}
|
||||
|
||||
// Recharge wallet
|
||||
//
|
||||
// @Router /v1/me/wallet/recharge [post]
|
||||
// @Summary Recharge wallet
|
||||
// @Description Recharge wallet
|
||||
// @Tags UserCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param form body dto.RechargeForm true "Recharge form"
|
||||
// @Success 200 {object} dto.RechargeResponse
|
||||
// @Bind form body
|
||||
func (u *User) Recharge(ctx fiber.Ctx, form *dto.RechargeForm) (*dto.RechargeResponse, error) {
|
||||
return services.Wallet.Recharge(ctx.Context(), form)
|
||||
}
|
||||
|
||||
// List user orders
|
||||
//
|
||||
// @Router /v1/me/orders [get]
|
||||
// @Summary List orders
|
||||
// @Description List user orders
|
||||
// @Tags UserCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param status query string false "Status enum(all, unpaid, completed, refund)"
|
||||
// @Success 200 {array} dto.Order
|
||||
// @Bind status query
|
||||
func (u *User) ListOrders(ctx fiber.Ctx, status string) ([]dto.Order, error) {
|
||||
return services.Order.ListUserOrders(ctx.Context(), status)
|
||||
}
|
||||
|
||||
// Get user order detail
|
||||
//
|
||||
// @Router /v1/me/orders/:id [get]
|
||||
// @Summary Get order detail
|
||||
// @Description Get user order detail
|
||||
// @Tags UserCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "Order ID"
|
||||
// @Success 200 {object} dto.Order
|
||||
// @Bind id path
|
||||
func (u *User) GetOrder(ctx fiber.Ctx, id string) (*dto.Order, error) {
|
||||
return services.Order.GetUserOrder(ctx.Context(), id)
|
||||
}
|
||||
|
||||
// Get purchased content
|
||||
//
|
||||
// @Router /v1/me/library [get]
|
||||
// @Summary Get library
|
||||
// @Description Get purchased content
|
||||
// @Tags UserCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {array} dto.ContentItem
|
||||
func (u *User) Library(ctx fiber.Ctx) ([]dto.ContentItem, error) {
|
||||
return services.Content.GetLibrary(ctx.Context())
|
||||
}
|
||||
|
||||
// Get favorites
|
||||
//
|
||||
// @Router /v1/me/favorites [get]
|
||||
// @Summary Get favorites
|
||||
// @Description Get favorites
|
||||
// @Tags UserCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {array} dto.ContentItem
|
||||
func (u *User) Favorites(ctx fiber.Ctx) ([]dto.ContentItem, error) {
|
||||
return services.Content.GetFavorites(ctx.Context())
|
||||
}
|
||||
|
||||
// Add to favorites
|
||||
//
|
||||
// @Router /v1/me/favorites [post]
|
||||
// @Summary Add favorite
|
||||
// @Description Add to favorites
|
||||
// @Tags UserCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param contentId query string true "Content ID"
|
||||
// @Success 200 {string} string "Added"
|
||||
// @Bind contentId query
|
||||
func (u *User) AddFavorite(ctx fiber.Ctx, contentId string) error {
|
||||
return services.Content.AddFavorite(ctx.Context(), contentId)
|
||||
}
|
||||
|
||||
// Remove from favorites
|
||||
//
|
||||
// @Router /v1/me/favorites/:contentId [delete]
|
||||
// @Summary Remove favorite
|
||||
// @Description Remove from favorites
|
||||
// @Tags UserCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param contentId path string true "Content ID"
|
||||
// @Success 200 {string} string "Removed"
|
||||
// @Bind contentId path
|
||||
func (u *User) RemoveFavorite(ctx fiber.Ctx, contentId string) error {
|
||||
return services.Content.RemoveFavorite(ctx.Context(), contentId)
|
||||
}
|
||||
|
||||
// Get liked contents
|
||||
//
|
||||
// @Router /v1/me/likes [get]
|
||||
// @Summary Get likes
|
||||
// @Description Get liked contents
|
||||
// @Tags UserCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {array} dto.ContentItem
|
||||
func (u *User) Likes(ctx fiber.Ctx) ([]dto.ContentItem, error) {
|
||||
return services.Content.GetLikes(ctx.Context())
|
||||
}
|
||||
|
||||
// Like content
|
||||
//
|
||||
// @Router /v1/me/likes [post]
|
||||
// @Summary Like content
|
||||
// @Description Like content
|
||||
// @Tags UserCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param contentId query string true "Content ID"
|
||||
// @Success 200 {string} string "Liked"
|
||||
// @Bind contentId query
|
||||
func (u *User) AddLike(ctx fiber.Ctx, contentId string) error {
|
||||
return services.Content.AddLike(ctx.Context(), contentId)
|
||||
}
|
||||
|
||||
// Unlike content
|
||||
//
|
||||
// @Router /v1/me/likes/:contentId [delete]
|
||||
// @Summary Unlike content
|
||||
// @Description Unlike content
|
||||
// @Tags UserCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param contentId path string true "Content ID"
|
||||
// @Success 200 {string} string "Unliked"
|
||||
// @Bind contentId path
|
||||
func (u *User) RemoveLike(ctx fiber.Ctx, contentId string) error {
|
||||
return services.Content.RemoveLike(ctx.Context(), contentId)
|
||||
}
|
||||
|
||||
// Get notifications
|
||||
//
|
||||
// @Router /v1/me/notifications [get]
|
||||
// @Summary Get notifications
|
||||
// @Description Get notifications
|
||||
// @Tags UserCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param type query string false "Type enum(all, system, order, audit, interaction)"
|
||||
// @Success 200 {array} dto.Notification
|
||||
// @Bind typeArg query key(type)
|
||||
func (u *User) Notifications(ctx fiber.Ctx, typeArg string) ([]dto.Notification, error) {
|
||||
return services.User.GetNotifications(ctx.Context(), typeArg)
|
||||
}
|
||||
Reference in New Issue
Block a user