refactor: 移除不必要的上下文调用,简化服务方法参数
This commit is contained in:
@@ -22,7 +22,7 @@ type Transaction struct{}
|
||||
// @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)
|
||||
return services.Order.Create(ctx, form)
|
||||
}
|
||||
|
||||
// Pay for order
|
||||
@@ -39,7 +39,7 @@ func (t *Transaction) Create(ctx fiber.Ctx, form *dto.OrderCreateForm) (*dto.Ord
|
||||
// @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)
|
||||
return services.Order.Pay(ctx, id, form)
|
||||
}
|
||||
|
||||
// Check order payment status
|
||||
@@ -54,7 +54,7 @@ func (t *Transaction) Pay(ctx fiber.Ctx, id string, form *dto.OrderPayForm) (*dt
|
||||
// @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)
|
||||
return services.Order.Status(ctx, id)
|
||||
}
|
||||
|
||||
type WebhookForm struct {
|
||||
@@ -74,7 +74,7 @@ type WebhookForm struct {
|
||||
// @Success 200 {string} string "success"
|
||||
// @Bind form body
|
||||
func (t *Transaction) Webhook(ctx fiber.Ctx, form *WebhookForm) (string, error) {
|
||||
err := services.Order.ProcessExternalPayment(ctx.Context(), form.OrderID, form.ExternalID)
|
||||
err := services.Order.ProcessExternalPayment(ctx, form.OrderID, form.ExternalID)
|
||||
if err != nil {
|
||||
return "fail", err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user