Skip to content

Commit

Permalink
return type
Browse files Browse the repository at this point in the history
  • Loading branch information
sean-david-welch committed Sep 8, 2024
1 parent 459fe42 commit 9fdb3f5
Showing 1 changed file with 36 additions and 4 deletions.
40 changes: 36 additions & 4 deletions server/services/supplierService.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,52 @@ func NewSupplierService(store stores.SupplierStore, s3Client lib.S3Client, folde
}
}

func (service *SupplierServiceImpl) GetSuppliers(ctx context.Context) ([]db.Supplier, error) {
func (service *SupplierServiceImpl) GetSuppliers(ctx context.Context) ([]types.Supplier, error) {
suppliers, err := service.store.GetSuppliers(ctx)
if err != nil {
return nil, err
}
return suppliers, nil

var result []types.Supplier
for _, supplier := range suppliers {
result = append(result, types.Supplier{
ID: supplier.ID,
Name: supplier.Name,
LogoImage: supplier.LogoImage.String,
MarketingImage: supplier.MarketingImage.String,
Description: supplier.Description.String,
SocialFacebook: &supplier.SocialFacebook.String,
SocialInstagram: &supplier.SocialInstagram.String,
SocialLinkedin: &supplier.SocialLinkedin.String,
SocialTwitter: &supplier.SocialTwitter.String,
SocialYoutube: &supplier.SocialYoutube.String,
SocialWebsite: &supplier.SocialWebsite.String,
Created: supplier.Created.String,
})
}
return result, nil
}

func (service *SupplierServiceImpl) GetSupplierById(ctx context.Context, id string) (*db.Supplier, error) {
func (service *SupplierServiceImpl) GetSupplierById(ctx context.Context, id string) (*types.Supplier, error) {
supplier, err := service.store.GetSupplierById(ctx, id)
if err != nil {
return nil, err
}
return supplier, nil
result := &types.Supplier{
ID: supplier.ID,
Name: supplier.Name,
LogoImage: supplier.LogoImage.String,
MarketingImage: supplier.MarketingImage.String,
Description: supplier.Description.String,
SocialFacebook: &supplier.SocialFacebook.String,
SocialInstagram: &supplier.SocialInstagram.String,
SocialLinkedin: &supplier.SocialLinkedin.String,
SocialTwitter: &supplier.SocialTwitter.String,
SocialYoutube: &supplier.SocialYoutube.String,
SocialWebsite: &supplier.SocialWebsite.String,
Created: supplier.Created.String,
}
return result, nil
}

func (service *SupplierServiceImpl) CreateSupplier(ctx context.Context, supplier *db.Supplier) (*types.SupplierResult, error) {
Expand Down

0 comments on commit 9fdb3f5

Please sign in to comment.