优化结构
This commit is contained in:
@@ -26,12 +26,12 @@ func NewPaymentRepo(data Provider) bizpayment.PaymentRepo { return &paymentRepo{
|
||||
|
||||
func ensurePaymentIntegrationConfigs(db *gorm.DB) error {
|
||||
for _, provider := range bizpayment.SupportedPaymentProviders {
|
||||
var row integrationConfigPO
|
||||
var row dataintegration.ConfigPO
|
||||
err := db.Where("kind = ? AND provider = ?", integrationKindPayment, provider).First(&row).Error
|
||||
defaults := integrationbiz.DefaultIntegrationConfig(integrationKindPayment, provider)
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
encoded, _ := json.Marshal(defaults)
|
||||
if err := db.Create(&integrationConfigPO{Kind: integrationKindPayment, Provider: provider, Enabled: false, Config: string(encoded)}).Error; err != nil {
|
||||
if err := db.Create(&dataintegration.ConfigPO{Kind: integrationKindPayment, Provider: provider, Enabled: false, Config: string(encoded)}).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
continue
|
||||
@@ -58,8 +58,8 @@ func ensurePaymentIntegrationConfigs(db *gorm.DB) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *paymentRepo) row(ctx context.Context, provider string) (*integrationConfigPO, map[string]any, error) {
|
||||
var row integrationConfigPO
|
||||
func (r *paymentRepo) row(ctx context.Context, provider string) (*dataintegration.ConfigPO, map[string]any, error) {
|
||||
var row dataintegration.ConfigPO
|
||||
if err := r.data.DB().WithContext(ctx).Where("kind = ? AND provider = ?", integrationKindPayment, provider).First(&row).Error; err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return nil, nil, bizpayment.ErrPaymentProviderNotFound
|
||||
@@ -298,7 +298,7 @@ func recordPaymentTestError(ctx context.Context, data Provider, provider, tradeN
|
||||
}
|
||||
|
||||
func (r *paymentRepo) testRow(ctx context.Context, provider string) (map[string]any, error) {
|
||||
var row integrationConfigPO
|
||||
var row dataintegration.ConfigPO
|
||||
if err := r.data.DB().WithContext(ctx).Where("kind = ? AND provider = ?", integrationKindPayment, provider).First(&row).Error; err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return nil, bizpayment.ErrPaymentProviderNotFound
|
||||
|
||||
Reference in New Issue
Block a user