package adminkindboxservice import ( "context" entity "git.gocasts.ir/ebhomengo/niki/entity" param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box" richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error" ) func (s Service) AddBatchKindBox(ctx context.Context, req param.AddKindBoxRequest) (param.AddKindBoxResponse, error) { const op = "adminkindboxservice.AddKindBox" kindBoxes := make([]entity.KindBox, 0) kb := entity.KindBox{ KindBoxReqID: req.KindBoxReqID, BenefactorID: req.BenefactorID, KindBoxType: req.Type, DeliverReferDate: req.DeliverReferDate, DeliverAddressID: req.DeliverAddressID, DeliveredAt: req.DeliveredAt, SenderAgentID: req.SenderAgentID, Status: entity.KindBoxDeliveredStatus, } for i := uint(0); i < req.CountAccepted; i++ { kindBoxes = append(kindBoxes, kb) } aErr := s.repo.AddBatchKindBox(ctx, kindBoxes) if aErr != nil { return param.AddKindBoxResponse{}, richerror.New(op).WithErr(aErr).WithKind(richerror.KindUnexpected) } return param.AddKindBoxResponse{}, nil }