package adminseederservice import ( "context" "git.gocasts.ir/ebhomengo/niki/entity" richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error" "github.com/brianvoe/gofakeit/v7" ) func (s Service) AddKindBoxReq(ctx context.Context, status entity.KindBoxReqStatus) (entity.KindBoxReq, error) { const op = "adminseederservice.AddKindBoxReq" benefactor, bErr := s.AddBenefactor(ctx) if bErr != nil { return entity.KindBoxReq{}, richerror.New(op).WithErr(bErr).WithKind(richerror.KindUnexpected) } address, aErr := s.getAddress(ctx, benefactor.ID) if aErr != nil { return entity.KindBoxReq{}, richerror.New(op).WithErr(aErr).WithKind(richerror.KindUnexpected) } kindBoxReq, kErr := s.kindBoxReqRepo.AddKindBoxReq(ctx, entity.KindBoxReq{ BenefactorID: benefactor.ID, KindBoxType: new(entity.KindBoxType).GetRandom(), DeliverAddressID: address.ID, DeliverReferDate: gofakeit.Date(), DeliverReferTimeID: uint(gofakeit.IntRange(1, 7)), Status: status, }) if kErr != nil { return entity.KindBoxReq{}, richerror.New(op).WithErr(kErr).WithKind(richerror.KindUnexpected) } return kindBoxReq, nil }