You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
500 B

1 year ago
  1. package tag
  2. import (
  3. "context"
  4. "git.aiterp.net/rpdata2-take2/rpdata2"
  5. "git.aiterp.net/rpdata2-take2/rpdata2/auth"
  6. )
  7. type Service struct {
  8. Repository Repository
  9. Auth auth.Service
  10. }
  11. func (s *Service) Find(ctx context.Context, id string) (*Node, error) {
  12. tags, err := s.Repository.FindRecursive(ctx, id)
  13. if err != nil {
  14. return nil, err
  15. }
  16. root := BuildForest(tags)[0].WithoutSecret(s.Auth.GetUser(ctx))
  17. if root == nil {
  18. return nil, rpdata2.NotFound("Tag")
  19. }
  20. return root, nil
  21. }