2024-01-22 15:21:13 +00:00
|
|
|
package adminkindboxreqservice
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box_req"
|
|
|
|
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (s Service) Reject(ctx context.Context, req param.KindBoxReqRejectRequest) (param.KindBoxReqRejectResponse, error) {
|
|
|
|
const op = "adminkindboxreqservice.Reject"
|
2024-08-01 10:20:18 +00:00
|
|
|
if fieldErrors, vErr := s.vld.ValidateRejectRequest(ctx, req); vErr != nil {
|
|
|
|
return param.KindBoxReqRejectResponse{FieldErrors: fieldErrors}, richerror.New(op).WithErr(vErr)
|
|
|
|
}
|
2024-01-22 15:21:13 +00:00
|
|
|
err := s.repo.RejectKindBoxReq(ctx, req.ID, req.Description)
|
|
|
|
if err != nil {
|
|
|
|
return param.KindBoxReqRejectResponse{}, richerror.New(op).WithErr(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
kindBoxReq, gErr := s.repo.GetByID(ctx, req.ID)
|
|
|
|
if gErr != nil {
|
|
|
|
return param.KindBoxReqRejectResponse{}, richerror.New(op).WithErr(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return param.KindBoxReqRejectResponse{
|
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-01-22 15:21:13 +00:00
|
|
|
}, nil
|
|
|
|
}
|