forked from ebhomengo/niki
fix(niki): agent structure refactor
This commit is contained in:
parent
5526088b35
commit
b55ec32b21
|
@ -13,11 +13,8 @@ func (h Handler) SetRoutes(e *echo.Echo) {
|
||||||
r.POST("", h.AddKindBoxReq, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxReqAddPermission))
|
r.POST("", h.AddKindBoxReq, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxReqAddPermission))
|
||||||
r.PATCH("/:id/accept-kind-box-req", h.Accept, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxReqAcceptPermission))
|
r.PATCH("/:id/accept-kind-box-req", h.Accept, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxReqAcceptPermission))
|
||||||
r.PATCH("/:id/reject-kind-box-req", h.Reject, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxReqRejectPermission))
|
r.PATCH("/:id/reject-kind-box-req", h.Reject, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxReqRejectPermission))
|
||||||
r.PATCH("/:id/deliver-kind-box-req", h.Deliver, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxReqDeliverPermission))
|
|
||||||
r.PATCH("/:id/assign-sender-agent", h.AssignSenderAgent, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxReqAssignSenderAgentPermission))
|
r.PATCH("/:id/assign-sender-agent", h.AssignSenderAgent, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxReqAssignSenderAgentPermission))
|
||||||
r.GET("", h.GetAll, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxReqGetAllPermission))
|
r.GET("", h.GetAll, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxReqGetAllPermission))
|
||||||
r.GET("/awaiting-delivery/:id", h.GetAwaitingDelivery, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxReqGetAwaitingDeliveryPermission))
|
|
||||||
r.GET("/awaiting-delivery", h.GetAllAwaitingDelivery, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxReqGetAwaitingDeliveryPermission))
|
|
||||||
r.PUT("/:id", h.Update, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxReqUpdatePermission))
|
r.PUT("/:id", h.Update, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxReqUpdatePermission))
|
||||||
r.GET("/:id", h.Get, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxReqGetPermission))
|
r.GET("/:id", h.Get, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxReqGetPermission))
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package adminkindboxreqhandler
|
package agentkindboxreqhandler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
param "git.gocasts.ir/ebhomengo/niki/param/agent/kind_box_req"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box_req"
|
|
||||||
errmsg "git.gocasts.ir/ebhomengo/niki/pkg/err_msg"
|
errmsg "git.gocasts.ir/ebhomengo/niki/pkg/err_msg"
|
||||||
httpmsg "git.gocasts.ir/ebhomengo/niki/pkg/http_msg"
|
httpmsg "git.gocasts.ir/ebhomengo/niki/pkg/http_msg"
|
||||||
querier "git.gocasts.ir/ebhomengo/niki/pkg/query_transaction/sql"
|
querier "git.gocasts.ir/ebhomengo/niki/pkg/query_transaction/sql"
|
||||||
|
@ -12,8 +12,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// Deliver godoc
|
// Deliver godoc
|
||||||
// @Summary Admin deliver a kindboxreq
|
// @Summary Agent deliver a kindboxreq
|
||||||
// @Tags Admins KindBoxReqs
|
// @Tags Agents KindBoxReqs
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param id path int true "KindBoxReq ID"
|
// @Param id path int true "KindBoxReq ID"
|
||||||
|
@ -21,7 +21,7 @@ import (
|
||||||
// @Success 200 {object} param.DeliverKindBoxReqResponse
|
// @Success 200 {object} param.DeliverKindBoxReqResponse
|
||||||
// @Failure 400 {string} "Bad request"
|
// @Failure 400 {string} "Bad request"
|
||||||
// @Security AuthBearerAdmin
|
// @Security AuthBearerAdmin
|
||||||
// @Router /admins/kindboxreqs/{id}/deliver-kind-box-req [patch].
|
// @Router /agents/kindboxreqs/{id}/deliver-kind-box-req [patch].
|
||||||
func (h Handler) Deliver(c echo.Context) error {
|
func (h Handler) Deliver(c echo.Context) error {
|
||||||
var req param.DeliverKindBoxReqRequest
|
var req param.DeliverKindBoxReqRequest
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ func (h Handler) Deliver(c echo.Context) error {
|
||||||
|
|
||||||
q := querier.GetQuerierFromContextOrNew(c.Request().Context()).Begin()
|
q := querier.GetQuerierFromContextOrNew(c.Request().Context()).Begin()
|
||||||
ctx := context.WithValue(c.Request().Context(), querier.QuerierContextKey, q)
|
ctx := context.WithValue(c.Request().Context(), querier.QuerierContextKey, q)
|
||||||
resp, sErr := h.adminKindBoxReqSvc.Deliver(ctx, req)
|
resp, sErr := h.agentKindBoxReqSvc.Deliver(ctx, req)
|
||||||
if sErr != nil {
|
if sErr != nil {
|
||||||
msg, code := httpmsg.Error(sErr)
|
msg, code := httpmsg.Error(sErr)
|
||||||
if resp.FieldErrors != nil {
|
if resp.FieldErrors != nil {
|
|
@ -1,10 +1,10 @@
|
||||||
package adminkindboxreqhandler
|
package agentkindboxreqhandler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
param "git.gocasts.ir/ebhomengo/niki/param/agent/kind_box_req"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"git.gocasts.ir/ebhomengo/niki/entity"
|
"git.gocasts.ir/ebhomengo/niki/entity"
|
||||||
param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box_req"
|
|
||||||
"git.gocasts.ir/ebhomengo/niki/pkg/claim"
|
"git.gocasts.ir/ebhomengo/niki/pkg/claim"
|
||||||
httpmsg "git.gocasts.ir/ebhomengo/niki/pkg/http_msg"
|
httpmsg "git.gocasts.ir/ebhomengo/niki/pkg/http_msg"
|
||||||
queryparam "git.gocasts.ir/ebhomengo/niki/pkg/query_param"
|
queryparam "git.gocasts.ir/ebhomengo/niki/pkg/query_param"
|
||||||
|
@ -14,7 +14,7 @@ import (
|
||||||
// GetAllAwaitingDelivery godoc
|
// GetAllAwaitingDelivery godoc
|
||||||
// @Summary Get all awaiting delivery KindBox requests
|
// @Summary Get all awaiting delivery KindBox requests
|
||||||
// @Description Retrieves a list of all awaiting KindBox requests with filtering, sorting, and pagination options
|
// @Description Retrieves a list of all awaiting KindBox requests with filtering, sorting, and pagination options
|
||||||
// @Tags Admins KindBoxReqs
|
// @Tags Agents KindBoxReqs
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param filter_id query int false "Filter by ID"
|
// @Param filter_id query int false "Filter by ID"
|
||||||
|
@ -32,7 +32,7 @@ import (
|
||||||
// @Success 200 {object} param.DeliveryAwaitingGetAllResponse
|
// @Success 200 {object} param.DeliveryAwaitingGetAllResponse
|
||||||
// @Failure 400 {string} "Bad request"
|
// @Failure 400 {string} "Bad request"
|
||||||
// @Security AuthBearerAdmin
|
// @Security AuthBearerAdmin
|
||||||
// @Router /admins/kindboxreqs/awaiting-delivery [get].
|
// @Router /agents/kindboxreqs/awaiting-delivery [get].
|
||||||
func (h Handler) GetAllAwaitingDelivery(c echo.Context) error {
|
func (h Handler) GetAllAwaitingDelivery(c echo.Context) error {
|
||||||
var req param.DeliveryAwaitingGetAllRequest
|
var req param.DeliveryAwaitingGetAllRequest
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ func (h Handler) GetAllAwaitingDelivery(c echo.Context) error {
|
||||||
req.Filter = queryparam.GetFilterParams(c)
|
req.Filter = queryparam.GetFilterParams(c)
|
||||||
req.Filter["sender_agent_id"] = claim.GetClaimsFromEchoContext(c).UserID
|
req.Filter["sender_agent_id"] = claim.GetClaimsFromEchoContext(c).UserID
|
||||||
req.Filter["status"] = entity.KindBoxReqAssignedSenderAgentStatus
|
req.Filter["status"] = entity.KindBoxReqAssignedSenderAgentStatus
|
||||||
resp, sErr := h.adminKindBoxReqSvc.GetAllAwaitingDelivery(c.Request().Context(), req)
|
resp, sErr := h.agentKindBoxReqSvc.GetAllAwaitingDelivery(c.Request().Context(), req)
|
||||||
if sErr != nil {
|
if sErr != nil {
|
||||||
msg, code := httpmsg.Error(sErr)
|
msg, code := httpmsg.Error(sErr)
|
||||||
if resp.FieldErrors != nil {
|
if resp.FieldErrors != nil {
|
|
@ -1,9 +1,9 @@
|
||||||
package adminkindboxreqhandler
|
package agentkindboxreqhandler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
param "git.gocasts.ir/ebhomengo/niki/param/agent/kind_box_req"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box_req"
|
|
||||||
"git.gocasts.ir/ebhomengo/niki/pkg/claim"
|
"git.gocasts.ir/ebhomengo/niki/pkg/claim"
|
||||||
httpmsg "git.gocasts.ir/ebhomengo/niki/pkg/http_msg"
|
httpmsg "git.gocasts.ir/ebhomengo/niki/pkg/http_msg"
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
|
@ -11,14 +11,14 @@ import (
|
||||||
|
|
||||||
// GetAwaitingDelivery godoc
|
// GetAwaitingDelivery godoc
|
||||||
// @Summary Get a kind box reqs that is awaiting delivery by agent
|
// @Summary Get a kind box reqs that is awaiting delivery by agent
|
||||||
// @Tags Admins KindBoxReqs
|
// @Tags Agents KindBoxReqs
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param id path int true "KindBoxReq ID"
|
// @Param id path int true "KindBoxReq ID"
|
||||||
// @Success 200 {object} param.DeliveryAwaitingGetResponse
|
// @Success 200 {object} param.DeliveryAwaitingGetResponse
|
||||||
// @Failure 400 {string} "Bad request"
|
// @Failure 400 {string} "Bad request"
|
||||||
// @Security AuthBearerAdmin
|
// @Security AuthBearerAdmin
|
||||||
// @Router /admins/kindboxreqs/awaiting-delivery/{id} [get].
|
// @Router /agents/kindboxreqs/awaiting-delivery/{id} [get].
|
||||||
func (h Handler) GetAwaitingDelivery(c echo.Context) error {
|
func (h Handler) GetAwaitingDelivery(c echo.Context) error {
|
||||||
var req param.DeliveryAwaitingGetRequest
|
var req param.DeliveryAwaitingGetRequest
|
||||||
if bErr := c.Bind(&req); bErr != nil {
|
if bErr := c.Bind(&req); bErr != nil {
|
||||||
|
@ -28,7 +28,7 @@ func (h Handler) GetAwaitingDelivery(c echo.Context) error {
|
||||||
claims := claim.GetClaimsFromEchoContext(c)
|
claims := claim.GetClaimsFromEchoContext(c)
|
||||||
req.AgentID = claims.UserID
|
req.AgentID = claims.UserID
|
||||||
|
|
||||||
resp, sErr := h.adminKindBoxReqSvc.GetAwaitingDelivery(c.Request().Context(), req)
|
resp, sErr := h.agentKindBoxReqSvc.GetAwaitingDelivery(c.Request().Context(), req)
|
||||||
if sErr != nil {
|
if sErr != nil {
|
||||||
msg, code := httpmsg.Error(sErr)
|
msg, code := httpmsg.Error(sErr)
|
||||||
if resp.FieldErrors != nil {
|
if resp.FieldErrors != nil {
|
|
@ -0,0 +1,24 @@
|
||||||
|
package agentkindboxreqhandler
|
||||||
|
|
||||||
|
import (
|
||||||
|
adminauthorizationservice "git.gocasts.ir/ebhomengo/niki/service/admin/authorization"
|
||||||
|
agentkindboxreqservice "git.gocasts.ir/ebhomengo/niki/service/agent/kind_box_req"
|
||||||
|
authservice "git.gocasts.ir/ebhomengo/niki/service/auth"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Handler struct {
|
||||||
|
authSvc authservice.Service
|
||||||
|
agentKindBoxReqSvc agentkindboxreqservice.Service
|
||||||
|
adminAuthorizeSvc adminauthorizationservice.Service
|
||||||
|
}
|
||||||
|
|
||||||
|
func New(authSvc authservice.Service,
|
||||||
|
agentKindBoxReqSvc agentkindboxreqservice.Service,
|
||||||
|
adminAuthorizeSvc adminauthorizationservice.Service,
|
||||||
|
) Handler {
|
||||||
|
return Handler{
|
||||||
|
authSvc: authSvc,
|
||||||
|
agentKindBoxReqSvc: agentKindBoxReqSvc,
|
||||||
|
adminAuthorizeSvc: adminAuthorizeSvc,
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package agentkindboxreqhandler
|
||||||
|
|
||||||
|
import (
|
||||||
|
"git.gocasts.ir/ebhomengo/niki/delivery/http_server/middleware"
|
||||||
|
"git.gocasts.ir/ebhomengo/niki/entity"
|
||||||
|
"github.com/labstack/echo/v4"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (h Handler) SetRoutes(e *echo.Echo) {
|
||||||
|
r := e.Group("/agents/kindboxreqs")
|
||||||
|
|
||||||
|
r.Use(middleware.Auth(h.authSvc))
|
||||||
|
r.GET("/awaiting-delivery/:id", h.GetAwaitingDelivery, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxReqGetAwaitingDeliveryPermission))
|
||||||
|
r.GET("/awaiting-delivery", h.GetAllAwaitingDelivery, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxReqGetAwaitingDeliveryPermission))
|
||||||
|
r.PATCH("/:id/deliver-kind-box-req", h.Deliver, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxReqDeliverPermission))
|
||||||
|
}
|
|
@ -2,6 +2,7 @@ package httpserver
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
agentkindboxreqhandler "git.gocasts.ir/ebhomengo/niki/delivery/http_server/agent/kind_box_req"
|
||||||
|
|
||||||
"git.gocasts.ir/ebhomengo/niki/config"
|
"git.gocasts.ir/ebhomengo/niki/config"
|
||||||
adminhandler "git.gocasts.ir/ebhomengo/niki/delivery/http_server/admin/admin"
|
adminhandler "git.gocasts.ir/ebhomengo/niki/delivery/http_server/admin/admin"
|
||||||
|
@ -28,6 +29,7 @@ type Server struct {
|
||||||
adminKindBoxHandler adminKindBoxHandler.Handler
|
adminKindBoxHandler adminKindBoxHandler.Handler
|
||||||
adminAgentHandler adminagenthandler.Handler
|
adminAgentHandler adminagenthandler.Handler
|
||||||
agentKindBoxHandler agentkindboxhandler.Handler
|
agentKindBoxHandler agentkindboxhandler.Handler
|
||||||
|
agentKindBoxReqHandler agentkindboxreqhandler.Handler
|
||||||
benefactorHandler benefactorhandler.Handler
|
benefactorHandler benefactorhandler.Handler
|
||||||
benefactorKindBoxReqHandler benefactorkindboxreqhandler.Handler
|
benefactorKindBoxReqHandler benefactorkindboxreqhandler.Handler
|
||||||
benefactorAddressHandler benefactoraddresshandler.Handler
|
benefactorAddressHandler benefactoraddresshandler.Handler
|
||||||
|
@ -46,6 +48,7 @@ func New(
|
||||||
adminKindBoxHandler: adminKindBoxHandler.New(svc.AdminAuthSvc, svc.AdminKindBoxSvc, svc.AdminAuthorizeSvc, svc.NotificationSvc),
|
adminKindBoxHandler: adminKindBoxHandler.New(svc.AdminAuthSvc, svc.AdminKindBoxSvc, svc.AdminAuthorizeSvc, svc.NotificationSvc),
|
||||||
adminAgentHandler: adminagenthandler.New(svc.AdminAuthSvc, svc.AdminAgentSvc, svc.AdminAuthorizeSvc),
|
adminAgentHandler: adminagenthandler.New(svc.AdminAuthSvc, svc.AdminAgentSvc, svc.AdminAuthorizeSvc),
|
||||||
agentKindBoxHandler: agentkindboxhandler.New(svc.AdminAuthSvc, svc.AgentKindBoxSvc, svc.AdminAuthorizeSvc),
|
agentKindBoxHandler: agentkindboxhandler.New(svc.AdminAuthSvc, svc.AgentKindBoxSvc, svc.AdminAuthorizeSvc),
|
||||||
|
agentKindBoxReqHandler: agentkindboxreqhandler.New(svc.AdminAuthSvc, svc.AgentKindBoxReqSvc, svc.AdminAuthorizeSvc),
|
||||||
benefactorHandler: benefactorhandler.New(svc.BenefactorAuthSvc, svc.BenefactorSvc),
|
benefactorHandler: benefactorhandler.New(svc.BenefactorAuthSvc, svc.BenefactorSvc),
|
||||||
benefactorKindBoxReqHandler: benefactorkindboxreqhandler.New(svc.BenefactorAuthSvc, svc.BenefactorKindBoxReqSvc, svc.NotificationSvc),
|
benefactorKindBoxReqHandler: benefactorkindboxreqhandler.New(svc.BenefactorAuthSvc, svc.BenefactorKindBoxReqSvc, svc.NotificationSvc),
|
||||||
benefactorAddressHandler: benefactoraddresshandler.New(svc.BenefactorAuthSvc, svc.BenefactorAddressSvc),
|
benefactorAddressHandler: benefactoraddresshandler.New(svc.BenefactorAuthSvc, svc.BenefactorAddressSvc),
|
||||||
|
@ -83,6 +86,7 @@ func (s Server) RegisterRoutes() {
|
||||||
s.adminKindBoxReqHandler.SetRoutes(s.Router)
|
s.adminKindBoxReqHandler.SetRoutes(s.Router)
|
||||||
s.adminKindBoxHandler.SetRoutes(s.Router)
|
s.adminKindBoxHandler.SetRoutes(s.Router)
|
||||||
s.agentKindBoxHandler.SetRoutes(s.Router)
|
s.agentKindBoxHandler.SetRoutes(s.Router)
|
||||||
|
s.agentKindBoxReqHandler.SetRoutes(s.Router)
|
||||||
}
|
}
|
||||||
|
|
||||||
func registerSwagger(s *echo.Echo) {
|
func registerSwagger(s *echo.Echo) {
|
||||||
|
|
607
docs/docs.go
607
docs/docs.go
|
@ -709,177 +709,6 @@ const docTemplate = `{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/admins/kindboxreqs/awaiting-delivery": {
|
|
||||||
"get": {
|
|
||||||
"security": [
|
|
||||||
{
|
|
||||||
"AuthBearerAdmin": []
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Retrieves a list of all awaiting KindBox requests with filtering, sorting, and pagination options",
|
|
||||||
"consumes": [
|
|
||||||
"application/json"
|
|
||||||
],
|
|
||||||
"produces": [
|
|
||||||
"application/json"
|
|
||||||
],
|
|
||||||
"tags": [
|
|
||||||
"Admins KindBoxReqs"
|
|
||||||
],
|
|
||||||
"summary": "Get all awaiting delivery KindBox requests",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"type": "integer",
|
|
||||||
"description": "Filter by ID",
|
|
||||||
"name": "filter_id",
|
|
||||||
"in": "query"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "integer",
|
|
||||||
"description": "Filter by benefactor ID",
|
|
||||||
"name": "filter_benefactor_id",
|
|
||||||
"in": "query"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"enum": [
|
|
||||||
"on-table",
|
|
||||||
"cylindrical",
|
|
||||||
"stand-up"
|
|
||||||
],
|
|
||||||
"type": "string",
|
|
||||||
"format": "enum",
|
|
||||||
"description": "Filter by KindBox type",
|
|
||||||
"name": "filter_kind_box_type",
|
|
||||||
"in": "query"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "integer",
|
|
||||||
"description": "Filter by count requested",
|
|
||||||
"name": "filter_count_requested",
|
|
||||||
"in": "query"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "integer",
|
|
||||||
"description": "Filter by count accepted",
|
|
||||||
"name": "filter_count_accepted",
|
|
||||||
"in": "query"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "integer",
|
|
||||||
"description": "Filter by deliver refer time ID",
|
|
||||||
"name": "filter_deliver_refer_time_id",
|
|
||||||
"in": "query"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "string",
|
|
||||||
"format": "date",
|
|
||||||
"description": "Filter by deliver refer date",
|
|
||||||
"name": "filter_deliver_refer_date",
|
|
||||||
"in": "query"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "integer",
|
|
||||||
"description": "Filter by deliver address ID",
|
|
||||||
"name": "filter_deliver_address_id",
|
|
||||||
"in": "query"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "integer",
|
|
||||||
"description": "Page number",
|
|
||||||
"name": "page_number",
|
|
||||||
"in": "query"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "integer",
|
|
||||||
"description": "Page size",
|
|
||||||
"name": "page_size",
|
|
||||||
"in": "query"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"enum": [
|
|
||||||
"id",
|
|
||||||
"benefactor_id",
|
|
||||||
"kind_box_type",
|
|
||||||
"count_requested",
|
|
||||||
"count_accepted",
|
|
||||||
"deliver_refer_time_id",
|
|
||||||
"deliver_refer_date",
|
|
||||||
"deliver_address_id"
|
|
||||||
],
|
|
||||||
"type": "string",
|
|
||||||
"description": "Sort by field",
|
|
||||||
"name": "sort_field",
|
|
||||||
"in": "query"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"enum": [
|
|
||||||
"asc",
|
|
||||||
"desc"
|
|
||||||
],
|
|
||||||
"type": "string",
|
|
||||||
"description": "Sort order",
|
|
||||||
"name": "sort_direction",
|
|
||||||
"in": "query"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description": "OK",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/adminkindboxreqparam.DeliveryAwaitingGetAllResponse"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"400": {
|
|
||||||
"description": "Bad request",
|
|
||||||
"schema": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"/admins/kindboxreqs/awaiting-delivery/{id}": {
|
|
||||||
"get": {
|
|
||||||
"security": [
|
|
||||||
{
|
|
||||||
"AuthBearerAdmin": []
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"consumes": [
|
|
||||||
"application/json"
|
|
||||||
],
|
|
||||||
"produces": [
|
|
||||||
"application/json"
|
|
||||||
],
|
|
||||||
"tags": [
|
|
||||||
"Admins KindBoxReqs"
|
|
||||||
],
|
|
||||||
"summary": "Get a kind box reqs that is awaiting delivery by agent",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"type": "integer",
|
|
||||||
"description": "KindBoxReq ID",
|
|
||||||
"name": "id",
|
|
||||||
"in": "path",
|
|
||||||
"required": true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description": "OK",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/adminkindboxreqparam.DeliveryAwaitingGetResponse"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"400": {
|
|
||||||
"description": "Bad request",
|
|
||||||
"schema": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"/admins/kindboxreqs/{id}": {
|
"/admins/kindboxreqs/{id}": {
|
||||||
"get": {
|
"get": {
|
||||||
"security": [
|
"security": [
|
||||||
|
@ -1094,57 +923,6 @@ const docTemplate = `{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/admins/kindboxreqs/{id}/deliver-kind-box-req": {
|
|
||||||
"patch": {
|
|
||||||
"security": [
|
|
||||||
{
|
|
||||||
"AuthBearerAdmin": []
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"consumes": [
|
|
||||||
"application/json"
|
|
||||||
],
|
|
||||||
"produces": [
|
|
||||||
"application/json"
|
|
||||||
],
|
|
||||||
"tags": [
|
|
||||||
"Admins KindBoxReqs"
|
|
||||||
],
|
|
||||||
"summary": "Admin deliver a kindboxreq",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"type": "integer",
|
|
||||||
"description": "KindBoxReq ID",
|
|
||||||
"name": "id",
|
|
||||||
"in": "path",
|
|
||||||
"required": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "KindBoxReq deliver request details",
|
|
||||||
"name": "Request",
|
|
||||||
"in": "body",
|
|
||||||
"required": true,
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/adminkindboxreqparam.DeliverKindBoxReqRequest"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description": "OK",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/adminkindboxreqparam.DeliverKindBoxReqResponse"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"400": {
|
|
||||||
"description": "Bad request",
|
|
||||||
"schema": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"/admins/kindboxreqs/{id}/reject-kind-box-req": {
|
"/admins/kindboxreqs/{id}/reject-kind-box-req": {
|
||||||
"patch": {
|
"patch": {
|
||||||
"security": [
|
"security": [
|
||||||
|
@ -1563,6 +1341,228 @@ const docTemplate = `{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/agents/kindboxreqs/awaiting-delivery": {
|
||||||
|
"get": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"AuthBearerAdmin": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Retrieves a list of all awaiting KindBox requests with filtering, sorting, and pagination options",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"Agents KindBoxReqs"
|
||||||
|
],
|
||||||
|
"summary": "Get all awaiting delivery KindBox requests",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "Filter by ID",
|
||||||
|
"name": "filter_id",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "Filter by benefactor ID",
|
||||||
|
"name": "filter_benefactor_id",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"enum": [
|
||||||
|
"on-table",
|
||||||
|
"cylindrical",
|
||||||
|
"stand-up"
|
||||||
|
],
|
||||||
|
"type": "string",
|
||||||
|
"format": "enum",
|
||||||
|
"description": "Filter by KindBox type",
|
||||||
|
"name": "filter_kind_box_type",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "Filter by count requested",
|
||||||
|
"name": "filter_count_requested",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "Filter by count accepted",
|
||||||
|
"name": "filter_count_accepted",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "Filter by deliver refer time ID",
|
||||||
|
"name": "filter_deliver_refer_time_id",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"format": "date",
|
||||||
|
"description": "Filter by deliver refer date",
|
||||||
|
"name": "filter_deliver_refer_date",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "Filter by deliver address ID",
|
||||||
|
"name": "filter_deliver_address_id",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "Page number",
|
||||||
|
"name": "page_number",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "Page size",
|
||||||
|
"name": "page_size",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"enum": [
|
||||||
|
"id",
|
||||||
|
"benefactor_id",
|
||||||
|
"kind_box_type",
|
||||||
|
"count_requested",
|
||||||
|
"count_accepted",
|
||||||
|
"deliver_refer_time_id",
|
||||||
|
"deliver_refer_date",
|
||||||
|
"deliver_address_id"
|
||||||
|
],
|
||||||
|
"type": "string",
|
||||||
|
"description": "Sort by field",
|
||||||
|
"name": "sort_field",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"enum": [
|
||||||
|
"asc",
|
||||||
|
"desc"
|
||||||
|
],
|
||||||
|
"type": "string",
|
||||||
|
"description": "Sort order",
|
||||||
|
"name": "sort_direction",
|
||||||
|
"in": "query"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/agentkindboxreqparam.DeliveryAwaitingGetAllResponse"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "Bad request",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/agents/kindboxreqs/awaiting-delivery/{id}": {
|
||||||
|
"get": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"AuthBearerAdmin": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"Agents KindBoxReqs"
|
||||||
|
],
|
||||||
|
"summary": "Get a kind box reqs that is awaiting delivery by agent",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "KindBoxReq ID",
|
||||||
|
"name": "id",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/agentkindboxreqparam.DeliveryAwaitingGetResponse"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "Bad request",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/agents/kindboxreqs/{id}/deliver-kind-box-req": {
|
||||||
|
"patch": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"AuthBearerAdmin": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"Agents KindBoxReqs"
|
||||||
|
],
|
||||||
|
"summary": "Agent deliver a kindboxreq",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "KindBoxReq ID",
|
||||||
|
"name": "id",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "KindBoxReq deliver request details",
|
||||||
|
"name": "Request",
|
||||||
|
"in": "body",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/agentkindboxreqparam.DeliverKindBoxReqRequest"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/agentkindboxreqparam.DeliverKindBoxReqResponse"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "Bad request",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/benefactors/addresses": {
|
"/benefactors/addresses": {
|
||||||
"get": {
|
"get": {
|
||||||
"security": [
|
"security": [
|
||||||
|
@ -2907,67 +2907,6 @@ const docTemplate = `{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"adminkindboxreqparam.DeliverKindBoxReqRequest": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"serial_numbers": {
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"example": [
|
|
||||||
"1",
|
|
||||||
"2",
|
|
||||||
"3"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"adminkindboxreqparam.DeliverKindBoxReqResponse": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"field_errors": {
|
|
||||||
"type": "object",
|
|
||||||
"additionalProperties": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"adminkindboxreqparam.DeliveryAwaitingGetAllResponse": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"data": {
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/definitions/adminkindboxreqparam.Data"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"field_errors": {
|
|
||||||
"type": "object",
|
|
||||||
"additionalProperties": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"pagination": {
|
|
||||||
"$ref": "#/definitions/param.PaginationResponse"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"adminkindboxreqparam.DeliveryAwaitingGetResponse": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"data": {
|
|
||||||
"$ref": "#/definitions/adminkindboxreqparam.Data"
|
|
||||||
},
|
|
||||||
"field_errors": {
|
|
||||||
"type": "object",
|
|
||||||
"additionalProperties": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"adminkindboxreqparam.GetKindBoxReqResponse": {
|
"adminkindboxreqparam.GetKindBoxReqResponse": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
@ -3390,6 +3329,108 @@ const docTemplate = `{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"agentkindboxreqparam.Data": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"benefactor_id": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"count_accepted": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"count_requested": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"deliver_address_id": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"deliver_refer_date": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"deliver_refer_time_id": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"delivered_at": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"description": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"kind_box_type": {
|
||||||
|
"$ref": "#/definitions/entity.KindBoxType"
|
||||||
|
},
|
||||||
|
"sender_agent_id": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
"$ref": "#/definitions/entity.KindBoxReqStatus"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"agentkindboxreqparam.DeliverKindBoxReqRequest": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"serial_numbers": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"example": [
|
||||||
|
"1",
|
||||||
|
"2",
|
||||||
|
"3"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"agentkindboxreqparam.DeliverKindBoxReqResponse": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"field_errors": {
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"agentkindboxreqparam.DeliveryAwaitingGetAllResponse": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"data": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/agentkindboxreqparam.Data"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"field_errors": {
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"pagination": {
|
||||||
|
"$ref": "#/definitions/param.PaginationResponse"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"agentkindboxreqparam.DeliveryAwaitingGetResponse": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"data": {
|
||||||
|
"$ref": "#/definitions/agentkindboxreqparam.Data"
|
||||||
|
},
|
||||||
|
"field_errors": {
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"benefactoreparam.Data": {
|
"benefactoreparam.Data": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|
|
@ -698,177 +698,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/admins/kindboxreqs/awaiting-delivery": {
|
|
||||||
"get": {
|
|
||||||
"security": [
|
|
||||||
{
|
|
||||||
"AuthBearerAdmin": []
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Retrieves a list of all awaiting KindBox requests with filtering, sorting, and pagination options",
|
|
||||||
"consumes": [
|
|
||||||
"application/json"
|
|
||||||
],
|
|
||||||
"produces": [
|
|
||||||
"application/json"
|
|
||||||
],
|
|
||||||
"tags": [
|
|
||||||
"Admins KindBoxReqs"
|
|
||||||
],
|
|
||||||
"summary": "Get all awaiting delivery KindBox requests",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"type": "integer",
|
|
||||||
"description": "Filter by ID",
|
|
||||||
"name": "filter_id",
|
|
||||||
"in": "query"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "integer",
|
|
||||||
"description": "Filter by benefactor ID",
|
|
||||||
"name": "filter_benefactor_id",
|
|
||||||
"in": "query"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"enum": [
|
|
||||||
"on-table",
|
|
||||||
"cylindrical",
|
|
||||||
"stand-up"
|
|
||||||
],
|
|
||||||
"type": "string",
|
|
||||||
"format": "enum",
|
|
||||||
"description": "Filter by KindBox type",
|
|
||||||
"name": "filter_kind_box_type",
|
|
||||||
"in": "query"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "integer",
|
|
||||||
"description": "Filter by count requested",
|
|
||||||
"name": "filter_count_requested",
|
|
||||||
"in": "query"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "integer",
|
|
||||||
"description": "Filter by count accepted",
|
|
||||||
"name": "filter_count_accepted",
|
|
||||||
"in": "query"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "integer",
|
|
||||||
"description": "Filter by deliver refer time ID",
|
|
||||||
"name": "filter_deliver_refer_time_id",
|
|
||||||
"in": "query"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "string",
|
|
||||||
"format": "date",
|
|
||||||
"description": "Filter by deliver refer date",
|
|
||||||
"name": "filter_deliver_refer_date",
|
|
||||||
"in": "query"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "integer",
|
|
||||||
"description": "Filter by deliver address ID",
|
|
||||||
"name": "filter_deliver_address_id",
|
|
||||||
"in": "query"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "integer",
|
|
||||||
"description": "Page number",
|
|
||||||
"name": "page_number",
|
|
||||||
"in": "query"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "integer",
|
|
||||||
"description": "Page size",
|
|
||||||
"name": "page_size",
|
|
||||||
"in": "query"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"enum": [
|
|
||||||
"id",
|
|
||||||
"benefactor_id",
|
|
||||||
"kind_box_type",
|
|
||||||
"count_requested",
|
|
||||||
"count_accepted",
|
|
||||||
"deliver_refer_time_id",
|
|
||||||
"deliver_refer_date",
|
|
||||||
"deliver_address_id"
|
|
||||||
],
|
|
||||||
"type": "string",
|
|
||||||
"description": "Sort by field",
|
|
||||||
"name": "sort_field",
|
|
||||||
"in": "query"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"enum": [
|
|
||||||
"asc",
|
|
||||||
"desc"
|
|
||||||
],
|
|
||||||
"type": "string",
|
|
||||||
"description": "Sort order",
|
|
||||||
"name": "sort_direction",
|
|
||||||
"in": "query"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description": "OK",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/adminkindboxreqparam.DeliveryAwaitingGetAllResponse"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"400": {
|
|
||||||
"description": "Bad request",
|
|
||||||
"schema": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"/admins/kindboxreqs/awaiting-delivery/{id}": {
|
|
||||||
"get": {
|
|
||||||
"security": [
|
|
||||||
{
|
|
||||||
"AuthBearerAdmin": []
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"consumes": [
|
|
||||||
"application/json"
|
|
||||||
],
|
|
||||||
"produces": [
|
|
||||||
"application/json"
|
|
||||||
],
|
|
||||||
"tags": [
|
|
||||||
"Admins KindBoxReqs"
|
|
||||||
],
|
|
||||||
"summary": "Get a kind box reqs that is awaiting delivery by agent",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"type": "integer",
|
|
||||||
"description": "KindBoxReq ID",
|
|
||||||
"name": "id",
|
|
||||||
"in": "path",
|
|
||||||
"required": true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description": "OK",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/adminkindboxreqparam.DeliveryAwaitingGetResponse"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"400": {
|
|
||||||
"description": "Bad request",
|
|
||||||
"schema": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"/admins/kindboxreqs/{id}": {
|
"/admins/kindboxreqs/{id}": {
|
||||||
"get": {
|
"get": {
|
||||||
"security": [
|
"security": [
|
||||||
|
@ -1083,57 +912,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/admins/kindboxreqs/{id}/deliver-kind-box-req": {
|
|
||||||
"patch": {
|
|
||||||
"security": [
|
|
||||||
{
|
|
||||||
"AuthBearerAdmin": []
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"consumes": [
|
|
||||||
"application/json"
|
|
||||||
],
|
|
||||||
"produces": [
|
|
||||||
"application/json"
|
|
||||||
],
|
|
||||||
"tags": [
|
|
||||||
"Admins KindBoxReqs"
|
|
||||||
],
|
|
||||||
"summary": "Admin deliver a kindboxreq",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"type": "integer",
|
|
||||||
"description": "KindBoxReq ID",
|
|
||||||
"name": "id",
|
|
||||||
"in": "path",
|
|
||||||
"required": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "KindBoxReq deliver request details",
|
|
||||||
"name": "Request",
|
|
||||||
"in": "body",
|
|
||||||
"required": true,
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/adminkindboxreqparam.DeliverKindBoxReqRequest"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description": "OK",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/adminkindboxreqparam.DeliverKindBoxReqResponse"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"400": {
|
|
||||||
"description": "Bad request",
|
|
||||||
"schema": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"/admins/kindboxreqs/{id}/reject-kind-box-req": {
|
"/admins/kindboxreqs/{id}/reject-kind-box-req": {
|
||||||
"patch": {
|
"patch": {
|
||||||
"security": [
|
"security": [
|
||||||
|
@ -1552,6 +1330,228 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/agents/kindboxreqs/awaiting-delivery": {
|
||||||
|
"get": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"AuthBearerAdmin": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Retrieves a list of all awaiting KindBox requests with filtering, sorting, and pagination options",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"Agents KindBoxReqs"
|
||||||
|
],
|
||||||
|
"summary": "Get all awaiting delivery KindBox requests",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "Filter by ID",
|
||||||
|
"name": "filter_id",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "Filter by benefactor ID",
|
||||||
|
"name": "filter_benefactor_id",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"enum": [
|
||||||
|
"on-table",
|
||||||
|
"cylindrical",
|
||||||
|
"stand-up"
|
||||||
|
],
|
||||||
|
"type": "string",
|
||||||
|
"format": "enum",
|
||||||
|
"description": "Filter by KindBox type",
|
||||||
|
"name": "filter_kind_box_type",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "Filter by count requested",
|
||||||
|
"name": "filter_count_requested",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "Filter by count accepted",
|
||||||
|
"name": "filter_count_accepted",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "Filter by deliver refer time ID",
|
||||||
|
"name": "filter_deliver_refer_time_id",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"format": "date",
|
||||||
|
"description": "Filter by deliver refer date",
|
||||||
|
"name": "filter_deliver_refer_date",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "Filter by deliver address ID",
|
||||||
|
"name": "filter_deliver_address_id",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "Page number",
|
||||||
|
"name": "page_number",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "Page size",
|
||||||
|
"name": "page_size",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"enum": [
|
||||||
|
"id",
|
||||||
|
"benefactor_id",
|
||||||
|
"kind_box_type",
|
||||||
|
"count_requested",
|
||||||
|
"count_accepted",
|
||||||
|
"deliver_refer_time_id",
|
||||||
|
"deliver_refer_date",
|
||||||
|
"deliver_address_id"
|
||||||
|
],
|
||||||
|
"type": "string",
|
||||||
|
"description": "Sort by field",
|
||||||
|
"name": "sort_field",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"enum": [
|
||||||
|
"asc",
|
||||||
|
"desc"
|
||||||
|
],
|
||||||
|
"type": "string",
|
||||||
|
"description": "Sort order",
|
||||||
|
"name": "sort_direction",
|
||||||
|
"in": "query"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/agentkindboxreqparam.DeliveryAwaitingGetAllResponse"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "Bad request",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/agents/kindboxreqs/awaiting-delivery/{id}": {
|
||||||
|
"get": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"AuthBearerAdmin": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"Agents KindBoxReqs"
|
||||||
|
],
|
||||||
|
"summary": "Get a kind box reqs that is awaiting delivery by agent",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "KindBoxReq ID",
|
||||||
|
"name": "id",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/agentkindboxreqparam.DeliveryAwaitingGetResponse"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "Bad request",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/agents/kindboxreqs/{id}/deliver-kind-box-req": {
|
||||||
|
"patch": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"AuthBearerAdmin": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"Agents KindBoxReqs"
|
||||||
|
],
|
||||||
|
"summary": "Agent deliver a kindboxreq",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "KindBoxReq ID",
|
||||||
|
"name": "id",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "KindBoxReq deliver request details",
|
||||||
|
"name": "Request",
|
||||||
|
"in": "body",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/agentkindboxreqparam.DeliverKindBoxReqRequest"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/agentkindboxreqparam.DeliverKindBoxReqResponse"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "Bad request",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/benefactors/addresses": {
|
"/benefactors/addresses": {
|
||||||
"get": {
|
"get": {
|
||||||
"security": [
|
"security": [
|
||||||
|
@ -2896,67 +2896,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"adminkindboxreqparam.DeliverKindBoxReqRequest": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"serial_numbers": {
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"example": [
|
|
||||||
"1",
|
|
||||||
"2",
|
|
||||||
"3"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"adminkindboxreqparam.DeliverKindBoxReqResponse": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"field_errors": {
|
|
||||||
"type": "object",
|
|
||||||
"additionalProperties": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"adminkindboxreqparam.DeliveryAwaitingGetAllResponse": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"data": {
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/definitions/adminkindboxreqparam.Data"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"field_errors": {
|
|
||||||
"type": "object",
|
|
||||||
"additionalProperties": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"pagination": {
|
|
||||||
"$ref": "#/definitions/param.PaginationResponse"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"adminkindboxreqparam.DeliveryAwaitingGetResponse": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"data": {
|
|
||||||
"$ref": "#/definitions/adminkindboxreqparam.Data"
|
|
||||||
},
|
|
||||||
"field_errors": {
|
|
||||||
"type": "object",
|
|
||||||
"additionalProperties": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"adminkindboxreqparam.GetKindBoxReqResponse": {
|
"adminkindboxreqparam.GetKindBoxReqResponse": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
@ -3379,6 +3318,108 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"agentkindboxreqparam.Data": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"benefactor_id": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"count_accepted": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"count_requested": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"deliver_address_id": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"deliver_refer_date": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"deliver_refer_time_id": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"delivered_at": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"description": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"kind_box_type": {
|
||||||
|
"$ref": "#/definitions/entity.KindBoxType"
|
||||||
|
},
|
||||||
|
"sender_agent_id": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
"$ref": "#/definitions/entity.KindBoxReqStatus"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"agentkindboxreqparam.DeliverKindBoxReqRequest": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"serial_numbers": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"example": [
|
||||||
|
"1",
|
||||||
|
"2",
|
||||||
|
"3"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"agentkindboxreqparam.DeliverKindBoxReqResponse": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"field_errors": {
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"agentkindboxreqparam.DeliveryAwaitingGetAllResponse": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"data": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/agentkindboxreqparam.Data"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"field_errors": {
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"pagination": {
|
||||||
|
"$ref": "#/definitions/param.PaginationResponse"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"agentkindboxreqparam.DeliveryAwaitingGetResponse": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"data": {
|
||||||
|
"$ref": "#/definitions/agentkindboxreqparam.Data"
|
||||||
|
},
|
||||||
|
"field_errors": {
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"benefactoreparam.Data": {
|
"benefactoreparam.Data": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|
|
@ -252,46 +252,6 @@ definitions:
|
||||||
status:
|
status:
|
||||||
$ref: '#/definitions/entity.KindBoxReqStatus'
|
$ref: '#/definitions/entity.KindBoxReqStatus'
|
||||||
type: object
|
type: object
|
||||||
adminkindboxreqparam.DeliverKindBoxReqRequest:
|
|
||||||
properties:
|
|
||||||
serial_numbers:
|
|
||||||
example:
|
|
||||||
- "1"
|
|
||||||
- "2"
|
|
||||||
- "3"
|
|
||||||
items:
|
|
||||||
type: string
|
|
||||||
type: array
|
|
||||||
type: object
|
|
||||||
adminkindboxreqparam.DeliverKindBoxReqResponse:
|
|
||||||
properties:
|
|
||||||
field_errors:
|
|
||||||
additionalProperties:
|
|
||||||
type: string
|
|
||||||
type: object
|
|
||||||
type: object
|
|
||||||
adminkindboxreqparam.DeliveryAwaitingGetAllResponse:
|
|
||||||
properties:
|
|
||||||
data:
|
|
||||||
items:
|
|
||||||
$ref: '#/definitions/adminkindboxreqparam.Data'
|
|
||||||
type: array
|
|
||||||
field_errors:
|
|
||||||
additionalProperties:
|
|
||||||
type: string
|
|
||||||
type: object
|
|
||||||
pagination:
|
|
||||||
$ref: '#/definitions/param.PaginationResponse'
|
|
||||||
type: object
|
|
||||||
adminkindboxreqparam.DeliveryAwaitingGetResponse:
|
|
||||||
properties:
|
|
||||||
data:
|
|
||||||
$ref: '#/definitions/adminkindboxreqparam.Data'
|
|
||||||
field_errors:
|
|
||||||
additionalProperties:
|
|
||||||
type: string
|
|
||||||
type: object
|
|
||||||
type: object
|
|
||||||
adminkindboxreqparam.GetKindBoxReqResponse:
|
adminkindboxreqparam.GetKindBoxReqResponse:
|
||||||
properties:
|
properties:
|
||||||
data:
|
data:
|
||||||
|
@ -565,6 +525,73 @@ definitions:
|
||||||
serial_number:
|
serial_number:
|
||||||
type: string
|
type: string
|
||||||
type: object
|
type: object
|
||||||
|
agentkindboxreqparam.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
|
||||||
|
agentkindboxreqparam.DeliverKindBoxReqRequest:
|
||||||
|
properties:
|
||||||
|
serial_numbers:
|
||||||
|
example:
|
||||||
|
- "1"
|
||||||
|
- "2"
|
||||||
|
- "3"
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
type: array
|
||||||
|
type: object
|
||||||
|
agentkindboxreqparam.DeliverKindBoxReqResponse:
|
||||||
|
properties:
|
||||||
|
field_errors:
|
||||||
|
additionalProperties:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
|
type: object
|
||||||
|
agentkindboxreqparam.DeliveryAwaitingGetAllResponse:
|
||||||
|
properties:
|
||||||
|
data:
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/agentkindboxreqparam.Data'
|
||||||
|
type: array
|
||||||
|
field_errors:
|
||||||
|
additionalProperties:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
|
pagination:
|
||||||
|
$ref: '#/definitions/param.PaginationResponse'
|
||||||
|
type: object
|
||||||
|
agentkindboxreqparam.DeliveryAwaitingGetResponse:
|
||||||
|
properties:
|
||||||
|
data:
|
||||||
|
$ref: '#/definitions/agentkindboxreqparam.Data'
|
||||||
|
field_errors:
|
||||||
|
additionalProperties:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
|
type: object
|
||||||
benefactoreparam.Data:
|
benefactoreparam.Data:
|
||||||
properties:
|
properties:
|
||||||
first_name:
|
first_name:
|
||||||
|
@ -1514,38 +1541,6 @@ paths:
|
||||||
summary: Admin Assign Sender Agent to kindboxreq
|
summary: Admin Assign Sender Agent to kindboxreq
|
||||||
tags:
|
tags:
|
||||||
- Admins KindBoxReqs
|
- Admins KindBoxReqs
|
||||||
/admins/kindboxreqs/{id}/deliver-kind-box-req:
|
|
||||||
patch:
|
|
||||||
consumes:
|
|
||||||
- application/json
|
|
||||||
parameters:
|
|
||||||
- description: KindBoxReq ID
|
|
||||||
in: path
|
|
||||||
name: id
|
|
||||||
required: true
|
|
||||||
type: integer
|
|
||||||
- description: KindBoxReq deliver request details
|
|
||||||
in: body
|
|
||||||
name: Request
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
$ref: '#/definitions/adminkindboxreqparam.DeliverKindBoxReqRequest'
|
|
||||||
produces:
|
|
||||||
- application/json
|
|
||||||
responses:
|
|
||||||
"200":
|
|
||||||
description: OK
|
|
||||||
schema:
|
|
||||||
$ref: '#/definitions/adminkindboxreqparam.DeliverKindBoxReqResponse'
|
|
||||||
"400":
|
|
||||||
description: Bad request
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
security:
|
|
||||||
- AuthBearerAdmin: []
|
|
||||||
summary: Admin deliver a kindboxreq
|
|
||||||
tags:
|
|
||||||
- Admins KindBoxReqs
|
|
||||||
/admins/kindboxreqs/{id}/reject-kind-box-req:
|
/admins/kindboxreqs/{id}/reject-kind-box-req:
|
||||||
patch:
|
patch:
|
||||||
consumes:
|
consumes:
|
||||||
|
@ -1578,121 +1573,6 @@ paths:
|
||||||
summary: Reject a kindboxreq by admin
|
summary: Reject a kindboxreq by admin
|
||||||
tags:
|
tags:
|
||||||
- Admins KindBoxReqs
|
- Admins KindBoxReqs
|
||||||
/admins/kindboxreqs/awaiting-delivery:
|
|
||||||
get:
|
|
||||||
consumes:
|
|
||||||
- application/json
|
|
||||||
description: Retrieves a list of all awaiting KindBox requests with filtering,
|
|
||||||
sorting, and pagination options
|
|
||||||
parameters:
|
|
||||||
- description: Filter by ID
|
|
||||||
in: query
|
|
||||||
name: filter_id
|
|
||||||
type: integer
|
|
||||||
- description: Filter by benefactor ID
|
|
||||||
in: query
|
|
||||||
name: filter_benefactor_id
|
|
||||||
type: integer
|
|
||||||
- description: Filter by KindBox type
|
|
||||||
enum:
|
|
||||||
- on-table
|
|
||||||
- cylindrical
|
|
||||||
- stand-up
|
|
||||||
format: enum
|
|
||||||
in: query
|
|
||||||
name: filter_kind_box_type
|
|
||||||
type: string
|
|
||||||
- description: Filter by count requested
|
|
||||||
in: query
|
|
||||||
name: filter_count_requested
|
|
||||||
type: integer
|
|
||||||
- description: Filter by count accepted
|
|
||||||
in: query
|
|
||||||
name: filter_count_accepted
|
|
||||||
type: integer
|
|
||||||
- description: Filter by deliver refer time ID
|
|
||||||
in: query
|
|
||||||
name: filter_deliver_refer_time_id
|
|
||||||
type: integer
|
|
||||||
- description: Filter by deliver refer date
|
|
||||||
format: date
|
|
||||||
in: query
|
|
||||||
name: filter_deliver_refer_date
|
|
||||||
type: string
|
|
||||||
- description: Filter by deliver address ID
|
|
||||||
in: query
|
|
||||||
name: filter_deliver_address_id
|
|
||||||
type: integer
|
|
||||||
- description: Page number
|
|
||||||
in: query
|
|
||||||
name: page_number
|
|
||||||
type: integer
|
|
||||||
- description: Page size
|
|
||||||
in: query
|
|
||||||
name: page_size
|
|
||||||
type: integer
|
|
||||||
- description: Sort by field
|
|
||||||
enum:
|
|
||||||
- id
|
|
||||||
- benefactor_id
|
|
||||||
- kind_box_type
|
|
||||||
- count_requested
|
|
||||||
- count_accepted
|
|
||||||
- deliver_refer_time_id
|
|
||||||
- deliver_refer_date
|
|
||||||
- deliver_address_id
|
|
||||||
in: query
|
|
||||||
name: sort_field
|
|
||||||
type: string
|
|
||||||
- description: Sort order
|
|
||||||
enum:
|
|
||||||
- asc
|
|
||||||
- desc
|
|
||||||
in: query
|
|
||||||
name: sort_direction
|
|
||||||
type: string
|
|
||||||
produces:
|
|
||||||
- application/json
|
|
||||||
responses:
|
|
||||||
"200":
|
|
||||||
description: OK
|
|
||||||
schema:
|
|
||||||
$ref: '#/definitions/adminkindboxreqparam.DeliveryAwaitingGetAllResponse'
|
|
||||||
"400":
|
|
||||||
description: Bad request
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
security:
|
|
||||||
- AuthBearerAdmin: []
|
|
||||||
summary: Get all awaiting delivery KindBox requests
|
|
||||||
tags:
|
|
||||||
- Admins KindBoxReqs
|
|
||||||
/admins/kindboxreqs/awaiting-delivery/{id}:
|
|
||||||
get:
|
|
||||||
consumes:
|
|
||||||
- application/json
|
|
||||||
parameters:
|
|
||||||
- description: KindBoxReq ID
|
|
||||||
in: path
|
|
||||||
name: id
|
|
||||||
required: true
|
|
||||||
type: integer
|
|
||||||
produces:
|
|
||||||
- application/json
|
|
||||||
responses:
|
|
||||||
"200":
|
|
||||||
description: OK
|
|
||||||
schema:
|
|
||||||
$ref: '#/definitions/adminkindboxreqparam.DeliveryAwaitingGetResponse'
|
|
||||||
"400":
|
|
||||||
description: Bad request
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
security:
|
|
||||||
- AuthBearerAdmin: []
|
|
||||||
summary: Get a kind box reqs that is awaiting delivery by agent
|
|
||||||
tags:
|
|
||||||
- Admins KindBoxReqs
|
|
||||||
/admins/login-by-phone:
|
/admins/login-by-phone:
|
||||||
post:
|
post:
|
||||||
consumes:
|
consumes:
|
||||||
|
@ -1933,6 +1813,153 @@ paths:
|
||||||
summary: Return KindBox from benefactor by agent
|
summary: Return KindBox from benefactor by agent
|
||||||
tags:
|
tags:
|
||||||
- Agents KindBoxes
|
- Agents KindBoxes
|
||||||
|
/agents/kindboxreqs/{id}/deliver-kind-box-req:
|
||||||
|
patch:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
parameters:
|
||||||
|
- description: KindBoxReq ID
|
||||||
|
in: path
|
||||||
|
name: id
|
||||||
|
required: true
|
||||||
|
type: integer
|
||||||
|
- description: KindBoxReq deliver request details
|
||||||
|
in: body
|
||||||
|
name: Request
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/agentkindboxreqparam.DeliverKindBoxReqRequest'
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/agentkindboxreqparam.DeliverKindBoxReqResponse'
|
||||||
|
"400":
|
||||||
|
description: Bad request
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
security:
|
||||||
|
- AuthBearerAdmin: []
|
||||||
|
summary: Agent deliver a kindboxreq
|
||||||
|
tags:
|
||||||
|
- Agents KindBoxReqs
|
||||||
|
/agents/kindboxreqs/awaiting-delivery:
|
||||||
|
get:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
description: Retrieves a list of all awaiting KindBox requests with filtering,
|
||||||
|
sorting, and pagination options
|
||||||
|
parameters:
|
||||||
|
- description: Filter by ID
|
||||||
|
in: query
|
||||||
|
name: filter_id
|
||||||
|
type: integer
|
||||||
|
- description: Filter by benefactor ID
|
||||||
|
in: query
|
||||||
|
name: filter_benefactor_id
|
||||||
|
type: integer
|
||||||
|
- description: Filter by KindBox type
|
||||||
|
enum:
|
||||||
|
- on-table
|
||||||
|
- cylindrical
|
||||||
|
- stand-up
|
||||||
|
format: enum
|
||||||
|
in: query
|
||||||
|
name: filter_kind_box_type
|
||||||
|
type: string
|
||||||
|
- description: Filter by count requested
|
||||||
|
in: query
|
||||||
|
name: filter_count_requested
|
||||||
|
type: integer
|
||||||
|
- description: Filter by count accepted
|
||||||
|
in: query
|
||||||
|
name: filter_count_accepted
|
||||||
|
type: integer
|
||||||
|
- description: Filter by deliver refer time ID
|
||||||
|
in: query
|
||||||
|
name: filter_deliver_refer_time_id
|
||||||
|
type: integer
|
||||||
|
- description: Filter by deliver refer date
|
||||||
|
format: date
|
||||||
|
in: query
|
||||||
|
name: filter_deliver_refer_date
|
||||||
|
type: string
|
||||||
|
- description: Filter by deliver address ID
|
||||||
|
in: query
|
||||||
|
name: filter_deliver_address_id
|
||||||
|
type: integer
|
||||||
|
- description: Page number
|
||||||
|
in: query
|
||||||
|
name: page_number
|
||||||
|
type: integer
|
||||||
|
- description: Page size
|
||||||
|
in: query
|
||||||
|
name: page_size
|
||||||
|
type: integer
|
||||||
|
- description: Sort by field
|
||||||
|
enum:
|
||||||
|
- id
|
||||||
|
- benefactor_id
|
||||||
|
- kind_box_type
|
||||||
|
- count_requested
|
||||||
|
- count_accepted
|
||||||
|
- deliver_refer_time_id
|
||||||
|
- deliver_refer_date
|
||||||
|
- deliver_address_id
|
||||||
|
in: query
|
||||||
|
name: sort_field
|
||||||
|
type: string
|
||||||
|
- description: Sort order
|
||||||
|
enum:
|
||||||
|
- asc
|
||||||
|
- desc
|
||||||
|
in: query
|
||||||
|
name: sort_direction
|
||||||
|
type: string
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/agentkindboxreqparam.DeliveryAwaitingGetAllResponse'
|
||||||
|
"400":
|
||||||
|
description: Bad request
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
security:
|
||||||
|
- AuthBearerAdmin: []
|
||||||
|
summary: Get all awaiting delivery KindBox requests
|
||||||
|
tags:
|
||||||
|
- Agents KindBoxReqs
|
||||||
|
/agents/kindboxreqs/awaiting-delivery/{id}:
|
||||||
|
get:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
parameters:
|
||||||
|
- description: KindBoxReq ID
|
||||||
|
in: path
|
||||||
|
name: id
|
||||||
|
required: true
|
||||||
|
type: integer
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/agentkindboxreqparam.DeliveryAwaitingGetResponse'
|
||||||
|
"400":
|
||||||
|
description: Bad request
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
security:
|
||||||
|
- AuthBearerAdmin: []
|
||||||
|
summary: Get a kind box reqs that is awaiting delivery by agent
|
||||||
|
tags:
|
||||||
|
- Agents KindBoxReqs
|
||||||
/benefactors/addresses:
|
/benefactors/addresses:
|
||||||
get:
|
get:
|
||||||
consumes:
|
consumes:
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
package agentkindboxreqparam
|
||||||
|
|
||||||
|
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"`
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package adminkindboxreqparam
|
package agentkindboxreqparam
|
||||||
|
|
||||||
type DeliverKindBoxReqRequest struct {
|
type DeliverKindBoxReqRequest struct {
|
||||||
KindBoxReqID uint `json:"-" param:"id"`
|
KindBoxReqID uint `json:"-" param:"id"`
|
|
@ -1,4 +1,4 @@
|
||||||
package adminkindboxreqparam
|
package agentkindboxreqparam
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"git.gocasts.ir/ebhomengo/niki/param"
|
"git.gocasts.ir/ebhomengo/niki/param"
|
|
@ -1,4 +1,4 @@
|
||||||
package adminkindboxreqparam
|
package agentkindboxreqparam
|
||||||
|
|
||||||
type DeliveryAwaitingGetRequest struct {
|
type DeliveryAwaitingGetRequest struct {
|
||||||
KindBoxReqID uint `param:"id"`
|
KindBoxReqID uint `param:"id"`
|
|
@ -5,7 +5,6 @@ import (
|
||||||
|
|
||||||
"git.gocasts.ir/ebhomengo/niki/entity"
|
"git.gocasts.ir/ebhomengo/niki/entity"
|
||||||
params "git.gocasts.ir/ebhomengo/niki/param"
|
params "git.gocasts.ir/ebhomengo/niki/param"
|
||||||
param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box"
|
|
||||||
validator "git.gocasts.ir/ebhomengo/niki/validator/admin/kind_box_req"
|
validator "git.gocasts.ir/ebhomengo/niki/validator/admin/kind_box_req"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -21,20 +20,14 @@ type Repository interface {
|
||||||
UpdateKindBoxReq(ctx context.Context, kindBoxReq entity.KindBoxReq) error
|
UpdateKindBoxReq(ctx context.Context, kindBoxReq entity.KindBoxReq) error
|
||||||
}
|
}
|
||||||
|
|
||||||
type KindBoxSvc interface {
|
|
||||||
AddBatchKindBox(ctx context.Context, req param.AddKindBoxRequest) (param.AddKindBoxResponse, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type Service struct {
|
type Service struct {
|
||||||
repo Repository
|
repo Repository
|
||||||
kindBoxSvc KindBoxSvc
|
vld validator.Validator
|
||||||
vld validator.Validator
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(repository Repository, kindBoxSvc KindBoxSvc, vld validator.Validator) Service {
|
func New(repository Repository, vld validator.Validator) Service {
|
||||||
return Service{
|
return Service{
|
||||||
repo: repository,
|
repo: repository,
|
||||||
kindBoxSvc: kindBoxSvc,
|
vld: vld,
|
||||||
vld: vld,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package adminkindboxreqservice
|
package agentkindboxreqservice
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
param "git.gocasts.ir/ebhomengo/niki/param/agent/kind_box_req"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
kindboxParam "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box"
|
kindboxParam "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box"
|
||||||
param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box_req"
|
|
||||||
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
|
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
package adminkindboxreqservice
|
package agentkindboxreqservice
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
paginationparam "git.gocasts.ir/ebhomengo/niki/param"
|
paginationparam "git.gocasts.ir/ebhomengo/niki/param"
|
||||||
param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box_req"
|
param "git.gocasts.ir/ebhomengo/niki/param/agent/kind_box_req"
|
||||||
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
|
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
package adminkindboxreqservice
|
package agentkindboxreqservice
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
param "git.gocasts.ir/ebhomengo/niki/param/agent/kind_box_req"
|
||||||
param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box_req"
|
|
||||||
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
|
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
|
||||||
)
|
)
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
package agentkindboxreqservice
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box"
|
||||||
|
|
||||||
|
"git.gocasts.ir/ebhomengo/niki/entity"
|
||||||
|
params "git.gocasts.ir/ebhomengo/niki/param"
|
||||||
|
validator "git.gocasts.ir/ebhomengo/niki/validator/agent/kind_box_req"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Repository interface {
|
||||||
|
GetAllKindBoxReq(ctx context.Context, filter params.FilterRequest, pagination params.PaginationRequest, sort params.SortRequest) ([]entity.KindBoxReq, uint, error)
|
||||||
|
DeliverKindBoxReq(ctx context.Context, kindBoxReqID uint) error
|
||||||
|
GetAwaitingDeliveryByAgent(ctx context.Context, kindBoxReqID uint, agentID uint) (entity.KindBoxReq, error)
|
||||||
|
GetByID(ctx context.Context, id uint) (entity.KindBoxReq, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type KindBoxSvc interface {
|
||||||
|
AddBatchKindBox(ctx context.Context, req param.AddKindBoxRequest) (param.AddKindBoxResponse, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type Service struct {
|
||||||
|
repo Repository
|
||||||
|
kindBoxSvc KindBoxSvc
|
||||||
|
vld validator.Validator
|
||||||
|
}
|
||||||
|
|
||||||
|
func New(repo Repository, vld validator.Validator) Service {
|
||||||
|
return Service{
|
||||||
|
repo: repo,
|
||||||
|
vld: vld,
|
||||||
|
}
|
||||||
|
}
|
|
@ -22,6 +22,7 @@ import (
|
||||||
adminkindboxreqservice "git.gocasts.ir/ebhomengo/niki/service/admin/kind_box_req"
|
adminkindboxreqservice "git.gocasts.ir/ebhomengo/niki/service/admin/kind_box_req"
|
||||||
adminrefertimeservice "git.gocasts.ir/ebhomengo/niki/service/admin/refer_time"
|
adminrefertimeservice "git.gocasts.ir/ebhomengo/niki/service/admin/refer_time"
|
||||||
agentkindboxservice "git.gocasts.ir/ebhomengo/niki/service/agent/kind_box"
|
agentkindboxservice "git.gocasts.ir/ebhomengo/niki/service/agent/kind_box"
|
||||||
|
agentkindboxreqservice "git.gocasts.ir/ebhomengo/niki/service/agent/kind_box_req"
|
||||||
"git.gocasts.ir/ebhomengo/niki/service/auth"
|
"git.gocasts.ir/ebhomengo/niki/service/auth"
|
||||||
benefactoraddressservice "git.gocasts.ir/ebhomengo/niki/service/benefactor/address"
|
benefactoraddressservice "git.gocasts.ir/ebhomengo/niki/service/benefactor/address"
|
||||||
benefactorservice "git.gocasts.ir/ebhomengo/niki/service/benefactor/benefactor"
|
benefactorservice "git.gocasts.ir/ebhomengo/niki/service/benefactor/benefactor"
|
||||||
|
@ -33,6 +34,7 @@ import (
|
||||||
adminkindboxvalidator "git.gocasts.ir/ebhomengo/niki/validator/admin/kind_box"
|
adminkindboxvalidator "git.gocasts.ir/ebhomengo/niki/validator/admin/kind_box"
|
||||||
adminkindboxreqvalidator "git.gocasts.ir/ebhomengo/niki/validator/admin/kind_box_req"
|
adminkindboxreqvalidator "git.gocasts.ir/ebhomengo/niki/validator/admin/kind_box_req"
|
||||||
agentkindboxvalidator "git.gocasts.ir/ebhomengo/niki/validator/agent/kind_box"
|
agentkindboxvalidator "git.gocasts.ir/ebhomengo/niki/validator/agent/kind_box"
|
||||||
|
agentkindboxreqvalidator "git.gocasts.ir/ebhomengo/niki/validator/agent/kind_box_req"
|
||||||
benefactoraddressvalidator "git.gocasts.ir/ebhomengo/niki/validator/benefactor/address"
|
benefactoraddressvalidator "git.gocasts.ir/ebhomengo/niki/validator/benefactor/address"
|
||||||
benefactorvalidator "git.gocasts.ir/ebhomengo/niki/validator/benefactor/benefactor"
|
benefactorvalidator "git.gocasts.ir/ebhomengo/niki/validator/benefactor/benefactor"
|
||||||
benefactorkindboxvalidator "git.gocasts.ir/ebhomengo/niki/validator/benefactor/kind_box"
|
benefactorkindboxvalidator "git.gocasts.ir/ebhomengo/niki/validator/benefactor/kind_box"
|
||||||
|
@ -47,6 +49,7 @@ type Service struct {
|
||||||
AdminSvc adminservice.Service
|
AdminSvc adminservice.Service
|
||||||
AdminAgentSvc adminagentservice.Service
|
AdminAgentSvc adminagentservice.Service
|
||||||
AgentKindBoxSvc agentkindboxservice.Service
|
AgentKindBoxSvc agentkindboxservice.Service
|
||||||
|
AgentKindBoxReqSvc agentkindboxreqservice.Service
|
||||||
BenefactorAuthSvc auth.Service
|
BenefactorAuthSvc auth.Service
|
||||||
BenefactorKindBoxSvc benefactorkindboxservice.Service
|
BenefactorKindBoxSvc benefactorkindboxservice.Service
|
||||||
BenefactorKindBoxReqSvc benefactorkindboxreqservice.Service
|
BenefactorKindBoxReqSvc benefactorkindboxreqservice.Service
|
||||||
|
@ -79,11 +82,13 @@ func New(cfg config.Config, db *mysql.DB, rds *redis.Adapter, smsAdapter smscont
|
||||||
AdminKindBoxVld = adminkindboxvalidator.New(kindBoxRepo, AdminAgentSvc, AdminBenefactorSvc, AdminReferTimeSvc, AdminAddressSvc)
|
AdminKindBoxVld = adminkindboxvalidator.New(kindBoxRepo, AdminAgentSvc, AdminBenefactorSvc, AdminReferTimeSvc, AdminAddressSvc)
|
||||||
AdminKindBoxSvc = adminkindboxservice.New(kindBoxRepo, AdminKindBoxVld)
|
AdminKindBoxSvc = adminkindboxservice.New(kindBoxRepo, AdminKindBoxVld)
|
||||||
AdminKindBoxReqVld = adminkindboxreqvalidator.New(kindBoxReqRepo, AdminSvc, AdminAgentSvc, AdminBenefactorSvc, AdminReferTimeSvc, AdminAddressSvc)
|
AdminKindBoxReqVld = adminkindboxreqvalidator.New(kindBoxReqRepo, AdminSvc, AdminAgentSvc, AdminBenefactorSvc, AdminReferTimeSvc, AdminAddressSvc)
|
||||||
AdminKindBoxReqSvc = adminkindboxreqservice.New(kindBoxReqRepo, AdminKindBoxSvc, AdminKindBoxReqVld)
|
AdminKindBoxReqSvc = adminkindboxreqservice.New(kindBoxReqRepo, AdminKindBoxReqVld)
|
||||||
)
|
)
|
||||||
var (
|
var (
|
||||||
AgentKindBoxVld = agentkindboxvalidator.New(kindBoxRepo)
|
AgentKindBoxVld = agentkindboxvalidator.New(kindBoxRepo)
|
||||||
AgentKindBoxSvc = agentkindboxservice.New(kindBoxRepo, AgentKindBoxVld)
|
AgentKindBoxSvc = agentkindboxservice.New(kindBoxRepo, AgentKindBoxVld)
|
||||||
|
AgentKindBoxReqVld = agentkindboxreqvalidator.New(kindBoxReqRepo)
|
||||||
|
AgentKindBoxReqSvc = agentkindboxreqservice.New(kindBoxReqRepo, AgentKindBoxReqVld)
|
||||||
)
|
)
|
||||||
var (
|
var (
|
||||||
BenefactorAuthSvc = auth.New(cfg.BenefactorAuth)
|
BenefactorAuthSvc = auth.New(cfg.BenefactorAuth)
|
||||||
|
@ -108,6 +113,7 @@ func New(cfg config.Config, db *mysql.DB, rds *redis.Adapter, smsAdapter smscont
|
||||||
AdminSvc: AdminSvc,
|
AdminSvc: AdminSvc,
|
||||||
AdminAgentSvc: AdminAgentSvc,
|
AdminAgentSvc: AdminAgentSvc,
|
||||||
AgentKindBoxSvc: AgentKindBoxSvc,
|
AgentKindBoxSvc: AgentKindBoxSvc,
|
||||||
|
AgentKindBoxReqSvc: AgentKindBoxReqSvc,
|
||||||
BenefactorAuthSvc: BenefactorAuthSvc,
|
BenefactorAuthSvc: BenefactorAuthSvc,
|
||||||
BenefactorKindBoxSvc: BenefactorKindBoxSvc,
|
BenefactorKindBoxSvc: BenefactorKindBoxSvc,
|
||||||
BenefactorKindBoxReqSvc: BenefactorKindBoxReqSvc,
|
BenefactorKindBoxReqSvc: BenefactorKindBoxReqSvc,
|
||||||
|
|
|
@ -6,7 +6,6 @@ import (
|
||||||
param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box"
|
param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box"
|
||||||
errmsg "git.gocasts.ir/ebhomengo/niki/pkg/err_msg"
|
errmsg "git.gocasts.ir/ebhomengo/niki/pkg/err_msg"
|
||||||
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
|
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
|
||||||
"git.gocasts.ir/ebhomengo/niki/validator"
|
|
||||||
validation "github.com/go-ozzo/ozzo-validation/v4"
|
validation "github.com/go-ozzo/ozzo-validation/v4"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -20,8 +19,8 @@ func (v Validator) ValidateGetAll(req param.KindBoxGetAllRequest) (map[string]st
|
||||||
"return_address_id", "receiver_agent_id", "returned_at",
|
"return_address_id", "receiver_agent_id", "returned_at",
|
||||||
}
|
}
|
||||||
if err := validation.ValidateStruct(&req,
|
if err := validation.ValidateStruct(&req,
|
||||||
validation.Field(&req.Filter, validation.By(validator.AreFilterFieldsValid(validFields))),
|
validation.Field(&req.Filter, validation.By(v.AreFilterFieldsValid(validFields))),
|
||||||
validation.Field(&req.Sort, validation.By(validator.AreSortFieldsValid(validFields))),
|
validation.Field(&req.Sort, validation.By(v.AreSortFieldsValid(validFields))),
|
||||||
); err != nil {
|
); err != nil {
|
||||||
|
|
||||||
fieldErrors := make(map[string]string)
|
fieldErrors := make(map[string]string)
|
||||||
|
|
|
@ -4,6 +4,8 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
params "git.gocasts.ir/ebhomengo/niki/param"
|
||||||
|
"slices"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
entity "git.gocasts.ir/ebhomengo/niki/entity"
|
entity "git.gocasts.ir/ebhomengo/niki/entity"
|
||||||
|
@ -98,7 +100,6 @@ func (v Validator) doesBenefactorExist(ctx context.Context) validation.RuleFunc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (v Validator) doesBenefactorHaveKindBox(ctx context.Context, kindBoxID uint, benefactorID uint) validation.RuleFunc {
|
func (v Validator) doesBenefactorHaveKindBox(ctx context.Context, kindBoxID uint, benefactorID uint) validation.RuleFunc {
|
||||||
return func(value interface{}) error {
|
return func(value interface{}) error {
|
||||||
const op = "Validator.doesBenefactorHaveKindBox"
|
const op = "Validator.doesBenefactorHaveKindBox"
|
||||||
|
@ -220,7 +221,6 @@ func (v Validator) isDateValid(value interface{}) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (v Validator) isAmountValid(ctx context.Context) validation.RuleFunc {
|
func (v Validator) isAmountValid(ctx context.Context) validation.RuleFunc {
|
||||||
return func(value interface{}) error {
|
return func(value interface{}) error {
|
||||||
const op = "Validator.isAmountValid"
|
const op = "Validator.isAmountValid"
|
||||||
|
@ -232,7 +232,7 @@ func (v Validator) isAmountValid(ctx context.Context) validation.RuleFunc {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//processing errors
|
// processing errors
|
||||||
func (v Validator) processValidationErrors(err error, fieldErrors map[string]string) {
|
func (v Validator) processValidationErrors(err error, fieldErrors map[string]string) {
|
||||||
var errV validation.Errors
|
var errV validation.Errors
|
||||||
if errors.As(err, &errV) {
|
if errors.As(err, &errV) {
|
||||||
|
@ -243,3 +243,39 @@ func (v Validator) processValidationErrors(err error, fieldErrors map[string]str
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (v Validator) AreSortFieldsValid(validSortFields []string) validation.RuleFunc {
|
||||||
|
return func(value interface{}) error {
|
||||||
|
sort, ok := value.(params.SortRequest)
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf(errmsg.ErrorMsgSomethingWentWrong)
|
||||||
|
}
|
||||||
|
if sort.Field == "" && sort.Direction != "" {
|
||||||
|
return fmt.Errorf(errmsg.ErrorMsgSortFieldIsRequired)
|
||||||
|
}
|
||||||
|
if sort.Direction != "" && sort.Direction != params.AscSortDirection && sort.Direction != params.DescSortDirection {
|
||||||
|
return fmt.Errorf(errmsg.ErrorMsgSortDirectionShouldBeAscOrDesc)
|
||||||
|
}
|
||||||
|
if sort.Field != "" && !slices.Contains(validSortFields, sort.Field) {
|
||||||
|
return fmt.Errorf(errmsg.ErrorMsgSortFieldIsNotValid)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v Validator) AreFilterFieldsValid(validFilters []string) validation.RuleFunc {
|
||||||
|
return func(value interface{}) error {
|
||||||
|
filters, ok := value.(params.FilterRequest)
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf(errmsg.ErrorMsgSomethingWentWrong)
|
||||||
|
}
|
||||||
|
for filter := range filters {
|
||||||
|
if !slices.Contains(validFilters, filter) {
|
||||||
|
return fmt.Errorf(errmsg.ErrorMsgFiltersAreNotValid)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ import (
|
||||||
param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box_req"
|
param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box_req"
|
||||||
errmsg "git.gocasts.ir/ebhomengo/niki/pkg/err_msg"
|
errmsg "git.gocasts.ir/ebhomengo/niki/pkg/err_msg"
|
||||||
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
|
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
|
||||||
"git.gocasts.ir/ebhomengo/niki/validator"
|
|
||||||
validation "github.com/go-ozzo/ozzo-validation/v4"
|
validation "github.com/go-ozzo/ozzo-validation/v4"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -19,8 +18,8 @@ func (v Validator) ValidateGetAll(req param.KindBoxReqGetAllRequest) (map[string
|
||||||
"deliver_address_id", "delivered_at",
|
"deliver_address_id", "delivered_at",
|
||||||
}
|
}
|
||||||
if err := validation.ValidateStruct(&req,
|
if err := validation.ValidateStruct(&req,
|
||||||
validation.Field(&req.Filter, validation.By(validator.AreFilterFieldsValid(validFields))),
|
validation.Field(&req.Filter, validation.By(v.AreFilterFieldsValid(validFields))),
|
||||||
validation.Field(&req.Sort, validation.By(validator.AreSortFieldsValid(validFields))),
|
validation.Field(&req.Sort, validation.By(v.AreSortFieldsValid(validFields))),
|
||||||
); err != nil {
|
); err != nil {
|
||||||
fieldErrors := make(map[string]string)
|
fieldErrors := make(map[string]string)
|
||||||
|
|
||||||
|
|
|
@ -304,3 +304,39 @@ func (v Validator) IsSerialNumbersCountValid(ctx context.Context, kindBoxReqID u
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (v Validator) AreSortFieldsValid(validSortFields []string) validation.RuleFunc {
|
||||||
|
return func(value interface{}) error {
|
||||||
|
sort, ok := value.(params.SortRequest)
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf(errmsg.ErrorMsgSomethingWentWrong)
|
||||||
|
}
|
||||||
|
if sort.Field == "" && sort.Direction != "" {
|
||||||
|
return fmt.Errorf(errmsg.ErrorMsgSortFieldIsRequired)
|
||||||
|
}
|
||||||
|
if sort.Direction != "" && sort.Direction != params.AscSortDirection && sort.Direction != params.DescSortDirection {
|
||||||
|
return fmt.Errorf(errmsg.ErrorMsgSortDirectionShouldBeAscOrDesc)
|
||||||
|
}
|
||||||
|
if sort.Field != "" && !slices.Contains(validSortFields, sort.Field) {
|
||||||
|
return fmt.Errorf(errmsg.ErrorMsgSortFieldIsNotValid)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v Validator) AreFilterFieldsValid(validFilters []string) validation.RuleFunc {
|
||||||
|
return func(value interface{}) error {
|
||||||
|
filters, ok := value.(params.FilterRequest)
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf(errmsg.ErrorMsgSomethingWentWrong)
|
||||||
|
}
|
||||||
|
for filter := range filters {
|
||||||
|
if !slices.Contains(validFilters, filter) {
|
||||||
|
return fmt.Errorf(errmsg.ErrorMsgFiltersAreNotValid)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ import (
|
||||||
param "git.gocasts.ir/ebhomengo/niki/param/agent/kind_box"
|
param "git.gocasts.ir/ebhomengo/niki/param/agent/kind_box"
|
||||||
errmsg "git.gocasts.ir/ebhomengo/niki/pkg/err_msg"
|
errmsg "git.gocasts.ir/ebhomengo/niki/pkg/err_msg"
|
||||||
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
|
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
|
||||||
"git.gocasts.ir/ebhomengo/niki/validator"
|
|
||||||
validation "github.com/go-ozzo/ozzo-validation/v4"
|
validation "github.com/go-ozzo/ozzo-validation/v4"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -19,8 +18,8 @@ func (v Validator) ValidateGetAll(req param.GetAllRequest) (map[string]string, e
|
||||||
"return_refer_time_id", "return_refer_date", "return_address_id",
|
"return_refer_time_id", "return_refer_date", "return_address_id",
|
||||||
}
|
}
|
||||||
if err := validation.ValidateStruct(&req,
|
if err := validation.ValidateStruct(&req,
|
||||||
validation.Field(&req.Filter, validation.By(validator.AreFilterFieldsValid(validFields))),
|
validation.Field(&req.Filter, validation.By(v.AreFilterFieldsValid(validFields))),
|
||||||
validation.Field(&req.Sort, validation.By(validator.AreSortFieldsValid(validFields))),
|
validation.Field(&req.Sort, validation.By(v.AreSortFieldsValid(validFields))),
|
||||||
); err != nil {
|
); err != nil {
|
||||||
|
|
||||||
fieldErrors := make(map[string]string)
|
fieldErrors := make(map[string]string)
|
|
@ -3,6 +3,8 @@ package agentkindboxvalidator
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
params "git.gocasts.ir/ebhomengo/niki/param"
|
||||||
|
"slices"
|
||||||
|
|
||||||
errmsg "git.gocasts.ir/ebhomengo/niki/pkg/err_msg"
|
errmsg "git.gocasts.ir/ebhomengo/niki/pkg/err_msg"
|
||||||
validation "github.com/go-ozzo/ozzo-validation/v4"
|
validation "github.com/go-ozzo/ozzo-validation/v4"
|
||||||
|
@ -37,3 +39,38 @@ func (v Validator) doesKindBoxExistForAgent(ctx context.Context, agentID uint) v
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
func (v Validator) AreSortFieldsValid(validSortFields []string) validation.RuleFunc {
|
||||||
|
return func(value interface{}) error {
|
||||||
|
sort, ok := value.(params.SortRequest)
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf(errmsg.ErrorMsgSomethingWentWrong)
|
||||||
|
}
|
||||||
|
if sort.Field == "" && sort.Direction != "" {
|
||||||
|
return fmt.Errorf(errmsg.ErrorMsgSortFieldIsRequired)
|
||||||
|
}
|
||||||
|
if sort.Direction != "" && sort.Direction != params.AscSortDirection && sort.Direction != params.DescSortDirection {
|
||||||
|
return fmt.Errorf(errmsg.ErrorMsgSortDirectionShouldBeAscOrDesc)
|
||||||
|
}
|
||||||
|
if sort.Field != "" && !slices.Contains(validSortFields, sort.Field) {
|
||||||
|
return fmt.Errorf(errmsg.ErrorMsgSortFieldIsNotValid)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v Validator) AreFilterFieldsValid(validFilters []string) validation.RuleFunc {
|
||||||
|
return func(value interface{}) error {
|
||||||
|
filters, ok := value.(params.FilterRequest)
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf(errmsg.ErrorMsgSomethingWentWrong)
|
||||||
|
}
|
||||||
|
for filter := range filters {
|
||||||
|
if !slices.Contains(validFilters, filter) {
|
||||||
|
return fmt.Errorf(errmsg.ErrorMsgFiltersAreNotValid)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
package adminkindboxreqvalidator
|
package agentkindboxreqvalidator
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
param "git.gocasts.ir/ebhomengo/niki/param/agent/kind_box_req"
|
||||||
param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box_req"
|
|
||||||
errmsg "git.gocasts.ir/ebhomengo/niki/pkg/err_msg"
|
errmsg "git.gocasts.ir/ebhomengo/niki/pkg/err_msg"
|
||||||
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
|
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
|
||||||
validation "github.com/go-ozzo/ozzo-validation/v4"
|
validation "github.com/go-ozzo/ozzo-validation/v4"
|
|
@ -1,9 +1,8 @@
|
||||||
package adminkindboxreqvalidator
|
package agentkindboxreqvalidator
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
kbrparam "git.gocasts.ir/ebhomengo/niki/param/agent/kind_box_req"
|
||||||
kbrparam "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box_req"
|
|
||||||
errmsg "git.gocasts.ir/ebhomengo/niki/pkg/err_msg"
|
errmsg "git.gocasts.ir/ebhomengo/niki/pkg/err_msg"
|
||||||
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
|
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
|
||||||
validation "github.com/go-ozzo/ozzo-validation/v4"
|
validation "github.com/go-ozzo/ozzo-validation/v4"
|
|
@ -1,9 +1,8 @@
|
||||||
package adminkindboxreqvalidator
|
package agentkindboxreqvalidator
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
param "git.gocasts.ir/ebhomengo/niki/param/agent/kind_box_req"
|
||||||
param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box_req"
|
|
||||||
errmsg "git.gocasts.ir/ebhomengo/niki/pkg/err_msg"
|
errmsg "git.gocasts.ir/ebhomengo/niki/pkg/err_msg"
|
||||||
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
|
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
|
||||||
validation "github.com/go-ozzo/ozzo-validation/v4"
|
validation "github.com/go-ozzo/ozzo-validation/v4"
|
|
@ -0,0 +1,117 @@
|
||||||
|
package agentkindboxreqvalidator
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"git.gocasts.ir/ebhomengo/niki/entity"
|
||||||
|
params "git.gocasts.ir/ebhomengo/niki/param"
|
||||||
|
"slices"
|
||||||
|
|
||||||
|
errmsg "git.gocasts.ir/ebhomengo/niki/pkg/err_msg"
|
||||||
|
validation "github.com/go-ozzo/ozzo-validation/v4"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Repository interface {
|
||||||
|
KindBoxRequestExist(ctx context.Context, id uint) (bool, error)
|
||||||
|
GetByID(ctx context.Context, id uint) (entity.KindBoxReq, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type Validator struct {
|
||||||
|
repo Repository
|
||||||
|
}
|
||||||
|
|
||||||
|
func New(repo Repository) Validator {
|
||||||
|
return Validator{repo: repo}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v Validator) doesKindBoxRequestExist(ctx context.Context) validation.RuleFunc {
|
||||||
|
return func(value interface{}) error {
|
||||||
|
kindboxreqID, ok := value.(uint)
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf(errmsg.ErrorMsgSomethingWentWrong)
|
||||||
|
}
|
||||||
|
if isExist, err := v.repo.KindBoxRequestExist(ctx, kindboxreqID); !isExist || err != nil {
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if !isExist {
|
||||||
|
return errors.New("kind box request is not exist")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v Validator) IsSerialNumbersCountValid(ctx context.Context, kindBoxReqID uint) validation.RuleFunc {
|
||||||
|
return func(value interface{}) error {
|
||||||
|
serialNumbers, ok := value.([]string)
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf(errmsg.ErrorMsgSomethingWentWrong)
|
||||||
|
}
|
||||||
|
kindBoxReq, gErr := v.repo.GetByID(ctx, kindBoxReqID)
|
||||||
|
if gErr != nil {
|
||||||
|
return fmt.Errorf(errmsg.ErrorMsgSomethingWentWrong)
|
||||||
|
}
|
||||||
|
if len(serialNumbers) != 0 && len(serialNumbers) > int(kindBoxReq.CountAccepted) {
|
||||||
|
return fmt.Errorf(errmsg.ErrorMsgInvalidSerialNumberRange)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v Validator) areFilterFieldsValid(validFilters []string) validation.RuleFunc {
|
||||||
|
return func(value interface{}) error {
|
||||||
|
filters, ok := value.(params.FilterRequest)
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf(errmsg.ErrorMsgSomethingWentWrong)
|
||||||
|
}
|
||||||
|
for filter := range filters {
|
||||||
|
if !slices.Contains(validFilters, filter) {
|
||||||
|
return fmt.Errorf(errmsg.ErrorMsgFiltersAreNotValid)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v Validator) areSortFieldsValid(validSortFields []string) validation.RuleFunc {
|
||||||
|
return func(value interface{}) error {
|
||||||
|
sort, ok := value.(params.SortRequest)
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf(errmsg.ErrorMsgSomethingWentWrong)
|
||||||
|
}
|
||||||
|
if sort.Field == "" && sort.Direction != "" {
|
||||||
|
return fmt.Errorf(errmsg.ErrorMsgSortFieldIsRequired)
|
||||||
|
}
|
||||||
|
if sort.Direction != "" && sort.Direction != params.AscSortDirection && sort.Direction != params.DescSortDirection {
|
||||||
|
return fmt.Errorf(errmsg.ErrorMsgSortDirectionShouldBeAscOrDesc)
|
||||||
|
}
|
||||||
|
if sort.Field != "" && !slices.Contains(validSortFields, sort.Field) {
|
||||||
|
return fmt.Errorf(errmsg.ErrorMsgSortFieldIsNotValid)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v Validator) checkKindBoxReqStatusForDelivering(ctx context.Context) validation.RuleFunc {
|
||||||
|
return func(value interface{}) error {
|
||||||
|
kindboxreqID, ok := value.(uint)
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf(errmsg.ErrorMsgSomethingWentWrong)
|
||||||
|
}
|
||||||
|
kindBoxReq, err := v.repo.GetByID(ctx, kindboxreqID)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if kindBoxReq.Status != entity.KindBoxReqAssignedSenderAgentStatus {
|
||||||
|
return fmt.Errorf(errmsg.ErrorMsgDeliverKindBoxReqStatus)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,26 +0,0 @@
|
||||||
package validator
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"slices"
|
|
||||||
|
|
||||||
params "git.gocasts.ir/ebhomengo/niki/param"
|
|
||||||
errmsg "git.gocasts.ir/ebhomengo/niki/pkg/err_msg"
|
|
||||||
validation "github.com/go-ozzo/ozzo-validation/v4"
|
|
||||||
)
|
|
||||||
|
|
||||||
func AreFilterFieldsValid(validFilters []string) validation.RuleFunc {
|
|
||||||
return func(value interface{}) error {
|
|
||||||
filters, ok := value.(params.FilterRequest)
|
|
||||||
if !ok {
|
|
||||||
return fmt.Errorf(errmsg.ErrorMsgSomethingWentWrong)
|
|
||||||
}
|
|
||||||
for filter := range filters {
|
|
||||||
if !slices.Contains(validFilters, filter) {
|
|
||||||
return fmt.Errorf(errmsg.ErrorMsgFiltersAreNotValid)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,30 +0,0 @@
|
||||||
package validator
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"slices"
|
|
||||||
|
|
||||||
params "git.gocasts.ir/ebhomengo/niki/param"
|
|
||||||
errmsg "git.gocasts.ir/ebhomengo/niki/pkg/err_msg"
|
|
||||||
validation "github.com/go-ozzo/ozzo-validation/v4"
|
|
||||||
)
|
|
||||||
|
|
||||||
func AreSortFieldsValid(validSortFields []string) validation.RuleFunc {
|
|
||||||
return func(value interface{}) error {
|
|
||||||
sort, ok := value.(params.SortRequest)
|
|
||||||
if !ok {
|
|
||||||
return fmt.Errorf(errmsg.ErrorMsgSomethingWentWrong)
|
|
||||||
}
|
|
||||||
if sort.Field == "" && sort.Direction != "" {
|
|
||||||
return fmt.Errorf(errmsg.ErrorMsgSortFieldIsRequired)
|
|
||||||
}
|
|
||||||
if sort.Direction != "" && sort.Direction != params.AscSortDirection && sort.Direction != params.DescSortDirection {
|
|
||||||
return fmt.Errorf(errmsg.ErrorMsgSortDirectionShouldBeAscOrDesc)
|
|
||||||
}
|
|
||||||
if sort.Field != "" && !slices.Contains(validSortFields, sort.Field) {
|
|
||||||
return fmt.Errorf(errmsg.ErrorMsgSortFieldIsNotValid)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue