2024-09-15 07:36:09 +00:00
|
|
|
package agentkindboxreqservice
|
2024-06-12 08:15:28 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
paginationparam "git.gocasts.ir/ebhomengo/niki/param"
|
2024-09-15 07:36:09 +00:00
|
|
|
param "git.gocasts.ir/ebhomengo/niki/param/agent/kind_box_req"
|
2024-06-12 08:15:28 +00:00
|
|
|
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (s Service) GetAllAwaitingDelivery(ctx context.Context, req param.DeliveryAwaitingGetAllRequest) (param.DeliveryAwaitingGetAllResponse, error) {
|
2024-09-16 11:14:45 +00:00
|
|
|
const op = "agentkindboxreqservice.GetAllAwaitingDelivery"
|
2024-06-12 08:15:28 +00:00
|
|
|
|
2024-08-01 10:20:18 +00:00
|
|
|
if fieldErrors, vErr := s.vld.ValidateGetAllAwaitingDelivery(req); vErr != nil {
|
|
|
|
return param.DeliveryAwaitingGetAllResponse{FieldErrors: fieldErrors}, richerror.New(op).WithErr(vErr)
|
|
|
|
}
|
|
|
|
|
2024-06-12 08:15:28 +00:00
|
|
|
allAwaitingKindBoxReq, total, err := s.repo.GetAllKindBoxReq(ctx, req.Filter, req.Pagination, req.Sort)
|
|
|
|
if err != nil {
|
|
|
|
return param.DeliveryAwaitingGetAllResponse{}, richerror.New(op).WithErr(err)
|
|
|
|
}
|
2024-09-10 20:55:19 +00:00
|
|
|
var data []param.Data
|
|
|
|
for _, kindBoxReq := range allAwaitingKindBoxReq {
|
|
|
|
data = append(data, param.Data{
|
|
|
|
ID: kindBoxReq.ID,
|
|
|
|
BenefactorID: kindBoxReq.BenefactorID,
|
|
|
|
KindBoxType: kindBoxReq.KindBoxType,
|
|
|
|
CountRequested: kindBoxReq.CountRequested,
|
|
|
|
CountAccepted: kindBoxReq.CountAccepted,
|
|
|
|
Description: kindBoxReq.Description,
|
|
|
|
Status: kindBoxReq.Status,
|
|
|
|
DeliverReferTimeID: kindBoxReq.DeliverReferTimeID,
|
|
|
|
DeliverReferDate: kindBoxReq.DeliverReferDate,
|
|
|
|
DeliverAddressID: kindBoxReq.DeliverAddressID,
|
|
|
|
SenderAgentID: kindBoxReq.SenderAgentID,
|
|
|
|
DeliveredAt: kindBoxReq.DeliveredAt,
|
|
|
|
})
|
|
|
|
}
|
2024-06-12 08:15:28 +00:00
|
|
|
|
|
|
|
return param.DeliveryAwaitingGetAllResponse{
|
2024-09-10 20:55:19 +00:00
|
|
|
Data: data,
|
2024-06-12 08:15:28 +00:00
|
|
|
Pagination: paginationparam.PaginationResponse{
|
|
|
|
PageSize: req.Pagination.GetPageSize(),
|
|
|
|
PageNumber: req.Pagination.GetPageNumber(),
|
|
|
|
Total: total,
|
|
|
|
},
|
|
|
|
}, nil
|
|
|
|
}
|