dapper.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package service
  2. import (
  3. "context"
  4. "go-common/app/admin/ep/melloi/model"
  5. "go-common/library/log"
  6. )
  7. // QueryDependServiceAdmins query depend Service admin
  8. func (s *Service) QueryDependServiceAdmins(c context.Context, serviceName string, sessionValue string) (map[string][]string, error) {
  9. var (
  10. biliPrex = "bilibili."
  11. err error
  12. roles []*model.TreeRole
  13. dependService []string
  14. olesMap = make(map[string][]string)
  15. )
  16. if dependService, err = s.dao.QueryServiceDepend(c, serviceName); err != nil {
  17. log.Error("query service depend error(%v)", err)
  18. return nil, err
  19. }
  20. dependService = append(dependService, serviceName)
  21. for _, service := range dependService {
  22. var userService []string
  23. if roles, err = s.QueryTreeAdmin(c, biliPrex+service, sessionValue); err != nil {
  24. log.Warn("query tree admin of service (%s) depend error (%v)", biliPrex+service, err)
  25. continue
  26. }
  27. for _, role := range roles {
  28. // 增加多个service
  29. userService = append(olesMap[role.UserName], biliPrex+service)
  30. olesMap[role.UserName] = userService
  31. }
  32. }
  33. return olesMap, err
  34. }