2024-06-01 00:29:11 +00:00
|
|
|
package benefactoraddressservice
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2024-06-14 08:41:36 +00:00
|
|
|
|
2024-06-01 00:29:11 +00:00
|
|
|
param "git.gocasts.ir/ebhomengo/niki/param/benefactor/address"
|
|
|
|
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (s Service) Get(ctx context.Context, req param.GetAddressRequest) (param.GetAddressResponse, error) {
|
|
|
|
const op = "benefactoraddressservice.Get"
|
2024-08-01 10:20:18 +00:00
|
|
|
if fieldErrors, vErr := s.vld.ValidateGetAddress(ctx, req); vErr != nil {
|
|
|
|
return param.GetAddressResponse{FieldErrors: fieldErrors}, richerror.New(op).WithErr(vErr)
|
|
|
|
}
|
2024-06-01 00:29:11 +00:00
|
|
|
address, err := s.repo.GetAddress(ctx, req.AddressID, req.BenefactorID)
|
|
|
|
if err != nil {
|
|
|
|
return param.GetAddressResponse{}, richerror.New(op).WithErr(err)
|
|
|
|
}
|
|
|
|
|
2024-09-10 20:55:19 +00:00
|
|
|
return param.GetAddressResponse{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,
|
|
|
|
}}, nil
|
2024-06-01 00:29:11 +00:00
|
|
|
}
|