2024-06-12 08:15:28 +00:00
|
|
|
package adminkindboxreqservice
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
paginationparam "git.gocasts.ir/ebhomengo/niki/param"
|
|
|
|
param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box_req"
|
|
|
|
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (s Service) GetAllAwaitingDelivery(ctx context.Context, req param.DeliveryAwaitingGetAllRequest) (param.DeliveryAwaitingGetAllResponse, error) {
|
|
|
|
const op = "adminkindboxreqservice.GetAllAwaitingDelivery"
|
|
|
|
|
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
|
|
|
|
}
|