Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
630 lines
18 KiB
Go
630 lines
18 KiB
Go
package v1
|
|
|
|
import (
|
|
"quyun/v2/app/errorx"
|
|
"quyun/v2/app/http/v1/dto"
|
|
"quyun/v2/app/requests"
|
|
"quyun/v2/app/services"
|
|
|
|
"github.com/gofiber/fiber/v3"
|
|
)
|
|
|
|
// @provider
|
|
type Creator struct{}
|
|
|
|
// Apply creator profile
|
|
//
|
|
// @Router /v1/t/:tenantCode/creator/apply [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("参数无效")
|
|
}
|
|
|
|
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 id path
|
|
// @Bind form body
|
|
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)
|
|
}
|
|
|
|
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)
|
|
}
|