You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: impl.go
    path of file: ./repos/erda/internal/tools/orchestrator/hepa/services/domain/impl
    
    the code of the file until where you have to start completion: // Copyright (c) 2021 Terminus, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT W
    
func (impl GatewayDomainServiceImpl) GetTenantDomains(projectId, env string) (result []string, err error) {
	defer func() {
		if err != nil {
			log.Errorf("error happened, err:%+v", err)
		}
	}()
	if projectId == "" || env == "" {
		err = errors.New("invalid params")
		return
	}
	domainMap := map[string]bool{}
	var packages []orm.GatewayPackage
	var runtimes []orm.GatewayRuntimeService
	orgId := apis.GetOrgID(impl.reqCtx)
	if orgId == "" {
		orgId, _ = (*impl.globalBiz).GetOrgId(projectId)
	}
	az, err := impl.azDb.GetAz(&orm.GatewayAzInfo{
		OrgId:     orgId,
		ProjectId: projectId,
		Env:       env,
	})
	if err != nil {
		return
	}
	if az == "" {
		err = errors.New("find cluster failed")
		return
	}
	runtimes, err = impl.runtimeDb.SelectByAny(&orm.GatewayRuntimeService{
		ProjectId:   projectId,
		Workspace:   env,
		ClusterName: az,
	})
	if err != nil {
		return
	}
	packages, err = impl.packageDb.SelectByAny(&orm.GatewayPackage{
		DiceProjectId:   projectId,
		DiceEnv:         env,
		DiceClusterName: az,
	})
	if err != nil {
		return
	}
	for _, runtime := range runtimes {
		var domains []orm.GatewayDomain
		domains, err = impl.domainDb.SelectByAny(&orm.GatewayDomain{
			RuntimeServiceId: runtime.Id,
		})
		if err != nil {
			return
		}
		for _, domain := range domains {
			if _, exist := domainMap[domain.Domain]; !exist {
				domainMap[domain.Domain] = true
				result = append(result, domain.Domain)
			}
		}
	}
	for _, pack := range packages {
		var domains []orm.GatewayDomain
		domains, err = impl.domainDb.SelectByAny(&orm.GatewayDomain{
			PackageId: pack.Id,
		})
		if err != nil {
			return
		}
		for _, domain := range domains {
			if _, exist := domainMap[domain.Domain]; !exist {
				domainMap[domain.Domain] = true
				result = append(result, domain.Domain)
			}
		}
	}
	return
}