forked from ebhomengo/niki
1
0
Fork 0

refactor(param): remove embedded entities in delivery response structs

This commit is contained in:
Erfan Mohammadi 2024-09-11 00:25:19 +03:30
parent 9ddcdd7a82
commit e5b380851c
74 changed files with 1464 additions and 1462 deletions

View File

@ -44,7 +44,7 @@ func (h Handler) RegisterEmptyingRequest(c echo.Context) error {
} }
go h.notificationSvc.KindBoxRegisteredEmptyingRequest(params.NotificationKindBoxRegisteredEmptyingRequest{ go h.notificationSvc.KindBoxRegisteredEmptyingRequest(params.NotificationKindBoxRegisteredEmptyingRequest{
KindBoxID: resp.ID, KindBoxID: resp.Data.ID,
}) })
return c.JSON(http.StatusNoContent, nil) return c.JSON(http.StatusNoContent, nil)

View File

@ -46,7 +46,7 @@ func (h Handler) Add(c echo.Context) error {
} }
go h.notificationSvc.KindBoxReqAdded(params.NotificationKindBoxReqAdded{ go h.notificationSvc.KindBoxReqAdded(params.NotificationKindBoxReqAdded{
KindBoxReqID: resp.KindBoxReq.ID, KindBoxReqID: resp.Data.ID,
}) })
return c.JSON(http.StatusCreated, resp) return c.JSON(http.StatusCreated, resp)

View File

