2024-09-15 07:36:09 +00:00
|
|
|
package agentkindboxreqservice
|
2024-06-10 22:54:16 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2024-09-15 07:36:09 +00:00
|
|
|
param "git.gocasts.ir/ebhomengo/niki/param/agent/kind_box_req"
|
2024-07-24 23:45:04 +00:00
|
|
|
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
|
2024-06-10 22:54:16 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func (s Service) GetAwaitingDelivery(ctx context.Context, req param.DeliveryAwaitingGetRequest) (param.DeliveryAwaitingGetResponse, error) {
|
2024-09-16 11:14:45 +00:00
|
|
|
const op = "agentkindboxreqservice.GetAwaitingDelivery"
|
2024-08-01 10:20:18 +00:00
|
|
|
if fieldErrors, vErr := s.vld.ValidateGetAwaitingDeliveryRequest(req); vErr != nil {
|
|
|
|
return param.DeliveryAwaitingGetResponse{FieldErrors: fieldErrors}, richerror.New(op).WithErr(vErr)
|
|
|
|
}
|
2024-06-10 22:54:16 +00:00
|
|
|
kindBoxReq, err := s.repo.GetAwaitingDeliveryByAgent(ctx, req.KindBoxReqID, req.AgentID)
|
|
|
|
if err != nil {
|
2024-07-24 23:45:04 +00:00
|
|
|
return param.DeliveryAwaitingGetResponse{}, richerror.New(op).WithErr(err)
|
2024-06-10 22:54:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return param.DeliveryAwaitingGetResponse{
|
2024-09-10 20:55:19 +00:00
|
|
|
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-10 22:54:16 +00:00
|
|
|
}, nil
|
|
|
|
}
|