优化结构

This commit is contained in:
Yvan
2026-08-28 09:19:54 +08:00
parent 03a4131f6e
commit 279692375b
57 changed files with 778 additions and 799 deletions
+3 -11
View File
@@ -27,14 +27,6 @@ func authorityDomain(req *dto.AuthorityRequest) *system.Authority {
return &system.Authority{AuthorityID: req.AuthorityID, AuthorityName: req.AuthorityName, ParentID: req.ParentID, DataScope: req.DataScope, DefaultRouter: req.DefaultRouter}
}
func authorityResponse(value *system.Authority) *dto.AuthorityResponse {
var menus []*dto.MenuResponse
if value.Menus != nil {
menus = menuResponses(value.Menus)
}
return &dto.AuthorityResponse{CreatedAt: value.CreatedAt, UpdatedAt: value.UpdatedAt, DeletedAt: value.DeletedAt, AuthorityID: value.AuthorityID, AuthorityName: value.AuthorityName, ParentID: value.ParentID, Children: nil, Menus: menus, DataScope: value.DataScope, DefaultRouter: value.DefaultRouter}
}
func (s *AuthorityService) Authorities(ctx context.Context) ([]*dto.AuthorityResponse, error) {
items, err := s.uc.AuthorityTree(ctx)
if err != nil {
@@ -52,7 +44,7 @@ func (s *AuthorityService) CreateAuthorityRequest(ctx context.Context, req *dto.
if err := s.uc.CreateAuthority(ctx, value); err != nil {
return nil, err
}
return authorityResponse(value), nil
return convertAuthority(*value), nil
}
func (s *AuthorityService) CopyAuthorityRequest(ctx context.Context, req *dto.CopyAuthorityRequest) (*dto.AuthorityResponse, error) {
@@ -60,7 +52,7 @@ func (s *AuthorityService) CopyAuthorityRequest(ctx context.Context, req *dto.Co
if err := s.uc.CopyAuthority(ctx, req.OldAuthorityID, value); err != nil {
return nil, err
}
result := authorityResponse(value)
result := convertAuthority(*value)
result.Children = []*dto.AuthorityResponse{}
return result, nil
}
@@ -70,7 +62,7 @@ func (s *AuthorityService) UpdateAuthorityRequest(ctx context.Context, req *dto.
if err := s.uc.UpdateAuthority(ctx, value); err != nil {
return nil, err
}
return authorityResponse(value), nil
return convertAuthority(*value), nil
}
func (s *AuthorityService) DeleteAuthority(ctx context.Context, id uint) error {