@ -1,12 +1,12 @@
package setup package setup
import ( import (
"github.com/labstack/echo/v4"
"net/http" "net/http"
"git.gocasts.ir/ebhomengo/niki/config" "git.gocasts.ir/ebhomengo/niki/config"
httpserver "git.gocasts.ir/ebhomengo/niki/delivery/http_server" httpserver "git.gocasts.ir/ebhomengo/niki/delivery/http_server"
"git.gocasts.ir/ebhomengo/niki/service" "git.gocasts.ir/ebhomengo/niki/service"
"github.com/labstack/echo/v4"
) )
type TestServer struct { type TestServer struct {

View File

@ -9,7 +9,7 @@ import (
"github.com/labstack/echo/v4" "github.com/labstack/echo/v4"
) )
//nolint // nolint
func BenefactorAuthorization(role entity.UserRole) echo.MiddlewareFunc { func BenefactorAuthorization(role entity.UserRole) echo.MiddlewareFunc {
return func(next echo.HandlerFunc) echo.HandlerFunc { return func(next echo.HandlerFunc) echo.HandlerFunc {
return func(c echo.Context) error { return func(c echo.Context) error {

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -22,17 +22,38 @@ definitions:
type: object type: object
addressparam.BenefactorAddAddressResponse: addressparam.BenefactorAddAddressResponse:
properties: properties:
address: data:
$ref: '#/definitions/entity.Address' $ref: '#/definitions/addressparam.Data'
field_errors: field_errors:
additionalProperties: additionalProperties:
type: string type: string
type: object type: object
type: object type: object
addressparam.GetAddressResponse: addressparam.Data:
properties: properties:
address: 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: field_errors:
additionalProperties: additionalProperties:
type: string type: string
@ -40,21 +61,21 @@ definitions:
type: object type: object
addressparam.GetAllAddressesResponse: addressparam.GetAllAddressesResponse:
properties: properties:
all_addresses: data:
items: items:
$ref: '#/definitions/entity.Address' $ref: '#/definitions/addressparam.Data'
type: array type: array
type: object type: object
addressparam.GetAllCitiesResponse: addressparam.GetAllCitiesResponse:
properties: properties:
cities: data:
items: items:
$ref: '#/definitions/entity.City' $ref: '#/definitions/entity.City'
type: array type: array
type: object type: object
addressparam.GetAllProvincesResponse: addressparam.GetAllProvincesResponse:
properties: properties:
provinces: data:
items: items:
$ref: '#/definitions/entity.Province' $ref: '#/definitions/entity.Province'
type: array type: array
@ -80,7 +101,7 @@ definitions:
example: "1234567890" example: "1234567890"
type: string type: string
type: object type: object
adminagentparam.Agent: adminagentparam.Data:
properties: properties:
first_name: first_name:
example: John example: John
@ -97,9 +118,9 @@ definitions:
type: object type: object
adminagentparam.GetAllAgentResponse: adminagentparam.GetAllAgentResponse:
properties: properties:
agents: data:
items: items:
$ref: '#/definitions/adminagentparam.Agent' $ref: '#/definitions/adminagentparam.Data'
type: array type: array
type: object type: object
adminkindboxparam.AssignReceiverRequest: adminkindboxparam.AssignReceiverRequest:
@ -107,6 +128,43 @@ definitions:
receiver_agent_id: receiver_agent_id:
type: integer type: integer
type: object 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: adminkindboxparam.EnumerateKindBoxRequest:
properties: properties:
amount: amount:
@ -114,9 +172,9 @@ definitions:
type: object type: object
adminkindboxparam.KindBoxGetAllResponse: adminkindboxparam.KindBoxGetAllResponse:
properties: properties:
all_kind_box: data:
items: items:
$ref: '#/definitions/entity.KindBox' $ref: '#/definitions/adminkindboxparam.Data'
type: array type: array
field_errors: field_errors:
additionalProperties: additionalProperties:
@ -127,44 +185,12 @@ definitions:
type: object type: object
adminkindboxparam.KindBoxGetResponse: adminkindboxparam.KindBoxGetResponse:
properties: properties:
amount: data:
type: integer $ref: '#/definitions/adminkindboxparam.Data'
benefactorID:
type: integer
deliverAddressID:
type: integer
deliverReferDate:
type: string
deliverReferTimeID:
type: integer
deliveredAt:
type: string
field_errors: field_errors:
additionalProperties: additionalProperties:
type: string type: string
type: object 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 type: object
adminkindboxreqparam.AssignSenderRequest: adminkindboxreqparam.AssignSenderRequest:
properties: properties:
@ -178,6 +204,33 @@ definitions:
type: string type: string
type: object type: object
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: adminkindboxreqparam.DeliverKindBoxReqRequest:
properties: properties:
serial_numbers: serial_numbers:
@ -198,9 +251,9 @@ definitions:
type: object type: object
adminkindboxreqparam.DeliveryAwaitingGetAllResponse: adminkindboxreqparam.DeliveryAwaitingGetAllResponse:
properties: properties:
all_awaiting_kind_box_req: data:
items: items:
$ref: '#/definitions/entity.KindBoxReq' $ref: '#/definitions/adminkindboxreqparam.Data'
type: array type: array
field_errors: field_errors:
additionalProperties: additionalProperties:
@ -211,65 +264,21 @@ definitions:
type: object type: object
adminkindboxreqparam.DeliveryAwaitingGetResponse: adminkindboxreqparam.DeliveryAwaitingGetResponse:
properties: properties:
benefactorID: data:
type: integer $ref: '#/definitions/adminkindboxreqparam.Data'
countAccepted:
type: integer
countRequested:
type: integer
deliverAddressID:
type: integer
deliverReferDate:
type: string
deliverReferTimeID:
type: integer
deliveredAt:
type: string
description:
type: string
field_errors: field_errors:
additionalProperties: additionalProperties:
type: string type: string
type: object type: object
id:
type: integer
kindBoxType:
$ref: '#/definitions/entity.KindBoxType'
senderAgentID:
type: integer
status:
$ref: '#/definitions/entity.KindBoxReqStatus'
type: object type: object
adminkindboxreqparam.GetKindBoxReqResponse: adminkindboxreqparam.GetKindBoxReqResponse:
properties: properties:
benefactorID: data:
type: integer $ref: '#/definitions/adminkindboxreqparam.Data'
countAccepted:
type: integer
countRequested:
type: integer
deliverAddressID:
type: integer
deliverReferDate:
type: string
deliverReferTimeID:
type: integer
deliveredAt:
type: string
description:
type: string
field_errors: field_errors:
additionalProperties: additionalProperties:
type: string type: string
type: object type: object
id:
type: integer
kindBoxType:
$ref: '#/definitions/entity.KindBoxType'
senderAgentID:
type: integer
status:
$ref: '#/definitions/entity.KindBoxReqStatus'
type: object type: object
adminkindboxreqparam.KindBoxReqAcceptRequest: adminkindboxreqparam.KindBoxReqAcceptRequest:
properties: properties:
@ -278,22 +287,12 @@ definitions:
type: object type: object
adminkindboxreqparam.KindBoxReqAcceptResponse: adminkindboxreqparam.KindBoxReqAcceptResponse:
properties: properties:
count_accepted: data:
type: integer $ref: '#/definitions/adminkindboxreqparam.Data'
count_requested:
type: integer
deliver_address_id:
type: integer
deliver_refer_date:
type: string
field_errors: field_errors:
additionalProperties: additionalProperties:
type: string type: string
type: object type: object
kind_box_req_id:
type: integer
kind_box_req_status:
$ref: '#/definitions/entity.KindBoxReqStatus'
type: object type: object
adminkindboxreqparam.KindBoxReqAddRequest: adminkindboxreqparam.KindBoxReqAddRequest:
properties: properties:
@ -316,18 +315,18 @@ definitions:
type: object type: object
adminkindboxreqparam.KindBoxReqAddResponse: adminkindboxreqparam.KindBoxReqAddResponse:
properties: properties:
data:
$ref: '#/definitions/adminkindboxreqparam.Data'
field_errors: field_errors:
additionalProperties: additionalProperties:
type: string type: string
type: object type: object
kindBoxReq:
$ref: '#/definitions/entity.KindBoxReq'
type: object type: object
adminkindboxreqparam.KindBoxReqGetAllResponse: adminkindboxreqparam.KindBoxReqGetAllResponse:
properties: properties:
all_awaiting_kind_box_req: data:
items: items:
$ref: '#/definitions/entity.KindBoxReq' $ref: '#/definitions/adminkindboxreqparam.Data'
type: array type: array
field_errors: field_errors:
additionalProperties: additionalProperties:
@ -344,36 +343,12 @@ definitions:
type: object type: object
adminkindboxreqparam.KindBoxReqRejectResponse: adminkindboxreqparam.KindBoxReqRejectResponse:
properties: properties:
benefactor_id: data:
example: 1 $ref: '#/definitions/adminkindboxreqparam.Data'
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
field_errors: field_errors:
additionalProperties: additionalProperties:
type: string type: string
type: object 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 type: object
adminkindboxreqparam.KindBoxReqUpdateRequest: adminkindboxreqparam.KindBoxReqUpdateRequest:
properties: properties:
@ -403,7 +378,7 @@ definitions:
example: 1 example: 1
type: integer type: integer
type: object type: object
adminserviceparam.AdminInfo: adminserviceparam.Data:
properties: properties:
description: description:
example: This is a description example: This is a description
@ -447,8 +422,8 @@ definitions:
type: object type: object
adminserviceparam.LoginWithPhoneNumberResponse: adminserviceparam.LoginWithPhoneNumberResponse:
properties: properties:
admin_info: data:
$ref: '#/definitions/adminserviceparam.AdminInfo' $ref: '#/definitions/adminserviceparam.Data'
field_errors: field_errors:
additionalProperties: additionalProperties:
type: string type: string
@ -491,8 +466,8 @@ definitions:
type: object type: object
adminserviceparam.RegisterResponse: adminserviceparam.RegisterResponse:
properties: properties:
admin: data:
$ref: '#/definitions/entity.Admin' $ref: '#/definitions/adminserviceparam.Data'
field_errors: field_errors:
additionalProperties: additionalProperties:
type: string type: string
@ -505,11 +480,48 @@ definitions:
refresh_token: refresh_token:
type: string type: string
type: object 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: agentkindboxparam.GetAllResponse:
properties: properties:
all_kind_boxes: data:
items: items:
$ref: '#/definitions/entity.KindBox' $ref: '#/definitions/agentkindboxparam.Data'
type: array type: array
field_errors: field_errors:
additionalProperties: additionalProperties:
@ -520,51 +532,19 @@ definitions:
type: object type: object
agentkindboxparam.GetKindBoxResponse: agentkindboxparam.GetKindBoxResponse:
properties: properties:
amount: data:
type: integer $ref: '#/definitions/agentkindboxparam.Data'
benefactorID:
type: integer
deliverAddressID:
type: integer
deliverReferDate:
type: string
deliverReferTimeID:
type: integer
deliveredAt:
type: string
field_errors: field_errors:
additionalProperties: additionalProperties:
type: string type: string
type: object 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 type: object
agentkindboxparam.ReturnKindBoxRequest: agentkindboxparam.ReturnKindBoxRequest:
properties: properties:
serial_number: serial_number:
type: string type: string
type: object type: object
benefactoreparam.BenefactroInfo: benefactoreparam.Data:
properties: properties:
first_name: first_name:
example: mehdi example: mehdi
@ -591,8 +571,8 @@ definitions:
type: object type: object
benefactoreparam.LoginOrRegisterResponse: benefactoreparam.LoginOrRegisterResponse:
properties: properties:
benefactore_info: data:
$ref: '#/definitions/benefactoreparam.BenefactroInfo' $ref: '#/definitions/benefactoreparam.Data'
field_errors: field_errors:
additionalProperties: additionalProperties:
type: string type: string
@ -626,11 +606,48 @@ definitions:
refresh_token: refresh_token:
type: string type: string
type: object 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: benefactorkindboxparam.KindBoxGetAllResponse:
properties: properties:
all_kind_box: data:
items: items:
$ref: '#/definitions/entity.KindBox' $ref: '#/definitions/benefactorkindboxparam.Data'
type: array type: array
field_errors: field_errors:
additionalProperties: additionalProperties:
@ -641,44 +658,12 @@ definitions:
type: object type: object
benefactorkindboxparam.KindBoxGetResponse: benefactorkindboxparam.KindBoxGetResponse:
properties: properties:
amount: data:
type: integer $ref: '#/definitions/benefactorkindboxparam.Data'
benefactorID:
type: integer
deliverAddressID:
type: integer
deliverReferDate:
type: string
deliverReferTimeID:
type: integer
deliveredAt:
type: string
field_errors: field_errors:
additionalProperties: additionalProperties:
type: string type: string
type: object 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 type: object
benefactorkindboxparam.KindBoxRegisterEmptyingRequest: benefactorkindboxparam.KindBoxRegisterEmptyingRequest:
properties: properties:
@ -692,11 +677,38 @@ definitions:
example: 1 example: 1
type: integer type: integer
type: object 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: benefactorkindboxreqparam.GetAllResponse:
properties: properties:
all_kind_box_req: data:
items: items:
$ref: '#/definitions/entity.KindBoxReq' $ref: '#/definitions/benefactorkindboxreqparam.Data'
type: array type: array
field_errors: field_errors:
additionalProperties: additionalProperties:
@ -726,12 +738,12 @@ definitions:
type: object type: object
benefactorkindboxreqparam.KindBoxReqAddResponse: benefactorkindboxreqparam.KindBoxReqAddResponse:
properties: properties:
data:
$ref: '#/definitions/benefactorkindboxreqparam.Data'
field_errors: field_errors:
additionalProperties: additionalProperties:
type: string type: string
type: object type: object
kind_box_req:
$ref: '#/definitions/entity.KindBoxReq'
type: object type: object
benefactorkindboxreqparam.KindBoxReqDeleteResponse: benefactorkindboxreqparam.KindBoxReqDeleteResponse:
properties: properties:
@ -742,12 +754,12 @@ definitions:
type: object type: object
benefactorkindboxreqparam.KindBoxReqGetResponse: benefactorkindboxreqparam.KindBoxReqGetResponse:
properties: properties:
data:
$ref: '#/definitions/benefactorkindboxreqparam.Data'
field_errors: field_errors:
additionalProperties: additionalProperties:
type: string type: string
type: object type: object
kind_box_req:
$ref: '#/definitions/entity.KindBoxReq'
type: object type: object
benefactorkindboxreqparam.KindBoxReqUpdateRequest: benefactorkindboxreqparam.KindBoxReqUpdateRequest:
properties: properties:
@ -771,50 +783,6 @@ definitions:
- $ref: '#/definitions/entity.KindBoxType' - $ref: '#/definitions/entity.KindBoxType'
example: cylindrical example: cylindrical
type: object 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: entity.AdminRole:
enum: enum:
- 1 - 1
@ -850,70 +818,6 @@ definitions:
x-enum-varnames: x-enum-varnames:
- MaleGender - MaleGender
- FemaleGender - 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: entity.KindBoxReqStatus:
enum: enum:
- pending - pending

15
param/admin/admin/data.go Normal file
View File

@ -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"`
}

View File

@ -1,26 +1,12 @@
package adminserviceparam package adminserviceparam
import "git.gocasts.ir/ebhomengo/niki/entity"
type LoginWithPhoneNumberRequest struct { type LoginWithPhoneNumberRequest struct {
PhoneNumber string `json:"phone_number" example:"09123456789"` PhoneNumber string `json:"phone_number" example:"09123456789"`
Password string `json:"password" example:"password123"` Password string `json:"password" example:"password123"`
} }
type LoginWithPhoneNumberResponse struct { type LoginWithPhoneNumberResponse struct {
AdminInfo AdminInfo `json:"admin_info"` Data Data `json:"data"`
Tokens Tokens `json:"tokens"` Tokens Tokens `json:"tokens"`
FieldErrors map[string]string `json:"field_errors,omitempty"` 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"`
}

View File

@ -15,6 +15,6 @@ type RegisterRequest struct {
} }
type RegisterResponse struct { type RegisterResponse struct {
Admin entity.Admin `json:"admin"` Data Data `json:"data"`
FieldErrors map[string]string `json:"field_errors,omitempty"` FieldErrors map[string]string `json:"field_errors,omitempty"`
} }

View File

@ -1,10 +1,10 @@
package adminagentparam package adminagentparam
type GetAllAgentResponse struct { type GetAllAgentResponse struct {
Agents []Agent `json:"agents"` Data []Data `json:"data"`
} }
type Agent struct { type Data struct {
ID uint `json:"id" example:"1"` ID uint `json:"id" example:"1"`
FirstName string `json:"first_name" example:"John"` FirstName string `json:"first_name" example:"John"`
LastName string `json:"last_name" example:"Doe"` LastName string `json:"last_name" example:"Doe"`

View File

@ -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"`
}

View File

@ -1,12 +1,10 @@
package adminkindboxparam package adminkindboxparam
import entity "git.gocasts.ir/ebhomengo/niki/entity"
type KindBoxGetRequest struct { type KindBoxGetRequest struct {
KindBoxID uint `param:"id"` KindBoxID uint `param:"id"`
} }
type KindBoxGetResponse struct { type KindBoxGetResponse struct {
entity.KindBox Data Data `json:"data"`
FieldErrors map[string]string `json:"field_errors,omitempty"` FieldErrors map[string]string `json:"field_errors,omitempty"`
} }

View File

@ -1,7 +1,6 @@
package adminkindboxparam package adminkindboxparam
import ( import (
"git.gocasts.ir/ebhomengo/niki/entity"
"git.gocasts.ir/ebhomengo/niki/param" "git.gocasts.ir/ebhomengo/niki/param"
) )
@ -12,7 +11,7 @@ type KindBoxGetAllRequest struct {
} }
type KindBoxGetAllResponse struct { type KindBoxGetAllResponse struct {
AllKindBox []entity.KindBox `json:"all_kind_box"` Data []Data `json:"data"`
Pagination param.PaginationResponse `json:"pagination"` Pagination param.PaginationResponse `json:"pagination"`
FieldErrors map[string]string `json:"field_errors,omitempty"` FieldErrors map[string]string `json:"field_errors,omitempty"`
} }

View File

@ -1,22 +1,11 @@
package adminkindboxreqparam package adminkindboxreqparam
import (
"time"
"git.gocasts.ir/ebhomengo/niki/entity"
)
type KindBoxReqAcceptRequest struct { type KindBoxReqAcceptRequest struct {
ID uint `json:"-"` ID uint `json:"-"`
CountAccepted uint `json:"count_accepted"` CountAccepted uint `json:"count_accepted"`
} }
type KindBoxReqAcceptResponse struct { type KindBoxReqAcceptResponse struct {
KindBoxReqID uint `json:"kind_box_req_id"` Data Data `json:"data"`
KindBoxReqStatus entity.KindBoxReqStatus `json:"kind_box_req_status"` FieldErrors map[string]string `json:"field_errors,omitempty"`
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"`
} }

View File

@ -11,6 +11,6 @@ type KindBoxReqAddRequest struct {
} }
type KindBoxReqAddResponse struct { type KindBoxReqAddResponse struct {
KindBoxReq entity.KindBoxReq Data Data `json:"data"`
FieldErrors map[string]string `json:"field_errors,omitempty"` FieldErrors map[string]string `json:"field_errors,omitempty"`
} }

View File

@ -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"`
}

View File

@ -1,12 +1,10 @@
package adminkindboxreqparam package adminkindboxreqparam
import "git.gocasts.ir/ebhomengo/niki/entity"
type GetKindBoxReqRequest struct { type GetKindBoxReqRequest struct {
KindBoxID uint `param:"id"` KindBoxID uint `param:"id"`
} }
type GetKindBoxReqResponse struct { type GetKindBoxReqResponse struct {
entity.KindBoxReq Data Data `json:"data"`
FieldErrors map[string]string `json:"field_errors,omitempty"` FieldErrors map[string]string `json:"field_errors,omitempty"`
} }

View File

@ -1,7 +1,6 @@
package adminkindboxreqparam package adminkindboxreqparam
import ( import (
"git.gocasts.ir/ebhomengo/niki/entity"
"git.gocasts.ir/ebhomengo/niki/param" "git.gocasts.ir/ebhomengo/niki/param"
) )
@ -12,7 +11,7 @@ type KindBoxReqGetAllRequest struct {
} }
type KindBoxReqGetAllResponse struct { type KindBoxReqGetAllResponse struct {
AllKindBoxReq []entity.KindBoxReq `json:"all_awaiting_kind_box_req"` Data []Data `json:"data"`
Pagination param.PaginationResponse `json:"pagination"` Pagination param.PaginationResponse `json:"pagination"`
FieldErrors map[string]string `json:"field_errors,omitempty"` FieldErrors map[string]string `json:"field_errors,omitempty"`
} }

View File

@ -1,7 +1,6 @@
package adminkindboxreqparam package adminkindboxreqparam
import ( import (
"git.gocasts.ir/ebhomengo/niki/entity"
"git.gocasts.ir/ebhomengo/niki/param" "git.gocasts.ir/ebhomengo/niki/param"
) )
@ -12,7 +11,7 @@ type DeliveryAwaitingGetAllRequest struct {
} }
type DeliveryAwaitingGetAllResponse struct { type DeliveryAwaitingGetAllResponse struct {
AllAwaitingKindBoxReq []entity.KindBoxReq `json:"all_awaiting_kind_box_req"` Data []Data `json:"data"`
Pagination param.PaginationResponse `json:"pagination"` Pagination param.PaginationResponse `json:"pagination"`
FieldErrors map[string]string `json:"field_errors,omitempty"` FieldErrors map[string]string `json:"field_errors,omitempty"`
} }

View File

@ -1,13 +1,11 @@
package adminkindboxreqparam package adminkindboxreqparam
import "git.gocasts.ir/ebhomengo/niki/entity"
type DeliveryAwaitingGetRequest struct { type DeliveryAwaitingGetRequest struct {
KindBoxReqID uint `param:"id"` KindBoxReqID uint `param:"id"`
AgentID uint AgentID uint
} }
type DeliveryAwaitingGetResponse struct { type DeliveryAwaitingGetResponse struct {
entity.KindBoxReq Data Data `json:"data"`
FieldErrors map[string]string `json:"field_errors,omitempty"` FieldErrors map[string]string `json:"field_errors,omitempty"`
} }

View File

@ -1,24 +1,11 @@
package adminkindboxreqparam package adminkindboxreqparam
import (
"time"
"git.gocasts.ir/ebhomengo/niki/entity"
)
type KindBoxReqRejectRequest struct { type KindBoxReqRejectRequest struct {
ID uint `json:"-"` ID uint `json:"-"`
Description string `json:"description" example:"description"` Description string `json:"description" example:"description"`
} }
type KindBoxReqRejectResponse struct { type KindBoxReqRejectResponse struct {
ID uint `json:"id" example:"1"` Data Data `json:"data"`
KindBoxType entity.KindBoxType `json:"kind_box_type" example:"on-table"` FieldErrors map[string]string `json:"field_errors,omitempty"`
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"`
} }

View File

@ -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"`
}

View File

@ -1,13 +1,11 @@
package agentkindboxparam package agentkindboxparam
import "git.gocasts.ir/ebhomengo/niki/entity"
type GetKindBoxRequest struct { type GetKindBoxRequest struct {
KindBoxID uint `param:"id"` KindBoxID uint `param:"id"`
AgentID uint AgentID uint
} }
type GetKindBoxResponse struct { type GetKindBoxResponse struct {
entity.KindBox Data Data `json:"data"`
FieldErrors map[string]string `json:"field_errors,omitempty"` FieldErrors map[string]string `json:"field_errors,omitempty"`
} }

View File

@ -1,7 +1,6 @@
package agentkindboxparam package agentkindboxparam
import ( import (
"git.gocasts.ir/ebhomengo/niki/entity"
"git.gocasts.ir/ebhomengo/niki/param" "git.gocasts.ir/ebhomengo/niki/param"
) )
@ -12,7 +11,7 @@ type GetAllRequest struct {
} }
type GetAllResponse struct { type GetAllResponse struct {
AllKindBoxes []entity.KindBox `json:"all_kind_boxes"` Data []Data `json:"data"`
Pagination param.PaginationResponse `json:"pagination"` Pagination param.PaginationResponse `json:"pagination"`
FieldErrors map[string]string `json:"field_errors,omitempty"` FieldErrors map[string]string `json:"field_errors,omitempty"`
} }

