add pagination approval flows

This commit is contained in:
efrilm
2025-10-10 19:02:52 +07:00
parent 239f052a9a
commit 3717b0b53c
5 changed files with 83 additions and 34 deletions
+17 -1
View File
@@ -173,10 +173,26 @@ func (s *ApprovalFlowServiceImpl) DeleteApprovalFlow(ctx context.Context, id uui
func (s *ApprovalFlowServiceImpl) ListApprovalFlows(ctx context.Context, req *contract.ListApprovalFlowsRequest) (*contract.ListApprovalFlowsResponse, error) {
filter := repository.ListApprovalFlowsFilter{
DepartmentID: req.DepartmentID,
Search: req.Search,
IsActive: req.IsActive,
}
page := req.Page
if page <= 0 {
page = 1
}
flows, total, err := s.flowRepo.List(ctx, filter, req.Limit, req.Offset)
limit := req.Limit
if limit <= 0 {
limit = 10
}
if limit > 100 {
limit = 100 // Max limit to prevent performance issues
}
offset := (page - 1) * limit
flows, total, err := s.flowRepo.List(ctx, filter, limit, offset)
if err != nil {
return nil, err
}