2023-12-25 17:08:19 +00:00
|
|
|
package adminkindboxservice
|
2023-12-20 08:27:13 +00:00
|
|
|
|
|
|
|
import (
|
2023-12-22 21:42:57 +00:00
|
|
|
"context"
|
|
|
|
|
2023-12-22 21:25:16 +00:00
|
|
|
entity "git.gocasts.ir/ebhomengo/niki/entity"
|
2023-12-25 17:08:19 +00:00
|
|
|
param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box"
|
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.KindBoxAddRequest) (param.KindBoxAddResponse, error) {
|
2023-12-25 17:08:19 +00:00
|
|
|
const op = "adminkindboxservice.Add"
|
2023-12-26 21:42:33 +00:00
|
|
|
|
|
|
|
// TODO: check validation
|
|
|
|
// exist, err := s.benefactorService.IsBenefactorExist(ctx, req.BenefactorID)
|
|
|
|
// if err != nil {
|
|
|
|
// return param.KindBoxAddResponse{}, richerror.New(op).WithErr(err).WithKind(richerror.KindUnexpected)
|
|
|
|
//}
|
|
|
|
//if !exist {
|
|
|
|
// return param.KindBoxAddResponse{}, richerror.New(op).WithMessage(errmsg.ErrorMsgUserNotFound).WithKind(richerror.KindInvalid)
|
|
|
|
//}
|
|
|
|
|
2023-12-22 21:42:57 +00:00
|
|
|
kindBox, err := s.repo.AddKindBox(ctx, entity.KindBox{
|
2023-12-26 21:42:33 +00:00
|
|
|
BenefactorID: req.BenefactorID,
|
2023-12-22 21:25:16 +00:00
|
|
|
KindBoxReqID: req.KindBoxReqID,
|
|
|
|
SenderID: req.SenderID,
|
|
|
|
SerialNumber: req.SerialNumber,
|
|
|
|
Status: entity.KindBoxPendingSendStatus,
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
return param.KindBoxAddResponse{}, richerror.New(op).WithErr(err).WithKind(richerror.KindUnexpected)
|
|
|
|
}
|
|
|
|
return param.KindBoxAddResponse{KindBox: kindBox}, nil
|
2023-12-20 08:27:13 +00:00
|
|
|
}
|