优化
This commit is contained in:
@@ -124,6 +124,21 @@ func (s *DictionaryService) DictionaryDetail(ctx context.Context, id uint) (*dto
|
||||
}
|
||||
return detailDTO(v), nil
|
||||
}
|
||||
func (s *DictionaryService) DictionaryPath(ctx context.Context, id uint) ([]*dto.DictionaryDetailResponse, error) {
|
||||
path := make([]*dto.DictionaryDetailResponse, 0)
|
||||
for id != 0 {
|
||||
value, err := s.uc.FindDictionaryDetail(ctx, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
path = append([]*dto.DictionaryDetailResponse{detailDTO(value)}, path...)
|
||||
if value.ParentID == nil {
|
||||
break
|
||||
}
|
||||
id = *value.ParentID
|
||||
}
|
||||
return path, nil
|
||||
}
|
||||
func (s *DictionaryService) DictionaryTree(ctx context.Context, id uint, typ string) ([]*dto.DictionaryDetailResponse, error) {
|
||||
items, err := s.uc.DictionaryDetailTree(ctx, id, typ)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user