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"
|
2024-01-23 10:21:56 +00:00
|
|
|
"github.com/oklog/ulid/v2"
|
2023-12-20 08:27:13 +00:00
|
|
|
)
|
|
|
|
|
2024-01-23 10:21:56 +00:00
|
|
|
func (s Service) AddKindBoxAfterAcceptingRequest(ctx context.Context, req param.KindBoxAddAfterAcceptingReqRequest) (param.KindBoxAddAfterAcceptingReqResponse, error) {
|
|
|
|
const op = "adminkindboxservice.AddKindBoxAfterAcceptingRequest"
|
2023-12-26 21:42:33 +00:00
|
|
|
|
2024-01-23 10:21:56 +00:00
|
|
|
var kindBoxes []entity.KindBox
|
|
|
|
for i := 0; i < int(req.Count); i++ {
|
|
|
|
kindBoxes = append(kindBoxes, entity.KindBox{
|
|
|
|
KindBoxReqID: req.KindBoxReqID,
|
|
|
|
BenefactorID: req.BenefactorID,
|
|
|
|
Type: req.Type,
|
|
|
|
Status: entity.KindBoxPendingSendStatus,
|
|
|
|
SerialNumber: ulid.Make().String(),
|
|
|
|
})
|
|
|
|
}
|
2024-01-27 08:27:16 +00:00
|
|
|
err := s.repo.AddBatchKindBox(ctx, kindBoxes)
|
2023-12-22 21:25:16 +00:00
|
|
|
if err != nil {
|
2024-01-23 10:21:56 +00:00
|
|
|
return param.KindBoxAddAfterAcceptingReqResponse{}, richerror.New(op).WithErr(err).WithKind(richerror.KindUnexpected)
|
2023-12-22 21:25:16 +00:00
|
|
|
}
|
2024-01-01 07:22:14 +00:00
|
|
|
|
2024-01-27 08:27:16 +00:00
|
|
|
return param.KindBoxAddAfterAcceptingReqResponse{}, nil
|
2023-12-20 08:27:13 +00:00
|
|
|
}
|