forked from ebhomengo/niki
fix(delivery): remove unused filter from delivery to service layer (#165)
This commit is contained in:
parent
5f7ce41418
commit
6f6643552d
|
|
@ -44,8 +44,8 @@ func (h Handler) GetAll(c echo.Context) error {
|
|||
}
|
||||
|
||||
req.Filter = queryparam.GetFilterParams(c)
|
||||
req.Filter["receiver_agent_id"] = claim.GetClaimsFromEchoContext(c).UserID
|
||||
req.Filter["status"] = entity.KindBoxAssignedReceiverAgentStatus
|
||||
req.ReceiverAgentId = claim.GetClaimsFromEchoContext(c).UserID
|
||||
req.Status = entity.KindBoxAssignedReceiverAgentStatus
|
||||
|
||||
resp, err := h.agentKindBoxSvc.GetAll(c.Request().Context(), req)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -40,8 +40,10 @@ func (h Handler) GetAllAwaitingDelivery(c echo.Context) error {
|
|||
return echo.NewHTTPError(http.StatusBadRequest)
|
||||
}
|
||||
req.Filter = queryparam.GetFilterParams(c)
|
||||
req.Filter["sender_agent_id"] = claim.GetClaimsFromEchoContext(c).UserID
|
||||
req.Filter["status"] = entity.KindBoxReqAssignedSenderAgentStatus
|
||||
|
||||
req.SenderAgentId = claim.GetClaimsFromEchoContext(c).UserID
|
||||
req.Status = entity.KindBoxReqAssignedSenderAgentStatus
|
||||
|
||||
resp, sErr := h.agentKindBoxReqSvc.GetAllAwaitingDelivery(c.Request().Context(), req)
|
||||
if sErr != nil {
|
||||
msg, code := httpmsg.Error(sErr)
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ import (
|
|||
// @Produce json
|
||||
// @Param filter_id query int false "Filter by ID"
|
||||
// @Param filter_kind_box_req_id query int false "Filter by KindBox request ID"
|
||||
// @Param filter_benefactor_id query int false "Filter by benefactor ID"
|
||||
// @Param filter_kind_box_type query string false "Filter by KindBox type" Enums(on-table,cylindrical,stand-up)
|
||||
// @Param filter_amount query int false "Filter by amount"
|
||||
// @Param filter_serial_number query string false "Filter by serial number"
|
||||
|
|
@ -49,7 +48,8 @@ func (h Handler) GetAll(c echo.Context) error {
|
|||
}
|
||||
|
||||
req.Filter = queryparam.GetFilterParams(c)
|
||||
req.Filter["benefactor_id"] = claim.GetClaimsFromEchoContext(c).UserID
|
||||
req.BenefactorId = claim.GetClaimsFromEchoContext(c).UserID
|
||||
|
||||
resp, sErr := h.benefactorKindBoxSvc.GetAll(c.Request().Context(), req)
|
||||
if sErr != nil {
|
||||
msg, code := httpmsg.Error(sErr)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ import (
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param filter_id query int false "Filter by ID"
|
||||
// @Param filter_benefactor_id query int false "Filter by benefactor ID"
|
||||
// @Param filter_kind_box_type query entity.KindBoxType false "Filter by KindBox type" Format(enum)
|
||||
// @Param filter_status query string false "Filter by KindBoxReq Status" Enums(pending,accepted,assigned-sender-agent,rejected,delivered)
|
||||
// @Param filter_count_requested query int false "Filter by count requested"
|
||||
|
|
@ -41,7 +40,7 @@ func (h Handler) GetAll(c echo.Context) error {
|
|||
}
|
||||
|
||||
req.Filter = queryparam.GetFilterParams(c)
|
||||
req.Filter["benefactor_id"] = claim.GetClaimsFromEchoContext(c).UserID
|
||||
req.BenefactorId = claim.GetClaimsFromEchoContext(c).UserID
|
||||
|
||||
resp, sErr := h.benefactorKindBoxReqSvc.GetAll(c.Request().Context(), req)
|
||||
if sErr != nil {
|
||||
|
|
|
|||
12
docs/docs.go
12
docs/docs.go
|
|
@ -1897,12 +1897,6 @@ const docTemplate = `{
|
|||
"name": "filter_kind_box_req_id",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Filter by benefactor ID",
|
||||
"name": "filter_benefactor_id",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"enum": [
|
||||
"on-table",
|
||||
|
|
@ -2186,12 +2180,6 @@ const docTemplate = `{
|
|||
"name": "filter_id",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Filter by benefactor ID",
|
||||
"name": "filter_benefactor_id",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"enum": [
|
||||
"on-table",
|
||||
|
|
|
|||
|
|
@ -1886,12 +1886,6 @@
|
|||
"name": "filter_kind_box_req_id",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Filter by benefactor ID",
|
||||
"name": "filter_benefactor_id",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"enum": [
|
||||
"on-table",
|
||||
|
|
@ -2175,12 +2169,6 @@
|
|||
"name": "filter_id",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Filter by benefactor ID",
|
||||
"name": "filter_benefactor_id",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"enum": [
|
||||
"on-table",
|
||||
|
|
|
|||
|
|
@ -2190,10 +2190,6 @@ paths:
|
|||
in: query
|
||||
name: filter_kind_box_req_id
|
||||
type: integer
|
||||
- description: Filter by benefactor ID
|
||||
in: query
|
||||
name: filter_benefactor_id
|
||||
type: integer
|
||||
- description: Filter by KindBox type
|
||||
enum:
|
||||
- on-table
|
||||
|
|
@ -2388,10 +2384,6 @@ paths:
|
|||
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
|
||||
|
|
|
|||
|
|
@ -1,13 +1,16 @@
|
|||
package agentkindboxparam
|
||||
|
||||
import (
|
||||
"git.gocasts.ir/ebhomengo/niki/entity"
|
||||
"git.gocasts.ir/ebhomengo/niki/param"
|
||||
)
|
||||
|
||||
type GetAllRequest struct {
|
||||
Pagination param.PaginationRequest
|
||||
Sort param.SortRequest
|
||||
Filter param.FilterRequest
|
||||
Pagination param.PaginationRequest
|
||||
Sort param.SortRequest
|
||||
Filter param.FilterRequest
|
||||
ReceiverAgentId uint
|
||||
Status entity.KindBoxStatus
|
||||
}
|
||||
|
||||
type GetAllResponse struct {
|
||||
|
|
|
|||
|
|
@ -1,13 +1,16 @@
|
|||
package agentkindboxreqparam
|
||||
|
||||
import (
|
||||
"git.gocasts.ir/ebhomengo/niki/entity"
|
||||
"git.gocasts.ir/ebhomengo/niki/param"
|
||||
)
|
||||
|
||||
type DeliveryAwaitingGetAllRequest struct {
|
||||
Pagination param.PaginationRequest
|
||||
Sort param.SortRequest
|
||||
Filter param.FilterRequest
|
||||
Pagination param.PaginationRequest
|
||||
Sort param.SortRequest
|
||||
Filter param.FilterRequest
|
||||
SenderAgentId uint
|
||||
Status entity.KindBoxReqStatus
|
||||
}
|
||||
|
||||
type DeliveryAwaitingGetAllResponse struct {
|
||||
|
|
|
|||
|
|
@ -5,9 +5,10 @@ import (
|
|||
)
|
||||
|
||||
type KindBoxGetAllRequest struct {
|
||||
Pagination param.PaginationRequest
|
||||
Sort param.SortRequest
|
||||
Filter param.FilterRequest
|
||||
Pagination param.PaginationRequest
|
||||
Sort param.SortRequest
|
||||
Filter param.FilterRequest
|
||||
BenefactorId uint
|
||||
}
|
||||
|
||||
type KindBoxGetAllResponse struct {
|
||||
|
|
|
|||
|
|
@ -5,9 +5,10 @@ import (
|
|||
)
|
||||
|
||||
type GetAllRequest struct {
|
||||
Pagination param.PaginationRequest
|
||||
Sort param.SortRequest
|
||||
Filter param.FilterRequest
|
||||
Pagination param.PaginationRequest
|
||||
Sort param.SortRequest
|
||||
Filter param.FilterRequest
|
||||
BenefactorId uint
|
||||
}
|
||||
|
||||
type GetAllResponse struct {
|
||||
|
|
|
|||
|
|
@ -17,6 +17,9 @@ func (s Service) GetAll(ctx context.Context, req param.GetAllRequest) (param.Get
|
|||
req.Pagination.GetPageSize()
|
||||
req.Pagination.GetPageNumber()
|
||||
|
||||
req.Filter["receiver_agent_id"] = req.ReceiverAgentId
|
||||
req.Filter["status"] = req.Status
|
||||
|
||||
allKindBoxes, total, err := s.repo.GetAllKindBox(ctx, req.Filter, req.Pagination, req.Sort)
|
||||
if err != nil {
|
||||
return param.GetAllResponse{}, richerror.New(op).WithErr(err)
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ func (s Service) GetAllAwaitingDelivery(ctx context.Context, req param.DeliveryA
|
|||
|
||||
req.Pagination.GetPageSize()
|
||||
req.Pagination.GetPageNumber()
|
||||
req.Filter["sender_agent_id"] = req.SenderAgentId
|
||||
req.Filter["status"] = req.Status
|
||||
|
||||
allAwaitingKindBoxReq, total, err := s.repo.GetAllKindBoxReq(ctx, req.Filter, req.Pagination, req.Sort)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ func (s Service) GetAll(ctx context.Context, req param.KindBoxGetAllRequest) (pa
|
|||
return param.KindBoxGetAllResponse{FieldErrors: fieldErrors}, richerror.New(op).WithErr(vErr)
|
||||
}
|
||||
|
||||
req.Filter["benefactor_id"] = req.BenefactorId
|
||||
req.Pagination.GetPageSize()
|
||||
req.Pagination.GetPageNumber()
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ func (s Service) GetAll(ctx context.Context, req param.GetAllRequest) (param.Get
|
|||
return param.GetAllResponse{FieldErrors: fieldErrors}, richerror.New(op).WithErr(vErr)
|
||||
}
|
||||
|
||||
req.Filter["benefactor_id"] = req.BenefactorId
|
||||
req.Pagination.GetPageSize()
|
||||
req.Pagination.GetPageNumber()
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ func (v Validator) ValidateGetAll(req param.GetAllRequest) (map[string]string, e
|
|||
const op = "agentkindboxvalidator.ValidateGetAll"
|
||||
validFields := []string{
|
||||
"id", "kind_box_req_id",
|
||||
"receiver_agent_id", "status",
|
||||
"benefactor_id", "type", "serial_number",
|
||||
"return_refer_time_id", "return_refer_date", "return_address_id",
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ func (v Validator) ValidateGetAllAwaitingDelivery(req kbrparam.DeliveryAwaitingG
|
|||
const op = "adminkindboxreqvalidator.ValidateGetAllAwaitingDelivery"
|
||||
validFields := []string{
|
||||
"id", "benefactor_id", "kind_box_type",
|
||||
"sender_agent_id", "status",
|
||||
"count_requested", "count_accepted",
|
||||
"deliver_refer_time_id", "deliver_refer_date", "deliver_address_id",
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ func (v Validator) ValidateGetAll(req param.KindBoxGetAllRequest) (map[string]st
|
|||
|
||||
validFields := []string{
|
||||
"id", "kind_box_req_id", "kind_box_type", "amount", "serial_number",
|
||||
"benefactor_id",
|
||||
"status", "deliver_refer_time_id", "deliver_refer_date", "deliver_address_id", "sender_agent_id",
|
||||
"delivered_at", "return_refer_time_id", "return_refer_date",
|
||||
"return_address_id", "receiver_agent_id", "returned_at",
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ func (v Validator) ValidateGetAll(req param.GetAllRequest) (map[string]string, e
|
|||
const op = "benefactorkindboxreqvalidator.ValidateGetAllAwaitingDelivery"
|
||||
validFields := []string{
|
||||
"id", "kind_box_type", "status", "sender_agent_id",
|
||||
"benefactor_id",
|
||||
"count_requested", "count_accepted",
|
||||
"deliver_refer_time_id", "deliver_refer_date", "deliver_address_id",
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue