niki/service/kind_box_req/add.go

24 lines
779 B
Go
Raw Normal View History

package kindboxreqservice
import (
"context"
entity "git.gocasts.ir/ebhomengo/niki/entity"
param "git.gocasts.ir/ebhomengo/niki/param/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) {
const op = "kindboxreqservice.Add"
kindBoxReq, err := s.repo.AddKindBoxReq(ctx, entity.KindBoxReq{
TypeID: req.TypeID,
CountRequested: req.CountRequested,
BenefactorID: req.BenefactorID,
Status: entity.KindBoxReqPendingStatus,
})
if err != nil {
return param.KindBoxReqAddResponse{}, richerror.New(op).WithErr(err).WithKind(richerror.KindUnexpected)
}
return param.KindBoxReqAddResponse{KindBoxReq: kindBoxReq}, nil
}