View File

@ -1,7 +1,5 @@
package addressparam package addressparam
import "git.gocasts.ir/ebhomengo/niki/entity"
type BenefactorAddAddressRequest struct { type BenefactorAddAddressRequest struct {
PostalCode string `json:"postal_code" example:"1234567890"` PostalCode string `json:"postal_code" example:"1234567890"`
Address string `json:"address" example:"tehran"` Address string `json:"address" example:"tehran"`
@ -13,6 +11,6 @@ type BenefactorAddAddressRequest struct {
} }
type BenefactorAddAddressResponse struct { type BenefactorAddAddressResponse struct {
Address entity.Address `json:"address"` Data Data `json:"data"`
FieldErrors map[string]string `json:"field_errors,omitempty"` FieldErrors map[string]string `json:"field_errors,omitempty"`
} }

View File

@ -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"`
}

View File

@ -14,6 +14,6 @@ type GetAddressRequest struct {
AddressID uint AddressID uint
} }
type GetAddressResponse struct { type GetAddressResponse struct {
Address entity.Address `json:"address"` Data Data `json:"data"`
FieldErrors map[string]string `json:"field_errors,omitempty"` FieldErrors map[string]string `json:"field_errors,omitempty"`
} }

View File

@ -1,11 +1,9 @@
package addressparam package addressparam
import "git.gocasts.ir/ebhomengo/niki/entity"
type GetAllAddressesRequest struct { type GetAllAddressesRequest struct {
BenefactorID uint BenefactorID uint
} }
type GetAllAddressesResponse struct { type GetAllAddressesResponse struct {
AllAddresses []entity.Address `json:"all_addresses"` Data []Data `json:"data"`
} }

