2024-06-01 18:01:00 +00:00
|
|
|
package benefactoraddressservice
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
param "git.gocasts.ir/ebhomengo/niki/param/benefactor/address"
|
|
|
|
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (s Service) GetAll(ctx context.Context, request param.GetAllAddressesRequest) (param.GetAllAddressesResponse, error) {
|
|
|
|
const op = "benefactoraddressservice.GetAll"
|
|
|
|
|
|
|
|
addresses, err := s.repo.GetAddresses(ctx, request.BenefactorID)
|
|
|
|
if err != nil {
|
|
|
|
return param.GetAllAddressesResponse{}, richerror.New(op).WithErr(err).WithKind(richerror.KindUnexpected)
|
|
|
|
}
|
2024-09-10 20:55:19 +00:00
|
|
|
var data []param.Data
|
|
|
|
for _, address := range addresses {
|
|
|
|
data = append(data, param.Data{
|
|
|
|
ID: address.ID,
|
|
|
|
PostalCode: address.PostalCode,
|
|
|
|
Address: address.Address,
|
|
|
|
Name: address.Name,
|
|
|
|
Lat: address.Lat,
|
|
|
|
Lon: address.Lon,
|
|
|
|
CityID: address.CityID,
|
|
|
|
ProvinceID: address.ProvinceID,
|
|
|
|
BenefactorID: address.BenefactorID,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
return param.GetAllAddressesResponse{Data: data}, nil
|
2024-06-01 18:01:00 +00:00
|
|
|
}
|