78 lines
2.3 KiB
Go
78 lines
2.3 KiB
Go
package controller
|
|
|
|
import (
|
|
"context"
|
|
"order/model/dto"
|
|
"order/service"
|
|
)
|
|
|
|
type paymentConfig struct{}
|
|
|
|
// PaymentConfig 支付配置控制器
|
|
var PaymentConfig = new(paymentConfig)
|
|
|
|
// Create 创建支付配置
|
|
func (c *paymentConfig) Create(ctx context.Context, req *dto.CreatePaymentConfigReq) (res *dto.PaymentConfigResp, err error) {
|
|
// 创建支付配置
|
|
res, err = service.PaymentConfig.CreatePaymentConfig(ctx, req)
|
|
return
|
|
}
|
|
|
|
// Update 更新支付配置
|
|
func (c *paymentConfig) Update(ctx context.Context, req *dto.UpdatePaymentConfigReq) (res *dto.PaymentConfigResp, err error) {
|
|
// 更新支付配置
|
|
res, err = service.PaymentConfig.UpdatePaymentConfig(ctx, req)
|
|
return
|
|
}
|
|
|
|
// Query 查询支付配置
|
|
func (c *paymentConfig) Query(ctx context.Context, req *dto.QueryPaymentConfigReq) (res *dto.PaymentConfigResp, err error) {
|
|
// 查询支付配置
|
|
res, err = service.PaymentConfig.GetPaymentConfig(ctx, req)
|
|
return
|
|
}
|
|
|
|
// List 查询支付配置列表
|
|
func (c *paymentConfig) List(ctx context.Context, req *dto.ListPaymentConfigReq) (res *dto.PaymentConfigListResp, err error) {
|
|
// 查询支付配置列表
|
|
list, err := service.PaymentConfig.GetPaymentConfigList(ctx, req.TenantID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &dto.PaymentConfigListResp{
|
|
List: list,
|
|
Total: int64(len(list)),
|
|
}, nil
|
|
}
|
|
|
|
// 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
|
|
}
|
|
|
|
// 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
|
|
}
|
|
|
|
// 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
|
|
}
|