feat: implement new structure
This commit is contained in:
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)
|
||||
}
|
||||
Reference in New Issue
Block a user