优化结构

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
+15 -15
View File
@@ -2,19 +2,19 @@ package service
import (
"context"
"kra/internal/biz/system"
"kra/internal/biz"
"kra/internal/service/dto"
)
type DictionaryService struct{ uc *biz.DictionaryUsecase }
type DictionaryService struct{ uc *system.DictionaryUsecase }
func NewDictionaryService(uc *biz.DictionaryUsecase) *DictionaryService {
func NewDictionaryService(uc *system.DictionaryUsecase) *DictionaryService {
return &DictionaryService{uc: uc}
}
func dictionaryDomain(value *dto.DictionaryRequest) *biz.Dictionary {
return &biz.Dictionary{ID: value.ID, Name: value.Name, Type: value.Type, Status: value.Status, Desc: value.Description, ParentID: value.ParentID}
func dictionaryDomain(value *dto.DictionaryRequest) *system.Dictionary {
return &system.Dictionary{ID: value.ID, Name: value.Name, Type: value.Type, Status: value.Status, Desc: value.Description, ParentID: value.ParentID}
}
func (s *DictionaryService) CreateDictionaryRequest(ctx context.Context, req *dto.DictionaryRequest) (*dto.DictionaryResponse, error) {
value := dictionaryDomain(req)
@@ -26,7 +26,7 @@ func (s *DictionaryService) CreateDictionaryRequest(ctx context.Context, req *dt
func (s *DictionaryService) UpdateDictionaryRequest(ctx context.Context, req *dto.DictionaryRequest) error {
return s.UpdateDictionary(ctx, dictionaryDomain(req))
}
func dictionaryDTO(v *biz.Dictionary) *dto.DictionaryResponse {
func dictionaryDTO(v *system.Dictionary) *dto.DictionaryResponse {
var children []*dto.DictionaryResponse
if v.Children != nil {
children = make([]*dto.DictionaryResponse, 0, len(v.Children))
@@ -78,18 +78,18 @@ func (s *DictionaryService) ExportDictionary(ctx context.Context, id uint) (*dto
SysDictionaryDetails: details,
}, nil
}
func (s *DictionaryService) CreateDictionary(ctx context.Context, v *biz.Dictionary) error {
func (s *DictionaryService) CreateDictionary(ctx context.Context, v *system.Dictionary) error {
return s.uc.CreateDictionary(ctx, v)
}
func (s *DictionaryService) UpdateDictionary(ctx context.Context, v *biz.Dictionary) error {
func (s *DictionaryService) UpdateDictionary(ctx context.Context, v *system.Dictionary) error {
return s.uc.UpdateDictionary(ctx, v)
}
func (s *DictionaryService) DeleteDictionary(ctx context.Context, id uint) error {
return s.uc.DeleteDictionary(ctx, id)
}
func detailDomain(value *dto.DictionaryDetailRequest) *biz.DictionaryDetail {
return &biz.DictionaryDetail{ID: value.ID, Label: value.Label, Value: value.Value, Extend: value.Extend, Status: value.Status, Sort: value.Sort, DictionaryID: value.DictionaryID, ParentID: value.ParentID, Level: value.Level, Path: value.Path}
func detailDomain(value *dto.DictionaryDetailRequest) *system.DictionaryDetail {
return &system.DictionaryDetail{ID: value.ID, Label: value.Label, Value: value.Value, Extend: value.Extend, Status: value.Status, Sort: value.Sort, DictionaryID: value.DictionaryID, ParentID: value.ParentID, Level: value.Level, Path: value.Path}
}
func (s *DictionaryService) CreateDictionaryDetailRequest(ctx context.Context, req *dto.DictionaryDetailRequest) error {
return s.CreateDictionaryDetail(ctx, detailDomain(req))
@@ -97,7 +97,7 @@ func (s *DictionaryService) CreateDictionaryDetailRequest(ctx context.Context, r
func (s *DictionaryService) UpdateDictionaryDetailRequest(ctx context.Context, req *dto.DictionaryDetailRequest) error {
return s.UpdateDictionaryDetail(ctx, detailDomain(req))
}
func detailDTO(v *biz.DictionaryDetail) *dto.DictionaryDetailResponse {
func detailDTO(v *system.DictionaryDetail) *dto.DictionaryDetailResponse {
var children []*dto.DictionaryDetailResponse
if v.Children != nil {
children = make([]*dto.DictionaryDetailResponse, 0, len(v.Children))
@@ -108,7 +108,7 @@ func detailDTO(v *biz.DictionaryDetail) *dto.DictionaryDetailResponse {
disabled := v.Status != nil && !*v.Status
return &dto.DictionaryDetailResponse{ID: v.ID, CreatedAt: v.CreatedAt, UpdatedAt: v.UpdatedAt, DeletedAt: nil, Label: v.Label, Value: v.Value, Extend: v.Extend, Status: v.Status, Sort: v.Sort, DictionaryID: v.DictionaryID, ParentID: v.ParentID, Level: v.Level, Path: v.Path, Disabled: disabled, Children: children}
}
func (s *DictionaryService) DictionaryDetails(ctx context.Context, page, size int, filter biz.DictionaryDetailFilter) ([]*dto.DictionaryDetailResponse, int64, error) {
func (s *DictionaryService) DictionaryDetails(ctx context.Context, page, size int, filter system.DictionaryDetailFilter) ([]*dto.DictionaryDetailResponse, int64, error) {
items, total, err := s.uc.ListDictionaryDetails(ctx, page, size, filter)
if err != nil {
return nil, 0, err
@@ -120,7 +120,7 @@ func (s *DictionaryService) DictionaryDetails(ctx context.Context, page, size in
return out, total, nil
}
func (s *DictionaryService) DictionaryDetailsRequest(ctx context.Context, page, size int, request dto.DictionaryDetailListRequest) ([]*dto.DictionaryDetailResponse, int64, error) {
return s.DictionaryDetails(ctx, page, size, biz.DictionaryDetailFilter{
return s.DictionaryDetails(ctx, page, size, system.DictionaryDetailFilter{
DictionaryID: request.DictionaryID,
Label: request.Label,
Value: request.Value,
@@ -162,10 +162,10 @@ func (s *DictionaryService) DictionaryTree(ctx context.Context, id uint, typ str
}
return out, nil
}
func (s *DictionaryService) CreateDictionaryDetail(ctx context.Context, v *biz.DictionaryDetail) error {
func (s *DictionaryService) CreateDictionaryDetail(ctx context.Context, v *system.DictionaryDetail) error {
return s.uc.CreateDictionaryDetail(ctx, v)
}
func (s *DictionaryService) UpdateDictionaryDetail(ctx context.Context, v *biz.DictionaryDetail) error {
func (s *DictionaryService) UpdateDictionaryDetail(ctx context.Context, v *system.DictionaryDetail) error {
return s.uc.UpdateDictionaryDetail(ctx, v)
}
func (s *DictionaryService) DeleteDictionaryDetail(ctx context.Context, id uint) error {