fix pagination, filter to show only have children data on division

This commit is contained in:
dpurbosakti
2025-10-03 17:13:53 +07:00
parent 26357e88e9
commit bd6351e3a3
144 changed files with 759 additions and 845 deletions

No files matched your search

@@ -109,12 +109,13 @@ func ReadList(input e.ReadListDto) (*d.Data, error) {
return &d.Data{
Meta: d.IS{
"source": source,
"structure": "list-data",
"status": "fetched",
"page_number": strconv.Itoa(metaList.PageNumber),
"page_size": strconv.Itoa(metaList.PageSize),
"record_totalCount": strconv.Itoa(metaList.Count),
"source": source,
"structure": "list-data",
"status": "fetched",
"page_number": strconv.Itoa(metaList.PageNumber),
"page_size": strconv.Itoa(metaList.PageSize),
"record_totalCount": strconv.Itoa(metaList.Count),
"record_currentCount": strconv.Itoa(len(dataList)),
},
Data: e.ToResponseList(dataList),
}, nil
@@ -55,6 +55,16 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.Di
plh.SearchCodeOrName(input.Search, tx)
if input.OnlyHaveChildren {
tx = tx.Where(`
EXISTS (
SELECT 1
FROM "Division" c
WHERE c."Parent_Id" = "Division"."Id"
)
`)
}
tx = tx.
Model(&e.Division{}).
Scopes(gh.Filter(input.FilterDto)).