View File

@ -2,9 +2,8 @@ package addressparam
import "git.gocasts.ir/ebhomengo/niki/entity" import "git.gocasts.ir/ebhomengo/niki/entity"
type ( type GetAllCitiesRequest struct{}
GetAllCitiesRequest struct{}
GetAllCitiesResponse struct { type GetAllCitiesResponse struct {
Cities []entity.City `json:"cities"` Data []entity.City `json:"data"`
} }
)

View File

@ -2,9 +2,8 @@ package addressparam
import "git.gocasts.ir/ebhomengo/niki/entity" import "git.gocasts.ir/ebhomengo/niki/entity"
type ( type GetAllProvincesRequest struct{}
GetAllProvincesRequest struct{}
GetAllProvincesResponse struct { type GetAllProvincesResponse struct {
Provinces []entity.Province `json:"provinces"` Data []entity.Province `json:"data"`
} }
)

View File

@ -2,7 +2,7 @@ package benefactoreparam
import "git.gocasts.ir/ebhomengo/niki/entity" import "git.gocasts.ir/ebhomengo/niki/entity"
type BenefactroInfo struct { type Data struct {
ID uint `json:"id" example:"1"` ID uint `json:"id" example:"1"`
FirstName string `json:"first_name" example:"mehdi"` FirstName string `json:"first_name" example:"mehdi"`
LastName string `json:"last_name" example:"rez"` LastName string `json:"last_name" example:"rez"`

View File

@ -6,7 +6,7 @@ type LoginOrRegisterRequest struct {
} }
type LoginOrRegisterResponse struct { type LoginOrRegisterResponse struct {
BenefactorInfo BenefactroInfo `json:"benefactore_info"` Data Data `json:"data"`
Tokens Tokens `json:"tokens"` Tokens Tokens `json:"tokens"`
FieldErrors map[string]string `json:"field_errors,omitempty"` FieldErrors map[string]string `json:"field_errors,omitempty"`
} }

View File

@ -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"`
}

