forked from ebhomengo/niki
1
0
Fork 0
niki/service/admin/kind_box/enumerate.go

22 lines
723 B
Go
Raw Permalink Normal View History

package adminkindboxservice
import (
"context"
param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box"
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
)
func (s Service) Enumerate(ctx context.Context, req param.EnumerateKindBoxRequest) (param.EnumerateKindBoxResponse, error) {
const op = "AdminKindBoxService.Enumerate"
if fieldErrors, vErr := s.vld.ValidateEnumerate(ctx, req); vErr != nil {
return param.EnumerateKindBoxResponse{FieldErrors: fieldErrors}, richerror.New(op).WithErr(vErr)
}
err := s.repo.EnumerateKindBox(ctx, req.KindBoxID, req.Amount)
if err != nil {
return param.EnumerateKindBoxResponse{}, richerror.New(op).WithErr(err)
}
return param.EnumerateKindBoxResponse{}, nil
}