Files
astra-api-gateway/services/personal-information/personal-information.go
2023-10-09 03:26:47 +03:00

190 lines
4.5 KiB
Go

package personal_information
import (
"astra-api-gateway/config"
"astra-api-gateway/pkg/api"
"github.com/labstack/echo/v4"
"net/http"
)
func GetPDDocs(c echo.Context) error {
data, err, resp := api.GetRequest(
config.Env.MSHosts.PersonsHost+"/docs",
c.Request().Header, c.Request().URL.RawQuery)
if err != nil {
return c.NoContent(http.StatusBadGateway)
}
return c.Blob(resp.StatusCode, resp.Header.Get("Content-Type"), data)
}
func GetPDList(c echo.Context) error {
data, err, resp := api.GetRequest(
config.Env.MSHosts.PersonsHost+"/persons/",
c.Request().Header, c.Request().URL.RawQuery)
if err != nil {
return c.NoContent(http.StatusBadGateway)
}
return c.Blob(resp.StatusCode, resp.Header.Get("Content-Type"), data)
}
func GetPD(c echo.Context) error {
id := c.Param("id")
data, err, resp := api.GetRequest(
config.Env.MSHosts.PersonsHost+"/persons/"+id,
c.Request().Header, c.Request().URL.RawQuery)
if err != nil {
return c.NoContent(http.StatusBadGateway)
}
return c.Blob(resp.StatusCode, resp.Header.Get("Content-Type"), data)
}
func CreatePD(c echo.Context) error {
data, err, resp := api.PostRequest(
config.Env.MSHosts.PersonsHost+"/persons/",
c.Request().Body,
c.Request().Header)
if err != nil {
return c.NoContent(http.StatusBadGateway)
}
return c.Blob(resp.StatusCode, resp.Header.Get("Content-Type"), data)
}
func SearchPD(c echo.Context) error {
data, err, resp := api.PostRequest(
config.Env.MSHosts.PersonsHost+"/persons/search",
c.Request().Body,
c.Request().Header)
if err != nil {
return c.NoContent(http.StatusBadGateway)
}
return c.Blob(resp.StatusCode, resp.Header.Get("Content-Type"), data)
}
func CreateDocuments(c echo.Context) error {
data, err, resp := api.PostRequest(
config.Env.MSHosts.PersonsHost+"/documents/",
c.Request().Body,
c.Request().Header)
if err != nil {
return c.NoContent(http.StatusBadGateway)
}
return c.Blob(resp.StatusCode, resp.Header.Get("Content-Type"), data)
}
func CreateContacts(c echo.Context) error {
data, err, resp := api.PostRequest(
config.Env.MSHosts.PersonsHost+"/contacts/",
c.Request().Body,
c.Request().Header)
if err != nil {
return c.NoContent(http.StatusBadGateway)
}
return c.Blob(resp.StatusCode, resp.Header.Get("Content-Type"), data)
}
func CreateAddress(c echo.Context) error {
data, err, resp := api.PostRequest(
config.Env.MSHosts.PersonsHost+"/address/",
c.Request().Body,
c.Request().Header)
if err != nil {
return c.NoContent(http.StatusBadGateway)
}
return c.Blob(resp.StatusCode, resp.Header.Get("Content-Type"), data)
}
func UpdateDocuments(c echo.Context) error {
id := c.Param("id")
data, err, resp := api.PatchRequest(
config.Env.MSHosts.PersonsHost+"/documents/"+id,
c.Request().Body,
c.Request().Header)
if err != nil {
return c.NoContent(http.StatusBadGateway)
}
return c.Blob(resp.StatusCode, resp.Header.Get("Content-Type"), data)
}
func UpdateContacts(c echo.Context) error {
id := c.Param("id")
data, err, resp := api.PatchRequest(
config.Env.MSHosts.PersonsHost+"/contacts/"+id,
c.Request().Body,
c.Request().Header)
if err != nil {
return c.NoContent(http.StatusBadGateway)
}
return c.Blob(resp.StatusCode, resp.Header.Get("Content-Type"), data)
}
func UpdateAddress(c echo.Context) error {
id := c.Param("id")
data, err, resp := api.PatchRequest(
config.Env.MSHosts.PersonsHost+"/address/"+id,
c.Request().Body,
c.Request().Header)
if err != nil {
return c.NoContent(http.StatusBadGateway)
}
return c.Blob(resp.StatusCode, resp.Header.Get("Content-Type"), data)
}
func DeleteDocuments(c echo.Context) error {
id := c.Param("id")
data, err, resp := api.DeleteRequest(
config.Env.MSHosts.PersonsHost+"/documents/"+id,
c.Request().Header)
if err != nil {
return c.NoContent(http.StatusBadGateway)
}
return c.Blob(resp.StatusCode, resp.Header.Get("Content-Type"), data)
}
func DeleteContacts(c echo.Context) error {
id := c.Param("id")
data, err, resp := api.DeleteRequest(
config.Env.MSHosts.PersonsHost+"/contacts/"+id,
c.Request().Header)
if err != nil {
return c.NoContent(http.StatusBadGateway)
}
return c.Blob(resp.StatusCode, resp.Header.Get("Content-Type"), data)
}
func DeleteAddress(c echo.Context) error {
id := c.Param("id")
data, err, resp := api.DeleteRequest(
config.Env.MSHosts.PersonsHost+"/address/"+id,
c.Request().Header)
if err != nil {
return c.NoContent(http.StatusBadGateway)
}
return c.Blob(resp.StatusCode, resp.Header.Get("Content-Type"), data)
}