View File

@ -1,13 +1,11 @@
package benefactorkindboxparam package benefactorkindboxparam
import entity "git.gocasts.ir/ebhomengo/niki/entity"
type KindBoxGetRequest struct { type KindBoxGetRequest struct {
BenefactorID uint BenefactorID uint
KindBoxID uint KindBoxID uint
} }
type KindBoxGetResponse struct { type KindBoxGetResponse struct {
entity.KindBox Data Data `json:"data"`
FieldErrors map[string]string `json:"field_errors,omitempty"` FieldErrors map[string]string `json:"field_errors,omitempty"`
} }

View File

@ -1,7 +1,6 @@
package benefactorkindboxparam package benefactorkindboxparam
import ( import (
"git.gocasts.ir/ebhomengo/niki/entity"
"git.gocasts.ir/ebhomengo/niki/param" "git.gocasts.ir/ebhomengo/niki/param"
) )
@ -12,7 +11,7 @@ type KindBoxGetAllRequest struct {
} }
type KindBoxGetAllResponse struct { type KindBoxGetAllResponse struct {
AllKindBox []entity.KindBox `json:"all_kind_box"` Data []Data `json:"data"`
Pagination param.PaginationResponse `json:"pagination"` Pagination param.PaginationResponse `json:"pagination"`
FieldErrors map[string]string `json:"field_errors,omitempty"` FieldErrors map[string]string `json:"field_errors,omitempty"`
} }

