forked from ebhomengo/niki
1
0
Fork 0
niki/service/admin/kind_box_req/add.go

35 lines
1.2 KiB
Go
Raw Normal View History

2023-12-25 17:08:19 +00:00
package adminkindboxreqservice
import (
"context"
entity "git.gocasts.ir/ebhomengo/niki/entity"
param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box_req"
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
)
func (s Service) Add(ctx context.Context, req param.KindBoxReqAddRequest) (param.KindBoxReqAddResponse, error) {
2023-12-25 17:08:19 +00:00
const op = "adminkindboxreqservice.Add"
// TODO: check validation
//exist, err := s.benefactorService.IsBenefactorExist(ctx, req.BenefactorID)
//if err != nil {
// return param.KindBoxReqAddResponse{}, richerror.New(op).WithErr(err).WithKind(richerror.KindUnexpected)
//}
//if !exist {
// return param.KindBoxReqAddResponse{}, richerror.New(op).WithMessage(errmsg.ErrorMsgUserNotFound).WithKind(richerror.KindInvalid)
//}
kindBoxReq, err := s.repo.AddKindBoxReq(ctx, entity.KindBoxReq{
2023-12-25 17:08:19 +00:00
BenefactorID: req.BenefactorID,
TypeID: req.TypeID,
CountRequested: req.CountRequested,
Status: entity.KindBoxReqPendingStatus,
})
if err != nil {
return param.KindBoxReqAddResponse{}, richerror.New(op).WithErr(err).WithKind(richerror.KindUnexpected)
}
2023-12-25 17:08:19 +00:00
return param.KindBoxReqAddResponse{KindBoxReq: kindBoxReq}, nil
}