优化结构

This commit is contained in:
Yvan
2026-08-22 12:13:16 +08:00
parent d987244d0e
commit b27a66e9d3
200 changed files with 1794 additions and 1715 deletions
+10 -8
View File
@@ -3,14 +3,16 @@ package service
import (
"context"
"encoding/json"
"kra/internal/biz/system"
"kra/internal/biz"
"kra/internal/service/dto"
)
type IntegrationConfigService struct{ uc *biz.IntegrationConfigUsecase }
type IntegrationConfigService struct {
uc *system.IntegrationConfigUsecase
}
func NewIntegrationConfigService(uc *biz.IntegrationConfigUsecase) *IntegrationConfigService {
func NewIntegrationConfigService(uc *system.IntegrationConfigUsecase) *IntegrationConfigService {
return &IntegrationConfigService{uc: uc}
}
@@ -19,13 +21,13 @@ func (s *IntegrationConfigService) List(ctx context.Context, kind string) ([]*dt
if err != nil {
return nil, err
}
byProvider := make(map[string]*biz.IntegrationConfig, len(configs))
byProvider := make(map[string]*system.IntegrationConfig, len(configs))
for _, config := range configs {
if config != nil {
byProvider[config.Provider] = config
}
}
definitions := biz.IntegrationDefinitions(kind)
definitions := system.IntegrationDefinitions(kind)
result := make([]*dto.IntegrationConfigResponse, 0, len(definitions)+len(configs))
for _, definition := range definitions {
config, configured := byProvider[definition.Provider]
@@ -52,7 +54,7 @@ func (s *IntegrationConfigService) Find(ctx context.Context, kind, provider stri
if err != nil {
return nil, err
}
definition, found := biz.IntegrationDefinition(config.Kind, config.Provider)
definition, found := system.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
@@ -67,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, &biz.IntegrationConfig{Kind: kind, Provider: provider, Enabled: req.Enabled, Values: req.Config})
return s.uc.Save(ctx, &system.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, &biz.IntegrationConfig{Kind: kind, Provider: provider, Enabled: true, Values: req.Config})
return s.uc.Test(ctx, &system.IntegrationConfig{Kind: kind, Provider: provider, Enabled: true, Values: req.Config})
}
func (s *IntegrationConfigService) Delete(ctx context.Context, kind, provider string) error {