2024-01-02 14:04:16 +00:00
|
|
|
package benefactorkindboxservice
|
2023-12-26 17:52:20 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2024-07-24 23:45:04 +00:00
|
|
|
|
2024-07-09 17:17:04 +00:00
|
|
|
params "git.gocasts.ir/ebhomengo/niki/param"
|
2023-12-26 17:53:25 +00:00
|
|
|
param "git.gocasts.ir/ebhomengo/niki/param/benefactor/kind_box"
|
2023-12-26 17:52:20 +00:00
|
|
|
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
|
|
|
|
)
|
|
|
|
|
2023-12-26 17:53:25 +00:00
|
|
|
func (s Service) GetAll(ctx context.Context, req param.KindBoxGetAllRequest) (param.KindBoxGetAllResponse, error) {
|
2024-07-21 13:38:54 +00:00
|
|
|
const op = "benefactorkindboxservice.GetAll"
|
2024-08-01 10:20:18 +00:00
|
|
|
if fieldErrors, vErr := s.vld.ValidateGetAll(req); vErr != nil {
|
|
|
|
return param.KindBoxGetAllResponse{FieldErrors: fieldErrors}, richerror.New(op).WithErr(vErr)
|
|
|
|
}
|
2023-12-26 17:52:20 +00:00
|
|
|
|
2024-07-21 13:38:54 +00:00
|
|
|
allKindBox, total, err := s.repo.GetAllKindBox(ctx, req.Filter, req.Pagination, req.Sort)
|
2023-12-26 17:52:20 +00:00
|
|
|
if err != nil {
|
2024-07-21 13:38:54 +00:00
|
|
|
return param.KindBoxGetAllResponse{}, richerror.New(op).WithErr(err)
|
2023-12-26 17:52:20 +00:00
|
|
|
}
|
|
|
|
|
2024-07-21 13:38:54 +00:00
|
|
|
return param.KindBoxGetAllResponse{
|
|
|
|
AllKindBox: allKindBox,
|
|
|
|
Pagination: params.PaginationResponse{
|
|
|
|
PageSize: req.Pagination.GetPageSize(),
|
|
|
|
PageNumber: req.Pagination.GetPageNumber(),
|
|
|
|
Total: total,
|
|
|
|
},
|
|
|
|
}, nil
|
2023-12-26 17:52:20 +00:00
|
|
|
}
|