2024-07-14 08:58:37 +00:00
|
|
|
package agentkindboxservice
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2024-07-24 23:45:04 +00:00
|
|
|
|
2024-07-14 08:58:37 +00:00
|
|
|
paginationparam "git.gocasts.ir/ebhomengo/niki/param"
|
|
|
|
param "git.gocasts.ir/ebhomengo/niki/param/agent/kind_box"
|
|
|
|
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (s Service) GetAll(ctx context.Context, req param.GetAllRequest) (param.GetAllResponse, error) {
|
|
|
|
const op = "agentkindboxservice.GetAll"
|
2024-08-01 10:20:18 +00:00
|
|
|
if fieldErrors, vErr := s.vld.ValidateGetAll(req); vErr != nil {
|
|
|
|
return param.GetAllResponse{FieldErrors: fieldErrors}, richerror.New(op).WithErr(vErr)
|
|
|
|
}
|
2024-07-14 08:58:37 +00:00
|
|
|
allKindBoxes, total, err := s.repo.GetAllKindBox(ctx, req.Filter, req.Pagination, req.Sort)
|
|
|
|
if err != nil {
|
|
|
|
return param.GetAllResponse{}, richerror.New(op).WithErr(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return param.GetAllResponse{
|
|
|
|
AllKindBoxes: allKindBoxes,
|
|
|
|
Pagination: paginationparam.PaginationResponse{
|
|
|
|
PageSize: req.Pagination.GetPageSize(),
|
|
|
|
PageNumber: req.Pagination.GetPageNumber(),
|
|
|
|
Total: total,
|
|
|
|
},
|
|
|
|
}, nil
|
|
|
|
}
|