View File

@ -2,8 +2,6 @@ package benefactorkindboxparam
import ( import (
"time" "time"
"git.gocasts.ir/ebhomengo/niki/entity"
) )
type KindBoxRegisterEmptyingRequest struct { type KindBoxRegisterEmptyingRequest struct {
@ -15,6 +13,6 @@ type KindBoxRegisterEmptyingRequest struct {
} }
type KindBoxRegisterEmptyingRequestResponse struct { type KindBoxRegisterEmptyingRequestResponse struct {
entity.KindBox `json:"kind_box"` Data Data `json:"data"`
FieldErrors map[string]string `json:"field_errors,omitempty"` FieldErrors map[string]string `json:"field_errors,omitempty"`
} }

View File

@ -16,6 +16,6 @@ type KindBoxReqAddRequest struct {
} }
type KindBoxReqAddResponse struct { type KindBoxReqAddResponse struct {
KindBoxReq entity.KindBoxReq `json:"kind_box_req"` Data Data `json:"data"`
FieldErrors map[string]string `json:"field_errors,omitempty"` FieldErrors map[string]string `json:"field_errors,omitempty"`
} }

View File

@ -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"`
}

View File

@ -1,13 +1,11 @@
package benefactorkindboxreqparam package benefactorkindboxreqparam
import entity "git.gocasts.ir/ebhomengo/niki/entity"
type KindBoxReqGetRequest struct { type KindBoxReqGetRequest struct {
BenefactorID uint BenefactorID uint
KindBoxReqID uint KindBoxReqID uint
} }
type KindBoxReqGetResponse struct { type KindBoxReqGetResponse struct {
entity.KindBoxReq `json:"kind_box_req"` Data Data `json:"data"`
FieldErrors map[string]string `json:"field_errors,omitempty"` FieldErrors map[string]string `json:"field_errors,omitempty"`
} }

View File

@ -1,7 +1,6 @@
package benefactorkindboxreqparam package benefactorkindboxreqparam
import ( import (
"git.gocasts.ir/ebhomengo/niki/entity"
"git.gocasts.ir/ebhomengo/niki/param" "git.gocasts.ir/ebhomengo/niki/param"
) )
@ -12,7 +11,7 @@ type GetAllRequest struct {
} }
type GetAllResponse struct { type GetAllResponse struct {
AllKindBoxReq []entity.KindBoxReq `json:"all_kind_box_req"` Data []Data `json:"data"`
Pagination param.PaginationResponse `json:"pagination"` Pagination param.PaginationResponse `json:"pagination"`
FieldErrors map[string]string `json:"field_errors,omitempty"` FieldErrors map[string]string `json:"field_errors,omitempty"`
} }

View File

