company_adaptor.go
955 字节
package adaptor
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/service_gateway"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/service_gateway/translator"
)
type CompanyAdaptor struct {
}
func (adaptor *CompanyAdaptor) ToCompany(companyId int64) (*domain.Company, error) {
companyServiceGateway := service_gateway.NewHttplibUserServiceGateway()
response, err := companyServiceGateway.GetCompany(companyId)
if err != nil {
return nil, err
}
if companyTranslator, err := translator.NewCompanyTranslator(); err != nil {
return nil, err
} else {
company, err := companyTranslator.ToCompanyFromRepresentation(response)
if err != nil {
return nil, err
}
return company, nil
}
}
func NewCompanyAdaptor() (*CompanyAdaptor, error) {
return &CompanyAdaptor{}, nil
}