iloom/auth-service/internal/service/company_service.go

34 lines
824 B
Go
Raw Permalink Normal View History

package service
import (
"context"
"errors"
"fmt"
"github.com/muyuqingfeng/iloom/auth-service/internal/model"
"github.com/muyuqingfeng/iloom/auth-service/internal/repository"
)
type CompanyService struct {
repo *repository.CompanyRepo
}
func NewCompanyService(repo *repository.CompanyRepo) *CompanyService {
return &CompanyService{repo: repo}
}
func (s *CompanyService) GetByID(ctx context.Context, id string) (*model.Company, error) {
company, err := s.repo.GetByID(ctx, id)
if err != nil {
return nil, fmt.Errorf("get company: %w", err)
}
if company == nil {
return nil, errors.New("company not found")
}
return company, nil
}
func (s *CompanyService) ListRelationships(ctx context.Context, companyID string) ([]model.CompanyRelationship, error) {
return s.repo.ListRelationships(ctx, companyID)
}