forked from ebhomengo/niki
1
0
Fork 0
niki/service/benefactor/address/add.go

29 lines
865 B
Go
Raw Normal View History

2024-01-19 16:37:15 +00:00
package benefactoraddressservice
import (
"context"
"git.gocasts.ir/ebhomengo/niki/entity"
param "git.gocasts.ir/ebhomengo/niki/param/benefactor/address"
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
)
func (s Service) Add(ctx context.Context, req param.BenefactorAddAddressRequest) (param.BenefactorAddAddressResponse, error) {
const op = "benefactoraddressservice.Add"
address, err := s.repo.CreateBenefactorAddress(ctx, entity.Address{
PostalCode: req.PostalCode,
Address: req.Address,
Name: req.Name,
2024-01-19 16:37:15 +00:00
Lat: req.Lat,
Lon: req.Lon,
CityID: req.CityID,
BenefactorID: req.BenefactorID,
})
if err != nil {
return param.BenefactorAddAddressResponse{}, richerror.New(op).WithErr(err).WithKind(richerror.KindUnexpected)
}
return param.BenefactorAddAddressResponse{Address: address}, nil
}