fix pagination, filter to show only have children data on division
This commit is contained in:
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)).
|
||||
|
||||
Reference in New Issue
Block a user