refactor: separate backend domains and storage adapters

This commit is contained in:
2026-08-14 01:37:56 +08:00
parent e6775f0966
commit 8c4c6ba661
102 changed files with 6644 additions and 5735 deletions
+32
View File
@@ -6,6 +6,7 @@ import (
"time"
"kra/internal/biz"
"kra/internal/service/dto"
)
type VersionService struct{ uc *biz.VersionUsecase }
@@ -73,3 +74,34 @@ func (s *VersionService) Export(ctx context.Context, name, code, description str
func (s *VersionService) Import(ctx context.Context, bundle *biz.VersionBundle) error {
return s.uc.Repo().ImportVersionBundle(ctx, bundle)
}
func versionMenuDomain(value dto.VersionMenuRequest) *biz.Menu {
menu := &biz.Menu{Path: value.Path, Name: value.Name, Hidden: value.Hidden, Component: value.Component, Sort: value.Sort, ActiveName: value.Meta.ActiveName, KeepAlive: value.Meta.KeepAlive, DefaultMenu: value.Meta.DefaultMenu, Title: value.Meta.Title, Icon: value.Meta.Icon, CloseTab: value.Meta.CloseTab, TransitionType: value.Meta.TransitionType}
for _, button := range value.MenuButtons {
menu.Buttons = append(menu.Buttons, &biz.MenuButton{Name: button.Name, Description: button.Description})
}
for _, child := range value.Children {
menu.Children = append(menu.Children, versionMenuDomain(child))
}
return menu
}
func (s *VersionService) ImportRequest(ctx context.Context, req *dto.ImportVersionRequest) error {
bundle := &biz.VersionBundle{Name: req.Version.Name, Code: req.Version.Code, Description: req.Version.Description, ExportTime: req.Version.ExportTime}
for _, menu := range req.Menus {
bundle.Menus = append(bundle.Menus, versionMenuDomain(menu))
}
for _, api := range req.APIs {
bundle.APIs = append(bundle.APIs, &biz.API{Path: api.Path, Description: api.Description, APIGroup: api.APIGroup, Method: api.Method})
}
for _, dictionary := range req.Dictionaries {
item := &biz.Dictionary{Name: dictionary.Name, Type: dictionary.Type, Status: dictionary.Status, Desc: dictionary.Description}
for _, detail := range dictionary.Details {
status := true
if detail.Status != nil {
status = *detail.Status
}
item.Details = append(item.Details, &biz.DictionaryDetail{Label: detail.Label, Value: detail.Value, Extend: detail.Extend, Status: status, Sort: detail.Sort, ParentID: detail.ParentID, Level: detail.Level, Path: detail.Path})
}
bundle.Dictionaries = append(bundle.Dictionaries, item)
}
return s.Import(ctx, bundle)
}