feat: restore creator controller methods and regenerate routes
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -136,7 +136,7 @@ func (c *Common) CompleteUpload(ctx fiber.Ctx, user *models.User, form *dto.Uplo
|
||||
// @Param uploadId path string true "Upload ID"
|
||||
// @Success 200 {string} string "OK"
|
||||
// @Bind user local key(__ctx_user)
|
||||
// @Bind uploadId path
|
||||
// @Bind uploadID path key(uploadId)
|
||||
func (c *Common) AbortUpload(ctx fiber.Ctx, user *models.User, uploadID string) error {
|
||||
tenantID := getTenantID(ctx)
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@ package v1
|
||||
import (
|
||||
"quyun/v2/app/errorx"
|
||||
"quyun/v2/app/http/v1/dto"
|
||||
"quyun/v2/app/requests"
|
||||
"quyun/v2/app/services"
|
||||
"quyun/v2/database/models"
|
||||
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
@@ -12,54 +12,576 @@ import (
|
||||
// @provider
|
||||
type Creator struct{}
|
||||
|
||||
// Apply to become a creator
|
||||
// Apply creator profile
|
||||
//
|
||||
// @Router /v1/t/:tenantCode/creator/apply [post]
|
||||
// @Router /v1/t/:tenantCode/creator/members/:id<int>/review [post]
|
||||
// @Router /v1/t/:tenantCode/creator/members/invite [post]
|
||||
// @Router /v1/t/:tenantCode/creator/members [get]
|
||||
// @Router /v1/t/:tenantCode/creator/members/invites [get]
|
||||
// @Router /v1/t/:tenantCode/creator/members/invites/:id<int> [delete]
|
||||
// @Router /v1/t/:tenantCode/creator/members/join-requests [get]
|
||||
// @Router /v1/t/:tenantCode/creator/members/:id<int> [delete]
|
||||
// @Router /v1/t/:tenantCode/creator/reports/overview [get]
|
||||
// @Router /v1/t/:tenantCode/creator/reports/export [post]
|
||||
// @Router /v1/t/:tenantCode/creator/dashboard [get]
|
||||
// @Router /v1/t/:tenantCode/creator/contents/:id<int> [get]
|
||||
// @Router /v1/t/:tenantCode/creator/contents [get]
|
||||
// @Router /v1/t/:tenantCode/creator/contents [post]
|
||||
// @Router /v1/t/:tenantCode/creator/contents/:id<int> [put]
|
||||
// @Router /v1/t/:tenantCode/creator/contents/:id<int> [delete]
|
||||
// @Router /v1/t/:tenantCode/creator/orders [get]
|
||||
// @Router /v1/t/:tenantCode/creator/orders/:id<int>/refund [post]
|
||||
// @Router /v1/t/:tenantCode/creator/settings [get]
|
||||
// @Router /v1/t/:tenantCode/creator/settings [put]
|
||||
// @Router /v1/t/:tenantCode/creator/payout-accounts [get]
|
||||
// @Router /v1/t/:tenantCode/creator/payout-accounts [post]
|
||||
// @Router /v1/t/:tenantCode/creator/payout-accounts [delete]
|
||||
// @Router /v1/t/:tenantCode/creator/withdraw [post]
|
||||
// @Router /v1/t/:tenantCode/creator/coupons [post]
|
||||
// @Router /v1/t/:tenantCode/creator/coupons [get]
|
||||
// @Router /v1/t/:tenantCode/creator/coupons/:id<int> [get]
|
||||
// @Router /v1/t/:tenantCode/creator/coupons/:id<int> [put]
|
||||
// @Router /v1/t/:tenantCode/creator/coupons/:id<int>/grant [post]
|
||||
// @Summary Apply creator profile
|
||||
// @Description 申请成为创作者并创建频道
|
||||
// @Tags CreatorCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param form body dto.ApplyForm true "Apply form"
|
||||
// @Success 200 {string} string "Applied"
|
||||
// @Bind form body
|
||||
func (c *Creator) Apply(ctx fiber.Ctx, form *dto.ApplyForm) error {
|
||||
if form == nil {
|
||||
return errorx.ErrInvalidParameter.WithMsg("参数无效")
|
||||
}
|
||||
|
||||
// @Summary Grant coupon
|
||||
// @Description Grant coupon to users
|
||||
tenantID := getTenantID(ctx)
|
||||
userID := getUserID(ctx)
|
||||
|
||||
return services.Creator.Apply(ctx, tenantID, userID, form)
|
||||
}
|
||||
|
||||
// Get creator dashboard
|
||||
//
|
||||
// @Router /v1/t/:tenantCode/creator/dashboard [get]
|
||||
// @Summary Get creator dashboard
|
||||
// @Description 获取创作者看板统计
|
||||
// @Tags CreatorCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {object} dto.DashboardStats
|
||||
func (c *Creator) Dashboard(ctx fiber.Ctx) (*dto.DashboardStats, error) {
|
||||
tenantID := getTenantID(ctx)
|
||||
userID := getUserID(ctx)
|
||||
|
||||
return services.Creator.Dashboard(ctx, tenantID, userID)
|
||||
}
|
||||
|
||||
// List creator contents
|
||||
//
|
||||
// @Router /v1/t/:tenantCode/creator/contents [get]
|
||||
// @Summary List creator contents
|
||||
// @Description 创作者内容列表(分页/筛选)
|
||||
// @Tags CreatorCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param page query int false "Page"
|
||||
// @Param limit query int false "Limit"
|
||||
// @Param status query string false "Status"
|
||||
// @Param visibility query string false "Visibility"
|
||||
// @Param genre query string false "Genre"
|
||||
// @Param key query string false "Key"
|
||||
// @Param keyword query string false "Keyword"
|
||||
// @Param sort query string false "Sort"
|
||||
// @Success 200 {object} requests.Pager{items=[]dto.CreatorContentItem}
|
||||
// @Bind filter query
|
||||
func (c *Creator) ListContents(ctx fiber.Ctx, filter *dto.CreatorContentListFilter) (*requests.Pager, error) {
|
||||
if filter == nil {
|
||||
filter = &dto.CreatorContentListFilter{}
|
||||
}
|
||||
|
||||
tenantID := getTenantID(ctx)
|
||||
userID := getUserID(ctx)
|
||||
|
||||
return services.Creator.ListContents(ctx, tenantID, userID, filter)
|
||||
}
|
||||
|
||||
// Get creator content detail
|
||||
//
|
||||
// @Router /v1/t/:tenantCode/creator/contents/:id<int> [get]
|
||||
// @Summary Get creator content detail
|
||||
// @Description 获取创作者内容编辑详情
|
||||
// @Tags CreatorCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int64 true "Content ID"
|
||||
// @Success 200 {object} dto.ContentEditDTO
|
||||
// @Bind id path
|
||||
func (c *Creator) GetContent(ctx fiber.Ctx, id int64) (*dto.ContentEditDTO, error) {
|
||||
tenantID := getTenantID(ctx)
|
||||
userID := getUserID(ctx)
|
||||
|
||||
return services.Creator.GetContent(ctx, tenantID, userID, id)
|
||||
}
|
||||
|
||||
// Create creator content
|
||||
//
|
||||
// @Router /v1/t/:tenantCode/creator/contents [post]
|
||||
// @Summary Create creator content
|
||||
// @Description 创建创作者内容
|
||||
// @Tags CreatorCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param form body dto.ContentCreateForm true "Create form"
|
||||
// @Success 200 {string} string "Created"
|
||||
// @Bind form body
|
||||
func (c *Creator) CreateContent(ctx fiber.Ctx, form *dto.ContentCreateForm) error {
|
||||
if form == nil {
|
||||
return errorx.ErrInvalidParameter.WithMsg("参数无效")
|
||||
}
|
||||
|
||||
tenantID := getTenantID(ctx)
|
||||
userID := getUserID(ctx)
|
||||
|
||||
return services.Creator.CreateContent(ctx, tenantID, userID, form)
|
||||
}
|
||||
|
||||
// Update creator content
|
||||
//
|
||||
// @Router /v1/t/:tenantCode/creator/contents/:id<int> [put]
|
||||
// @Summary Update creator content
|
||||
// @Description 更新创作者内容
|
||||
// @Tags CreatorCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int64 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 int64, form *dto.ContentUpdateForm) error {
|
||||
if form == nil {
|
||||
return errorx.ErrInvalidParameter.WithMsg("参数无效")
|
||||
}
|
||||
|
||||
tenantID := getTenantID(ctx)
|
||||
userID := getUserID(ctx)
|
||||
|
||||
return services.Creator.UpdateContent(ctx, tenantID, userID, id, form)
|
||||
}
|
||||
|
||||
// Delete creator content
|
||||
//
|
||||
// @Router /v1/t/:tenantCode/creator/contents/:id<int> [delete]
|
||||
// @Summary Delete creator content
|
||||
// @Description 删除创作者内容
|
||||
// @Tags CreatorCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int64 true "Content ID"
|
||||
// @Success 200 {string} string "Deleted"
|
||||
// @Bind id path
|
||||
func (c *Creator) DeleteContent(ctx fiber.Ctx, id int64) error {
|
||||
tenantID := getTenantID(ctx)
|
||||
userID := getUserID(ctx)
|
||||
|
||||
return services.Creator.DeleteContent(ctx, tenantID, userID, id)
|
||||
}
|
||||
|
||||
// List creator orders
|
||||
//
|
||||
// @Router /v1/t/:tenantCode/creator/orders [get]
|
||||
// @Summary List creator orders
|
||||
// @Description 创作者订单列表
|
||||
// @Tags CreatorCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param page query int false "Page"
|
||||
// @Param limit query int false "Limit"
|
||||
// @Param status query string false "Status"
|
||||
// @Param keyword query string false "Keyword"
|
||||
// @Success 200 {array} dto.Order
|
||||
// @Bind filter query
|
||||
func (c *Creator) ListOrders(ctx fiber.Ctx, filter *dto.CreatorOrderListFilter) ([]dto.Order, error) {
|
||||
if filter == nil {
|
||||
filter = &dto.CreatorOrderListFilter{}
|
||||
}
|
||||
|
||||
tenantID := getTenantID(ctx)
|
||||
userID := getUserID(ctx)
|
||||
|
||||
return services.Creator.ListOrders(ctx, tenantID, userID, filter)
|
||||
}
|
||||
|
||||
// Process order refund
|
||||
//
|
||||
// @Router /v1/t/:tenantCode/creator/orders/:id<int>/refund [post]
|
||||
// @Summary Process order refund
|
||||
// @Description 处理创作者订单退款(同意/拒绝)
|
||||
// @Tags CreatorCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int64 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) RefundOrder(ctx fiber.Ctx, id int64, form *dto.RefundForm) error {
|
||||
if form == nil {
|
||||
return errorx.ErrInvalidParameter.WithMsg("参数无效")
|
||||
}
|
||||
|
||||
tenantID := getTenantID(ctx)
|
||||
userID := getUserID(ctx)
|
||||
|
||||
return services.Creator.ProcessRefund(ctx, tenantID, userID, id, form)
|
||||
}
|
||||
|
||||
// Get creator settings
|
||||
//
|
||||
// @Router /v1/t/:tenantCode/creator/settings [get]
|
||||
// @Summary Get creator settings
|
||||
// @Description 获取创作者频道设置
|
||||
// @Tags CreatorCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {object} dto.Settings
|
||||
func (c *Creator) GetSettings(ctx fiber.Ctx) (*dto.Settings, error) {
|
||||
tenantID := getTenantID(ctx)
|
||||
userID := getUserID(ctx)
|
||||
|
||||
return services.Creator.GetSettings(ctx, tenantID, userID)
|
||||
}
|
||||
|
||||
// Update creator settings
|
||||
//
|
||||
// @Router /v1/t/:tenantCode/creator/settings [put]
|
||||
// @Summary Update creator settings
|
||||
// @Description 更新创作者频道设置
|
||||
// @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 {
|
||||
if form == nil {
|
||||
return errorx.ErrInvalidParameter.WithMsg("参数无效")
|
||||
}
|
||||
|
||||
tenantID := getTenantID(ctx)
|
||||
userID := getUserID(ctx)
|
||||
|
||||
return services.Creator.UpdateSettings(ctx, tenantID, userID, form)
|
||||
}
|
||||
|
||||
// List payout accounts
|
||||
//
|
||||
// @Router /v1/t/:tenantCode/creator/payout-accounts [get]
|
||||
// @Summary List payout accounts
|
||||
// @Description 获取创作者收款账户列表
|
||||
// @Tags CreatorCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {array} dto.PayoutAccount
|
||||
func (c *Creator) ListPayoutAccounts(ctx fiber.Ctx) ([]dto.PayoutAccount, error) {
|
||||
tenantID := getTenantID(ctx)
|
||||
userID := getUserID(ctx)
|
||||
|
||||
return services.Creator.ListPayoutAccounts(ctx, tenantID, userID)
|
||||
}
|
||||
|
||||
// Add payout account
|
||||
//
|
||||
// @Router /v1/t/:tenantCode/creator/payout-accounts [post]
|
||||
// @Summary Add payout account
|
||||
// @Description 新增创作者收款账户
|
||||
// @Tags CreatorCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param form body dto.PayoutAccount true "Payout account form"
|
||||
// @Success 200 {string} string "Created"
|
||||
// @Bind form body
|
||||
func (c *Creator) AddPayoutAccount(ctx fiber.Ctx, form *dto.PayoutAccount) error {
|
||||
if form == nil {
|
||||
return errorx.ErrInvalidParameter.WithMsg("参数无效")
|
||||
}
|
||||
|
||||
tenantID := getTenantID(ctx)
|
||||
userID := getUserID(ctx)
|
||||
|
||||
return services.Creator.AddPayoutAccount(ctx, tenantID, userID, form)
|
||||
}
|
||||
|
||||
// Remove payout account
|
||||
//
|
||||
// @Router /v1/t/:tenantCode/creator/payout-accounts [delete]
|
||||
// @Summary Remove payout account
|
||||
// @Description 删除创作者收款账户
|
||||
// @Tags CreatorCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id query int64 true "Payout account ID"
|
||||
// @Success 200 {string} string "Deleted"
|
||||
// @Bind id query
|
||||
func (c *Creator) RemovePayoutAccount(ctx fiber.Ctx, id int64) error {
|
||||
tenantID := getTenantID(ctx)
|
||||
userID := getUserID(ctx)
|
||||
|
||||
return services.Creator.RemovePayoutAccount(ctx, tenantID, userID, id)
|
||||
}
|
||||
|
||||
// Create withdraw order
|
||||
//
|
||||
// @Router /v1/t/:tenantCode/creator/withdraw [post]
|
||||
// @Summary Create withdraw order
|
||||
// @Description 发起提现申请
|
||||
// @Tags CreatorCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param form body dto.WithdrawForm true "Withdraw form"
|
||||
// @Success 200 {string} string "Submitted"
|
||||
// @Bind form body
|
||||
func (c *Creator) Withdraw(ctx fiber.Ctx, form *dto.WithdrawForm) error {
|
||||
if form == nil {
|
||||
return errorx.ErrInvalidParameter.WithMsg("参数无效")
|
||||
}
|
||||
|
||||
tenantID := getTenantID(ctx)
|
||||
userID := getUserID(ctx)
|
||||
|
||||
return services.Creator.Withdraw(ctx, tenantID, userID, form)
|
||||
}
|
||||
|
||||
// List creator members
|
||||
//
|
||||
// @Router /v1/t/:tenantCode/creator/members [get]
|
||||
// @Summary List creator members
|
||||
// @Description 查询创作者成员列表
|
||||
// @Tags CreatorCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param page query int false "Page"
|
||||
// @Param limit query int false "Limit"
|
||||
// @Param keyword query string false "Keyword"
|
||||
// @Param role query string false "Role"
|
||||
// @Param status query string false "Status"
|
||||
// @Success 200 {object} requests.Pager{items=[]dto.TenantMemberItem}
|
||||
// @Bind filter query
|
||||
func (c *Creator) ListMembers(ctx fiber.Ctx, filter *dto.TenantMemberListFilter) (*requests.Pager, error) {
|
||||
if filter == nil {
|
||||
filter = &dto.TenantMemberListFilter{}
|
||||
}
|
||||
|
||||
tenantID := getTenantID(ctx)
|
||||
userID := getUserID(ctx)
|
||||
|
||||
return services.Tenant.ListMembers(ctx, tenantID, userID, filter)
|
||||
}
|
||||
|
||||
// Remove creator member
|
||||
//
|
||||
// @Router /v1/t/:tenantCode/creator/members/:id<int> [delete]
|
||||
// @Summary Remove creator member
|
||||
// @Description 移除创作者成员
|
||||
// @Tags CreatorCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int64 true "Member relation ID"
|
||||
// @Success 200 {string} string "Removed"
|
||||
// @Bind id path
|
||||
func (c *Creator) RemoveMember(ctx fiber.Ctx, id int64) error {
|
||||
tenantID := getTenantID(ctx)
|
||||
userID := getUserID(ctx)
|
||||
|
||||
return services.Tenant.RemoveMember(ctx, tenantID, userID, id)
|
||||
}
|
||||
|
||||
// List creator member invites
|
||||
//
|
||||
// @Router /v1/t/:tenantCode/creator/members/invites [get]
|
||||
// @Summary List creator member invites
|
||||
// @Description 查询创作者成员邀请记录
|
||||
// @Tags CreatorCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param page query int false "Page"
|
||||
// @Param limit query int false "Limit"
|
||||
// @Param status query string false "Status"
|
||||
// @Success 200 {object} requests.Pager{items=[]dto.TenantInviteListItem}
|
||||
// @Bind filter query
|
||||
func (c *Creator) ListMemberInvites(ctx fiber.Ctx, filter *dto.TenantInviteListFilter) (*requests.Pager, error) {
|
||||
if filter == nil {
|
||||
filter = &dto.TenantInviteListFilter{}
|
||||
}
|
||||
|
||||
tenantID := getTenantID(ctx)
|
||||
userID := getUserID(ctx)
|
||||
|
||||
return services.Tenant.ListInvites(ctx, tenantID, userID, filter)
|
||||
}
|
||||
|
||||
// Create creator member invite
|
||||
//
|
||||
// @Router /v1/t/:tenantCode/creator/members/invite [post]
|
||||
// @Summary Create creator member invite
|
||||
// @Description 创建成员邀请
|
||||
// @Tags CreatorCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param form body dto.TenantInviteCreateForm true "Invite form"
|
||||
// @Success 200 {object} dto.TenantInviteItem
|
||||
// @Bind form body
|
||||
func (c *Creator) CreateMemberInvite(ctx fiber.Ctx, form *dto.TenantInviteCreateForm) (*dto.TenantInviteItem, error) {
|
||||
if form == nil {
|
||||
return nil, errorx.ErrInvalidParameter.WithMsg("参数无效")
|
||||
}
|
||||
|
||||
tenantID := getTenantID(ctx)
|
||||
userID := getUserID(ctx)
|
||||
|
||||
return services.Tenant.CreateInvite(ctx, tenantID, userID, form)
|
||||
}
|
||||
|
||||
// Disable creator member invite
|
||||
//
|
||||
// @Router /v1/t/:tenantCode/creator/members/invites/:id<int> [delete]
|
||||
// @Summary Disable creator member invite
|
||||
// @Description 撤销成员邀请
|
||||
// @Tags CreatorCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int64 true "Invite ID"
|
||||
// @Success 200 {string} string "Disabled"
|
||||
// @Bind id path
|
||||
func (c *Creator) DisableMemberInvite(ctx fiber.Ctx, id int64) error {
|
||||
tenantID := getTenantID(ctx)
|
||||
userID := getUserID(ctx)
|
||||
|
||||
return services.Tenant.DisableInvite(ctx, tenantID, userID, id)
|
||||
}
|
||||
|
||||
// List creator join requests
|
||||
//
|
||||
// @Router /v1/t/:tenantCode/creator/members/join-requests [get]
|
||||
// @Summary List creator join requests
|
||||
// @Description 查询成员加入申请
|
||||
// @Tags CreatorCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param page query int false "Page"
|
||||
// @Param limit query int false "Limit"
|
||||
// @Param status query string false "Status"
|
||||
// @Param keyword query string false "Keyword"
|
||||
// @Success 200 {object} requests.Pager{items=[]dto.TenantJoinRequestItem}
|
||||
// @Bind filter query
|
||||
func (c *Creator) ListMemberJoinRequests(ctx fiber.Ctx, filter *dto.TenantJoinRequestListFilter) (*requests.Pager, error) {
|
||||
if filter == nil {
|
||||
filter = &dto.TenantJoinRequestListFilter{}
|
||||
}
|
||||
|
||||
tenantID := getTenantID(ctx)
|
||||
userID := getUserID(ctx)
|
||||
|
||||
return services.Tenant.ListJoinRequests(ctx, tenantID, userID, filter)
|
||||
}
|
||||
|
||||
// Review creator join request
|
||||
//
|
||||
// @Router /v1/t/:tenantCode/creator/members/:id<int>/review [post]
|
||||
// @Summary Review creator join request
|
||||
// @Description 审核成员加入申请
|
||||
// @Tags CreatorCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int64 true "Join request ID"
|
||||
// @Param form body dto.TenantJoinReviewForm true "Review form"
|
||||
// @Success 200 {string} string "Reviewed"
|
||||
// @Bind id path
|
||||
// @Bind form body
|
||||
func (c *Creator) ReviewMemberJoinRequest(ctx fiber.Ctx, id int64, form *dto.TenantJoinReviewForm) error {
|
||||
if form == nil {
|
||||
return errorx.ErrInvalidParameter.WithMsg("参数无效")
|
||||
}
|
||||
|
||||
tenantID := getTenantID(ctx)
|
||||
userID := getUserID(ctx)
|
||||
|
||||
return services.Tenant.ReviewJoin(ctx, tenantID, userID, id, form)
|
||||
}
|
||||
|
||||
// List creator coupons
|
||||
//
|
||||
// @Router /v1/t/:tenantCode/creator/coupons [get]
|
||||
// @Summary List creator coupons
|
||||
// @Description 查询创作者优惠券
|
||||
// @Tags CreatorCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param page query int false "Page"
|
||||
// @Param limit query int false "Limit"
|
||||
// @Param type query string false "Coupon type"
|
||||
// @Param status query string false "Coupon status"
|
||||
// @Param keyword query string false "Keyword"
|
||||
// @Success 200 {object} requests.Pager{items=[]dto.CouponItem}
|
||||
// @Bind filter query
|
||||
func (c *Creator) ListCoupons(ctx fiber.Ctx, filter *dto.CouponListFilter) (*requests.Pager, error) {
|
||||
if filter == nil {
|
||||
filter = &dto.CouponListFilter{}
|
||||
}
|
||||
|
||||
tenantID := getTenantID(ctx)
|
||||
|
||||
return services.Coupon.List(ctx, tenantID, filter)
|
||||
}
|
||||
|
||||
// Get creator coupon
|
||||
//
|
||||
// @Router /v1/t/:tenantCode/creator/coupons/:id<int> [get]
|
||||
// @Summary Get creator coupon
|
||||
// @Description 查询创作者优惠券详情
|
||||
// @Tags CreatorCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int64 true "Coupon ID"
|
||||
// @Success 200 {object} dto.CouponItem
|
||||
// @Bind id path
|
||||
func (c *Creator) GetCoupon(ctx fiber.Ctx, id int64) (*dto.CouponItem, error) {
|
||||
tenantID := getTenantID(ctx)
|
||||
|
||||
return services.Coupon.Get(ctx, tenantID, id)
|
||||
}
|
||||
|
||||
// Create creator coupon
|
||||
//
|
||||
// @Router /v1/t/:tenantCode/creator/coupons [post]
|
||||
// @Summary Create creator coupon
|
||||
// @Description 创建创作者优惠券
|
||||
// @Tags CreatorCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param form body dto.CouponCreateForm true "Coupon create form"
|
||||
// @Success 200 {object} dto.CouponItem
|
||||
// @Bind form body
|
||||
func (c *Creator) CreateCoupon(ctx fiber.Ctx, form *dto.CouponCreateForm) (*dto.CouponItem, error) {
|
||||
tenantID := getTenantID(ctx)
|
||||
userID := getUserID(ctx)
|
||||
|
||||
return services.Coupon.Create(ctx, tenantID, userID, form)
|
||||
}
|
||||
|
||||
// Update creator coupon
|
||||
//
|
||||
// @Router /v1/t/:tenantCode/creator/coupons/:id<int> [put]
|
||||
// @Summary Update creator coupon
|
||||
// @Description 更新创作者优惠券
|
||||
// @Tags CreatorCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int64 true "Coupon ID"
|
||||
// @Param form body dto.CouponUpdateForm true "Coupon update form"
|
||||
// @Success 200 {object} dto.CouponItem
|
||||
// @Bind id path
|
||||
// @Bind form body
|
||||
func (c *Creator) UpdateCoupon(ctx fiber.Ctx, id int64, form *dto.CouponUpdateForm) (*dto.CouponItem, error) {
|
||||
tenantID := getTenantID(ctx)
|
||||
userID := getUserID(ctx)
|
||||
|
||||
return services.Coupon.Update(ctx, tenantID, userID, id, form)
|
||||
}
|
||||
|
||||
// Grant creator coupon
|
||||
//
|
||||
// @Router /v1/t/:tenantCode/creator/coupons/:id<int>/grant [post]
|
||||
// @Summary Grant creator coupon
|
||||
// @Description 向用户发放优惠券
|
||||
// @Tags CreatorCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int64 true "Coupon ID"
|
||||
// @Param form body dto.CouponGrantForm true "Grant form"
|
||||
// @Success 200 {string} string "Granted"
|
||||
// @Bind user local key(__ctx_user)
|
||||
// @Bind id path
|
||||
// @Bind form body
|
||||
func (c *Creator) GrantCoupon(ctx fiber.Ctx, _ *models.User, id int64, form *dto.CouponGrantForm) (string, error) {
|
||||
tenantID := getTenantID(ctx)
|
||||
func (c *Creator) GrantCoupon(ctx fiber.Ctx, id int64, form *dto.CouponGrantForm) (string, error) {
|
||||
if form == nil {
|
||||
return "", errorx.ErrInvalidParameter.WithMsg("参数无效")
|
||||
}
|
||||
|
||||
tenantID := getTenantID(ctx)
|
||||
_, err := services.Coupon.Grant(ctx, tenantID, id, form.UserIDs)
|
||||
if err != nil {
|
||||
return "", errorx.ErrOperationFailed.WithCause(err)
|
||||
@@ -67,3 +589,41 @@ func (c *Creator) GrantCoupon(ctx fiber.Ctx, _ *models.User, id int64, form *dto
|
||||
|
||||
return "Granted", nil
|
||||
}
|
||||
|
||||
// Creator report overview
|
||||
//
|
||||
// @Router /v1/t/:tenantCode/creator/reports/overview [get]
|
||||
// @Summary Creator report overview
|
||||
// @Description 创作者经营看板概览
|
||||
// @Tags CreatorCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param start_at query string false "Start at (RFC3339)"
|
||||
// @Param end_at query string false "End at (RFC3339)"
|
||||
// @Param granularity query string false "Granularity"
|
||||
// @Success 200 {object} dto.ReportOverviewResponse
|
||||
// @Bind filter query
|
||||
func (c *Creator) ReportOverview(ctx fiber.Ctx, filter *dto.ReportOverviewFilter) (*dto.ReportOverviewResponse, error) {
|
||||
tenantID := getTenantID(ctx)
|
||||
userID := getUserID(ctx)
|
||||
|
||||
return services.Creator.ReportOverview(ctx, tenantID, userID, filter)
|
||||
}
|
||||
|
||||
// Creator export report
|
||||
//
|
||||
// @Router /v1/t/:tenantCode/creator/reports/export [post]
|
||||
// @Summary Creator export report
|
||||
// @Description 导出创作者经营报表
|
||||
// @Tags CreatorCenter
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param form body dto.ReportExportForm true "Export form"
|
||||
// @Success 200 {object} dto.ReportExportResponse
|
||||
// @Bind form body
|
||||
func (c *Creator) ExportReport(ctx fiber.Ctx, form *dto.ReportExportForm) (*dto.ReportExportResponse, error) {
|
||||
tenantID := getTenantID(ctx)
|
||||
userID := getUserID(ctx)
|
||||
|
||||
return services.Creator.ExportReport(ctx, tenantID, userID, form)
|
||||
}
|
||||
|
||||
@@ -150,6 +150,154 @@ func (r *Routes) Register(router fiber.Router) {
|
||||
r.content.AddLike,
|
||||
PathParam[int64]("id"),
|
||||
))
|
||||
// Register routes for controller: Creator
|
||||
r.log.Debugf("Registering route: Delete /v1/t/:tenantCode/creator/contents/:id<int> -> creator.DeleteContent")
|
||||
router.Delete("/v1/t/:tenantCode/creator/contents/:id<int>"[len(r.Path()):], Func1(
|
||||
r.creator.DeleteContent,
|
||||
PathParam[int64]("id"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Delete /v1/t/:tenantCode/creator/members/:id<int> -> creator.RemoveMember")
|
||||
router.Delete("/v1/t/:tenantCode/creator/members/:id<int>"[len(r.Path()):], Func1(
|
||||
r.creator.RemoveMember,
|
||||
PathParam[int64]("id"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Delete /v1/t/:tenantCode/creator/members/invites/:id<int> -> creator.DisableMemberInvite")
|
||||
router.Delete("/v1/t/:tenantCode/creator/members/invites/:id<int>"[len(r.Path()):], Func1(
|
||||
r.creator.DisableMemberInvite,
|
||||
PathParam[int64]("id"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Delete /v1/t/:tenantCode/creator/payout-accounts -> creator.RemovePayoutAccount")
|
||||
router.Delete("/v1/t/:tenantCode/creator/payout-accounts"[len(r.Path()):], Func1(
|
||||
r.creator.RemovePayoutAccount,
|
||||
QueryParam[int64]("id"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /v1/t/:tenantCode/creator/contents -> creator.ListContents")
|
||||
router.Get("/v1/t/:tenantCode/creator/contents"[len(r.Path()):], DataFunc1(
|
||||
r.creator.ListContents,
|
||||
Query[dto.CreatorContentListFilter]("filter"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /v1/t/:tenantCode/creator/contents/:id<int> -> creator.GetContent")
|
||||
router.Get("/v1/t/:tenantCode/creator/contents/:id<int>"[len(r.Path()):], DataFunc1(
|
||||
r.creator.GetContent,
|
||||
PathParam[int64]("id"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /v1/t/:tenantCode/creator/coupons -> creator.ListCoupons")
|
||||
router.Get("/v1/t/:tenantCode/creator/coupons"[len(r.Path()):], DataFunc1(
|
||||
r.creator.ListCoupons,
|
||||
Query[dto.CouponListFilter]("filter"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /v1/t/:tenantCode/creator/coupons/:id<int> -> creator.GetCoupon")
|
||||
router.Get("/v1/t/:tenantCode/creator/coupons/:id<int>"[len(r.Path()):], DataFunc1(
|
||||
r.creator.GetCoupon,
|
||||
PathParam[int64]("id"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /v1/t/:tenantCode/creator/dashboard -> creator.Dashboard")
|
||||
router.Get("/v1/t/:tenantCode/creator/dashboard"[len(r.Path()):], DataFunc0(
|
||||
r.creator.Dashboard,
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /v1/t/:tenantCode/creator/members -> creator.ListMembers")
|
||||
router.Get("/v1/t/:tenantCode/creator/members"[len(r.Path()):], DataFunc1(
|
||||
r.creator.ListMembers,
|
||||
Query[dto.TenantMemberListFilter]("filter"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /v1/t/:tenantCode/creator/members/invites -> creator.ListMemberInvites")
|
||||
router.Get("/v1/t/:tenantCode/creator/members/invites"[len(r.Path()):], DataFunc1(
|
||||
r.creator.ListMemberInvites,
|
||||
Query[dto.TenantInviteListFilter]("filter"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /v1/t/:tenantCode/creator/members/join-requests -> creator.ListMemberJoinRequests")
|
||||
router.Get("/v1/t/:tenantCode/creator/members/join-requests"[len(r.Path()):], DataFunc1(
|
||||
r.creator.ListMemberJoinRequests,
|
||||
Query[dto.TenantJoinRequestListFilter]("filter"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /v1/t/:tenantCode/creator/orders -> creator.ListOrders")
|
||||
router.Get("/v1/t/:tenantCode/creator/orders"[len(r.Path()):], DataFunc1(
|
||||
r.creator.ListOrders,
|
||||
Query[dto.CreatorOrderListFilter]("filter"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /v1/t/:tenantCode/creator/payout-accounts -> creator.ListPayoutAccounts")
|
||||
router.Get("/v1/t/:tenantCode/creator/payout-accounts"[len(r.Path()):], DataFunc0(
|
||||
r.creator.ListPayoutAccounts,
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /v1/t/:tenantCode/creator/reports/overview -> creator.ReportOverview")
|
||||
router.Get("/v1/t/:tenantCode/creator/reports/overview"[len(r.Path()):], DataFunc1(
|
||||
r.creator.ReportOverview,
|
||||
Query[dto.ReportOverviewFilter]("filter"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /v1/t/:tenantCode/creator/settings -> creator.GetSettings")
|
||||
router.Get("/v1/t/:tenantCode/creator/settings"[len(r.Path()):], DataFunc0(
|
||||
r.creator.GetSettings,
|
||||
))
|
||||
r.log.Debugf("Registering route: Post /v1/t/:tenantCode/creator/apply -> creator.Apply")
|
||||
router.Post("/v1/t/:tenantCode/creator/apply"[len(r.Path()):], Func1(
|
||||
r.creator.Apply,
|
||||
Body[dto.ApplyForm]("form"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Post /v1/t/:tenantCode/creator/contents -> creator.CreateContent")
|
||||
router.Post("/v1/t/:tenantCode/creator/contents"[len(r.Path()):], Func1(
|
||||
r.creator.CreateContent,
|
||||
Body[dto.ContentCreateForm]("form"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Post /v1/t/:tenantCode/creator/coupons -> creator.CreateCoupon")
|
||||
router.Post("/v1/t/:tenantCode/creator/coupons"[len(r.Path()):], DataFunc1(
|
||||
r.creator.CreateCoupon,
|
||||
Body[dto.CouponCreateForm]("form"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Post /v1/t/:tenantCode/creator/coupons/:id<int>/grant -> creator.GrantCoupon")
|
||||
router.Post("/v1/t/:tenantCode/creator/coupons/:id<int>/grant"[len(r.Path()):], DataFunc2(
|
||||
r.creator.GrantCoupon,
|
||||
PathParam[int64]("id"),
|
||||
Body[dto.CouponGrantForm]("form"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Post /v1/t/:tenantCode/creator/members/:id<int>/review -> creator.ReviewMemberJoinRequest")
|
||||
router.Post("/v1/t/:tenantCode/creator/members/:id<int>/review"[len(r.Path()):], Func2(
|
||||
r.creator.ReviewMemberJoinRequest,
|
||||
PathParam[int64]("id"),
|
||||
Body[dto.TenantJoinReviewForm]("form"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Post /v1/t/:tenantCode/creator/members/invite -> creator.CreateMemberInvite")
|
||||
router.Post("/v1/t/:tenantCode/creator/members/invite"[len(r.Path()):], DataFunc1(
|
||||
r.creator.CreateMemberInvite,
|
||||
Body[dto.TenantInviteCreateForm]("form"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Post /v1/t/:tenantCode/creator/orders/:id<int>/refund -> creator.RefundOrder")
|
||||
router.Post("/v1/t/:tenantCode/creator/orders/:id<int>/refund"[len(r.Path()):], Func2(
|
||||
r.creator.RefundOrder,
|
||||
PathParam[int64]("id"),
|
||||
Body[dto.RefundForm]("form"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Post /v1/t/:tenantCode/creator/payout-accounts -> creator.AddPayoutAccount")
|
||||
router.Post("/v1/t/:tenantCode/creator/payout-accounts"[len(r.Path()):], Func1(
|
||||
r.creator.AddPayoutAccount,
|
||||
Body[dto.PayoutAccount]("form"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Post /v1/t/:tenantCode/creator/reports/export -> creator.ExportReport")
|
||||
router.Post("/v1/t/:tenantCode/creator/reports/export"[len(r.Path()):], DataFunc1(
|
||||
r.creator.ExportReport,
|
||||
Body[dto.ReportExportForm]("form"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Post /v1/t/:tenantCode/creator/withdraw -> creator.Withdraw")
|
||||
router.Post("/v1/t/:tenantCode/creator/withdraw"[len(r.Path()):], Func1(
|
||||
r.creator.Withdraw,
|
||||
Body[dto.WithdrawForm]("form"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Put /v1/t/:tenantCode/creator/contents/:id<int> -> creator.UpdateContent")
|
||||
router.Put("/v1/t/:tenantCode/creator/contents/:id<int>"[len(r.Path()):], Func2(
|
||||
r.creator.UpdateContent,
|
||||
PathParam[int64]("id"),
|
||||
Body[dto.ContentUpdateForm]("form"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Put /v1/t/:tenantCode/creator/coupons/:id<int> -> creator.UpdateCoupon")
|
||||
router.Put("/v1/t/:tenantCode/creator/coupons/:id<int>"[len(r.Path()):], DataFunc2(
|
||||
r.creator.UpdateCoupon,
|
||||
PathParam[int64]("id"),
|
||||
Body[dto.CouponUpdateForm]("form"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Put /v1/t/:tenantCode/creator/settings -> creator.UpdateSettings")
|
||||
router.Put("/v1/t/:tenantCode/creator/settings"[len(r.Path()):], Func1(
|
||||
r.creator.UpdateSettings,
|
||||
Body[dto.Settings]("form"),
|
||||
))
|
||||
// Register routes for controller: Storage
|
||||
r.log.Debugf("Registering route: Get /v1/t/:tenantCode/storage/* -> storage.Download")
|
||||
router.Get("/v1/t/:tenantCode/storage/*"[len(r.Path()):], Func2(
|
||||
@@ -163,6 +311,44 @@ func (r *Routes) Register(router fiber.Router) {
|
||||
QueryParam[string]("expires"),
|
||||
QueryParam[string]("sign"),
|
||||
))
|
||||
// Register routes for controller: Tenant
|
||||
r.log.Debugf("Registering route: Delete /v1/t/:tenantCode/tenants/:id<int>/follow -> tenant.Unfollow")
|
||||
router.Delete("/v1/t/:tenantCode/tenants/:id<int>/follow"[len(r.Path()):], Func1(
|
||||
r.tenant.Unfollow,
|
||||
PathParam[int64]("id"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Delete /v1/t/:tenantCode/tenants/:id<int>/join -> tenant.CancelJoin")
|
||||
router.Delete("/v1/t/:tenantCode/tenants/:id<int>/join"[len(r.Path()):], Func1(
|
||||
r.tenant.CancelJoin,
|
||||
PathParam[int64]("id"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /v1/t/:tenantCode/tenants -> tenant.List")
|
||||
router.Get("/v1/t/:tenantCode/tenants"[len(r.Path()):], DataFunc1(
|
||||
r.tenant.List,
|
||||
Query[dto.TenantListFilter]("filter"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /v1/t/:tenantCode/tenants/:id<int> -> tenant.Get")
|
||||
router.Get("/v1/t/:tenantCode/tenants/:id<int>"[len(r.Path()):], DataFunc1(
|
||||
r.tenant.Get,
|
||||
PathParam[int64]("id"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Post /v1/t/:tenantCode/tenants/:id<int>/follow -> tenant.Follow")
|
||||
router.Post("/v1/t/:tenantCode/tenants/:id<int>/follow"[len(r.Path()):], Func1(
|
||||
r.tenant.Follow,
|
||||
PathParam[int64]("id"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Post /v1/t/:tenantCode/tenants/:id<int>/invites/accept -> tenant.AcceptInvite")
|
||||
router.Post("/v1/t/:tenantCode/tenants/:id<int>/invites/accept"[len(r.Path()):], Func2(
|
||||
r.tenant.AcceptInvite,
|
||||
PathParam[int64]("id"),
|
||||
Body[dto.TenantInviteAcceptForm]("form"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Post /v1/t/:tenantCode/tenants/:id<int>/join -> tenant.ApplyJoin")
|
||||
router.Post("/v1/t/:tenantCode/tenants/:id<int>/join"[len(r.Path()):], Func2(
|
||||
r.tenant.ApplyJoin,
|
||||
PathParam[int64]("id"),
|
||||
Body[dto.TenantJoinApplyForm]("form"),
|
||||
))
|
||||
// Register routes for controller: Transaction
|
||||
r.log.Debugf("Registering route: Get /v1/t/:tenantCode/orders/:id<int>/status -> transaction.Status")
|
||||
router.Get("/v1/t/:tenantCode/orders/:id<int>/status"[len(r.Path()):], DataFunc1(
|
||||
|
||||
Reference in New Issue
Block a user