Files
order/controller/payment_config.go

78 lines
2.3 KiB
Go
Raw Normal View History

2025-12-10 09:02:41 +08:00
package controller
import (
"context"
"order/model/dto"
"order/service"
)
2025-12-12 18:16:28 +08:00
type paymentConfig struct{}
2025-12-10 09:02:41 +08:00
2025-12-12 18:16:28 +08:00
// PaymentConfig 支付配置控制器
var PaymentConfig = new(paymentConfig)
2025-12-10 09:02:41 +08:00
2025-12-12 18:16:28 +08:00
// Create 创建支付配置
func (c *paymentConfig) Create(ctx context.Context, req *dto.CreatePaymentConfigReq) (res *dto.PaymentConfigResp, err error) {
// 创建支付配置
res, err = service.PaymentConfig.CreatePaymentConfig(ctx, req)
return
2025-12-10 09:02:41 +08:00
}
2025-12-12 18:16:28 +08:00
// Update 更新支付配置
func (c *paymentConfig) Update(ctx context.Context, req *dto.UpdatePaymentConfigReq) (res *dto.PaymentConfigResp, err error) {
// 更新支付配置
res, err = service.PaymentConfig.UpdatePaymentConfig(ctx, req)
return
2025-12-10 13:51:09 +08:00
}
2025-12-10 09:02:41 +08:00
2025-12-12 18:16:28 +08:00
// Query 查询支付配置
func (c *paymentConfig) Query(ctx context.Context, req *dto.QueryPaymentConfigReq) (res *dto.PaymentConfigResp, err error) {
// 查询支付配置
res, err = service.PaymentConfig.GetPaymentConfig(ctx, req)
return
2025-12-10 09:02:41 +08:00
}
2025-12-12 18:16:28 +08:00
// List 查询支付配置列表
func (c *paymentConfig) List(ctx context.Context, req *dto.ListPaymentConfigReq) (res *dto.PaymentConfigListResp, err error) {
// 查询支付配置列表
list, err := service.PaymentConfig.GetPaymentConfigList(ctx, req.TenantID)
2025-12-10 09:02:41 +08:00
if err != nil {
2025-12-12 18:16:28 +08:00
return nil, err
2025-12-10 09:02:41 +08:00
}
2025-12-12 18:16:28 +08:00
return &dto.PaymentConfigListResp{
List: list,
Total: int64(len(list)),
}, nil
2025-12-10 09:02:41 +08:00
}
2025-12-12 18:16:28 +08:00
// Delete 删除支付配置
func (c *paymentConfig) Delete(ctx context.Context, req *dto.DeletePaymentConfigReq) (res *dto.CommonResp, err error) {
// 删除支付配置
err = service.PaymentConfig.DeletePaymentConfig(ctx, req.TenantID, req.ConfigID)
return &dto.CommonResp{
Success: err == nil,
Message: "删除成功",
}, err
2025-12-10 13:51:09 +08:00
}
2025-12-12 18:16:28 +08:00
// Enable 启用支付配置
func (c *paymentConfig) Enable(ctx context.Context, req *dto.EnablePaymentConfigReq) (res *dto.CommonResp, err error) {
// 启用支付配置
err = service.PaymentConfig.EnablePaymentConfig(ctx, req.TenantID, req.ConfigID)
return &dto.CommonResp{
Success: err == nil,
Message: "启用成功",
}, err
2025-12-10 13:51:09 +08:00
}
2025-12-12 18:16:28 +08:00
// Disable 禁用支付配置
func (c *paymentConfig) Disable(ctx context.Context, req *dto.DisablePaymentConfigReq) (res *dto.CommonResp, err error) {
// 禁用支付配置
err = service.PaymentConfig.DisablePaymentConfig(ctx, req.TenantID, req.ConfigID)
return &dto.CommonResp{
Success: err == nil,
Message: "禁用成功",
}, err
2025-12-10 09:02:41 +08:00
}