26 lines
841 B
Go
26 lines
841 B
Go
package user
|
|
|
|
import (
|
|
"context"
|
|
"strings"
|
|
|
|
"hyapp/pkg/appcode"
|
|
"hyapp/pkg/xerr"
|
|
userdomain "hyapp/services/user-service/internal/domain/user"
|
|
)
|
|
|
|
// ResolveApp 解析或校验外部 App 身份,返回内部统一 app_code。
|
|
func (s *Service) ResolveApp(ctx context.Context, code string, packageName string, platform string) (userdomain.App, error) {
|
|
if s.appRegistryRepository == nil {
|
|
return userdomain.App{}, xerr.New(xerr.Unavailable, "app repository is not configured")
|
|
}
|
|
code = appcode.Normalize(code)
|
|
packageName = strings.TrimSpace(packageName)
|
|
platform = strings.ToLower(strings.TrimSpace(platform))
|
|
if packageName == "" && code == "" {
|
|
return userdomain.App{}, xerr.New(xerr.InvalidArgument, "app_code or package_name is required")
|
|
}
|
|
|
|
return s.appRegistryRepository.ResolveApp(ctx, code, packageName, platform)
|
|
}
|