feat: wire superadmin p1 data
This commit is contained in:
63
backend/app/http/super/v1/withdrawals.go
Normal file
63
backend/app/http/super/v1/withdrawals.go
Normal file
@@ -0,0 +1,63 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
dto "quyun/v2/app/http/super/v1/dto"
|
||||
"quyun/v2/app/requests"
|
||||
"quyun/v2/app/services"
|
||||
"quyun/v2/database/models"
|
||||
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
|
||||
// @provider
|
||||
type withdrawals struct{}
|
||||
|
||||
// List withdrawals
|
||||
//
|
||||
// @Router /super/v1/withdrawals [get]
|
||||
// @Summary List withdrawals
|
||||
// @Description List withdrawal orders across tenants
|
||||
// @Tags Finance
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param page query int false "Page number"
|
||||
// @Param limit query int false "Page size"
|
||||
// @Success 200 {object} requests.Pager{items=[]dto.SuperOrderItem}
|
||||
// @Bind filter query
|
||||
func (c *withdrawals) List(ctx fiber.Ctx, filter *dto.SuperOrderListFilter) (*requests.Pager, error) {
|
||||
return services.Super.ListWithdrawals(ctx, filter)
|
||||
}
|
||||
|
||||
// Approve withdrawal
|
||||
//
|
||||
// @Router /super/v1/withdrawals/:id<int>/approve [post]
|
||||
// @Summary Approve withdrawal
|
||||
// @Description Approve a withdrawal request
|
||||
// @Tags Finance
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int64 true "Withdrawal order ID"
|
||||
// @Success 200 {string} string "Approved"
|
||||
// @Bind user local key(__ctx_user)
|
||||
// @Bind id path
|
||||
func (c *withdrawals) Approve(ctx fiber.Ctx, user *models.User, id int64) error {
|
||||
return services.Super.ApproveWithdrawal(ctx, user.ID, id)
|
||||
}
|
||||
|
||||
// Reject withdrawal
|
||||
//
|
||||
// @Router /super/v1/withdrawals/:id<int>/reject [post]
|
||||
// @Summary Reject withdrawal
|
||||
// @Description Reject a withdrawal request
|
||||
// @Tags Finance
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int64 true "Withdrawal order ID"
|
||||
// @Param form body dto.SuperWithdrawalRejectForm true "Reject form"
|
||||
// @Success 200 {string} string "Rejected"
|
||||
// @Bind user local key(__ctx_user)
|
||||
// @Bind id path
|
||||
// @Bind form body
|
||||
func (c *withdrawals) Reject(ctx fiber.Ctx, user *models.User, id int64, form *dto.SuperWithdrawalRejectForm) error {
|
||||
return services.Super.RejectWithdrawal(ctx, user.ID, id, form.Reason)
|
||||
}
|
||||
Reference in New Issue
Block a user