add logs
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -7,17 +7,18 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"github.com/google/uuid"
|
||||
"github.com/labstack/echo/v4"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func GetUser(ID uint, header http.Header) (*model.User, error) {
|
||||
func GetUser(ID uint, header http.Header, c echo.Context) (*model.User, error) {
|
||||
id := strconv.Itoa(int(ID))
|
||||
|
||||
data, err, _ := api.GetRequest(
|
||||
config.Env.MSHosts.UsersHost+"/"+id,
|
||||
header)
|
||||
header, c)
|
||||
|
||||
if err != nil {
|
||||
return nil, errors.New("error Request to Users Service")
|
||||
@@ -34,7 +35,7 @@ func GetUser(ID uint, header http.Header) (*model.User, error) {
|
||||
return u, nil
|
||||
}
|
||||
|
||||
func GetUsers(ids []uuid.UUID, header http.Header) (map[uuid.UUID]model.User, error) {
|
||||
func GetUsers(ids []uuid.UUID, header http.Header, c echo.Context) (map[uuid.UUID]model.User, error) {
|
||||
var users []model.User
|
||||
var usersMap = make(map[uuid.UUID]model.User)
|
||||
Url, err := url.Parse(config.Env.MSHosts.UsersHost)
|
||||
@@ -48,7 +49,7 @@ func GetUsers(ids []uuid.UUID, header http.Header) (map[uuid.UUID]model.User, er
|
||||
|
||||
data, err, req := api.GetRequest(
|
||||
Url.String(),
|
||||
header)
|
||||
header, c)
|
||||
|
||||
if err != nil || req.StatusCode != 200 {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user