forked from ebhomengo/niki
1
0
Fork 0

Merge pull request 'refactor(param): remove embedded entities in delivery response structs' (#169) from stage/erfan/refactor-delivery-response-params into develop

Reviewed-on: ebhomengo/niki#169
This commit is contained in:
hossein 2024-09-11 06:07:35 +00:00
commit a3bd4247a2
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{
KindBoxID: resp.ID,
KindBoxID: resp.Data.ID,
})
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{
KindBoxReqID: resp.KindBoxReq.ID,
KindBoxReqID: resp.Data.ID,
})
return c.JSON(http.StatusCreated, resp)

View File

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

View File

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

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
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

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

View File

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

View File

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

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

View File

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

View File

@ -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"`
Data Data `json:"data"`
FieldErrors map[string]string `json:"field_errors,omitempty"`
}

View File

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

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

View File

@ -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"`
Data []Data `json:"data"`
Pagination param.PaginationResponse `json:"pagination"`
FieldErrors map[string]string `json:"field_errors,omitempty"`
}

View File

@ -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"`
Data []Data `json:"data"`
Pagination param.PaginationResponse `json:"pagination"`
FieldErrors map[string]string `json:"field_errors,omitempty"`
}

View File

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

View File

@ -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"`
Data Data `json:"data"`
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
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"`
}

View File

@ -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"`
Data []Data `json:"data"`
Pagination param.PaginationResponse `json:"pagination"`
FieldErrors map[string]string `json:"field_errors,omitempty"`
}

View File

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

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
}
type GetAddressResponse struct {
Address entity.Address `json:"address"`
Data Data `json:"data"`
FieldErrors map[string]string `json:"field_errors,omitempty"`
}

View File

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

View File

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

View File

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

View File

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

View File

@ -6,7 +6,7 @@ type LoginOrRegisterRequest struct {
}
type LoginOrRegisterResponse struct {
BenefactorInfo BenefactroInfo `json:"benefactore_info"`
Data Data `json:"data"`
Tokens Tokens `json:"tokens"`
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
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"`
}

View File

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

View File

@ -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"`
Data Data `json:"data"`
FieldErrors map[string]string `json:"field_errors,omitempty"`
}

View File

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

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
import entity "git.gocasts.ir/ebhomengo/niki/entity"
type KindBoxReqGetRequest struct {
BenefactorID uint
KindBoxReqID uint
}
type KindBoxReqGetResponse struct {
entity.KindBoxReq `json:"kind_box_req"`
Data Data `json:"data"`
FieldErrors map[string]string `json:"field_errors,omitempty"`
}

View File

@ -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"`
Data []Data `json:"data"`
Pagination param.PaginationResponse `json:"pagination"`
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
}
//nolint
// nolint
func (s *Supervisor) retryInterval(name string) time.Duration {
s.lock.Lock()
defer s.lock.Unlock()

View File

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

View File

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

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{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) {
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
}

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{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) {
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(),

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{
KindBoxReqID: kindBoxReq.ID,
KindBoxReqStatus: kindBoxReq.Status,
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,
}, nil
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{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{
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
}

View File

@ -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(),

View File

@ -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(),

View File

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

View File

@ -23,13 +23,19 @@ func (s Service) Reject(ctx context.Context, req param.KindBoxReqRejectRequest)
}
return param.KindBoxReqRejectResponse{
Data: param.Data{
ID: kindBoxReq.ID,
BenefactorID: kindBoxReq.BenefactorID,
KindBoxType: kindBoxReq.KindBoxType,
CountRequested: kindBoxReq.CountRequested,
BenefactorID: kindBoxReq.BenefactorID,
Status: kindBoxReq.Status,
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,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
}

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)
}
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(),

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

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{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{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{
BenefactorInfo: benefactoreparam.BenefactroInfo{
Data: benefactoreparam.Data{
ID: benefactor.ID,
FirstName: benefactor.FirstName,
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{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)
}
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(),

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{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{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)
}
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(),

View File

@ -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))
}

View File

@ -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))
}

View File

@ -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))
}

View File

@ -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))
}

View File

@ -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))
}

View File

@ -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))
}