2024-07-23 21:37:27 +00:00
|
|
|
package adminkindboxservice
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box"
|
|
|
|
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
|
|
|
|
)
|
|
|
|
|
2024-08-01 10:20:18 +00:00
|
|
|
func (s Service) Enumerate(ctx context.Context, req param.EnumerateKindBoxRequest) (param.EnumerateKindBoxResponse, error) {
|
2024-07-23 21:37:27 +00:00
|
|
|
const op = "AdminKindBoxService.Enumerate"
|
2024-08-01 10:20:18 +00:00
|
|
|
if fieldErrors, vErr := s.vld.ValidateEnumerate(ctx, req); vErr != nil {
|
|
|
|
return param.EnumerateKindBoxResponse{FieldErrors: fieldErrors}, richerror.New(op).WithErr(vErr)
|
|
|
|
}
|
2024-07-23 21:37:27 +00:00
|
|
|
err := s.repo.EnumerateKindBox(ctx, req.KindBoxID, req.Amount)
|
|
|
|
if err != nil {
|
2024-08-01 10:20:18 +00:00
|
|
|
return param.EnumerateKindBoxResponse{}, richerror.New(op).WithErr(err)
|
2024-07-23 21:37:27 +00:00
|
|
|
}
|
|
|
|
|
2024-08-01 10:20:18 +00:00
|
|
|
return param.EnumerateKindBoxResponse{}, nil
|
2024-07-23 21:37:27 +00:00
|
|
|
}
|