@ -284,7 +284,7 @@ func (s *Supervisor) retryCount(name string) int {
return v.options.RetryCount return v.options.RetryCount
} }
//nolint // nolint
func (s *Supervisor) retryInterval(name string) time.Duration { func (s *Supervisor) retryInterval(name string) time.Duration {
s.lock.Lock() s.lock.Lock()
defer s.lock.Unlock() defer s.lock.Unlock()

View File

@ -3,6 +3,7 @@ package mysqlkindbox
import ( import (
"context" "context"
"database/sql" "database/sql"
"git.gocasts.ir/ebhomengo/niki/entity" "git.gocasts.ir/ebhomengo/niki/entity"
errmsg "git.gocasts.ir/ebhomengo/niki/pkg/err_msg" errmsg "git.gocasts.ir/ebhomengo/niki/pkg/err_msg"
querytransaction "git.gocasts.ir/ebhomengo/niki/pkg/query_transaction/sql" querytransaction "git.gocasts.ir/ebhomengo/niki/pkg/query_transaction/sql"

View File

@ -37,7 +37,7 @@ func (s Service) LoginWithPhoneNumber(ctx context.Context, req adminserviceparam
} }
return adminserviceparam.LoginWithPhoneNumberResponse{ return adminserviceparam.LoginWithPhoneNumberResponse{
AdminInfo: adminserviceparam.AdminInfo{ Data: adminserviceparam.Data{
ID: admin.ID, ID: admin.ID,
FirstName: admin.FirstName, FirstName: admin.FirstName,
LastName: admin.LastName, LastName: admin.LastName,

View File

@ -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{}, 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
} }

View File

@ -10,7 +10,7 @@ import (
func (s Service) GetAllAgent(ctx context.Context) (param.GetAllAgentResponse, error) { func (s Service) GetAllAgent(ctx context.Context) (param.GetAllAgentResponse, error) {
const op = "adminagentservice.GetAllAgent" const op = "adminagentservice.GetAllAgent"
agentsInfo := make([]param.Agent, 0) agentsInfo := make([]param.Data, 0)
agents, err := s.repo.GetAllAgent(ctx) agents, err := s.repo.GetAllAgent(ctx)
if err != nil { if err != nil {
@ -18,7 +18,7 @@ func (s Service) GetAllAgent(ctx context.Context) (param.GetAllAgentResponse, er
} }
for _, agent := range agents { for _, agent := range agents {
agentsInfo = append(agentsInfo, param.Agent{ agentsInfo = append(agentsInfo, param.Data{
ID: agent.ID, ID: agent.ID,
FirstName: agent.FirstName, FirstName: agent.FirstName,
LastName: agent.LastName, 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
} }

View File

@ -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{}, 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
} }

View File

@ -10,6 +10,7 @@ import (
func (s Service) GetAll(ctx context.Context, req param.KindBoxGetAllRequest) (param.KindBoxGetAllResponse, error) { func (s Service) GetAll(ctx context.Context, req param.KindBoxGetAllRequest) (param.KindBoxGetAllResponse, error) {
const op = "adminkindboxservice.GetAll" const op = "adminkindboxservice.GetAll"
if fieldErrors, vErr := s.vld.ValidateGetAll(req); vErr != nil { if fieldErrors, vErr := s.vld.ValidateGetAll(req); vErr != nil {
return param.KindBoxGetAllResponse{FieldErrors: fieldErrors}, richerror.New(op).WithErr(vErr) 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) 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{ return param.KindBoxGetAllResponse{
AllKindBox: allKindBox, Data: data,
Pagination: paginationparam.PaginationResponse{ Pagination: paginationparam.PaginationResponse{
PageSize: req.Pagination.GetPageSize(), PageSize: req.Pagination.GetPageSize(),
PageNumber: req.Pagination.GetPageNumber(), PageNumber: req.Pagination.GetPageNumber(),

View File

@ -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{}, richerror.New(op).WithErr(gErr)
} }
return param.KindBoxReqAcceptResponse{ return param.KindBoxReqAcceptResponse{Data: param.Data{
KindBoxReqID: kindBoxReq.ID, ID: kindBoxReq.ID,
KindBoxReqStatus: kindBoxReq.Status, BenefactorID: kindBoxReq.BenefactorID,
CountRequested: kindBoxReq.CountRequested, KindBoxType: kindBoxReq.KindBoxType,
CountAccepted: kindBoxReq.CountAccepted, CountRequested: kindBoxReq.CountRequested,
DeliverReferDate: kindBoxReq.DeliverReferDate, CountAccepted: kindBoxReq.CountAccepted,
DeliverAddressID: kindBoxReq.DeliverAddressID, Description: kindBoxReq.Description,
}, nil Status: kindBoxReq.Status,
DeliverReferTimeID: kindBoxReq.DeliverReferTimeID,
DeliverReferDate: kindBoxReq.DeliverReferDate,
DeliverAddressID: kindBoxReq.DeliverAddressID,
SenderAgentID: kindBoxReq.SenderAgentID,
DeliveredAt: kindBoxReq.DeliveredAt,
}}, nil
} }

View File

@ -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{}, 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
} }

View File

@ -18,6 +18,19 @@ func (s Service) Get(ctx context.Context, req param.GetKindBoxReqRequest) (param
} }
return param.GetKindBoxReqResponse{ 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 }, nil
} }

View File

@ -18,9 +18,26 @@ func (s Service) GetAll(ctx context.Context, req param.KindBoxReqGetAllRequest)
if err != nil { if err != nil {
return param.KindBoxReqGetAllResponse{}, richerror.New(op).WithErr(err).WithKind(richerror.KindUnexpected) 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{ return param.KindBoxReqGetAllResponse{
AllKindBoxReq: allKindBoxReq, Data: data,
Pagination: paginationparam.PaginationResponse{ Pagination: paginationparam.PaginationResponse{
PageSize: req.Pagination.GetPageSize(), PageSize: req.Pagination.GetPageSize(),
PageNumber: req.Pagination.GetPageNumber(), PageNumber: req.Pagination.GetPageNumber(),

View File

@ -19,9 +19,26 @@ func (s Service) GetAllAwaitingDelivery(ctx context.Context, req param.DeliveryA
if err != nil { if err != nil {
return param.DeliveryAwaitingGetAllResponse{}, richerror.New(op).WithErr(err) 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{ return param.DeliveryAwaitingGetAllResponse{
AllAwaitingKindBoxReq: allAwaitingKindBoxReq, Data: data,
Pagination: paginationparam.PaginationResponse{ Pagination: paginationparam.PaginationResponse{
PageSize: req.Pagination.GetPageSize(), PageSize: req.Pagination.GetPageSize(),
PageNumber: req.Pagination.GetPageNumber(), PageNumber: req.Pagination.GetPageNumber(),

View File

@ -18,6 +18,19 @@ func (s Service) GetAwaitingDelivery(ctx context.Context, req param.DeliveryAwai
} }
return param.DeliveryAwaitingGetResponse{ 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 }, nil
} }

View File

@ -23,13 +23,19 @@ func (s Service) Reject(ctx context.Context, req param.KindBoxReqRejectRequest)
} }
return param.KindBoxReqRejectResponse{ return param.KindBoxReqRejectResponse{
ID: kindBoxReq.ID, Data: param.Data{
KindBoxType: kindBoxReq.KindBoxType, ID: kindBoxReq.ID,
CountRequested: kindBoxReq.CountRequested, BenefactorID: kindBoxReq.BenefactorID,
BenefactorID: kindBoxReq.BenefactorID, KindBoxType: kindBoxReq.KindBoxType,
Status: kindBoxReq.Status, CountRequested: kindBoxReq.CountRequested,
Description: kindBoxReq.Description, CountAccepted: kindBoxReq.CountAccepted,
DeliverReferDate: kindBoxReq.DeliverReferDate, Description: kindBoxReq.Description,
DeliverAddressID: kindBoxReq.DeliverAddressID, Status: kindBoxReq.Status,
DeliverReferTimeID: kindBoxReq.DeliverReferTimeID,
DeliverReferDate: kindBoxReq.DeliverReferDate,
DeliverAddressID: kindBoxReq.DeliverAddressID,
SenderAgentID: kindBoxReq.SenderAgentID,
DeliveredAt: kindBoxReq.DeliveredAt,
},
}, nil }, nil
} }

View File

@ -18,6 +18,24 @@ func (s Service) Get(ctx context.Context, req param.GetKindBoxRequest) (param.Ge
} }
return param.GetKindBoxResponse{ 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 }, nil
} }

View File

@ -18,8 +18,31 @@ func (s Service) GetAll(ctx context.Context, req param.GetAllRequest) (param.Get
return param.GetAllResponse{}, richerror.New(op).WithErr(err) 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{ return param.GetAllResponse{
AllKindBoxes: allKindBoxes, Data: data,
Pagination: paginationparam.PaginationResponse{ Pagination: paginationparam.PaginationResponse{
PageSize: req.Pagination.GetPageSize(), PageSize: req.Pagination.GetPageSize(),
PageNumber: req.Pagination.GetPageNumber(), PageNumber: req.Pagination.GetPageNumber(),

View File

@ -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{}, 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
} }

View File

@ -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{}, 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
} }

View File

@ -14,6 +14,19 @@ func (s Service) GetAll(ctx context.Context, request param.GetAllAddressesReques
if err != nil { if err != nil {
return param.GetAllAddressesResponse{}, richerror.New(op).WithErr(err).WithKind(richerror.KindUnexpected) return param.GetAllAddressesResponse{}, richerror.New(op).WithErr(err).WithKind(richerror.KindUnexpected)
} }
var data []param.Data
return param.GetAllAddressesResponse{AllAddresses: addresses}, nil 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
} }

View File

@ -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{}, richerror.New(op).WithErr(err).WithKind(richerror.KindUnexpected)
} }
return param.GetAllCitiesResponse{Cities: Cities}, nil return param.GetAllCitiesResponse{Data: Cities}, nil
} }

View File

@ -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{}, richerror.New(op).WithErr(err).WithKind(richerror.KindUnexpected)
} }
return param.GetAllProvincesResponse{Provinces: provinces}, nil return param.GetAllProvincesResponse{Data: provinces}, nil
} }

View File

@ -58,7 +58,7 @@ func (s Service) LoginOrRegister(ctx context.Context, req benefactoreparam.Login
} }
return benefactoreparam.LoginOrRegisterResponse{ return benefactoreparam.LoginOrRegisterResponse{
BenefactorInfo: benefactoreparam.BenefactroInfo{ Data: benefactoreparam.Data{
ID: benefactor.ID, ID: benefactor.ID,
FirstName: benefactor.FirstName, FirstName: benefactor.FirstName,
LastName: benefactor.LastName, LastName: benefactor.LastName,

View File

@ -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{}, 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
} }

View File

@ -19,8 +19,31 @@ func (s Service) GetAll(ctx context.Context, req param.KindBoxGetAllRequest) (pa
return param.KindBoxGetAllResponse{}, richerror.New(op).WithErr(err) 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{ return param.KindBoxGetAllResponse{
AllKindBox: allKindBox, Data: data,
Pagination: params.PaginationResponse{ Pagination: params.PaginationResponse{
PageSize: req.Pagination.GetPageSize(), PageSize: req.Pagination.GetPageSize(),
PageNumber: req.Pagination.GetPageNumber(), PageNumber: req.Pagination.GetPageNumber(),

View File

@ -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{}, 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
} }

View File

@ -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{}, 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
} }

View File

@ -19,8 +19,26 @@ func (s Service) GetAll(ctx context.Context, req param.GetAllRequest) (param.Get
return param.GetAllResponse{}, richerror.New(op).WithErr(err) 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{ return param.GetAllResponse{
AllKindBoxReq: allKindBoxReq, Data: data,
Pagination: params.PaginationResponse{ Pagination: params.PaginationResponse{
PageSize: req.Pagination.GetPageSize(), PageSize: req.Pagination.GetPageSize(),
PageNumber: req.Pagination.GetPageNumber(), PageNumber: req.Pagination.GetPageNumber(),

View File

@ -20,9 +20,9 @@ func (s Service) KindBoxEnumerated(req params.NotificationKindBoxEnumerated) {
if err != nil { if err != nil {
fmt.Println(fmt.Errorf("error(%s):%w", op, err)) 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 { if gErr != nil {
fmt.Println(fmt.Errorf("error(%s):%w", op, gErr)) 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))
} }

View File

@ -22,7 +22,7 @@ func (s Service) KindBoxRegisteredEmptyingRequest(req params.NotificationKindBox
if err != nil { if err != nil {
fmt.Println(fmt.Errorf("error(%s):%w", op, err)) 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 { if gErr != nil {
fmt.Println(fmt.Errorf("error(%s):%w", op, gErr)) fmt.Println(fmt.Errorf("error(%s):%w", op, gErr))
} }

View File

@ -20,7 +20,7 @@ func (s Service) KindBoxReqAccepted(req params.NotificationKindBoxReqAccepted) {
if err != nil { if err != nil {
fmt.Println(fmt.Errorf("error(%s):%w", op, err)) 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 { if gErr != nil {
fmt.Println(fmt.Errorf("error(%s):%w", op, gErr)) fmt.Println(fmt.Errorf("error(%s):%w", op, gErr))
} }

View File

@ -22,7 +22,7 @@ func (s Service) KindBoxReqAdded(req params.NotificationKindBoxReqAdded) {
if err != nil { if err != nil {
fmt.Println(fmt.Errorf("error(%s):%w", op, err)) 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 { if gErr != nil {
fmt.Println(fmt.Errorf("error(%s):%w", op, gErr)) fmt.Println(fmt.Errorf("error(%s):%w", op, gErr))
} }

View File

@ -20,9 +20,9 @@ func (s Service) KindBoxReqAssigned(req params.NotificationKindBoxReqAssigned) {
if err != nil { if err != nil {
fmt.Println(fmt.Errorf("error(%s):%w", op, err)) 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 { if gErr != nil {
fmt.Println(fmt.Errorf("error(%s):%w", op, gErr)) 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))
} }

View File

@ -20,7 +20,7 @@ func (s Service) KindBoxReqRejected(req params.NotificationKindBoxReqRejected) {
if err != nil { if err != nil {
fmt.Println(fmt.Errorf("error(%s):%w", op, err)) 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 { if gErr != nil {
fmt.Println(fmt.Errorf("error(%s):%w", op, gErr)) fmt.Println(fmt.Errorf("error(%s):%w", op, gErr))
} }