优化结构

This commit is contained in:
Yvan
2026-08-22 15:53:14 +08:00
parent ca52de5db0
commit 491ed21d48
72 changed files with 746 additions and 695 deletions
+8 -8
View File
@@ -3,16 +3,16 @@ package service
import (
"context"
"encoding/json"
"kra/internal/biz/system"
integrationbiz "kra/internal/biz/integration"
"kra/internal/service/dto"
)
type IntegrationConfigService struct {
uc *system.IntegrationConfigUsecase
uc *integrationbiz.IntegrationConfigUsecase
}
func NewIntegrationConfigService(uc *system.IntegrationConfigUsecase) *IntegrationConfigService {
func NewIntegrationConfigService(uc *integrationbiz.IntegrationConfigUsecase) *IntegrationConfigService {
return &IntegrationConfigService{uc: uc}
}
@@ -21,13 +21,13 @@ func (s *IntegrationConfigService) List(ctx context.Context, kind string) ([]*dt
if err != nil {
return nil, err
}
byProvider := make(map[string]*system.IntegrationConfig, len(configs))
byProvider := make(map[string]*integrationbiz.IntegrationConfig, len(configs))
for _, config := range configs {
if config != nil {
byProvider[config.Provider] = config
}
}
definitions := system.IntegrationDefinitions(kind)
definitions := integrationbiz.IntegrationDefinitions(kind)
result := make([]*dto.IntegrationConfigResponse, 0, len(definitions)+len(configs))
for _, definition := range definitions {
config, configured := byProvider[definition.Provider]
@@ -54,7 +54,7 @@ func (s *IntegrationConfigService) Find(ctx context.Context, kind, provider stri
if err != nil {
return nil, err
}
definition, found := system.IntegrationDefinition(config.Kind, config.Provider)
definition, found := integrationbiz.IntegrationDefinition(config.Kind, config.Provider)
response := &dto.IntegrationConfigResponse{Kind: config.Kind, Provider: config.Provider, Name: config.Provider, Enabled: config.Enabled, Configured: true, Config: config.Values}
if found {
response.Name = definition.Name
@@ -69,14 +69,14 @@ func (s *IntegrationConfigService) Save(ctx context.Context, kind, provider stri
if req == nil {
return s.uc.Save(ctx, nil)
}
return s.uc.Save(ctx, &system.IntegrationConfig{Kind: kind, Provider: provider, Enabled: req.Enabled, Values: req.Config})
return s.uc.Save(ctx, &integrationbiz.IntegrationConfig{Kind: kind, Provider: provider, Enabled: req.Enabled, Values: req.Config})
}
func (s *IntegrationConfigService) Test(ctx context.Context, kind, provider string, req *dto.IntegrationConfigRequest) error {
if req == nil {
return s.uc.Test(ctx, nil)
}
return s.uc.Test(ctx, &system.IntegrationConfig{Kind: kind, Provider: provider, Enabled: true, Values: req.Config})
return s.uc.Test(ctx, &integrationbiz.IntegrationConfig{Kind: kind, Provider: provider, Enabled: true, Values: req.Config})
}
func (s *IntegrationConfigService) Delete(ctx context.Context, kind, provider string) error {