From e5b380851cef83ac4e3640363c3cf47941caccb1 Mon Sep 17 00:00:00 2001 From: ErfanTech Date: Wed, 11 Sep 2024 00:25:19 +0330 Subject: [PATCH] refactor(param): remove embedded entities in delivery response structs --- .../kind_box/register_emptying_request.go | 2 +- .../benefactor/kind_box_req/add.go | 2 +- delivery/http_server/end2end/setup/server.go | 2 +- .../middleware/benefactor_authorization.go | 2 +- docs/docs.go | 816 ++++++++---------- docs/swagger.json | 816 ++++++++---------- docs/swagger.yaml | 570 +++++------- param/admin/admin/data.go | 15 + param/admin/admin/login.go | 16 +- param/admin/admin/register.go | 2 +- param/admin/agent/get_all.go | 4 +- param/admin/kind_box/data.go | 27 + param/admin/kind_box/get.go | 4 +- param/admin/kind_box/get_all.go | 3 +- param/admin/kind_box_req/accept.go | 15 +- param/admin/kind_box_req/add.go | 2 +- param/admin/kind_box_req/data.go | 22 + param/admin/kind_box_req/get.go | 4 +- param/admin/kind_box_req/get_all.go | 7 +- .../kind_box_req/get_all_delivery_awaiting.go | 7 +- .../kind_box_req/get_delivery_awaiting.go | 4 +- param/admin/kind_box_req/reject.go | 17 +- param/agent/kind_box/data.go | 27 + param/agent/kind_box/get.go | 4 +- param/agent/kind_box/get_all.go | 7 +- param/benefactor/address/add.go | 4 +- param/benefactor/address/data.go | 13 + param/benefactor/address/get.go | 2 +- param/benefactor/address/get_all.go | 4 +- param/benefactor/address/get_all_cities.go | 11 +- param/benefactor/address/get_all_provinces.go | 11 +- .../benefactor/{info.go => data.go} | 2 +- param/benefactor/benefactor/login_register.go | 6 +- param/benefactor/kind_box/data.go | 27 + param/benefactor/kind_box/get.go | 4 +- param/benefactor/kind_box/get_all.go | 3 +- .../kind_box/register_emptying_request.go | 6 +- param/benefactor/kind_box_req/add.go | 2 +- param/benefactor/kind_box_req/data.go | 22 + param/benefactor/kind_box_req/get.go | 6 +- param/benefactor/kind_box_req/get_all.go | 7 +- pkg/supervisor/supervisor.go | 2 +- repository/mysql/kind_box/add.go | 1 + service/admin/admin/login.go | 2 +- service/admin/admin/register.go | 12 +- service/admin/agent/get_all.go | 6 +- service/admin/kind_box/get.go | 20 +- service/admin/kind_box/get_all.go | 26 +- service/admin/kind_box_req/accept.go | 22 +- service/admin/kind_box_req/add.go | 15 +- service/admin/kind_box_req/get.go | 15 +- service/admin/kind_box_req/get_all.go | 19 +- .../kind_box_req/get_all_delivery_awaiting.go | 19 +- .../kind_box_req/get_delivery_awaiting.go | 15 +- service/admin/kind_box_req/reject.go | 22 +- service/agent/kind_box/get.go | 20 +- service/agent/kind_box/get_all.go | 25 +- service/benefactor/address/add.go | 12 +- service/benefactor/address/get.go | 12 +- service/benefactor/address/get_all.go | 17 +- service/benefactor/address/get_all_cities.go | 2 +- .../benefactor/address/get_all_provinces.go | 2 +- .../benefactor/benefactor/login_register.go | 2 +- service/benefactor/kind_box/get.go | 20 +- service/benefactor/kind_box/get_all.go | 25 +- service/benefactor/kind_box_req/add.go | 15 +- service/benefactor/kind_box_req/get.go | 15 +- service/benefactor/kind_box_req/get_all.go | 20 +- service/notification/kindbox_enumerated.go | 4 +- .../kindbox_registered_emptying_request.go | 2 +- service/notification/kindboxreq_accepted.go | 2 +- service/notification/kindboxreq_added.go | 2 +- service/notification/kindboxreq_assigned.go | 4 +- service/notification/kindboxreq_rejected.go | 2 +- 74 files changed, 1464 insertions(+), 1462 deletions(-) create mode 100644 param/admin/admin/data.go create mode 100644 param/admin/kind_box/data.go create mode 100644 param/admin/kind_box_req/data.go create mode 100644 param/agent/kind_box/data.go create mode 100644 param/benefactor/address/data.go rename param/benefactor/benefactor/{info.go => data.go} (91%) create mode 100644 param/benefactor/kind_box/data.go create mode 100644 param/benefactor/kind_box_req/data.go diff --git a/delivery/http_server/benefactor/kind_box/register_emptying_request.go b/delivery/http_server/benefactor/kind_box/register_emptying_request.go index 7217f27..3036102 100644 --- a/delivery/http_server/benefactor/kind_box/register_emptying_request.go +++ b/delivery/http_server/benefactor/kind_box/register_emptying_request.go @@ -44,7 +44,7 @@ func (h Handler) RegisterEmptyingRequest(c echo.Context) error { } go h.notificationSvc.KindBoxRegisteredEmptyingRequest(params.NotificationKindBoxRegisteredEmptyingRequest{ - KindBoxID: resp.ID, + KindBoxID: resp.Data.ID, }) return c.JSON(http.StatusNoContent, nil) diff --git a/delivery/http_server/benefactor/kind_box_req/add.go b/delivery/http_server/benefactor/kind_box_req/add.go index f575d2e..e66db27 100644 --- a/delivery/http_server/benefactor/kind_box_req/add.go +++ b/delivery/http_server/benefactor/kind_box_req/add.go @@ -46,7 +46,7 @@ func (h Handler) Add(c echo.Context) error { } go h.notificationSvc.KindBoxReqAdded(params.NotificationKindBoxReqAdded{ - KindBoxReqID: resp.KindBoxReq.ID, + KindBoxReqID: resp.Data.ID, }) return c.JSON(http.StatusCreated, resp) diff --git a/delivery/http_server/end2end/setup/server.go b/delivery/http_server/end2end/setup/server.go index 68e9c9f..9954d25 100644 --- a/delivery/http_server/end2end/setup/server.go +++ b/delivery/http_server/end2end/setup/server.go @@ -1,12 +1,12 @@ package setup import ( - "github.com/labstack/echo/v4" "net/http" "git.gocasts.ir/ebhomengo/niki/config" httpserver "git.gocasts.ir/ebhomengo/niki/delivery/http_server" "git.gocasts.ir/ebhomengo/niki/service" + "github.com/labstack/echo/v4" ) type TestServer struct { diff --git a/delivery/http_server/middleware/benefactor_authorization.go b/delivery/http_server/middleware/benefactor_authorization.go index e442cda..3ce864f 100644 --- a/delivery/http_server/middleware/benefactor_authorization.go +++ b/delivery/http_server/middleware/benefactor_authorization.go @@ -9,7 +9,7 @@ import ( "github.com/labstack/echo/v4" ) -//nolint +// nolint func BenefactorAuthorization(role entity.UserRole) echo.MiddlewareFunc { return func(next echo.HandlerFunc) echo.HandlerFunc { return func(c echo.Context) error { diff --git a/docs/docs.go b/docs/docs.go index 0af1ef6..f045a18 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -2489,8 +2489,8 @@ const docTemplate = `{ "addressparam.BenefactorAddAddressResponse": { "type": "object", "properties": { - "address": { - "$ref": "#/definitions/entity.Address" + "data": { + "$ref": "#/definitions/addressparam.Data" }, "field_errors": { "type": "object", @@ -2500,11 +2500,43 @@ const docTemplate = `{ } } }, - "addressparam.GetAddressResponse": { + "addressparam.Data": { "type": "object", "properties": { "address": { - "$ref": "#/definitions/entity.Address" + "type": "string" + }, + "benefactor_id": { + "type": "integer" + }, + "city_id": { + "type": "integer" + }, + "id": { + "type": "integer" + }, + "lat": { + "type": "number" + }, + "lon": { + "type": "number" + }, + "name": { + "type": "string" + }, + "postal_code": { + "type": "string" + }, + "province_id": { + "type": "integer" + } + } + }, + "addressparam.GetAddressResponse": { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/addressparam.Data" }, "field_errors": { "type": "object", @@ -2517,10 +2549,10 @@ const docTemplate = `{ "addressparam.GetAllAddressesResponse": { "type": "object", "properties": { - "all_addresses": { + "data": { "type": "array", "items": { - "$ref": "#/definitions/entity.Address" + "$ref": "#/definitions/addressparam.Data" } } } @@ -2528,7 +2560,7 @@ const docTemplate = `{ "addressparam.GetAllCitiesResponse": { "type": "object", "properties": { - "cities": { + "data": { "type": "array", "items": { "$ref": "#/definitions/entity.City" @@ -2539,7 +2571,7 @@ const docTemplate = `{ "addressparam.GetAllProvincesResponse": { "type": "object", "properties": { - "provinces": { + "data": { "type": "array", "items": { "$ref": "#/definitions/entity.Province" @@ -2576,7 +2608,7 @@ const docTemplate = `{ } } }, - "adminagentparam.Agent": { + "adminagentparam.Data": { "type": "object", "properties": { "first_name": { @@ -2600,10 +2632,10 @@ const docTemplate = `{ "adminagentparam.GetAllAgentResponse": { "type": "object", "properties": { - "agents": { + "data": { "type": "array", "items": { - "$ref": "#/definitions/adminagentparam.Agent" + "$ref": "#/definitions/adminagentparam.Data" } } } @@ -2616,6 +2648,62 @@ const docTemplate = `{ } } }, + "adminkindboxparam.Data": { + "type": "object", + "properties": { + "amount": { + "type": "integer" + }, + "benefactor_id": { + "type": "integer" + }, + "deliver_address_id": { + "type": "integer" + }, + "deliver_refer_date": { + "type": "string" + }, + "deliver_refer_time_id": { + "type": "integer" + }, + "delivered_at": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "kind_box_req_id": { + "type": "integer" + }, + "kind_box_type": { + "$ref": "#/definitions/entity.KindBoxType" + }, + "receiver_agent_id": { + "type": "integer" + }, + "return_address_id": { + "type": "integer" + }, + "return_refer_date": { + "type": "string" + }, + "return_refer_time_id": { + "type": "integer" + }, + "returned_at": { + "type": "string" + }, + "sender_agent_id": { + "type": "integer" + }, + "serial_number": { + "type": "string" + }, + "status": { + "$ref": "#/definitions/entity.KindBoxStatus" + } + } + }, "adminkindboxparam.EnumerateKindBoxRequest": { "type": "object", "properties": { @@ -2627,10 +2715,10 @@ const docTemplate = `{ "adminkindboxparam.KindBoxGetAllResponse": { "type": "object", "properties": { - "all_kind_box": { + "data": { "type": "array", "items": { - "$ref": "#/definitions/entity.KindBox" + "$ref": "#/definitions/adminkindboxparam.Data" } }, "field_errors": { @@ -2647,62 +2735,14 @@ const docTemplate = `{ "adminkindboxparam.KindBoxGetResponse": { "type": "object", "properties": { - "amount": { - "type": "integer" - }, - "benefactorID": { - "type": "integer" - }, - "deliverAddressID": { - "type": "integer" - }, - "deliverReferDate": { - "type": "string" - }, - "deliverReferTimeID": { - "type": "integer" - }, - "deliveredAt": { - "type": "string" + "data": { + "$ref": "#/definitions/adminkindboxparam.Data" }, "field_errors": { "type": "object", "additionalProperties": { "type": "string" } - }, - "id": { - "type": "integer" - }, - "kindBoxReqID": { - "type": "integer" - }, - "kindBoxType": { - "$ref": "#/definitions/entity.KindBoxType" - }, - "receiverAgentID": { - "type": "integer" - }, - "returnAddressID": { - "type": "integer" - }, - "returnReferDate": { - "type": "string" - }, - "returnReferTimeID": { - "type": "integer" - }, - "returnedAt": { - "type": "string" - }, - "senderAgentID": { - "type": "integer" - }, - "serialNumber": { - "type": "string" - }, - "status": { - "$ref": "#/definitions/entity.KindBoxStatus" } } }, @@ -2725,6 +2765,47 @@ const docTemplate = `{ } } }, + "adminkindboxreqparam.Data": { + "type": "object", + "properties": { + "benefactor_id": { + "type": "integer" + }, + "count_accepted": { + "type": "integer" + }, + "count_requested": { + "type": "integer" + }, + "deliver_address_id": { + "type": "integer" + }, + "deliver_refer_date": { + "type": "string" + }, + "deliver_refer_time_id": { + "type": "integer" + }, + "delivered_at": { + "type": "string" + }, + "description": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "kind_box_type": { + "$ref": "#/definitions/entity.KindBoxType" + }, + "sender_agent_id": { + "type": "integer" + }, + "status": { + "$ref": "#/definitions/entity.KindBoxReqStatus" + } + } + }, "adminkindboxreqparam.DeliverKindBoxReqRequest": { "type": "object", "properties": { @@ -2755,10 +2836,10 @@ const docTemplate = `{ "adminkindboxreqparam.DeliveryAwaitingGetAllResponse": { "type": "object", "properties": { - "all_awaiting_kind_box_req": { + "data": { "type": "array", "items": { - "$ref": "#/definitions/entity.KindBoxReq" + "$ref": "#/definitions/adminkindboxreqparam.Data" } }, "field_errors": { @@ -2775,94 +2856,28 @@ const docTemplate = `{ "adminkindboxreqparam.DeliveryAwaitingGetResponse": { "type": "object", "properties": { - "benefactorID": { - "type": "integer" - }, - "countAccepted": { - "type": "integer" - }, - "countRequested": { - "type": "integer" - }, - "deliverAddressID": { - "type": "integer" - }, - "deliverReferDate": { - "type": "string" - }, - "deliverReferTimeID": { - "type": "integer" - }, - "deliveredAt": { - "type": "string" - }, - "description": { - "type": "string" + "data": { + "$ref": "#/definitions/adminkindboxreqparam.Data" }, "field_errors": { "type": "object", "additionalProperties": { "type": "string" } - }, - "id": { - "type": "integer" - }, - "kindBoxType": { - "$ref": "#/definitions/entity.KindBoxType" - }, - "senderAgentID": { - "type": "integer" - }, - "status": { - "$ref": "#/definitions/entity.KindBoxReqStatus" } } }, "adminkindboxreqparam.GetKindBoxReqResponse": { "type": "object", "properties": { - "benefactorID": { - "type": "integer" - }, - "countAccepted": { - "type": "integer" - }, - "countRequested": { - "type": "integer" - }, - "deliverAddressID": { - "type": "integer" - }, - "deliverReferDate": { - "type": "string" - }, - "deliverReferTimeID": { - "type": "integer" - }, - "deliveredAt": { - "type": "string" - }, - "description": { - "type": "string" + "data": { + "$ref": "#/definitions/adminkindboxreqparam.Data" }, "field_errors": { "type": "object", "additionalProperties": { "type": "string" } - }, - "id": { - "type": "integer" - }, - "kindBoxType": { - "$ref": "#/definitions/entity.KindBoxType" - }, - "senderAgentID": { - "type": "integer" - }, - "status": { - "$ref": "#/definitions/entity.KindBoxReqStatus" } } }, @@ -2877,29 +2892,14 @@ const docTemplate = `{ "adminkindboxreqparam.KindBoxReqAcceptResponse": { "type": "object", "properties": { - "count_accepted": { - "type": "integer" - }, - "count_requested": { - "type": "integer" - }, - "deliver_address_id": { - "type": "integer" - }, - "deliver_refer_date": { - "type": "string" + "data": { + "$ref": "#/definitions/adminkindboxreqparam.Data" }, "field_errors": { "type": "object", "additionalProperties": { "type": "string" } - }, - "kind_box_req_id": { - "type": "integer" - }, - "kind_box_req_status": { - "$ref": "#/definitions/entity.KindBoxReqStatus" } } }, @@ -2935,24 +2935,24 @@ const docTemplate = `{ "adminkindboxreqparam.KindBoxReqAddResponse": { "type": "object", "properties": { + "data": { + "$ref": "#/definitions/adminkindboxreqparam.Data" + }, "field_errors": { "type": "object", "additionalProperties": { "type": "string" } - }, - "kindBoxReq": { - "$ref": "#/definitions/entity.KindBoxReq" } } }, "adminkindboxreqparam.KindBoxReqGetAllResponse": { "type": "object", "properties": { - "all_awaiting_kind_box_req": { + "data": { "type": "array", "items": { - "$ref": "#/definitions/entity.KindBoxReq" + "$ref": "#/definitions/adminkindboxreqparam.Data" } }, "field_errors": { @@ -2978,51 +2978,14 @@ const docTemplate = `{ "adminkindboxreqparam.KindBoxReqRejectResponse": { "type": "object", "properties": { - "benefactor_id": { - "type": "integer", - "example": 1 - }, - "count_requested": { - "type": "integer", - "example": 1 - }, - "deliver_address_id": { - "type": "integer", - "example": 1 - }, - "deliver_refer_date": { - "type": "string", - "example": "2025-01-02 15:04:05" - }, - "description": { - "type": "string", - "example": "description" + "data": { + "$ref": "#/definitions/adminkindboxreqparam.Data" }, "field_errors": { "type": "object", "additionalProperties": { "type": "string" } - }, - "id": { - "type": "integer", - "example": 1 - }, - "kind_box_type": { - "allOf": [ - { - "$ref": "#/definitions/entity.KindBoxType" - } - ], - "example": "on-table" - }, - "status": { - "allOf": [ - { - "$ref": "#/definitions/entity.KindBoxReqStatus" - } - ], - "example": "pending" } } }, @@ -3067,7 +3030,7 @@ const docTemplate = `{ } } }, - "adminserviceparam.AdminInfo": { + "adminserviceparam.Data": { "type": "object", "properties": { "description": { @@ -3136,8 +3099,8 @@ const docTemplate = `{ "adminserviceparam.LoginWithPhoneNumberResponse": { "type": "object", "properties": { - "admin_info": { - "$ref": "#/definitions/adminserviceparam.AdminInfo" + "data": { + "$ref": "#/definitions/adminserviceparam.Data" }, "field_errors": { "type": "object", @@ -3206,8 +3169,8 @@ const docTemplate = `{ "adminserviceparam.RegisterResponse": { "type": "object", "properties": { - "admin": { - "$ref": "#/definitions/entity.Admin" + "data": { + "$ref": "#/definitions/adminserviceparam.Data" }, "field_errors": { "type": "object", @@ -3228,13 +3191,69 @@ const docTemplate = `{ } } }, + "agentkindboxparam.Data": { + "type": "object", + "properties": { + "amount": { + "type": "integer" + }, + "benefactor_id": { + "type": "integer" + }, + "deliver_address_id": { + "type": "integer" + }, + "deliver_refer_date": { + "type": "string" + }, + "deliver_refer_time_id": { + "type": "integer" + }, + "delivered_at": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "kind_box_req_id": { + "type": "integer" + }, + "kind_box_type": { + "$ref": "#/definitions/entity.KindBoxType" + }, + "receiver_agent_id": { + "type": "integer" + }, + "return_address_id": { + "type": "integer" + }, + "return_refer_date": { + "type": "string" + }, + "return_refer_time_id": { + "type": "integer" + }, + "returned_at": { + "type": "string" + }, + "sender_agent_id": { + "type": "integer" + }, + "serial_number": { + "type": "string" + }, + "status": { + "$ref": "#/definitions/entity.KindBoxStatus" + } + } + }, "agentkindboxparam.GetAllResponse": { "type": "object", "properties": { - "all_kind_boxes": { + "data": { "type": "array", "items": { - "$ref": "#/definitions/entity.KindBox" + "$ref": "#/definitions/agentkindboxparam.Data" } }, "field_errors": { @@ -3251,62 +3270,14 @@ const docTemplate = `{ "agentkindboxparam.GetKindBoxResponse": { "type": "object", "properties": { - "amount": { - "type": "integer" - }, - "benefactorID": { - "type": "integer" - }, - "deliverAddressID": { - "type": "integer" - }, - "deliverReferDate": { - "type": "string" - }, - "deliverReferTimeID": { - "type": "integer" - }, - "deliveredAt": { - "type": "string" + "data": { + "$ref": "#/definitions/agentkindboxparam.Data" }, "field_errors": { "type": "object", "additionalProperties": { "type": "string" } - }, - "id": { - "type": "integer" - }, - "kindBoxReqID": { - "type": "integer" - }, - "kindBoxType": { - "$ref": "#/definitions/entity.KindBoxType" - }, - "receiverAgentID": { - "type": "integer" - }, - "returnAddressID": { - "type": "integer" - }, - "returnReferDate": { - "type": "string" - }, - "returnReferTimeID": { - "type": "integer" - }, - "returnedAt": { - "type": "string" - }, - "senderAgentID": { - "type": "integer" - }, - "serialNumber": { - "type": "string" - }, - "status": { - "$ref": "#/definitions/entity.KindBoxStatus" } } }, @@ -3318,7 +3289,7 @@ const docTemplate = `{ } } }, - "benefactoreparam.BenefactroInfo": { + "benefactoreparam.Data": { "type": "object", "properties": { "first_name": { @@ -3359,8 +3330,8 @@ const docTemplate = `{ "benefactoreparam.LoginOrRegisterResponse": { "type": "object", "properties": { - "benefactore_info": { - "$ref": "#/definitions/benefactoreparam.BenefactroInfo" + "data": { + "$ref": "#/definitions/benefactoreparam.Data" }, "field_errors": { "type": "object", @@ -3412,13 +3383,69 @@ const docTemplate = `{ } } }, + "benefactorkindboxparam.Data": { + "type": "object", + "properties": { + "amount": { + "type": "integer" + }, + "benefactor_id": { + "type": "integer" + }, + "deliver_address_id": { + "type": "integer" + }, + "deliver_refer_date": { + "type": "string" + }, + "deliver_refer_time_id": { + "type": "integer" + }, + "delivered_at": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "kind_box_req_id": { + "type": "integer" + }, + "kind_box_type": { + "$ref": "#/definitions/entity.KindBoxType" + }, + "receiver_agent_id": { + "type": "integer" + }, + "return_address_id": { + "type": "integer" + }, + "return_refer_date": { + "type": "string" + }, + "return_refer_time_id": { + "type": "integer" + }, + "returned_at": { + "type": "string" + }, + "sender_agent_id": { + "type": "integer" + }, + "serial_number": { + "type": "string" + }, + "status": { + "$ref": "#/definitions/entity.KindBoxStatus" + } + } + }, "benefactorkindboxparam.KindBoxGetAllResponse": { "type": "object", "properties": { - "all_kind_box": { + "data": { "type": "array", "items": { - "$ref": "#/definitions/entity.KindBox" + "$ref": "#/definitions/benefactorkindboxparam.Data" } }, "field_errors": { @@ -3435,62 +3462,14 @@ const docTemplate = `{ "benefactorkindboxparam.KindBoxGetResponse": { "type": "object", "properties": { - "amount": { - "type": "integer" - }, - "benefactorID": { - "type": "integer" - }, - "deliverAddressID": { - "type": "integer" - }, - "deliverReferDate": { - "type": "string" - }, - "deliverReferTimeID": { - "type": "integer" - }, - "deliveredAt": { - "type": "string" + "data": { + "$ref": "#/definitions/benefactorkindboxparam.Data" }, "field_errors": { "type": "object", "additionalProperties": { "type": "string" } - }, - "id": { - "type": "integer" - }, - "kindBoxReqID": { - "type": "integer" - }, - "kindBoxType": { - "$ref": "#/definitions/entity.KindBoxType" - }, - "receiverAgentID": { - "type": "integer" - }, - "returnAddressID": { - "type": "integer" - }, - "returnReferDate": { - "type": "string" - }, - "returnReferTimeID": { - "type": "integer" - }, - "returnedAt": { - "type": "string" - }, - "senderAgentID": { - "type": "integer" - }, - "serialNumber": { - "type": "string" - }, - "status": { - "$ref": "#/definitions/entity.KindBoxStatus" } } }, @@ -3511,13 +3490,54 @@ const docTemplate = `{ } } }, + "benefactorkindboxreqparam.Data": { + "type": "object", + "properties": { + "benefactor_id": { + "type": "integer" + }, + "count_accepted": { + "type": "integer" + }, + "count_requested": { + "type": "integer" + }, + "deliver_address_id": { + "type": "integer" + }, + "deliver_refer_date": { + "type": "string" + }, + "deliver_refer_time_id": { + "type": "integer" + }, + "delivered_at": { + "type": "string" + }, + "description": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "kind_box_type": { + "$ref": "#/definitions/entity.KindBoxType" + }, + "sender_agent_id": { + "type": "integer" + }, + "status": { + "$ref": "#/definitions/entity.KindBoxReqStatus" + } + } + }, "benefactorkindboxreqparam.GetAllResponse": { "type": "object", "properties": { - "all_kind_box_req": { + "data": { "type": "array", "items": { - "$ref": "#/definitions/entity.KindBoxReq" + "$ref": "#/definitions/benefactorkindboxreqparam.Data" } }, "field_errors": { @@ -3563,14 +3583,14 @@ const docTemplate = `{ "benefactorkindboxreqparam.KindBoxReqAddResponse": { "type": "object", "properties": { + "data": { + "$ref": "#/definitions/benefactorkindboxreqparam.Data" + }, "field_errors": { "type": "object", "additionalProperties": { "type": "string" } - }, - "kind_box_req": { - "$ref": "#/definitions/entity.KindBoxReq" } } }, @@ -3588,14 +3608,14 @@ const docTemplate = `{ "benefactorkindboxreqparam.KindBoxReqGetResponse": { "type": "object", "properties": { + "data": { + "$ref": "#/definitions/benefactorkindboxreqparam.Data" + }, "field_errors": { "type": "object", "additionalProperties": { "type": "string" } - }, - "kind_box_req": { - "$ref": "#/definitions/entity.KindBoxReq" } } }, @@ -3632,73 +3652,6 @@ const docTemplate = `{ } } }, - "entity.Address": { - "type": "object", - "properties": { - "address": { - "type": "string" - }, - "benefactorID": { - "type": "integer" - }, - "cityID": { - "type": "integer" - }, - "id": { - "type": "integer" - }, - "lat": { - "type": "number" - }, - "lon": { - "type": "number" - }, - "name": { - "type": "string" - }, - "postalCode": { - "type": "string" - }, - "provinceID": { - "type": "integer" - } - } - }, - "entity.Admin": { - "type": "object", - "properties": { - "description": { - "type": "string" - }, - "email": { - "type": "string" - }, - "firstName": { - "type": "string" - }, - "gender": { - "$ref": "#/definitions/entity.Gender" - }, - "id": { - "type": "integer" - }, - "lastName": { - "type": "string" - }, - "password": { - "type": "string" - }, - "phoneNumber": { - "type": "string" - }, - "role": { - "$ref": "#/definitions/entity.AdminRole" - }, - "status": { - "$ref": "#/definitions/entity.AdminStatus" - } - } - }, "entity.AdminRole": { "type": "integer", "enum": [ @@ -3748,103 +3701,6 @@ const docTemplate = `{ "FemaleGender" ] }, - "entity.KindBox": { - "type": "object", - "properties": { - "amount": { - "type": "integer" - }, - "benefactorID": { - "type": "integer" - }, - "deliverAddressID": { - "type": "integer" - }, - "deliverReferDate": { - "type": "string" - }, - "deliverReferTimeID": { - "type": "integer" - }, - "deliveredAt": { - "type": "string" - }, - "id": { - "type": "integer" - }, - "kindBoxReqID": { - "type": "integer" - }, - "kindBoxType": { - "$ref": "#/definitions/entity.KindBoxType" - }, - "receiverAgentID": { - "type": "integer" - }, - "returnAddressID": { - "type": "integer" - }, - "returnReferDate": { - "type": "string" - }, - "returnReferTimeID": { - "type": "integer" - }, - "returnedAt": { - "type": "string" - }, - "senderAgentID": { - "type": "integer" - }, - "serialNumber": { - "type": "string" - }, - "status": { - "$ref": "#/definitions/entity.KindBoxStatus" - } - } - }, - "entity.KindBoxReq": { - "type": "object", - "properties": { - "benefactorID": { - "type": "integer" - }, - "countAccepted": { - "type": "integer" - }, - "countRequested": { - "type": "integer" - }, - "deliverAddressID": { - "type": "integer" - }, - "deliverReferDate": { - "type": "string" - }, - "deliverReferTimeID": { - "type": "integer" - }, - "deliveredAt": { - "type": "string" - }, - "description": { - "type": "string" - }, - "id": { - "type": "integer" - }, - "kindBoxType": { - "$ref": "#/definitions/entity.KindBoxType" - }, - "senderAgentID": { - "type": "integer" - }, - "status": { - "$ref": "#/definitions/entity.KindBoxReqStatus" - } - } - }, "entity.KindBoxReqStatus": { "type": "string", "enum": [ diff --git a/docs/swagger.json b/docs/swagger.json index 86a6211..9a05883 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -2478,8 +2478,8 @@ "addressparam.BenefactorAddAddressResponse": { "type": "object", "properties": { - "address": { - "$ref": "#/definitions/entity.Address" + "data": { + "$ref": "#/definitions/addressparam.Data" }, "field_errors": { "type": "object", @@ -2489,11 +2489,43 @@ } } }, - "addressparam.GetAddressResponse": { + "addressparam.Data": { "type": "object", "properties": { "address": { - "$ref": "#/definitions/entity.Address" + "type": "string" + }, + "benefactor_id": { + "type": "integer" + }, + "city_id": { + "type": "integer" + }, + "id": { + "type": "integer" + }, + "lat": { + "type": "number" + }, + "lon": { + "type": "number" + }, + "name": { + "type": "string" + }, + "postal_code": { + "type": "string" + }, + "province_id": { + "type": "integer" + } + } + }, + "addressparam.GetAddressResponse": { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/addressparam.Data" }, "field_errors": { "type": "object", @@ -2506,10 +2538,10 @@ "addressparam.GetAllAddressesResponse": { "type": "object", "properties": { - "all_addresses": { + "data": { "type": "array", "items": { - "$ref": "#/definitions/entity.Address" + "$ref": "#/definitions/addressparam.Data" } } } @@ -2517,7 +2549,7 @@ "addressparam.GetAllCitiesResponse": { "type": "object", "properties": { - "cities": { + "data": { "type": "array", "items": { "$ref": "#/definitions/entity.City" @@ -2528,7 +2560,7 @@ "addressparam.GetAllProvincesResponse": { "type": "object", "properties": { - "provinces": { + "data": { "type": "array", "items": { "$ref": "#/definitions/entity.Province" @@ -2565,7 +2597,7 @@ } } }, - "adminagentparam.Agent": { + "adminagentparam.Data": { "type": "object", "properties": { "first_name": { @@ -2589,10 +2621,10 @@ "adminagentparam.GetAllAgentResponse": { "type": "object", "properties": { - "agents": { + "data": { "type": "array", "items": { - "$ref": "#/definitions/adminagentparam.Agent" + "$ref": "#/definitions/adminagentparam.Data" } } } @@ -2605,6 +2637,62 @@ } } }, + "adminkindboxparam.Data": { + "type": "object", + "properties": { + "amount": { + "type": "integer" + }, + "benefactor_id": { + "type": "integer" + }, + "deliver_address_id": { + "type": "integer" + }, + "deliver_refer_date": { + "type": "string" + }, + "deliver_refer_time_id": { + "type": "integer" + }, + "delivered_at": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "kind_box_req_id": { + "type": "integer" + }, + "kind_box_type": { + "$ref": "#/definitions/entity.KindBoxType" + }, + "receiver_agent_id": { + "type": "integer" + }, + "return_address_id": { + "type": "integer" + }, + "return_refer_date": { + "type": "string" + }, + "return_refer_time_id": { + "type": "integer" + }, + "returned_at": { + "type": "string" + }, + "sender_agent_id": { + "type": "integer" + }, + "serial_number": { + "type": "string" + }, + "status": { + "$ref": "#/definitions/entity.KindBoxStatus" + } + } + }, "adminkindboxparam.EnumerateKindBoxRequest": { "type": "object", "properties": { @@ -2616,10 +2704,10 @@ "adminkindboxparam.KindBoxGetAllResponse": { "type": "object", "properties": { - "all_kind_box": { + "data": { "type": "array", "items": { - "$ref": "#/definitions/entity.KindBox" + "$ref": "#/definitions/adminkindboxparam.Data" } }, "field_errors": { @@ -2636,62 +2724,14 @@ "adminkindboxparam.KindBoxGetResponse": { "type": "object", "properties": { - "amount": { - "type": "integer" - }, - "benefactorID": { - "type": "integer" - }, - "deliverAddressID": { - "type": "integer" - }, - "deliverReferDate": { - "type": "string" - }, - "deliverReferTimeID": { - "type": "integer" - }, - "deliveredAt": { - "type": "string" + "data": { + "$ref": "#/definitions/adminkindboxparam.Data" }, "field_errors": { "type": "object", "additionalProperties": { "type": "string" } - }, - "id": { - "type": "integer" - }, - "kindBoxReqID": { - "type": "integer" - }, - "kindBoxType": { - "$ref": "#/definitions/entity.KindBoxType" - }, - "receiverAgentID": { - "type": "integer" - }, - "returnAddressID": { - "type": "integer" - }, - "returnReferDate": { - "type": "string" - }, - "returnReferTimeID": { - "type": "integer" - }, - "returnedAt": { - "type": "string" - }, - "senderAgentID": { - "type": "integer" - }, - "serialNumber": { - "type": "string" - }, - "status": { - "$ref": "#/definitions/entity.KindBoxStatus" } } }, @@ -2714,6 +2754,47 @@ } } }, + "adminkindboxreqparam.Data": { + "type": "object", + "properties": { + "benefactor_id": { + "type": "integer" + }, + "count_accepted": { + "type": "integer" + }, + "count_requested": { + "type": "integer" + }, + "deliver_address_id": { + "type": "integer" + }, + "deliver_refer_date": { + "type": "string" + }, + "deliver_refer_time_id": { + "type": "integer" + }, + "delivered_at": { + "type": "string" + }, + "description": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "kind_box_type": { + "$ref": "#/definitions/entity.KindBoxType" + }, + "sender_agent_id": { + "type": "integer" + }, + "status": { + "$ref": "#/definitions/entity.KindBoxReqStatus" + } + } + }, "adminkindboxreqparam.DeliverKindBoxReqRequest": { "type": "object", "properties": { @@ -2744,10 +2825,10 @@ "adminkindboxreqparam.DeliveryAwaitingGetAllResponse": { "type": "object", "properties": { - "all_awaiting_kind_box_req": { + "data": { "type": "array", "items": { - "$ref": "#/definitions/entity.KindBoxReq" + "$ref": "#/definitions/adminkindboxreqparam.Data" } }, "field_errors": { @@ -2764,94 +2845,28 @@ "adminkindboxreqparam.DeliveryAwaitingGetResponse": { "type": "object", "properties": { - "benefactorID": { - "type": "integer" - }, - "countAccepted": { - "type": "integer" - }, - "countRequested": { - "type": "integer" - }, - "deliverAddressID": { - "type": "integer" - }, - "deliverReferDate": { - "type": "string" - }, - "deliverReferTimeID": { - "type": "integer" - }, - "deliveredAt": { - "type": "string" - }, - "description": { - "type": "string" + "data": { + "$ref": "#/definitions/adminkindboxreqparam.Data" }, "field_errors": { "type": "object", "additionalProperties": { "type": "string" } - }, - "id": { - "type": "integer" - }, - "kindBoxType": { - "$ref": "#/definitions/entity.KindBoxType" - }, - "senderAgentID": { - "type": "integer" - }, - "status": { - "$ref": "#/definitions/entity.KindBoxReqStatus" } } }, "adminkindboxreqparam.GetKindBoxReqResponse": { "type": "object", "properties": { - "benefactorID": { - "type": "integer" - }, - "countAccepted": { - "type": "integer" - }, - "countRequested": { - "type": "integer" - }, - "deliverAddressID": { - "type": "integer" - }, - "deliverReferDate": { - "type": "string" - }, - "deliverReferTimeID": { - "type": "integer" - }, - "deliveredAt": { - "type": "string" - }, - "description": { - "type": "string" + "data": { + "$ref": "#/definitions/adminkindboxreqparam.Data" }, "field_errors": { "type": "object", "additionalProperties": { "type": "string" } - }, - "id": { - "type": "integer" - }, - "kindBoxType": { - "$ref": "#/definitions/entity.KindBoxType" - }, - "senderAgentID": { - "type": "integer" - }, - "status": { - "$ref": "#/definitions/entity.KindBoxReqStatus" } } }, @@ -2866,29 +2881,14 @@ "adminkindboxreqparam.KindBoxReqAcceptResponse": { "type": "object", "properties": { - "count_accepted": { - "type": "integer" - }, - "count_requested": { - "type": "integer" - }, - "deliver_address_id": { - "type": "integer" - }, - "deliver_refer_date": { - "type": "string" + "data": { + "$ref": "#/definitions/adminkindboxreqparam.Data" }, "field_errors": { "type": "object", "additionalProperties": { "type": "string" } - }, - "kind_box_req_id": { - "type": "integer" - }, - "kind_box_req_status": { - "$ref": "#/definitions/entity.KindBoxReqStatus" } } }, @@ -2924,24 +2924,24 @@ "adminkindboxreqparam.KindBoxReqAddResponse": { "type": "object", "properties": { + "data": { + "$ref": "#/definitions/adminkindboxreqparam.Data" + }, "field_errors": { "type": "object", "additionalProperties": { "type": "string" } - }, - "kindBoxReq": { - "$ref": "#/definitions/entity.KindBoxReq" } } }, "adminkindboxreqparam.KindBoxReqGetAllResponse": { "type": "object", "properties": { - "all_awaiting_kind_box_req": { + "data": { "type": "array", "items": { - "$ref": "#/definitions/entity.KindBoxReq" + "$ref": "#/definitions/adminkindboxreqparam.Data" } }, "field_errors": { @@ -2967,51 +2967,14 @@ "adminkindboxreqparam.KindBoxReqRejectResponse": { "type": "object", "properties": { - "benefactor_id": { - "type": "integer", - "example": 1 - }, - "count_requested": { - "type": "integer", - "example": 1 - }, - "deliver_address_id": { - "type": "integer", - "example": 1 - }, - "deliver_refer_date": { - "type": "string", - "example": "2025-01-02 15:04:05" - }, - "description": { - "type": "string", - "example": "description" + "data": { + "$ref": "#/definitions/adminkindboxreqparam.Data" }, "field_errors": { "type": "object", "additionalProperties": { "type": "string" } - }, - "id": { - "type": "integer", - "example": 1 - }, - "kind_box_type": { - "allOf": [ - { - "$ref": "#/definitions/entity.KindBoxType" - } - ], - "example": "on-table" - }, - "status": { - "allOf": [ - { - "$ref": "#/definitions/entity.KindBoxReqStatus" - } - ], - "example": "pending" } } }, @@ -3056,7 +3019,7 @@ } } }, - "adminserviceparam.AdminInfo": { + "adminserviceparam.Data": { "type": "object", "properties": { "description": { @@ -3125,8 +3088,8 @@ "adminserviceparam.LoginWithPhoneNumberResponse": { "type": "object", "properties": { - "admin_info": { - "$ref": "#/definitions/adminserviceparam.AdminInfo" + "data": { + "$ref": "#/definitions/adminserviceparam.Data" }, "field_errors": { "type": "object", @@ -3195,8 +3158,8 @@ "adminserviceparam.RegisterResponse": { "type": "object", "properties": { - "admin": { - "$ref": "#/definitions/entity.Admin" + "data": { + "$ref": "#/definitions/adminserviceparam.Data" }, "field_errors": { "type": "object", @@ -3217,13 +3180,69 @@ } } }, + "agentkindboxparam.Data": { + "type": "object", + "properties": { + "amount": { + "type": "integer" + }, + "benefactor_id": { + "type": "integer" + }, + "deliver_address_id": { + "type": "integer" + }, + "deliver_refer_date": { + "type": "string" + }, + "deliver_refer_time_id": { + "type": "integer" + }, + "delivered_at": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "kind_box_req_id": { + "type": "integer" + }, + "kind_box_type": { + "$ref": "#/definitions/entity.KindBoxType" + }, + "receiver_agent_id": { + "type": "integer" + }, + "return_address_id": { + "type": "integer" + }, + "return_refer_date": { + "type": "string" + }, + "return_refer_time_id": { + "type": "integer" + }, + "returned_at": { + "type": "string" + }, + "sender_agent_id": { + "type": "integer" + }, + "serial_number": { + "type": "string" + }, + "status": { + "$ref": "#/definitions/entity.KindBoxStatus" + } + } + }, "agentkindboxparam.GetAllResponse": { "type": "object", "properties": { - "all_kind_boxes": { + "data": { "type": "array", "items": { - "$ref": "#/definitions/entity.KindBox" + "$ref": "#/definitions/agentkindboxparam.Data" } }, "field_errors": { @@ -3240,62 +3259,14 @@ "agentkindboxparam.GetKindBoxResponse": { "type": "object", "properties": { - "amount": { - "type": "integer" - }, - "benefactorID": { - "type": "integer" - }, - "deliverAddressID": { - "type": "integer" - }, - "deliverReferDate": { - "type": "string" - }, - "deliverReferTimeID": { - "type": "integer" - }, - "deliveredAt": { - "type": "string" + "data": { + "$ref": "#/definitions/agentkindboxparam.Data" }, "field_errors": { "type": "object", "additionalProperties": { "type": "string" } - }, - "id": { - "type": "integer" - }, - "kindBoxReqID": { - "type": "integer" - }, - "kindBoxType": { - "$ref": "#/definitions/entity.KindBoxType" - }, - "receiverAgentID": { - "type": "integer" - }, - "returnAddressID": { - "type": "integer" - }, - "returnReferDate": { - "type": "string" - }, - "returnReferTimeID": { - "type": "integer" - }, - "returnedAt": { - "type": "string" - }, - "senderAgentID": { - "type": "integer" - }, - "serialNumber": { - "type": "string" - }, - "status": { - "$ref": "#/definitions/entity.KindBoxStatus" } } }, @@ -3307,7 +3278,7 @@ } } }, - "benefactoreparam.BenefactroInfo": { + "benefactoreparam.Data": { "type": "object", "properties": { "first_name": { @@ -3348,8 +3319,8 @@ "benefactoreparam.LoginOrRegisterResponse": { "type": "object", "properties": { - "benefactore_info": { - "$ref": "#/definitions/benefactoreparam.BenefactroInfo" + "data": { + "$ref": "#/definitions/benefactoreparam.Data" }, "field_errors": { "type": "object", @@ -3401,13 +3372,69 @@ } } }, + "benefactorkindboxparam.Data": { + "type": "object", + "properties": { + "amount": { + "type": "integer" + }, + "benefactor_id": { + "type": "integer" + }, + "deliver_address_id": { + "type": "integer" + }, + "deliver_refer_date": { + "type": "string" + }, + "deliver_refer_time_id": { + "type": "integer" + }, + "delivered_at": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "kind_box_req_id": { + "type": "integer" + }, + "kind_box_type": { + "$ref": "#/definitions/entity.KindBoxType" + }, + "receiver_agent_id": { + "type": "integer" + }, + "return_address_id": { + "type": "integer" + }, + "return_refer_date": { + "type": "string" + }, + "return_refer_time_id": { + "type": "integer" + }, + "returned_at": { + "type": "string" + }, + "sender_agent_id": { + "type": "integer" + }, + "serial_number": { + "type": "string" + }, + "status": { + "$ref": "#/definitions/entity.KindBoxStatus" + } + } + }, "benefactorkindboxparam.KindBoxGetAllResponse": { "type": "object", "properties": { - "all_kind_box": { + "data": { "type": "array", "items": { - "$ref": "#/definitions/entity.KindBox" + "$ref": "#/definitions/benefactorkindboxparam.Data" } }, "field_errors": { @@ -3424,62 +3451,14 @@ "benefactorkindboxparam.KindBoxGetResponse": { "type": "object", "properties": { - "amount": { - "type": "integer" - }, - "benefactorID": { - "type": "integer" - }, - "deliverAddressID": { - "type": "integer" - }, - "deliverReferDate": { - "type": "string" - }, - "deliverReferTimeID": { - "type": "integer" - }, - "deliveredAt": { - "type": "string" + "data": { + "$ref": "#/definitions/benefactorkindboxparam.Data" }, "field_errors": { "type": "object", "additionalProperties": { "type": "string" } - }, - "id": { - "type": "integer" - }, - "kindBoxReqID": { - "type": "integer" - }, - "kindBoxType": { - "$ref": "#/definitions/entity.KindBoxType" - }, - "receiverAgentID": { - "type": "integer" - }, - "returnAddressID": { - "type": "integer" - }, - "returnReferDate": { - "type": "string" - }, - "returnReferTimeID": { - "type": "integer" - }, - "returnedAt": { - "type": "string" - }, - "senderAgentID": { - "type": "integer" - }, - "serialNumber": { - "type": "string" - }, - "status": { - "$ref": "#/definitions/entity.KindBoxStatus" } } }, @@ -3500,13 +3479,54 @@ } } }, + "benefactorkindboxreqparam.Data": { + "type": "object", + "properties": { + "benefactor_id": { + "type": "integer" + }, + "count_accepted": { + "type": "integer" + }, + "count_requested": { + "type": "integer" + }, + "deliver_address_id": { + "type": "integer" + }, + "deliver_refer_date": { + "type": "string" + }, + "deliver_refer_time_id": { + "type": "integer" + }, + "delivered_at": { + "type": "string" + }, + "description": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "kind_box_type": { + "$ref": "#/definitions/entity.KindBoxType" + }, + "sender_agent_id": { + "type": "integer" + }, + "status": { + "$ref": "#/definitions/entity.KindBoxReqStatus" + } + } + }, "benefactorkindboxreqparam.GetAllResponse": { "type": "object", "properties": { - "all_kind_box_req": { + "data": { "type": "array", "items": { - "$ref": "#/definitions/entity.KindBoxReq" + "$ref": "#/definitions/benefactorkindboxreqparam.Data" } }, "field_errors": { @@ -3552,14 +3572,14 @@ "benefactorkindboxreqparam.KindBoxReqAddResponse": { "type": "object", "properties": { + "data": { + "$ref": "#/definitions/benefactorkindboxreqparam.Data" + }, "field_errors": { "type": "object", "additionalProperties": { "type": "string" } - }, - "kind_box_req": { - "$ref": "#/definitions/entity.KindBoxReq" } } }, @@ -3577,14 +3597,14 @@ "benefactorkindboxreqparam.KindBoxReqGetResponse": { "type": "object", "properties": { + "data": { + "$ref": "#/definitions/benefactorkindboxreqparam.Data" + }, "field_errors": { "type": "object", "additionalProperties": { "type": "string" } - }, - "kind_box_req": { - "$ref": "#/definitions/entity.KindBoxReq" } } }, @@ -3621,73 +3641,6 @@ } } }, - "entity.Address": { - "type": "object", - "properties": { - "address": { - "type": "string" - }, - "benefactorID": { - "type": "integer" - }, - "cityID": { - "type": "integer" - }, - "id": { - "type": "integer" - }, - "lat": { - "type": "number" - }, - "lon": { - "type": "number" - }, - "name": { - "type": "string" - }, - "postalCode": { - "type": "string" - }, - "provinceID": { - "type": "integer" - } - } - }, - "entity.Admin": { - "type": "object", - "properties": { - "description": { - "type": "string" - }, - "email": { - "type": "string" - }, - "firstName": { - "type": "string" - }, - "gender": { - "$ref": "#/definitions/entity.Gender" - }, - "id": { - "type": "integer" - }, - "lastName": { - "type": "string" - }, - "password": { - "type": "string" - }, - "phoneNumber": { - "type": "string" - }, - "role": { - "$ref": "#/definitions/entity.AdminRole" - }, - "status": { - "$ref": "#/definitions/entity.AdminStatus" - } - } - }, "entity.AdminRole": { "type": "integer", "enum": [ @@ -3737,103 +3690,6 @@ "FemaleGender" ] }, - "entity.KindBox": { - "type": "object", - "properties": { - "amount": { - "type": "integer" - }, - "benefactorID": { - "type": "integer" - }, - "deliverAddressID": { - "type": "integer" - }, - "deliverReferDate": { - "type": "string" - }, - "deliverReferTimeID": { - "type": "integer" - }, - "deliveredAt": { - "type": "string" - }, - "id": { - "type": "integer" - }, - "kindBoxReqID": { - "type": "integer" - }, - "kindBoxType": { - "$ref": "#/definitions/entity.KindBoxType" - }, - "receiverAgentID": { - "type": "integer" - }, - "returnAddressID": { - "type": "integer" - }, - "returnReferDate": { - "type": "string" - }, - "returnReferTimeID": { - "type": "integer" - }, - "returnedAt": { - "type": "string" - }, - "senderAgentID": { - "type": "integer" - }, - "serialNumber": { - "type": "string" - }, - "status": { - "$ref": "#/definitions/entity.KindBoxStatus" - } - } - }, - "entity.KindBoxReq": { - "type": "object", - "properties": { - "benefactorID": { - "type": "integer" - }, - "countAccepted": { - "type": "integer" - }, - "countRequested": { - "type": "integer" - }, - "deliverAddressID": { - "type": "integer" - }, - "deliverReferDate": { - "type": "string" - }, - "deliverReferTimeID": { - "type": "integer" - }, - "deliveredAt": { - "type": "string" - }, - "description": { - "type": "string" - }, - "id": { - "type": "integer" - }, - "kindBoxType": { - "$ref": "#/definitions/entity.KindBoxType" - }, - "senderAgentID": { - "type": "integer" - }, - "status": { - "$ref": "#/definitions/entity.KindBoxReqStatus" - } - } - }, "entity.KindBoxReqStatus": { "type": "string", "enum": [ diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 3350725..9e06187 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -22,17 +22,38 @@ definitions: type: object addressparam.BenefactorAddAddressResponse: properties: - address: - $ref: '#/definitions/entity.Address' + data: + $ref: '#/definitions/addressparam.Data' field_errors: additionalProperties: type: string type: object type: object - addressparam.GetAddressResponse: + addressparam.Data: properties: address: - $ref: '#/definitions/entity.Address' + type: string + benefactor_id: + type: integer + city_id: + type: integer + id: + type: integer + lat: + type: number + lon: + type: number + name: + type: string + postal_code: + type: string + province_id: + type: integer + type: object + addressparam.GetAddressResponse: + properties: + data: + $ref: '#/definitions/addressparam.Data' field_errors: additionalProperties: type: string @@ -40,21 +61,21 @@ definitions: type: object addressparam.GetAllAddressesResponse: properties: - all_addresses: + data: items: - $ref: '#/definitions/entity.Address' + $ref: '#/definitions/addressparam.Data' type: array type: object addressparam.GetAllCitiesResponse: properties: - cities: + data: items: $ref: '#/definitions/entity.City' type: array type: object addressparam.GetAllProvincesResponse: properties: - provinces: + data: items: $ref: '#/definitions/entity.Province' type: array @@ -80,7 +101,7 @@ definitions: example: "1234567890" type: string type: object - adminagentparam.Agent: + adminagentparam.Data: properties: first_name: example: John @@ -97,9 +118,9 @@ definitions: type: object adminagentparam.GetAllAgentResponse: properties: - agents: + data: items: - $ref: '#/definitions/adminagentparam.Agent' + $ref: '#/definitions/adminagentparam.Data' type: array type: object adminkindboxparam.AssignReceiverRequest: @@ -107,6 +128,43 @@ definitions: receiver_agent_id: type: integer type: object + adminkindboxparam.Data: + properties: + amount: + type: integer + benefactor_id: + type: integer + deliver_address_id: + type: integer + deliver_refer_date: + type: string + deliver_refer_time_id: + type: integer + delivered_at: + type: string + id: + type: integer + kind_box_req_id: + type: integer + kind_box_type: + $ref: '#/definitions/entity.KindBoxType' + receiver_agent_id: + type: integer + return_address_id: + type: integer + return_refer_date: + type: string + return_refer_time_id: + type: integer + returned_at: + type: string + sender_agent_id: + type: integer + serial_number: + type: string + status: + $ref: '#/definitions/entity.KindBoxStatus' + type: object adminkindboxparam.EnumerateKindBoxRequest: properties: amount: @@ -114,9 +172,9 @@ definitions: type: object adminkindboxparam.KindBoxGetAllResponse: properties: - all_kind_box: + data: items: - $ref: '#/definitions/entity.KindBox' + $ref: '#/definitions/adminkindboxparam.Data' type: array field_errors: additionalProperties: @@ -127,44 +185,12 @@ definitions: type: object adminkindboxparam.KindBoxGetResponse: properties: - amount: - type: integer - benefactorID: - type: integer - deliverAddressID: - type: integer - deliverReferDate: - type: string - deliverReferTimeID: - type: integer - deliveredAt: - type: string + data: + $ref: '#/definitions/adminkindboxparam.Data' field_errors: additionalProperties: type: string type: object - id: - type: integer - kindBoxReqID: - type: integer - kindBoxType: - $ref: '#/definitions/entity.KindBoxType' - receiverAgentID: - type: integer - returnAddressID: - type: integer - returnReferDate: - type: string - returnReferTimeID: - type: integer - returnedAt: - type: string - senderAgentID: - type: integer - serialNumber: - type: string - status: - $ref: '#/definitions/entity.KindBoxStatus' type: object adminkindboxreqparam.AssignSenderRequest: properties: @@ -178,6 +204,33 @@ definitions: type: string type: object type: object + adminkindboxreqparam.Data: + properties: + benefactor_id: + type: integer + count_accepted: + type: integer + count_requested: + type: integer + deliver_address_id: + type: integer + deliver_refer_date: + type: string + deliver_refer_time_id: + type: integer + delivered_at: + type: string + description: + type: string + id: + type: integer + kind_box_type: + $ref: '#/definitions/entity.KindBoxType' + sender_agent_id: + type: integer + status: + $ref: '#/definitions/entity.KindBoxReqStatus' + type: object adminkindboxreqparam.DeliverKindBoxReqRequest: properties: serial_numbers: @@ -198,9 +251,9 @@ definitions: type: object adminkindboxreqparam.DeliveryAwaitingGetAllResponse: properties: - all_awaiting_kind_box_req: + data: items: - $ref: '#/definitions/entity.KindBoxReq' + $ref: '#/definitions/adminkindboxreqparam.Data' type: array field_errors: additionalProperties: @@ -211,65 +264,21 @@ definitions: type: object adminkindboxreqparam.DeliveryAwaitingGetResponse: properties: - benefactorID: - type: integer - countAccepted: - type: integer - countRequested: - type: integer - deliverAddressID: - type: integer - deliverReferDate: - type: string - deliverReferTimeID: - type: integer - deliveredAt: - type: string - description: - type: string + data: + $ref: '#/definitions/adminkindboxreqparam.Data' field_errors: additionalProperties: type: string type: object - id: - type: integer - kindBoxType: - $ref: '#/definitions/entity.KindBoxType' - senderAgentID: - type: integer - status: - $ref: '#/definitions/entity.KindBoxReqStatus' type: object adminkindboxreqparam.GetKindBoxReqResponse: properties: - benefactorID: - type: integer - countAccepted: - type: integer - countRequested: - type: integer - deliverAddressID: - type: integer - deliverReferDate: - type: string - deliverReferTimeID: - type: integer - deliveredAt: - type: string - description: - type: string + data: + $ref: '#/definitions/adminkindboxreqparam.Data' field_errors: additionalProperties: type: string type: object - id: - type: integer - kindBoxType: - $ref: '#/definitions/entity.KindBoxType' - senderAgentID: - type: integer - status: - $ref: '#/definitions/entity.KindBoxReqStatus' type: object adminkindboxreqparam.KindBoxReqAcceptRequest: properties: @@ -278,22 +287,12 @@ definitions: type: object adminkindboxreqparam.KindBoxReqAcceptResponse: properties: - count_accepted: - type: integer - count_requested: - type: integer - deliver_address_id: - type: integer - deliver_refer_date: - type: string + data: + $ref: '#/definitions/adminkindboxreqparam.Data' field_errors: additionalProperties: type: string type: object - kind_box_req_id: - type: integer - kind_box_req_status: - $ref: '#/definitions/entity.KindBoxReqStatus' type: object adminkindboxreqparam.KindBoxReqAddRequest: properties: @@ -316,18 +315,18 @@ definitions: type: object adminkindboxreqparam.KindBoxReqAddResponse: properties: + data: + $ref: '#/definitions/adminkindboxreqparam.Data' field_errors: additionalProperties: type: string type: object - kindBoxReq: - $ref: '#/definitions/entity.KindBoxReq' type: object adminkindboxreqparam.KindBoxReqGetAllResponse: properties: - all_awaiting_kind_box_req: + data: items: - $ref: '#/definitions/entity.KindBoxReq' + $ref: '#/definitions/adminkindboxreqparam.Data' type: array field_errors: additionalProperties: @@ -344,36 +343,12 @@ definitions: type: object adminkindboxreqparam.KindBoxReqRejectResponse: properties: - benefactor_id: - example: 1 - type: integer - count_requested: - example: 1 - type: integer - deliver_address_id: - example: 1 - type: integer - deliver_refer_date: - example: "2025-01-02 15:04:05" - type: string - description: - example: description - type: string + data: + $ref: '#/definitions/adminkindboxreqparam.Data' field_errors: additionalProperties: type: string type: object - id: - example: 1 - type: integer - kind_box_type: - allOf: - - $ref: '#/definitions/entity.KindBoxType' - example: on-table - status: - allOf: - - $ref: '#/definitions/entity.KindBoxReqStatus' - example: pending type: object adminkindboxreqparam.KindBoxReqUpdateRequest: properties: @@ -403,7 +378,7 @@ definitions: example: 1 type: integer type: object - adminserviceparam.AdminInfo: + adminserviceparam.Data: properties: description: example: This is a description @@ -447,8 +422,8 @@ definitions: type: object adminserviceparam.LoginWithPhoneNumberResponse: properties: - admin_info: - $ref: '#/definitions/adminserviceparam.AdminInfo' + data: + $ref: '#/definitions/adminserviceparam.Data' field_errors: additionalProperties: type: string @@ -491,8 +466,8 @@ definitions: type: object adminserviceparam.RegisterResponse: properties: - admin: - $ref: '#/definitions/entity.Admin' + data: + $ref: '#/definitions/adminserviceparam.Data' field_errors: additionalProperties: type: string @@ -505,11 +480,48 @@ definitions: refresh_token: type: string type: object + agentkindboxparam.Data: + properties: + amount: + type: integer + benefactor_id: + type: integer + deliver_address_id: + type: integer + deliver_refer_date: + type: string + deliver_refer_time_id: + type: integer + delivered_at: + type: string + id: + type: integer + kind_box_req_id: + type: integer + kind_box_type: + $ref: '#/definitions/entity.KindBoxType' + receiver_agent_id: + type: integer + return_address_id: + type: integer + return_refer_date: + type: string + return_refer_time_id: + type: integer + returned_at: + type: string + sender_agent_id: + type: integer + serial_number: + type: string + status: + $ref: '#/definitions/entity.KindBoxStatus' + type: object agentkindboxparam.GetAllResponse: properties: - all_kind_boxes: + data: items: - $ref: '#/definitions/entity.KindBox' + $ref: '#/definitions/agentkindboxparam.Data' type: array field_errors: additionalProperties: @@ -520,51 +532,19 @@ definitions: type: object agentkindboxparam.GetKindBoxResponse: properties: - amount: - type: integer - benefactorID: - type: integer - deliverAddressID: - type: integer - deliverReferDate: - type: string - deliverReferTimeID: - type: integer - deliveredAt: - type: string + data: + $ref: '#/definitions/agentkindboxparam.Data' field_errors: additionalProperties: type: string type: object - id: - type: integer - kindBoxReqID: - type: integer - kindBoxType: - $ref: '#/definitions/entity.KindBoxType' - receiverAgentID: - type: integer - returnAddressID: - type: integer - returnReferDate: - type: string - returnReferTimeID: - type: integer - returnedAt: - type: string - senderAgentID: - type: integer - serialNumber: - type: string - status: - $ref: '#/definitions/entity.KindBoxStatus' type: object agentkindboxparam.ReturnKindBoxRequest: properties: serial_number: type: string type: object - benefactoreparam.BenefactroInfo: + benefactoreparam.Data: properties: first_name: example: mehdi @@ -591,8 +571,8 @@ definitions: type: object benefactoreparam.LoginOrRegisterResponse: properties: - benefactore_info: - $ref: '#/definitions/benefactoreparam.BenefactroInfo' + data: + $ref: '#/definitions/benefactoreparam.Data' field_errors: additionalProperties: type: string @@ -626,11 +606,48 @@ definitions: refresh_token: type: string type: object + benefactorkindboxparam.Data: + properties: + amount: + type: integer + benefactor_id: + type: integer + deliver_address_id: + type: integer + deliver_refer_date: + type: string + deliver_refer_time_id: + type: integer + delivered_at: + type: string + id: + type: integer + kind_box_req_id: + type: integer + kind_box_type: + $ref: '#/definitions/entity.KindBoxType' + receiver_agent_id: + type: integer + return_address_id: + type: integer + return_refer_date: + type: string + return_refer_time_id: + type: integer + returned_at: + type: string + sender_agent_id: + type: integer + serial_number: + type: string + status: + $ref: '#/definitions/entity.KindBoxStatus' + type: object benefactorkindboxparam.KindBoxGetAllResponse: properties: - all_kind_box: + data: items: - $ref: '#/definitions/entity.KindBox' + $ref: '#/definitions/benefactorkindboxparam.Data' type: array field_errors: additionalProperties: @@ -641,44 +658,12 @@ definitions: type: object benefactorkindboxparam.KindBoxGetResponse: properties: - amount: - type: integer - benefactorID: - type: integer - deliverAddressID: - type: integer - deliverReferDate: - type: string - deliverReferTimeID: - type: integer - deliveredAt: - type: string + data: + $ref: '#/definitions/benefactorkindboxparam.Data' field_errors: additionalProperties: type: string type: object - id: - type: integer - kindBoxReqID: - type: integer - kindBoxType: - $ref: '#/definitions/entity.KindBoxType' - receiverAgentID: - type: integer - returnAddressID: - type: integer - returnReferDate: - type: string - returnReferTimeID: - type: integer - returnedAt: - type: string - senderAgentID: - type: integer - serialNumber: - type: string - status: - $ref: '#/definitions/entity.KindBoxStatus' type: object benefactorkindboxparam.KindBoxRegisterEmptyingRequest: properties: @@ -692,11 +677,38 @@ definitions: example: 1 type: integer type: object + benefactorkindboxreqparam.Data: + properties: + benefactor_id: + type: integer + count_accepted: + type: integer + count_requested: + type: integer + deliver_address_id: + type: integer + deliver_refer_date: + type: string + deliver_refer_time_id: + type: integer + delivered_at: + type: string + description: + type: string + id: + type: integer + kind_box_type: + $ref: '#/definitions/entity.KindBoxType' + sender_agent_id: + type: integer + status: + $ref: '#/definitions/entity.KindBoxReqStatus' + type: object benefactorkindboxreqparam.GetAllResponse: properties: - all_kind_box_req: + data: items: - $ref: '#/definitions/entity.KindBoxReq' + $ref: '#/definitions/benefactorkindboxreqparam.Data' type: array field_errors: additionalProperties: @@ -726,12 +738,12 @@ definitions: type: object benefactorkindboxreqparam.KindBoxReqAddResponse: properties: + data: + $ref: '#/definitions/benefactorkindboxreqparam.Data' field_errors: additionalProperties: type: string type: object - kind_box_req: - $ref: '#/definitions/entity.KindBoxReq' type: object benefactorkindboxreqparam.KindBoxReqDeleteResponse: properties: @@ -742,12 +754,12 @@ definitions: type: object benefactorkindboxreqparam.KindBoxReqGetResponse: properties: + data: + $ref: '#/definitions/benefactorkindboxreqparam.Data' field_errors: additionalProperties: type: string type: object - kind_box_req: - $ref: '#/definitions/entity.KindBoxReq' type: object benefactorkindboxreqparam.KindBoxReqUpdateRequest: properties: @@ -771,50 +783,6 @@ definitions: - $ref: '#/definitions/entity.KindBoxType' example: cylindrical type: object - entity.Address: - properties: - address: - type: string - benefactorID: - type: integer - cityID: - type: integer - id: - type: integer - lat: - type: number - lon: - type: number - name: - type: string - postalCode: - type: string - provinceID: - type: integer - type: object - entity.Admin: - properties: - description: - type: string - email: - type: string - firstName: - type: string - gender: - $ref: '#/definitions/entity.Gender' - id: - type: integer - lastName: - type: string - password: - type: string - phoneNumber: - type: string - role: - $ref: '#/definitions/entity.AdminRole' - status: - $ref: '#/definitions/entity.AdminStatus' - type: object entity.AdminRole: enum: - 1 @@ -850,70 +818,6 @@ definitions: x-enum-varnames: - MaleGender - FemaleGender - entity.KindBox: - properties: - amount: - type: integer - benefactorID: - type: integer - deliverAddressID: - type: integer - deliverReferDate: - type: string - deliverReferTimeID: - type: integer - deliveredAt: - type: string - id: - type: integer - kindBoxReqID: - type: integer - kindBoxType: - $ref: '#/definitions/entity.KindBoxType' - receiverAgentID: - type: integer - returnAddressID: - type: integer - returnReferDate: - type: string - returnReferTimeID: - type: integer - returnedAt: - type: string - senderAgentID: - type: integer - serialNumber: - type: string - status: - $ref: '#/definitions/entity.KindBoxStatus' - type: object - entity.KindBoxReq: - properties: - benefactorID: - type: integer - countAccepted: - type: integer - countRequested: - type: integer - deliverAddressID: - type: integer - deliverReferDate: - type: string - deliverReferTimeID: - type: integer - deliveredAt: - type: string - description: - type: string - id: - type: integer - kindBoxType: - $ref: '#/definitions/entity.KindBoxType' - senderAgentID: - type: integer - status: - $ref: '#/definitions/entity.KindBoxReqStatus' - type: object entity.KindBoxReqStatus: enum: - pending diff --git a/param/admin/admin/data.go b/param/admin/admin/data.go new file mode 100644 index 0000000..6dadd9a --- /dev/null +++ b/param/admin/admin/data.go @@ -0,0 +1,15 @@ +package adminserviceparam + +import "git.gocasts.ir/ebhomengo/niki/entity" + +type Data struct { + ID uint `json:"id" example:"1"` + FirstName string `json:"first_name" example:"John"` + LastName string `json:"last_name" example:"Doe"` + PhoneNumber string `json:"phone_number" example:"09123456789"` + Role entity.AdminRole `json:"role" example:"2"` + Description string `json:"description" example:"This is a description"` + Email string `json:"email" example:"example@gmail.com"` + Gender entity.Gender `json:"gender" example:"male"` + Status entity.AdminStatus `json:"status" example:"active"` +} diff --git a/param/admin/admin/login.go b/param/admin/admin/login.go index 3dc73ba..ab11f06 100644 --- a/param/admin/admin/login.go +++ b/param/admin/admin/login.go @@ -1,26 +1,12 @@ package adminserviceparam -import "git.gocasts.ir/ebhomengo/niki/entity" - type LoginWithPhoneNumberRequest struct { PhoneNumber string `json:"phone_number" example:"09123456789"` Password string `json:"password" example:"password123"` } type LoginWithPhoneNumberResponse struct { - AdminInfo AdminInfo `json:"admin_info"` + Data Data `json:"data"` Tokens Tokens `json:"tokens"` FieldErrors map[string]string `json:"field_errors,omitempty"` } - -type AdminInfo struct { - ID uint `json:"id" example:"1"` - FirstName string `json:"first_name" example:"John"` - LastName string `json:"last_name" example:"Doe"` - PhoneNumber string `json:"phone_number" example:"09123456789"` - Role entity.AdminRole `json:"role" example:"2"` - Description string `json:"description" example:"This is a description"` - Email string `json:"email" example:"example@gmail.com"` - Gender entity.Gender `json:"gender" example:"male"` - Status entity.AdminStatus `json:"status" example:"active"` -} diff --git a/param/admin/admin/register.go b/param/admin/admin/register.go index 7d53fc1..f5d52a7 100644 --- a/param/admin/admin/register.go +++ b/param/admin/admin/register.go @@ -15,6 +15,6 @@ type RegisterRequest struct { } type RegisterResponse struct { - Admin entity.Admin `json:"admin"` + Data Data `json:"data"` FieldErrors map[string]string `json:"field_errors,omitempty"` } diff --git a/param/admin/agent/get_all.go b/param/admin/agent/get_all.go index 4bed1af..d097780 100644 --- a/param/admin/agent/get_all.go +++ b/param/admin/agent/get_all.go @@ -1,10 +1,10 @@ package adminagentparam type GetAllAgentResponse struct { - Agents []Agent `json:"agents"` + Data []Data `json:"data"` } -type Agent struct { +type Data struct { ID uint `json:"id" example:"1"` FirstName string `json:"first_name" example:"John"` LastName string `json:"last_name" example:"Doe"` diff --git a/param/admin/kind_box/data.go b/param/admin/kind_box/data.go new file mode 100644 index 0000000..438e192 --- /dev/null +++ b/param/admin/kind_box/data.go @@ -0,0 +1,27 @@ +package adminkindboxparam + +import ( + "time" + + "git.gocasts.ir/ebhomengo/niki/entity" +) + +type Data struct { + ID uint `json:"id"` + KindBoxReqID uint `json:"kind_box_req_id"` + BenefactorID uint `json:"benefactor_id"` + KindBoxType entity.KindBoxType `json:"kind_box_type"` + Amount uint `json:"amount"` + SerialNumber string `json:"serial_number"` + Status entity.KindBoxStatus `json:"status"` + DeliverReferTimeID uint `json:"deliver_refer_time_id"` + DeliverReferDate time.Time `json:"deliver_refer_date"` + DeliverAddressID uint `json:"deliver_address_id"` + SenderAgentID uint `json:"sender_agent_id"` + DeliveredAt time.Time `json:"delivered_at"` + ReturnReferTimeID uint `json:"return_refer_time_id"` + ReturnReferDate time.Time `json:"return_refer_date"` + ReturnAddressID uint `json:"return_address_id"` + ReceiverAgentID uint `json:"receiver_agent_id"` + ReturnedAt time.Time `json:"returned_at"` +} diff --git a/param/admin/kind_box/get.go b/param/admin/kind_box/get.go index 07f12b4..ae6e1c1 100644 --- a/param/admin/kind_box/get.go +++ b/param/admin/kind_box/get.go @@ -1,12 +1,10 @@ package adminkindboxparam -import entity "git.gocasts.ir/ebhomengo/niki/entity" - type KindBoxGetRequest struct { KindBoxID uint `param:"id"` } type KindBoxGetResponse struct { - entity.KindBox + Data Data `json:"data"` FieldErrors map[string]string `json:"field_errors,omitempty"` } diff --git a/param/admin/kind_box/get_all.go b/param/admin/kind_box/get_all.go index a7a7731..c020206 100644 --- a/param/admin/kind_box/get_all.go +++ b/param/admin/kind_box/get_all.go @@ -1,7 +1,6 @@ package adminkindboxparam import ( - "git.gocasts.ir/ebhomengo/niki/entity" "git.gocasts.ir/ebhomengo/niki/param" ) @@ -12,7 +11,7 @@ type KindBoxGetAllRequest struct { } type KindBoxGetAllResponse struct { - AllKindBox []entity.KindBox `json:"all_kind_box"` + Data []Data `json:"data"` Pagination param.PaginationResponse `json:"pagination"` FieldErrors map[string]string `json:"field_errors,omitempty"` } diff --git a/param/admin/kind_box_req/accept.go b/param/admin/kind_box_req/accept.go index dd09a60..f2895c9 100644 --- a/param/admin/kind_box_req/accept.go +++ b/param/admin/kind_box_req/accept.go @@ -1,22 +1,11 @@ package adminkindboxreqparam -import ( - "time" - - "git.gocasts.ir/ebhomengo/niki/entity" -) - type KindBoxReqAcceptRequest struct { ID uint `json:"-"` CountAccepted uint `json:"count_accepted"` } type KindBoxReqAcceptResponse struct { - KindBoxReqID uint `json:"kind_box_req_id"` - KindBoxReqStatus entity.KindBoxReqStatus `json:"kind_box_req_status"` - CountRequested uint `json:"count_requested"` - CountAccepted uint `json:"count_accepted"` - DeliverReferDate time.Time `json:"deliver_refer_date"` - DeliverAddressID uint `json:"deliver_address_id"` - FieldErrors map[string]string `json:"field_errors,omitempty"` + Data Data `json:"data"` + FieldErrors map[string]string `json:"field_errors,omitempty"` } diff --git a/param/admin/kind_box_req/add.go b/param/admin/kind_box_req/add.go index 4594c52..42db343 100644 --- a/param/admin/kind_box_req/add.go +++ b/param/admin/kind_box_req/add.go @@ -11,6 +11,6 @@ type KindBoxReqAddRequest struct { } type KindBoxReqAddResponse struct { - KindBoxReq entity.KindBoxReq + Data Data `json:"data"` FieldErrors map[string]string `json:"field_errors,omitempty"` } diff --git a/param/admin/kind_box_req/data.go b/param/admin/kind_box_req/data.go new file mode 100644 index 0000000..2a4008c --- /dev/null +++ b/param/admin/kind_box_req/data.go @@ -0,0 +1,22 @@ +package adminkindboxreqparam + +import ( + "time" + + "git.gocasts.ir/ebhomengo/niki/entity" +) + +type Data struct { + ID uint `json:"id"` + BenefactorID uint `json:"benefactor_id"` + KindBoxType entity.KindBoxType `json:"kind_box_type"` + CountRequested uint `json:"count_requested"` + CountAccepted uint `json:"count_accepted"` + Description string `json:"description"` + Status entity.KindBoxReqStatus `json:"status"` + DeliverReferTimeID uint `json:"deliver_refer_time_id"` + DeliverReferDate time.Time `json:"deliver_refer_date"` + DeliverAddressID uint `json:"deliver_address_id"` + SenderAgentID uint `json:"sender_agent_id"` + DeliveredAt time.Time `json:"delivered_at"` +} diff --git a/param/admin/kind_box_req/get.go b/param/admin/kind_box_req/get.go index 19d1294..1c27188 100644 --- a/param/admin/kind_box_req/get.go +++ b/param/admin/kind_box_req/get.go @@ -1,12 +1,10 @@ package adminkindboxreqparam -import "git.gocasts.ir/ebhomengo/niki/entity" - type GetKindBoxReqRequest struct { KindBoxID uint `param:"id"` } type GetKindBoxReqResponse struct { - entity.KindBoxReq + Data Data `json:"data"` FieldErrors map[string]string `json:"field_errors,omitempty"` } diff --git a/param/admin/kind_box_req/get_all.go b/param/admin/kind_box_req/get_all.go index 461f48a..80c855d 100644 --- a/param/admin/kind_box_req/get_all.go +++ b/param/admin/kind_box_req/get_all.go @@ -1,7 +1,6 @@ package adminkindboxreqparam import ( - "git.gocasts.ir/ebhomengo/niki/entity" "git.gocasts.ir/ebhomengo/niki/param" ) @@ -12,7 +11,7 @@ type KindBoxReqGetAllRequest struct { } type KindBoxReqGetAllResponse struct { - AllKindBoxReq []entity.KindBoxReq `json:"all_awaiting_kind_box_req"` - Pagination param.PaginationResponse `json:"pagination"` - FieldErrors map[string]string `json:"field_errors,omitempty"` + Data []Data `json:"data"` + Pagination param.PaginationResponse `json:"pagination"` + FieldErrors map[string]string `json:"field_errors,omitempty"` } diff --git a/param/admin/kind_box_req/get_all_delivery_awaiting.go b/param/admin/kind_box_req/get_all_delivery_awaiting.go index 90a43ff..aa11285 100644 --- a/param/admin/kind_box_req/get_all_delivery_awaiting.go +++ b/param/admin/kind_box_req/get_all_delivery_awaiting.go @@ -1,7 +1,6 @@ package adminkindboxreqparam import ( - "git.gocasts.ir/ebhomengo/niki/entity" "git.gocasts.ir/ebhomengo/niki/param" ) @@ -12,7 +11,7 @@ type DeliveryAwaitingGetAllRequest struct { } type DeliveryAwaitingGetAllResponse struct { - AllAwaitingKindBoxReq []entity.KindBoxReq `json:"all_awaiting_kind_box_req"` - Pagination param.PaginationResponse `json:"pagination"` - FieldErrors map[string]string `json:"field_errors,omitempty"` + Data []Data `json:"data"` + Pagination param.PaginationResponse `json:"pagination"` + FieldErrors map[string]string `json:"field_errors,omitempty"` } diff --git a/param/admin/kind_box_req/get_delivery_awaiting.go b/param/admin/kind_box_req/get_delivery_awaiting.go index 7456c40..2569285 100644 --- a/param/admin/kind_box_req/get_delivery_awaiting.go +++ b/param/admin/kind_box_req/get_delivery_awaiting.go @@ -1,13 +1,11 @@ package adminkindboxreqparam -import "git.gocasts.ir/ebhomengo/niki/entity" - type DeliveryAwaitingGetRequest struct { KindBoxReqID uint `param:"id"` AgentID uint } type DeliveryAwaitingGetResponse struct { - entity.KindBoxReq + Data Data `json:"data"` FieldErrors map[string]string `json:"field_errors,omitempty"` } diff --git a/param/admin/kind_box_req/reject.go b/param/admin/kind_box_req/reject.go index 719eb6a..1ffe172 100644 --- a/param/admin/kind_box_req/reject.go +++ b/param/admin/kind_box_req/reject.go @@ -1,24 +1,11 @@ package adminkindboxreqparam -import ( - "time" - - "git.gocasts.ir/ebhomengo/niki/entity" -) - type KindBoxReqRejectRequest struct { ID uint `json:"-"` Description string `json:"description" example:"description"` } type KindBoxReqRejectResponse struct { - ID uint `json:"id" example:"1"` - KindBoxType entity.KindBoxType `json:"kind_box_type" example:"on-table"` - CountRequested uint `json:"count_requested" example:"1"` - BenefactorID uint `json:"benefactor_id" example:"1"` - Status entity.KindBoxReqStatus `json:"status" example:"pending"` - Description string `json:"description" example:"description"` - DeliverReferDate time.Time `json:"deliver_refer_date" example:"2025-01-02 15:04:05"` - DeliverAddressID uint `json:"deliver_address_id" example:"1"` - FieldErrors map[string]string `json:"field_errors,omitempty"` + Data Data `json:"data"` + FieldErrors map[string]string `json:"field_errors,omitempty"` } diff --git a/param/agent/kind_box/data.go b/param/agent/kind_box/data.go new file mode 100644 index 0000000..55c6a2c --- /dev/null +++ b/param/agent/kind_box/data.go @@ -0,0 +1,27 @@ +package agentkindboxparam + +import ( + "time" + + "git.gocasts.ir/ebhomengo/niki/entity" +) + +type Data struct { + ID uint `json:"id"` + KindBoxReqID uint `json:"kind_box_req_id"` + BenefactorID uint `json:"benefactor_id"` + KindBoxType entity.KindBoxType `json:"kind_box_type"` + Amount uint `json:"amount"` + SerialNumber string `json:"serial_number"` + Status entity.KindBoxStatus `json:"status"` + DeliverReferTimeID uint `json:"deliver_refer_time_id"` + DeliverReferDate time.Time `json:"deliver_refer_date"` + DeliverAddressID uint `json:"deliver_address_id"` + SenderAgentID uint `json:"sender_agent_id"` + DeliveredAt time.Time `json:"delivered_at"` + ReturnReferTimeID uint `json:"return_refer_time_id"` + ReturnReferDate time.Time `json:"return_refer_date"` + ReturnAddressID uint `json:"return_address_id"` + ReceiverAgentID uint `json:"receiver_agent_id"` + ReturnedAt time.Time `json:"returned_at"` +} diff --git a/param/agent/kind_box/get.go b/param/agent/kind_box/get.go index 2467970..5f740d8 100644 --- a/param/agent/kind_box/get.go +++ b/param/agent/kind_box/get.go @@ -1,13 +1,11 @@ package agentkindboxparam -import "git.gocasts.ir/ebhomengo/niki/entity" - type GetKindBoxRequest struct { KindBoxID uint `param:"id"` AgentID uint } type GetKindBoxResponse struct { - entity.KindBox + Data Data `json:"data"` FieldErrors map[string]string `json:"field_errors,omitempty"` } diff --git a/param/agent/kind_box/get_all.go b/param/agent/kind_box/get_all.go index 7c22dd8..cc91b1d 100644 --- a/param/agent/kind_box/get_all.go +++ b/param/agent/kind_box/get_all.go @@ -1,7 +1,6 @@ package agentkindboxparam import ( - "git.gocasts.ir/ebhomengo/niki/entity" "git.gocasts.ir/ebhomengo/niki/param" ) @@ -12,7 +11,7 @@ type GetAllRequest struct { } type GetAllResponse struct { - AllKindBoxes []entity.KindBox `json:"all_kind_boxes"` - Pagination param.PaginationResponse `json:"pagination"` - FieldErrors map[string]string `json:"field_errors,omitempty"` + Data []Data `json:"data"` + Pagination param.PaginationResponse `json:"pagination"` + FieldErrors map[string]string `json:"field_errors,omitempty"` } diff --git a/param/benefactor/address/add.go b/param/benefactor/address/add.go index 288f2fa..8689a55 100644 --- a/param/benefactor/address/add.go +++ b/param/benefactor/address/add.go @@ -1,7 +1,5 @@ package addressparam -import "git.gocasts.ir/ebhomengo/niki/entity" - type BenefactorAddAddressRequest struct { PostalCode string `json:"postal_code" example:"1234567890"` Address string `json:"address" example:"tehran"` @@ -13,6 +11,6 @@ type BenefactorAddAddressRequest struct { } type BenefactorAddAddressResponse struct { - Address entity.Address `json:"address"` + Data Data `json:"data"` FieldErrors map[string]string `json:"field_errors,omitempty"` } diff --git a/param/benefactor/address/data.go b/param/benefactor/address/data.go new file mode 100644 index 0000000..e85e8c5 --- /dev/null +++ b/param/benefactor/address/data.go @@ -0,0 +1,13 @@ +package addressparam + +type Data struct { + ID uint `json:"id"` + PostalCode string `json:"postal_code"` + Address string `json:"address"` + Name string `json:"name"` + Lat float64 `json:"lat"` + Lon float64 `json:"lon"` + CityID uint `json:"city_id"` + ProvinceID uint `json:"province_id"` + BenefactorID uint `json:"benefactor_id"` +} diff --git a/param/benefactor/address/get.go b/param/benefactor/address/get.go index b1d439e..5b999b7 100644 --- a/param/benefactor/address/get.go +++ b/param/benefactor/address/get.go @@ -14,6 +14,6 @@ type GetAddressRequest struct { AddressID uint } type GetAddressResponse struct { - Address entity.Address `json:"address"` + Data Data `json:"data"` FieldErrors map[string]string `json:"field_errors,omitempty"` } diff --git a/param/benefactor/address/get_all.go b/param/benefactor/address/get_all.go index 580e258..4f1dc38 100644 --- a/param/benefactor/address/get_all.go +++ b/param/benefactor/address/get_all.go @@ -1,11 +1,9 @@ package addressparam -import "git.gocasts.ir/ebhomengo/niki/entity" - type GetAllAddressesRequest struct { BenefactorID uint } type GetAllAddressesResponse struct { - AllAddresses []entity.Address `json:"all_addresses"` + Data []Data `json:"data"` } diff --git a/param/benefactor/address/get_all_cities.go b/param/benefactor/address/get_all_cities.go index 56a6f59..5a97c93 100644 --- a/param/benefactor/address/get_all_cities.go +++ b/param/benefactor/address/get_all_cities.go @@ -2,9 +2,8 @@ package addressparam import "git.gocasts.ir/ebhomengo/niki/entity" -type ( - GetAllCitiesRequest struct{} - GetAllCitiesResponse struct { - Cities []entity.City `json:"cities"` - } -) +type GetAllCitiesRequest struct{} + +type GetAllCitiesResponse struct { + Data []entity.City `json:"data"` +} diff --git a/param/benefactor/address/get_all_provinces.go b/param/benefactor/address/get_all_provinces.go index 4963bd6..460982f 100644 --- a/param/benefactor/address/get_all_provinces.go +++ b/param/benefactor/address/get_all_provinces.go @@ -2,9 +2,8 @@ package addressparam import "git.gocasts.ir/ebhomengo/niki/entity" -type ( - GetAllProvincesRequest struct{} - GetAllProvincesResponse struct { - Provinces []entity.Province `json:"provinces"` - } -) +type GetAllProvincesRequest struct{} + +type GetAllProvincesResponse struct { + Data []entity.Province `json:"data"` +} diff --git a/param/benefactor/benefactor/info.go b/param/benefactor/benefactor/data.go similarity index 91% rename from param/benefactor/benefactor/info.go rename to param/benefactor/benefactor/data.go index 8251550..37be49f 100644 --- a/param/benefactor/benefactor/info.go +++ b/param/benefactor/benefactor/data.go @@ -2,7 +2,7 @@ package benefactoreparam import "git.gocasts.ir/ebhomengo/niki/entity" -type BenefactroInfo struct { +type Data struct { ID uint `json:"id" example:"1"` FirstName string `json:"first_name" example:"mehdi"` LastName string `json:"last_name" example:"rez"` diff --git a/param/benefactor/benefactor/login_register.go b/param/benefactor/benefactor/login_register.go index a898987..f1ceaa5 100644 --- a/param/benefactor/benefactor/login_register.go +++ b/param/benefactor/benefactor/login_register.go @@ -6,7 +6,7 @@ type LoginOrRegisterRequest struct { } type LoginOrRegisterResponse struct { - BenefactorInfo BenefactroInfo `json:"benefactore_info"` - Tokens Tokens `json:"tokens"` - FieldErrors map[string]string `json:"field_errors,omitempty"` + Data Data `json:"data"` + Tokens Tokens `json:"tokens"` + FieldErrors map[string]string `json:"field_errors,omitempty"` } diff --git a/param/benefactor/kind_box/data.go b/param/benefactor/kind_box/data.go new file mode 100644 index 0000000..ab44196 --- /dev/null +++ b/param/benefactor/kind_box/data.go @@ -0,0 +1,27 @@ +package benefactorkindboxparam + +import ( + "time" + + "git.gocasts.ir/ebhomengo/niki/entity" +) + +type Data struct { + ID uint `json:"id"` + KindBoxReqID uint `json:"kind_box_req_id"` + BenefactorID uint `json:"benefactor_id"` + KindBoxType entity.KindBoxType `json:"kind_box_type"` + Amount uint `json:"amount"` + SerialNumber string `json:"serial_number"` + Status entity.KindBoxStatus `json:"status"` + DeliverReferTimeID uint `json:"deliver_refer_time_id"` + DeliverReferDate time.Time `json:"deliver_refer_date"` + DeliverAddressID uint `json:"deliver_address_id"` + SenderAgentID uint `json:"sender_agent_id"` + DeliveredAt time.Time `json:"delivered_at"` + ReturnReferTimeID uint `json:"return_refer_time_id"` + ReturnReferDate time.Time `json:"return_refer_date"` + ReturnAddressID uint `json:"return_address_id"` + ReceiverAgentID uint `json:"receiver_agent_id"` + ReturnedAt time.Time `json:"returned_at"` +} diff --git a/param/benefactor/kind_box/get.go b/param/benefactor/kind_box/get.go index f6c5b61..c85cf4e 100644 --- a/param/benefactor/kind_box/get.go +++ b/param/benefactor/kind_box/get.go @@ -1,13 +1,11 @@ package benefactorkindboxparam -import entity "git.gocasts.ir/ebhomengo/niki/entity" - type KindBoxGetRequest struct { BenefactorID uint KindBoxID uint } type KindBoxGetResponse struct { - entity.KindBox + Data Data `json:"data"` FieldErrors map[string]string `json:"field_errors,omitempty"` } diff --git a/param/benefactor/kind_box/get_all.go b/param/benefactor/kind_box/get_all.go index 9048d3d..54b5ae7 100644 --- a/param/benefactor/kind_box/get_all.go +++ b/param/benefactor/kind_box/get_all.go @@ -1,7 +1,6 @@ package benefactorkindboxparam import ( - "git.gocasts.ir/ebhomengo/niki/entity" "git.gocasts.ir/ebhomengo/niki/param" ) @@ -12,7 +11,7 @@ type KindBoxGetAllRequest struct { } type KindBoxGetAllResponse struct { - AllKindBox []entity.KindBox `json:"all_kind_box"` + Data []Data `json:"data"` Pagination param.PaginationResponse `json:"pagination"` FieldErrors map[string]string `json:"field_errors,omitempty"` } diff --git a/param/benefactor/kind_box/register_emptying_request.go b/param/benefactor/kind_box/register_emptying_request.go index 473fff7..3dc4b03 100644 --- a/param/benefactor/kind_box/register_emptying_request.go +++ b/param/benefactor/kind_box/register_emptying_request.go @@ -2,8 +2,6 @@ package benefactorkindboxparam import ( "time" - - "git.gocasts.ir/ebhomengo/niki/entity" ) type KindBoxRegisterEmptyingRequest struct { @@ -15,6 +13,6 @@ type KindBoxRegisterEmptyingRequest struct { } type KindBoxRegisterEmptyingRequestResponse struct { - entity.KindBox `json:"kind_box"` - FieldErrors map[string]string `json:"field_errors,omitempty"` + Data Data `json:"data"` + FieldErrors map[string]string `json:"field_errors,omitempty"` } diff --git a/param/benefactor/kind_box_req/add.go b/param/benefactor/kind_box_req/add.go index 86d1c3a..e32dd09 100644 --- a/param/benefactor/kind_box_req/add.go +++ b/param/benefactor/kind_box_req/add.go @@ -16,6 +16,6 @@ type KindBoxReqAddRequest struct { } type KindBoxReqAddResponse struct { - KindBoxReq entity.KindBoxReq `json:"kind_box_req"` + Data Data `json:"data"` FieldErrors map[string]string `json:"field_errors,omitempty"` } diff --git a/param/benefactor/kind_box_req/data.go b/param/benefactor/kind_box_req/data.go new file mode 100644 index 0000000..8d3aace --- /dev/null +++ b/param/benefactor/kind_box_req/data.go @@ -0,0 +1,22 @@ +package benefactorkindboxreqparam + +import ( + "time" + + "git.gocasts.ir/ebhomengo/niki/entity" +) + +type Data struct { + ID uint `json:"id"` + BenefactorID uint `json:"benefactor_id"` + KindBoxType entity.KindBoxType `json:"kind_box_type"` + CountRequested uint `json:"count_requested"` + CountAccepted uint `json:"count_accepted"` + Description string `json:"description"` + Status entity.KindBoxReqStatus `json:"status"` + DeliverReferTimeID uint `json:"deliver_refer_time_id"` + DeliverReferDate time.Time `json:"deliver_refer_date"` + DeliverAddressID uint `json:"deliver_address_id"` + SenderAgentID uint `json:"sender_agent_id"` + DeliveredAt time.Time `json:"delivered_at"` +} diff --git a/param/benefactor/kind_box_req/get.go b/param/benefactor/kind_box_req/get.go index e6e2f25..eb1b115 100644 --- a/param/benefactor/kind_box_req/get.go +++ b/param/benefactor/kind_box_req/get.go @@ -1,13 +1,11 @@ package benefactorkindboxreqparam -import entity "git.gocasts.ir/ebhomengo/niki/entity" - type KindBoxReqGetRequest struct { BenefactorID uint KindBoxReqID uint } type KindBoxReqGetResponse struct { - entity.KindBoxReq `json:"kind_box_req"` - FieldErrors map[string]string `json:"field_errors,omitempty"` + Data Data `json:"data"` + FieldErrors map[string]string `json:"field_errors,omitempty"` } diff --git a/param/benefactor/kind_box_req/get_all.go b/param/benefactor/kind_box_req/get_all.go index 1af9680..b99bb82 100644 --- a/param/benefactor/kind_box_req/get_all.go +++ b/param/benefactor/kind_box_req/get_all.go @@ -1,7 +1,6 @@ package benefactorkindboxreqparam import ( - "git.gocasts.ir/ebhomengo/niki/entity" "git.gocasts.ir/ebhomengo/niki/param" ) @@ -12,7 +11,7 @@ type GetAllRequest struct { } type GetAllResponse struct { - AllKindBoxReq []entity.KindBoxReq `json:"all_kind_box_req"` - Pagination param.PaginationResponse `json:"pagination"` - FieldErrors map[string]string `json:"field_errors,omitempty"` + Data []Data `json:"data"` + Pagination param.PaginationResponse `json:"pagination"` + FieldErrors map[string]string `json:"field_errors,omitempty"` } diff --git a/pkg/supervisor/supervisor.go b/pkg/supervisor/supervisor.go index 3eeaab7..1933efa 100644 --- a/pkg/supervisor/supervisor.go +++ b/pkg/supervisor/supervisor.go @@ -284,7 +284,7 @@ func (s *Supervisor) retryCount(name string) int { return v.options.RetryCount } -//nolint +// nolint func (s *Supervisor) retryInterval(name string) time.Duration { s.lock.Lock() defer s.lock.Unlock() diff --git a/repository/mysql/kind_box/add.go b/repository/mysql/kind_box/add.go index 1c37997..5c5d77c 100644 --- a/repository/mysql/kind_box/add.go +++ b/repository/mysql/kind_box/add.go @@ -3,6 +3,7 @@ package mysqlkindbox import ( "context" "database/sql" + "git.gocasts.ir/ebhomengo/niki/entity" errmsg "git.gocasts.ir/ebhomengo/niki/pkg/err_msg" querytransaction "git.gocasts.ir/ebhomengo/niki/pkg/query_transaction/sql" diff --git a/service/admin/admin/login.go b/service/admin/admin/login.go index 28d290e..6422d60 100644 --- a/service/admin/admin/login.go +++ b/service/admin/admin/login.go @@ -37,7 +37,7 @@ func (s Service) LoginWithPhoneNumber(ctx context.Context, req adminserviceparam } return adminserviceparam.LoginWithPhoneNumberResponse{ - AdminInfo: adminserviceparam.AdminInfo{ + Data: adminserviceparam.Data{ ID: admin.ID, FirstName: admin.FirstName, LastName: admin.LastName, diff --git a/service/admin/admin/register.go b/service/admin/admin/register.go index 8f7ec29..7b027c3 100644 --- a/service/admin/admin/register.go +++ b/service/admin/admin/register.go @@ -50,5 +50,15 @@ func (s Service) Register(ctx context.Context, req adminserviceparam.RegisterReq return adminserviceparam.RegisterResponse{}, richerror.New(op).WithErr(err).WithKind(richerror.KindUnexpected) } - return adminserviceparam.RegisterResponse{Admin: admin}, err + return adminserviceparam.RegisterResponse{Data: adminserviceparam.Data{ + ID: admin.ID, + FirstName: admin.FirstName, + LastName: admin.LastName, + PhoneNumber: admin.PhoneNumber, + Role: admin.Role, + Description: admin.Description, + Email: admin.Email, + Gender: admin.Gender, + Status: admin.Status, + }}, err } diff --git a/service/admin/agent/get_all.go b/service/admin/agent/get_all.go index 5dcfa16..6e750a2 100644 --- a/service/admin/agent/get_all.go +++ b/service/admin/agent/get_all.go @@ -10,7 +10,7 @@ import ( func (s Service) GetAllAgent(ctx context.Context) (param.GetAllAgentResponse, error) { const op = "adminagentservice.GetAllAgent" - agentsInfo := make([]param.Agent, 0) + agentsInfo := make([]param.Data, 0) agents, err := s.repo.GetAllAgent(ctx) if err != nil { @@ -18,7 +18,7 @@ func (s Service) GetAllAgent(ctx context.Context) (param.GetAllAgentResponse, er } for _, agent := range agents { - agentsInfo = append(agentsInfo, param.Agent{ + agentsInfo = append(agentsInfo, param.Data{ ID: agent.ID, FirstName: agent.FirstName, LastName: agent.LastName, @@ -26,5 +26,5 @@ func (s Service) GetAllAgent(ctx context.Context) (param.GetAllAgentResponse, er }) } - return param.GetAllAgentResponse{Agents: agentsInfo}, nil + return param.GetAllAgentResponse{Data: agentsInfo}, nil } diff --git a/service/admin/kind_box/get.go b/service/admin/kind_box/get.go index a9ae7f1..0348ac9 100644 --- a/service/admin/kind_box/get.go +++ b/service/admin/kind_box/get.go @@ -17,5 +17,23 @@ func (s Service) Get(ctx context.Context, req param.KindBoxGetRequest) (param.Ki return param.KindBoxGetResponse{}, richerror.New(op).WithErr(err) } - return param.KindBoxGetResponse{KindBox: kindBox}, nil + return param.KindBoxGetResponse{Data: param.Data{ + ID: kindBox.ID, + KindBoxReqID: kindBox.KindBoxReqID, + BenefactorID: kindBox.BenefactorID, + KindBoxType: kindBox.KindBoxType, + Amount: kindBox.Amount, + SerialNumber: kindBox.SerialNumber, + Status: kindBox.Status, + DeliverReferTimeID: kindBox.DeliverReferTimeID, + DeliverReferDate: kindBox.DeliverReferDate, + DeliverAddressID: kindBox.DeliverAddressID, + SenderAgentID: kindBox.SenderAgentID, + DeliveredAt: kindBox.DeliveredAt, + ReturnReferTimeID: kindBox.ReturnReferTimeID, + ReturnReferDate: kindBox.ReturnReferDate, + ReturnAddressID: kindBox.ReturnAddressID, + ReceiverAgentID: kindBox.ReceiverAgentID, + ReturnedAt: kindBox.ReturnedAt, + }}, nil } diff --git a/service/admin/kind_box/get_all.go b/service/admin/kind_box/get_all.go index 085a60b..e4505d9 100644 --- a/service/admin/kind_box/get_all.go +++ b/service/admin/kind_box/get_all.go @@ -10,6 +10,7 @@ import ( func (s Service) GetAll(ctx context.Context, req param.KindBoxGetAllRequest) (param.KindBoxGetAllResponse, error) { const op = "adminkindboxservice.GetAll" + if fieldErrors, vErr := s.vld.ValidateGetAll(req); vErr != nil { return param.KindBoxGetAllResponse{FieldErrors: fieldErrors}, richerror.New(op).WithErr(vErr) } @@ -18,8 +19,31 @@ func (s Service) GetAll(ctx context.Context, req param.KindBoxGetAllRequest) (pa return param.KindBoxGetAllResponse{}, richerror.New(op).WithErr(err) } + var data []param.Data + for _, kindBox := range allKindBox { + data = append(data, param.Data{ + ID: kindBox.ID, + KindBoxReqID: kindBox.KindBoxReqID, + BenefactorID: kindBox.BenefactorID, + KindBoxType: kindBox.KindBoxType, + Amount: kindBox.Amount, + SerialNumber: kindBox.SerialNumber, + Status: kindBox.Status, + DeliverReferTimeID: kindBox.DeliverReferTimeID, + DeliverReferDate: kindBox.DeliverReferDate, + DeliverAddressID: kindBox.DeliverAddressID, + SenderAgentID: kindBox.SenderAgentID, + DeliveredAt: kindBox.DeliveredAt, + ReturnReferTimeID: kindBox.ReturnReferTimeID, + ReturnReferDate: kindBox.ReturnReferDate, + ReturnAddressID: kindBox.ReturnAddressID, + ReceiverAgentID: kindBox.ReceiverAgentID, + ReturnedAt: kindBox.ReturnedAt, + }) + } + return param.KindBoxGetAllResponse{ - AllKindBox: allKindBox, + Data: data, Pagination: paginationparam.PaginationResponse{ PageSize: req.Pagination.GetPageSize(), PageNumber: req.Pagination.GetPageNumber(), diff --git a/service/admin/kind_box_req/accept.go b/service/admin/kind_box_req/accept.go index ce638e5..dcbd278 100644 --- a/service/admin/kind_box_req/accept.go +++ b/service/admin/kind_box_req/accept.go @@ -27,12 +27,18 @@ func (s Service) Accept(ctx context.Context, req param.KindBoxReqAcceptRequest) return param.KindBoxReqAcceptResponse{}, richerror.New(op).WithErr(gErr) } - return param.KindBoxReqAcceptResponse{ - KindBoxReqID: kindBoxReq.ID, - KindBoxReqStatus: kindBoxReq.Status, - CountRequested: kindBoxReq.CountRequested, - CountAccepted: kindBoxReq.CountAccepted, - DeliverReferDate: kindBoxReq.DeliverReferDate, - DeliverAddressID: kindBoxReq.DeliverAddressID, - }, nil + return param.KindBoxReqAcceptResponse{Data: param.Data{ + ID: kindBoxReq.ID, + BenefactorID: kindBoxReq.BenefactorID, + KindBoxType: kindBoxReq.KindBoxType, + CountRequested: kindBoxReq.CountRequested, + CountAccepted: kindBoxReq.CountAccepted, + Description: kindBoxReq.Description, + Status: kindBoxReq.Status, + DeliverReferTimeID: kindBoxReq.DeliverReferTimeID, + DeliverReferDate: kindBoxReq.DeliverReferDate, + DeliverAddressID: kindBoxReq.DeliverAddressID, + SenderAgentID: kindBoxReq.SenderAgentID, + DeliveredAt: kindBoxReq.DeliveredAt, + }}, nil } diff --git a/service/admin/kind_box_req/add.go b/service/admin/kind_box_req/add.go index bc71941..1d856aa 100644 --- a/service/admin/kind_box_req/add.go +++ b/service/admin/kind_box_req/add.go @@ -30,5 +30,18 @@ func (s Service) Add(ctx context.Context, req param.KindBoxReqAddRequest) (param return param.KindBoxReqAddResponse{}, richerror.New(op).WithErr(err).WithKind(richerror.KindUnexpected) } - return param.KindBoxReqAddResponse{KindBoxReq: kindBoxReq}, nil + return param.KindBoxReqAddResponse{Data: param.Data{ + ID: kindBoxReq.ID, + BenefactorID: kindBoxReq.BenefactorID, + KindBoxType: kindBoxReq.KindBoxType, + CountRequested: kindBoxReq.CountRequested, + CountAccepted: kindBoxReq.CountAccepted, + Description: kindBoxReq.Description, + Status: kindBoxReq.Status, + DeliverReferTimeID: kindBoxReq.DeliverReferTimeID, + DeliverReferDate: kindBoxReq.DeliverReferDate, + DeliverAddressID: kindBoxReq.DeliverAddressID, + SenderAgentID: kindBoxReq.SenderAgentID, + DeliveredAt: kindBoxReq.DeliveredAt, + }}, nil } diff --git a/service/admin/kind_box_req/get.go b/service/admin/kind_box_req/get.go index eddeb1c..14e81d4 100644 --- a/service/admin/kind_box_req/get.go +++ b/service/admin/kind_box_req/get.go @@ -18,6 +18,19 @@ func (s Service) Get(ctx context.Context, req param.GetKindBoxReqRequest) (param } return param.GetKindBoxReqResponse{ - KindBoxReq: kindBoxReq, + Data: param.Data{ + ID: kindBoxReq.ID, + BenefactorID: kindBoxReq.BenefactorID, + KindBoxType: kindBoxReq.KindBoxType, + CountRequested: kindBoxReq.CountRequested, + CountAccepted: kindBoxReq.CountAccepted, + Description: kindBoxReq.Description, + Status: kindBoxReq.Status, + DeliverReferTimeID: kindBoxReq.DeliverReferTimeID, + DeliverReferDate: kindBoxReq.DeliverReferDate, + DeliverAddressID: kindBoxReq.DeliverAddressID, + SenderAgentID: kindBoxReq.SenderAgentID, + DeliveredAt: kindBoxReq.DeliveredAt, + }, }, nil } diff --git a/service/admin/kind_box_req/get_all.go b/service/admin/kind_box_req/get_all.go index b0071ee..f09d4e5 100644 --- a/service/admin/kind_box_req/get_all.go +++ b/service/admin/kind_box_req/get_all.go @@ -18,9 +18,26 @@ func (s Service) GetAll(ctx context.Context, req param.KindBoxReqGetAllRequest) if err != nil { return param.KindBoxReqGetAllResponse{}, richerror.New(op).WithErr(err).WithKind(richerror.KindUnexpected) } + var data []param.Data + for _, kindBoxReq := range allKindBoxReq { + data = append(data, param.Data{ + ID: kindBoxReq.ID, + BenefactorID: kindBoxReq.BenefactorID, + KindBoxType: kindBoxReq.KindBoxType, + CountRequested: kindBoxReq.CountRequested, + CountAccepted: kindBoxReq.CountAccepted, + Description: kindBoxReq.Description, + Status: kindBoxReq.Status, + DeliverReferTimeID: kindBoxReq.DeliverReferTimeID, + DeliverReferDate: kindBoxReq.DeliverReferDate, + DeliverAddressID: kindBoxReq.DeliverAddressID, + SenderAgentID: kindBoxReq.SenderAgentID, + DeliveredAt: kindBoxReq.DeliveredAt, + }) + } return param.KindBoxReqGetAllResponse{ - AllKindBoxReq: allKindBoxReq, + Data: data, Pagination: paginationparam.PaginationResponse{ PageSize: req.Pagination.GetPageSize(), PageNumber: req.Pagination.GetPageNumber(), diff --git a/service/admin/kind_box_req/get_all_delivery_awaiting.go b/service/admin/kind_box_req/get_all_delivery_awaiting.go index 59114c4..732e0d2 100644 --- a/service/admin/kind_box_req/get_all_delivery_awaiting.go +++ b/service/admin/kind_box_req/get_all_delivery_awaiting.go @@ -19,9 +19,26 @@ func (s Service) GetAllAwaitingDelivery(ctx context.Context, req param.DeliveryA if err != nil { return param.DeliveryAwaitingGetAllResponse{}, richerror.New(op).WithErr(err) } + var data []param.Data + for _, kindBoxReq := range allAwaitingKindBoxReq { + data = append(data, param.Data{ + ID: kindBoxReq.ID, + BenefactorID: kindBoxReq.BenefactorID, + KindBoxType: kindBoxReq.KindBoxType, + CountRequested: kindBoxReq.CountRequested, + CountAccepted: kindBoxReq.CountAccepted, + Description: kindBoxReq.Description, + Status: kindBoxReq.Status, + DeliverReferTimeID: kindBoxReq.DeliverReferTimeID, + DeliverReferDate: kindBoxReq.DeliverReferDate, + DeliverAddressID: kindBoxReq.DeliverAddressID, + SenderAgentID: kindBoxReq.SenderAgentID, + DeliveredAt: kindBoxReq.DeliveredAt, + }) + } return param.DeliveryAwaitingGetAllResponse{ - AllAwaitingKindBoxReq: allAwaitingKindBoxReq, + Data: data, Pagination: paginationparam.PaginationResponse{ PageSize: req.Pagination.GetPageSize(), PageNumber: req.Pagination.GetPageNumber(), diff --git a/service/admin/kind_box_req/get_delivery_awaiting.go b/service/admin/kind_box_req/get_delivery_awaiting.go index de936dc..8c51af3 100644 --- a/service/admin/kind_box_req/get_delivery_awaiting.go +++ b/service/admin/kind_box_req/get_delivery_awaiting.go @@ -18,6 +18,19 @@ func (s Service) GetAwaitingDelivery(ctx context.Context, req param.DeliveryAwai } return param.DeliveryAwaitingGetResponse{ - KindBoxReq: kindBoxReq, + Data: param.Data{ + ID: kindBoxReq.ID, + BenefactorID: kindBoxReq.BenefactorID, + KindBoxType: kindBoxReq.KindBoxType, + CountRequested: kindBoxReq.CountRequested, + CountAccepted: kindBoxReq.CountAccepted, + Description: kindBoxReq.Description, + Status: kindBoxReq.Status, + DeliverReferTimeID: kindBoxReq.DeliverReferTimeID, + DeliverReferDate: kindBoxReq.DeliverReferDate, + DeliverAddressID: kindBoxReq.DeliverAddressID, + SenderAgentID: kindBoxReq.SenderAgentID, + DeliveredAt: kindBoxReq.DeliveredAt, + }, }, nil } diff --git a/service/admin/kind_box_req/reject.go b/service/admin/kind_box_req/reject.go index 43f55c7..28cb3fe 100644 --- a/service/admin/kind_box_req/reject.go +++ b/service/admin/kind_box_req/reject.go @@ -23,13 +23,19 @@ func (s Service) Reject(ctx context.Context, req param.KindBoxReqRejectRequest) } return param.KindBoxReqRejectResponse{ - ID: kindBoxReq.ID, - KindBoxType: kindBoxReq.KindBoxType, - CountRequested: kindBoxReq.CountRequested, - BenefactorID: kindBoxReq.BenefactorID, - Status: kindBoxReq.Status, - Description: kindBoxReq.Description, - DeliverReferDate: kindBoxReq.DeliverReferDate, - DeliverAddressID: kindBoxReq.DeliverAddressID, + Data: param.Data{ + ID: kindBoxReq.ID, + BenefactorID: kindBoxReq.BenefactorID, + KindBoxType: kindBoxReq.KindBoxType, + CountRequested: kindBoxReq.CountRequested, + CountAccepted: kindBoxReq.CountAccepted, + Description: kindBoxReq.Description, + Status: kindBoxReq.Status, + DeliverReferTimeID: kindBoxReq.DeliverReferTimeID, + DeliverReferDate: kindBoxReq.DeliverReferDate, + DeliverAddressID: kindBoxReq.DeliverAddressID, + SenderAgentID: kindBoxReq.SenderAgentID, + DeliveredAt: kindBoxReq.DeliveredAt, + }, }, nil } diff --git a/service/agent/kind_box/get.go b/service/agent/kind_box/get.go index cc75929..5170ceb 100644 --- a/service/agent/kind_box/get.go +++ b/service/agent/kind_box/get.go @@ -18,6 +18,24 @@ func (s Service) Get(ctx context.Context, req param.GetKindBoxRequest) (param.Ge } return param.GetKindBoxResponse{ - KindBox: kindBox, + Data: param.Data{ + ID: kindBox.ID, + KindBoxReqID: kindBox.KindBoxReqID, + BenefactorID: kindBox.BenefactorID, + KindBoxType: kindBox.KindBoxType, + Amount: kindBox.Amount, + SerialNumber: kindBox.SerialNumber, + Status: kindBox.Status, + DeliverReferTimeID: kindBox.DeliverReferTimeID, + DeliverReferDate: kindBox.DeliverReferDate, + DeliverAddressID: kindBox.DeliverAddressID, + SenderAgentID: kindBox.SenderAgentID, + DeliveredAt: kindBox.DeliveredAt, + ReturnReferTimeID: kindBox.ReturnReferTimeID, + ReturnReferDate: kindBox.ReturnReferDate, + ReturnAddressID: kindBox.ReturnAddressID, + ReceiverAgentID: kindBox.ReceiverAgentID, + ReturnedAt: kindBox.ReturnedAt, + }, }, nil } diff --git a/service/agent/kind_box/get_all.go b/service/agent/kind_box/get_all.go index e5d7013..7464b42 100644 --- a/service/agent/kind_box/get_all.go +++ b/service/agent/kind_box/get_all.go @@ -18,8 +18,31 @@ func (s Service) GetAll(ctx context.Context, req param.GetAllRequest) (param.Get return param.GetAllResponse{}, richerror.New(op).WithErr(err) } + var data []param.Data + for _, kindBox := range allKindBoxes { + data = append(data, param.Data{ + ID: kindBox.ID, + KindBoxReqID: kindBox.KindBoxReqID, + BenefactorID: kindBox.BenefactorID, + KindBoxType: kindBox.KindBoxType, + Amount: kindBox.Amount, + SerialNumber: kindBox.SerialNumber, + Status: kindBox.Status, + DeliverReferTimeID: kindBox.DeliverReferTimeID, + DeliverReferDate: kindBox.DeliverReferDate, + DeliverAddressID: kindBox.DeliverAddressID, + SenderAgentID: kindBox.SenderAgentID, + DeliveredAt: kindBox.DeliveredAt, + ReturnReferTimeID: kindBox.ReturnReferTimeID, + ReturnReferDate: kindBox.ReturnReferDate, + ReturnAddressID: kindBox.ReturnAddressID, + ReceiverAgentID: kindBox.ReceiverAgentID, + ReturnedAt: kindBox.ReturnedAt, + }) + } + return param.GetAllResponse{ - AllKindBoxes: allKindBoxes, + Data: data, Pagination: paginationparam.PaginationResponse{ PageSize: req.Pagination.GetPageSize(), PageNumber: req.Pagination.GetPageNumber(), diff --git a/service/benefactor/address/add.go b/service/benefactor/address/add.go index 5dbc333..c20a6ce 100644 --- a/service/benefactor/address/add.go +++ b/service/benefactor/address/add.go @@ -26,5 +26,15 @@ func (s Service) Add(ctx context.Context, req param.BenefactorAddAddressRequest) return param.BenefactorAddAddressResponse{}, richerror.New(op).WithErr(err).WithKind(richerror.KindUnexpected) } - return param.BenefactorAddAddressResponse{Address: address}, nil + return param.BenefactorAddAddressResponse{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 } diff --git a/service/benefactor/address/get.go b/service/benefactor/address/get.go index b6b2d0f..d3d8adb 100644 --- a/service/benefactor/address/get.go +++ b/service/benefactor/address/get.go @@ -17,5 +17,15 @@ func (s Service) Get(ctx context.Context, req param.GetAddressRequest) (param.Ge return param.GetAddressResponse{}, richerror.New(op).WithErr(err) } - return param.GetAddressResponse{Address: address}, nil + 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 } diff --git a/service/benefactor/address/get_all.go b/service/benefactor/address/get_all.go index 88edbe1..6956304 100644 --- a/service/benefactor/address/get_all.go +++ b/service/benefactor/address/get_all.go @@ -14,6 +14,19 @@ func (s Service) GetAll(ctx context.Context, request param.GetAllAddressesReques if err != nil { return param.GetAllAddressesResponse{}, richerror.New(op).WithErr(err).WithKind(richerror.KindUnexpected) } - - return param.GetAllAddressesResponse{AllAddresses: addresses}, nil + var data []param.Data + for _, address := range addresses { + data = append(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, + }) + } + return param.GetAllAddressesResponse{Data: data}, nil } diff --git a/service/benefactor/address/get_all_cities.go b/service/benefactor/address/get_all_cities.go index 6c6b9da..b71b9c7 100644 --- a/service/benefactor/address/get_all_cities.go +++ b/service/benefactor/address/get_all_cities.go @@ -15,5 +15,5 @@ func (s Service) GetAllCities(ctx context.Context, _ param.GetAllCitiesRequest) return param.GetAllCitiesResponse{}, richerror.New(op).WithErr(err).WithKind(richerror.KindUnexpected) } - return param.GetAllCitiesResponse{Cities: Cities}, nil + return param.GetAllCitiesResponse{Data: Cities}, nil } diff --git a/service/benefactor/address/get_all_provinces.go b/service/benefactor/address/get_all_provinces.go index 73ea714..4275ab1 100644 --- a/service/benefactor/address/get_all_provinces.go +++ b/service/benefactor/address/get_all_provinces.go @@ -15,5 +15,5 @@ func (s Service) GetAllProvinces(ctx context.Context, _ param.GetAllProvincesReq return param.GetAllProvincesResponse{}, richerror.New(op).WithErr(err).WithKind(richerror.KindUnexpected) } - return param.GetAllProvincesResponse{Provinces: provinces}, nil + return param.GetAllProvincesResponse{Data: provinces}, nil } diff --git a/service/benefactor/benefactor/login_register.go b/service/benefactor/benefactor/login_register.go index 8f9790e..4bfe2ab 100644 --- a/service/benefactor/benefactor/login_register.go +++ b/service/benefactor/benefactor/login_register.go @@ -58,7 +58,7 @@ func (s Service) LoginOrRegister(ctx context.Context, req benefactoreparam.Login } return benefactoreparam.LoginOrRegisterResponse{ - BenefactorInfo: benefactoreparam.BenefactroInfo{ + Data: benefactoreparam.Data{ ID: benefactor.ID, FirstName: benefactor.FirstName, LastName: benefactor.LastName, diff --git a/service/benefactor/kind_box/get.go b/service/benefactor/kind_box/get.go index 86704e2..7232d05 100644 --- a/service/benefactor/kind_box/get.go +++ b/service/benefactor/kind_box/get.go @@ -17,5 +17,23 @@ func (s Service) Get(ctx context.Context, req param.KindBoxGetRequest) (param.Ki return param.KindBoxGetResponse{}, richerror.New(op).WithErr(err).WithKind(richerror.KindUnexpected) } - return param.KindBoxGetResponse{KindBox: kindBox}, nil + return param.KindBoxGetResponse{Data: param.Data{ + ID: kindBox.ID, + KindBoxReqID: kindBox.KindBoxReqID, + BenefactorID: kindBox.BenefactorID, + KindBoxType: kindBox.KindBoxType, + Amount: kindBox.Amount, + SerialNumber: kindBox.SerialNumber, + Status: kindBox.Status, + DeliverReferTimeID: kindBox.DeliverReferTimeID, + DeliverReferDate: kindBox.DeliverReferDate, + DeliverAddressID: kindBox.DeliverAddressID, + SenderAgentID: kindBox.SenderAgentID, + DeliveredAt: kindBox.DeliveredAt, + ReturnReferTimeID: kindBox.ReturnReferTimeID, + ReturnReferDate: kindBox.ReturnReferDate, + ReturnAddressID: kindBox.ReturnAddressID, + ReceiverAgentID: kindBox.ReceiverAgentID, + ReturnedAt: kindBox.ReturnedAt, + }}, nil } diff --git a/service/benefactor/kind_box/get_all.go b/service/benefactor/kind_box/get_all.go index 60f4099..1577fbe 100644 --- a/service/benefactor/kind_box/get_all.go +++ b/service/benefactor/kind_box/get_all.go @@ -19,8 +19,31 @@ func (s Service) GetAll(ctx context.Context, req param.KindBoxGetAllRequest) (pa return param.KindBoxGetAllResponse{}, richerror.New(op).WithErr(err) } + var data []param.Data + for _, kindBox := range allKindBox { + data = append(data, param.Data{ + ID: kindBox.ID, + KindBoxReqID: kindBox.KindBoxReqID, + BenefactorID: kindBox.BenefactorID, + KindBoxType: kindBox.KindBoxType, + Amount: kindBox.Amount, + SerialNumber: kindBox.SerialNumber, + Status: kindBox.Status, + DeliverReferTimeID: kindBox.DeliverReferTimeID, + DeliverReferDate: kindBox.DeliverReferDate, + DeliverAddressID: kindBox.DeliverAddressID, + SenderAgentID: kindBox.SenderAgentID, + DeliveredAt: kindBox.DeliveredAt, + ReturnReferTimeID: kindBox.ReturnReferTimeID, + ReturnReferDate: kindBox.ReturnReferDate, + ReturnAddressID: kindBox.ReturnAddressID, + ReceiverAgentID: kindBox.ReceiverAgentID, + ReturnedAt: kindBox.ReturnedAt, + }) + } + return param.KindBoxGetAllResponse{ - AllKindBox: allKindBox, + Data: data, Pagination: params.PaginationResponse{ PageSize: req.Pagination.GetPageSize(), PageNumber: req.Pagination.GetPageNumber(), diff --git a/service/benefactor/kind_box_req/add.go b/service/benefactor/kind_box_req/add.go index 5099f45..31460e0 100644 --- a/service/benefactor/kind_box_req/add.go +++ b/service/benefactor/kind_box_req/add.go @@ -26,5 +26,18 @@ func (s Service) Add(ctx context.Context, req param.KindBoxReqAddRequest) (param return param.KindBoxReqAddResponse{}, richerror.New(op).WithErr(err).WithKind(richerror.KindUnexpected) } - return param.KindBoxReqAddResponse{KindBoxReq: kindBoxReq}, nil + return param.KindBoxReqAddResponse{Data: param.Data{ + ID: kindBoxReq.ID, + BenefactorID: kindBoxReq.BenefactorID, + KindBoxType: kindBoxReq.KindBoxType, + CountRequested: kindBoxReq.CountRequested, + CountAccepted: kindBoxReq.CountAccepted, + Description: kindBoxReq.Description, + Status: kindBoxReq.Status, + DeliverReferTimeID: kindBoxReq.DeliverReferTimeID, + DeliverReferDate: kindBoxReq.DeliverReferDate, + DeliverAddressID: kindBoxReq.DeliverAddressID, + SenderAgentID: kindBoxReq.SenderAgentID, + DeliveredAt: kindBoxReq.DeliveredAt, + }}, nil } diff --git a/service/benefactor/kind_box_req/get.go b/service/benefactor/kind_box_req/get.go index 66d6186..560bd07 100644 --- a/service/benefactor/kind_box_req/get.go +++ b/service/benefactor/kind_box_req/get.go @@ -18,5 +18,18 @@ func (s Service) Get(ctx context.Context, req param.KindBoxReqGetRequest) (param return param.KindBoxReqGetResponse{}, richerror.New(op).WithErr(err) } - return param.KindBoxReqGetResponse{KindBoxReq: kindBoxReq}, nil + return param.KindBoxReqGetResponse{Data: param.Data{ + ID: kindBoxReq.ID, + BenefactorID: kindBoxReq.BenefactorID, + KindBoxType: kindBoxReq.KindBoxType, + CountRequested: kindBoxReq.CountRequested, + CountAccepted: kindBoxReq.CountAccepted, + Description: kindBoxReq.Description, + Status: kindBoxReq.Status, + DeliverReferTimeID: kindBoxReq.DeliverReferTimeID, + DeliverReferDate: kindBoxReq.DeliverReferDate, + DeliverAddressID: kindBoxReq.DeliverAddressID, + SenderAgentID: kindBoxReq.SenderAgentID, + DeliveredAt: kindBoxReq.DeliveredAt, + }}, nil } diff --git a/service/benefactor/kind_box_req/get_all.go b/service/benefactor/kind_box_req/get_all.go index eebf69a..2f7e8be 100644 --- a/service/benefactor/kind_box_req/get_all.go +++ b/service/benefactor/kind_box_req/get_all.go @@ -19,8 +19,26 @@ func (s Service) GetAll(ctx context.Context, req param.GetAllRequest) (param.Get return param.GetAllResponse{}, richerror.New(op).WithErr(err) } + var data []param.Data + for _, kindBoxReq := range allKindBoxReq { + data = append(data, param.Data{ + ID: kindBoxReq.ID, + BenefactorID: kindBoxReq.BenefactorID, + KindBoxType: kindBoxReq.KindBoxType, + CountRequested: kindBoxReq.CountRequested, + CountAccepted: kindBoxReq.CountAccepted, + Description: kindBoxReq.Description, + Status: kindBoxReq.Status, + DeliverReferTimeID: kindBoxReq.DeliverReferTimeID, + DeliverReferDate: kindBoxReq.DeliverReferDate, + DeliverAddressID: kindBoxReq.DeliverAddressID, + SenderAgentID: kindBoxReq.SenderAgentID, + DeliveredAt: kindBoxReq.DeliveredAt, + }) + } + return param.GetAllResponse{ - AllKindBoxReq: allKindBoxReq, + Data: data, Pagination: params.PaginationResponse{ PageSize: req.Pagination.GetPageSize(), PageNumber: req.Pagination.GetPageNumber(), diff --git a/service/notification/kindbox_enumerated.go b/service/notification/kindbox_enumerated.go index 08b7ab4..ecfbb9b 100644 --- a/service/notification/kindbox_enumerated.go +++ b/service/notification/kindbox_enumerated.go @@ -20,9 +20,9 @@ func (s Service) KindBoxEnumerated(req params.NotificationKindBoxEnumerated) { if err != nil { fmt.Println(fmt.Errorf("error(%s):%w", op, err)) } - bnf, gErr := s.BenefactorSvc.GetByID(ctx, bnfparam.GetBenefactorByIDRequest{BenefactorID: kb.BenefactorID}) + bnf, gErr := s.BenefactorSvc.GetByID(ctx, bnfparam.GetBenefactorByIDRequest{BenefactorID: kb.Data.BenefactorID}) if gErr != nil { fmt.Println(fmt.Errorf("error(%s):%w", op, gErr)) } - s.smsAdapter.Send(bnf.PhoneNumber, fmt.Sprintf(smsmsg.SmsMsgKindBoxEnumerated, bnf.FirstName, kb.SerialNumber, kb.Amount)) + s.smsAdapter.Send(bnf.PhoneNumber, fmt.Sprintf(smsmsg.SmsMsgKindBoxEnumerated, bnf.FirstName, kb.Data.SerialNumber, kb.Data.Amount)) } diff --git a/service/notification/kindbox_registered_emptying_request.go b/service/notification/kindbox_registered_emptying_request.go index cf1c35d..9177a3f 100644 --- a/service/notification/kindbox_registered_emptying_request.go +++ b/service/notification/kindbox_registered_emptying_request.go @@ -22,7 +22,7 @@ func (s Service) KindBoxRegisteredEmptyingRequest(req params.NotificationKindBox if err != nil { fmt.Println(fmt.Errorf("error(%s):%w", op, err)) } - bnf, gErr := s.BenefactorSvc.GetByID(ctx, bnfparam.GetBenefactorByIDRequest{BenefactorID: kb.BenefactorID}) + bnf, gErr := s.BenefactorSvc.GetByID(ctx, bnfparam.GetBenefactorByIDRequest{BenefactorID: kb.Data.BenefactorID}) if gErr != nil { fmt.Println(fmt.Errorf("error(%s):%w", op, gErr)) } diff --git a/service/notification/kindboxreq_accepted.go b/service/notification/kindboxreq_accepted.go index f5e9c67..11e1413 100644 --- a/service/notification/kindboxreq_accepted.go +++ b/service/notification/kindboxreq_accepted.go @@ -20,7 +20,7 @@ func (s Service) KindBoxReqAccepted(req params.NotificationKindBoxReqAccepted) { if err != nil { fmt.Println(fmt.Errorf("error(%s):%w", op, err)) } - bnf, gErr := s.BenefactorSvc.GetByID(ctx, bnfparam.GetBenefactorByIDRequest{BenefactorID: kb.BenefactorID}) + bnf, gErr := s.BenefactorSvc.GetByID(ctx, bnfparam.GetBenefactorByIDRequest{BenefactorID: kb.Data.BenefactorID}) if gErr != nil { fmt.Println(fmt.Errorf("error(%s):%w", op, gErr)) } diff --git a/service/notification/kindboxreq_added.go b/service/notification/kindboxreq_added.go index 6b50551..9a8155f 100644 --- a/service/notification/kindboxreq_added.go +++ b/service/notification/kindboxreq_added.go @@ -22,7 +22,7 @@ func (s Service) KindBoxReqAdded(req params.NotificationKindBoxReqAdded) { if err != nil { fmt.Println(fmt.Errorf("error(%s):%w", op, err)) } - bnf, gErr := s.BenefactorSvc.GetByID(ctx, bnfparam.GetBenefactorByIDRequest{BenefactorID: kb.BenefactorID}) + bnf, gErr := s.BenefactorSvc.GetByID(ctx, bnfparam.GetBenefactorByIDRequest{BenefactorID: kb.Data.BenefactorID}) if gErr != nil { fmt.Println(fmt.Errorf("error(%s):%w", op, gErr)) } diff --git a/service/notification/kindboxreq_assigned.go b/service/notification/kindboxreq_assigned.go index 9ef236f..288fc3e 100644 --- a/service/notification/kindboxreq_assigned.go +++ b/service/notification/kindboxreq_assigned.go @@ -20,9 +20,9 @@ func (s Service) KindBoxReqAssigned(req params.NotificationKindBoxReqAssigned) { if err != nil { fmt.Println(fmt.Errorf("error(%s):%w", op, err)) } - bnf, gErr := s.AdminSvc.AdminExistByID(ctx, adminserviceparam.AdminExistByIDRequest{AdminID: kb.SenderAgentID}) + bnf, gErr := s.AdminSvc.AdminExistByID(ctx, adminserviceparam.AdminExistByIDRequest{AdminID: kb.Data.SenderAgentID}) if gErr != nil { fmt.Println(fmt.Errorf("error(%s):%w", op, gErr)) } - s.smsAdapter.Send(bnf.Admin.PhoneNumber, fmt.Sprintf(smsmsg.SmsMsgKindBoxReqAssigned, bnf.Admin.FirstName, kb.ID)) + s.smsAdapter.Send(bnf.Admin.PhoneNumber, fmt.Sprintf(smsmsg.SmsMsgKindBoxReqAssigned, bnf.Admin.FirstName, kb.Data.ID)) } diff --git a/service/notification/kindboxreq_rejected.go b/service/notification/kindboxreq_rejected.go index ab40998..708bc2e 100644 --- a/service/notification/kindboxreq_rejected.go +++ b/service/notification/kindboxreq_rejected.go @@ -20,7 +20,7 @@ func (s Service) KindBoxReqRejected(req params.NotificationKindBoxReqRejected) { if err != nil { fmt.Println(fmt.Errorf("error(%s):%w", op, err)) } - bnf, gErr := s.BenefactorSvc.GetByID(ctx, bnfparam.GetBenefactorByIDRequest{BenefactorID: kb.BenefactorID}) + bnf, gErr := s.BenefactorSvc.GetByID(ctx, bnfparam.GetBenefactorByIDRequest{BenefactorID: kb.Data.BenefactorID}) if gErr != nil { fmt.Println(fmt.Errorf("error(%s):%w", op, gErr)) }