2024-01-02 14:04:16 +00:00
|
|
|
package benefactorkindboxreqservice
|
2023-12-20 08:27:13 +00:00
|
|
|
|
|
|
|
import (
|
2023-12-22 21:42:57 +00:00
|
|
|
"context"
|
2024-07-24 23:45:04 +00:00
|
|
|
|
2024-03-14 13:38:42 +00:00
|
|
|
"git.gocasts.ir/ebhomengo/niki/entity"
|
2023-12-25 17:08:19 +00:00
|
|
|
param "git.gocasts.ir/ebhomengo/niki/param/benefactor/kind_box_req"
|
2023-12-22 21:25:16 +00:00
|
|
|
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
|
2023-12-20 08:27:13 +00:00
|
|
|
)
|
|
|
|
|
2023-12-22 21:42:57 +00:00
|
|
|
func (s Service) Add(ctx context.Context, req param.KindBoxReqAddRequest) (param.KindBoxReqAddResponse, error) {
|
2023-12-25 17:08:19 +00:00
|
|
|
const op = "userkindboxreqservice.Add"
|
2024-05-31 12:36:48 +00:00
|
|
|
|
2023-12-22 21:42:57 +00:00
|
|
|
kindBoxReq, err := s.repo.AddKindBoxReq(ctx, entity.KindBoxReq{
|
2024-05-31 12:36:48 +00:00
|
|
|
BenefactorID: req.BenefactorID,
|
2024-07-03 17:18:06 +00:00
|
|
|
KindBoxType: req.KindBoxType,
|
2024-05-31 12:36:48 +00:00
|
|
|
DeliverAddressID: req.DeliverAddressID,
|
|
|
|
DeliverReferDate: req.DeliverReferDate,
|
|
|
|
DeliverReferTimeID: req.DeliverReferTimeID,
|
|
|
|
CountRequested: req.CountRequested,
|
|
|
|
Status: entity.KindBoxReqPendingStatus,
|
2023-12-22 21:25:16 +00:00
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
return param.KindBoxReqAddResponse{}, richerror.New(op).WithErr(err).WithKind(richerror.KindUnexpected)
|
|
|
|
}
|
2023-12-25 17:08:19 +00:00
|
|
|
|
2023-12-22 21:25:16 +00:00
|
|
|
return param.KindBoxReqAddResponse{KindBoxReq: kindBoxReq}, nil
|
2023-12-20 08:27:13 +00:00
|
|
|
}
|