fix pagination and search

This commit is contained in:
dpurbosakti
2025-10-08 12:21:42 +07:00
parent e9b262175d
commit 7940c895b1
46 changed files with 175 additions and 47 deletions
@@ -53,7 +53,7 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.De
}
}
plh.SearchCodeOrName(input.Search, tx)
tx = plh.SearchCodeOrName(input.Search, tx)
tx = tx.
Model(&e.Device{}).
@@ -87,6 +87,9 @@ func ReadList(input e.ReadListDto) (*d.Data, error) {
return err
}
if len(input.Includes) > 0 {
input.Preloads = pu.GetPreloads(input.Includes)
}
if dataList, metaList, err = ReadListData(input, &event, tx); err != nil {
return err
}
@@ -47,9 +47,17 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.Di
tx = dg.I
}
if len(input.Preloads) > 0 {
for _, preload := range input.Preloads {
tx = tx.Preload(preload)
}
}
tx = plh.SearchCodeOrName(input.Search, tx)
tx = tx.
Model(&e.DiagnoseSrc{}).
Scopes(gh.Filter(input)).
Scopes(gh.Filter(input.FilterDto)).
Count(&count).
Scopes(gh.Paginate(input, &pagination)).
Order("\"CreatedAt\" DESC")
@@ -53,6 +53,8 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.Di
}
}
tx = plh.SearchCodeOrName(input.Search, tx)
tx = tx.
Model(&e.DivisionPosition{}).
Preload("Division").
@@ -53,7 +53,7 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.Di
}
}
plh.SearchCodeOrName(input.Search, tx)
tx = plh.SearchCodeOrName(input.Search, tx)
if input.OnlyHaveChildren {
tx = tx.Where(`
@@ -87,6 +87,9 @@ func ReadList(input e.ReadListDto) (*d.Data, error) {
return err
}
if len(input.Includes) > 0 {
input.Preloads = pu.GetPreloads(input.Includes)
}
if dataList, metaList, err = ReadListData(input, &event, tx); err != nil {
return err
}
@@ -47,11 +47,11 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.Et
tx = dg.I
}
plh.SearchCodeOrName(input.Search, tx)
tx = plh.SearchCodeOrName(input.Search, tx)
tx = tx.
Model(&e.Ethnic{}).
Scopes(gh.Filter(input)).
Scopes(gh.Filter(input.FilterDto)).
Count(&count).
Scopes(gh.Paginate(input, &pagination)).
Order("\"CreatedAt\" DESC")
+1 -1
View File
@@ -53,7 +53,7 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.In
}
}
plh.SearchCodeOrName(input.Search, tx)
tx = plh.SearchCodeOrName(input.Search, tx)
if input.OnlyHaveChildren {
tx = tx.Where(`
@@ -53,7 +53,7 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.In
}
}
plh.SearchCodeOrName(input.Search, tx)
tx = plh.SearchCodeOrName(input.Search, tx)
tx = tx.
Model(&e.Installation{}).
@@ -53,6 +53,8 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.In
}
}
tx = plh.SearchCodeOrName(input.Search, tx)
tx = tx.
Model(&e.InsuranceCompany{}).
Scopes(gh.Filter(input.FilterDto)).
@@ -53,6 +53,8 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.It
}
}
tx = plh.SearchCodeOrName(input.Search, tx)
tx = tx.
Model(&e.Item{}).
Scopes(gh.Filter(input.FilterDto)).
@@ -87,6 +87,9 @@ func ReadList(input e.ReadListDto) (*d.Data, error) {
return err
}
if len(input.Includes) > 0 {
input.Preloads = pu.GetPreloads(input.Includes)
}
if dataList, metaList, err = ReadListData(input, &event, tx); err != nil {
return err
}
@@ -51,7 +51,7 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.La
tx = tx.
Model(&e.Language{}).
Scopes(gh.Filter(input)).
Scopes(gh.Filter(input.FilterDto)).
Count(&count).
Scopes(gh.Paginate(input, &pagination)).
Order("\"CreatedAt\" DESC")
@@ -87,6 +87,9 @@ func ReadList(input e.ReadListDto) (*d.Data, error) {
return err
}
if len(input.Includes) > 0 {
input.Preloads = pu.GetPreloads(input.Includes)
}
if dataList, metaList, err = ReadListData(input, &event, tx); err != nil {
return err
}
@@ -47,9 +47,17 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.Mc
tx = dg.I
}
if len(input.Preloads) > 0 {
for _, preload := range input.Preloads {
tx = tx.Preload(preload)
}
}
tx = plh.SearchCodeOrName(input.Search, tx)
tx = tx.
Model(&e.McuSrcCategory{}).
Scopes(gh.Filter(input)).
Scopes(gh.Filter(input.FilterDto)).
Count(&count).
Scopes(gh.Paginate(input, &pagination)).
Order("\"CreatedAt\" DESC")
@@ -53,7 +53,7 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.Mc
}
}
plh.SearchCodeOrName(input.Search, tx)
tx = plh.SearchCodeOrName(input.Search, tx)
tx = tx.
Model(&e.McuSrc{}).
@@ -53,7 +53,7 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.Mc
}
}
plh.SearchCodeOrName(input.Search, tx)
tx = plh.SearchCodeOrName(input.Search, tx)
tx = tx.
Model(&e.McuSubSrc{}).
@@ -53,7 +53,7 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.Me
}
}
plh.SearchCodeOrName(input.Search, tx)
tx = plh.SearchCodeOrName(input.Search, tx)
tx = tx.
Model(&e.MedicalActionSrc{}).
@@ -87,6 +87,9 @@ func ReadList(input e.ReadListDto) (*d.Data, error) {
return err
}
if len(input.Includes) > 0 {
input.Preloads = pu.GetPreloads(input.Includes)
}
if dataList, metaList, err = ReadListData(input, &event, tx); err != nil {
return err
}
@@ -47,9 +47,17 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.Me
tx = dg.I
}
if len(input.Preloads) > 0 {
for _, preload := range input.Preloads {
tx = tx.Preload(preload)
}
}
tx = plh.SearchCodeOrName(input.Search, tx)
tx = tx.
Model(&e.MedicineGroup{}).
Scopes(gh.Filter(input)).
Scopes(gh.Filter(input.FilterDto)).
Count(&count).
Scopes(gh.Paginate(input, &pagination)).
Order("\"CreatedAt\" DESC")
@@ -87,6 +87,9 @@ func ReadList(input e.ReadListDto) (*d.Data, error) {
return err
}
if len(input.Includes) > 0 {
input.Preloads = pu.GetPreloads(input.Includes)
}
if dataList, metaList, err = ReadListData(input, &event, tx); err != nil {
return err
}
@@ -47,9 +47,17 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.Me
tx = dg.I
}
if len(input.Preloads) > 0 {
for _, preload := range input.Preloads {
tx = tx.Preload(preload)
}
}
tx = plh.SearchCodeOrName(input.Search, tx)
tx = tx.
Model(&e.MedicineMethod{}).
Scopes(gh.Filter(input)).
Scopes(gh.Filter(input.FilterDto)).
Count(&count).
Scopes(gh.Paginate(input, &pagination)).
Order("\"CreatedAt\" DESC")
@@ -53,9 +53,9 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.Me
}
}
plh.SearchCodeOrName(input.Search, tx)
tx = plh.SearchCodeOrName(input.Search, tx)
tx = tx.
tx = tx.Debug().
Model(&e.Medicine{}).
Scopes(gh.Filter(input.FilterDto)).
Count(&count).
@@ -87,6 +87,9 @@ func ReadList(input e.ReadListDto) (*d.Data, error) {
return err
}
if len(input.Includes) > 0 {
input.Preloads = pu.GetPreloads(input.Includes)
}
if dataList, metaList, err = ReadListData(input, &event, tx); err != nil {
return err
}
@@ -47,9 +47,17 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.Ph
tx = dg.I
}
if len(input.Preloads) > 0 {
for _, preload := range input.Preloads {
tx = tx.Preload(preload)
}
}
tx = plh.SearchCodeOrName(input.Search, tx)
tx = tx.
Model(&e.PharmacyCompany{}).
Scopes(gh.Filter(input)).
Scopes(gh.Filter(input.FilterDto)).
Count(&count).
Scopes(gh.Paginate(input, &pagination)).
Order("\"CreatedAt\" DESC")
@@ -87,6 +87,9 @@ func ReadList(input e.ReadListDto) (*d.Data, error) {
return err
}
if len(input.Includes) > 0 {
input.Preloads = pu.GetPreloads(input.Includes)
}
if dataList, metaList, err = ReadListData(input, &event, tx); err != nil {
return err
}
@@ -47,11 +47,11 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.Pr
tx = dg.I
}
plh.SearchCodeOrName(input.Search, tx)
tx = plh.SearchCodeOrName(input.Search, tx)
tx = tx.
Model(&e.ProcedureSrc{}).
Scopes(gh.Filter(input)).
Scopes(gh.Filter(input.FilterDto)).
Count(&count).
Scopes(gh.Paginate(input, &pagination)).
Order("\"CreatedAt\" DESC")
@@ -53,9 +53,9 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.Pr
}
}
plh.SearchCodeOrName(input.Search, tx)
tx = plh.SearchCodeOrName(input.Search, tx)
tx = tx.
tx = tx.Debug().
Model(&e.Province{}).
Scopes(gh.Filter(input.FilterDto)).
Count(&count).
@@ -53,7 +53,7 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.Re
}
}
plh.SearchCodeOrName(input.Search, tx)
tx = plh.SearchCodeOrName(input.Search, tx)
tx = tx.
Model(&e.Regency{}).
@@ -53,7 +53,7 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.Sp
}
}
plh.SearchCodeOrName(input.Search, tx)
tx = plh.SearchCodeOrName(input.Search, tx)
tx = tx.
Model(&e.Specialist{}).
@@ -53,7 +53,7 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.Su
}
}
plh.SearchCodeOrName(input.Search, tx)
tx = plh.SearchCodeOrName(input.Search, tx)
tx = tx.
Model(&e.Subspecialist{}).
+1 -1
View File
@@ -53,7 +53,7 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.Un
}
}
plh.SearchCodeOrName(input.Search, tx)
tx = plh.SearchCodeOrName(input.Search, tx)
tx = tx.
Model(&e.Unit{}).
+1 -1
View File
@@ -53,7 +53,7 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.Uo
}
}
plh.SearchCodeOrName(input.Search, tx)
tx = plh.SearchCodeOrName(input.Search, tx)
tx = tx.
Model(&e.Uom{}).
@@ -53,7 +53,7 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.Vi
}
}
plh.SearchCodeOrName(input.Search, tx)
tx = plh.SearchCodeOrName(input.Search, tx)
tx = tx.
Model(&e.Village{}).