This commit is contained in:
kandrusyak
2023-09-25 21:57:43 +03:00
parent 1fb8c903dc
commit 075fbf89b0
3 changed files with 42 additions and 11 deletions

View File

@@ -7,13 +7,14 @@ import (
"encoding/json"
"errors"
"github.com/google/uuid"
"github.com/labstack/echo/v4"
"net/http"
)
func GetPerson(id uuid.UUID, header http.Header) (*model.PersonalInformationApi, error) {
func GetPerson(id uuid.UUID, header http.Header, c echo.Context) (*model.PersonalInformationApi, error) {
data, err, _ := api.GetRequest(
config.Env.MSHosts.PersonsHost+"/persons/"+id.String(),
header)
header, c)
if err != nil {
return nil, errors.New("error Request to Personal Information Service")
@@ -30,11 +31,12 @@ func GetPerson(id uuid.UUID, header http.Header) (*model.PersonalInformationApi,
return pi, nil
}
func CreatePerson(person model.PersonalInformationApi, header http.Header) (*model.PersonalInformationApi, error) {
func CreatePerson(person model.PersonalInformationApi, header http.Header, c echo.Context) (*model.PersonalInformationApi, error) {
data, err, _ := api.PostRequest(
config.Env.MSHosts.PersonsHost+"/persons/",
person,
header,
c,
)
if err != nil {
return nil, errors.New("error Request to Personal Information Service")
@@ -51,7 +53,7 @@ func CreatePerson(person model.PersonalInformationApi, header http.Header) (*mod
return pi, nil
}
func GetPersons(ids []uuid.UUID, header http.Header) (map[uuid.UUID]*model.PersonalInformationApi, error) {
func GetPersons(ids []uuid.UUID, header http.Header, c echo.Context) (map[uuid.UUID]*model.PersonalInformationApi, error) {
var persons []model.PersonalInformationApi
personsMap := make(map[uuid.UUID]*model.PersonalInformationApi)
@@ -60,7 +62,7 @@ func GetPersons(ids []uuid.UUID, header http.Header) (map[uuid.UUID]*model.Perso
&map[string][]uuid.UUID{
"ids": ids,
},
header)
header, c)
if err != nil || req.StatusCode != 200 {
return nil, err