add search on several data source
This commit is contained in:
@@ -25,6 +25,7 @@ type ReadListDto struct {
|
||||
FilterDto
|
||||
Includes string `json:"includes"`
|
||||
Preloads []string `json:"-"`
|
||||
Search string `json:"search"`
|
||||
}
|
||||
|
||||
type FilterDto struct {
|
||||
|
||||
@@ -14,6 +14,7 @@ type ReadListDto struct {
|
||||
FilterDto
|
||||
Includes string `json:"includes"`
|
||||
Preloads []string `json:"-"`
|
||||
Search string `json:"search"`
|
||||
}
|
||||
|
||||
type FilterDto struct {
|
||||
|
||||
@@ -14,6 +14,7 @@ type ReadListDto struct {
|
||||
FilterDto
|
||||
Includes string `json:"includes"`
|
||||
Preloads []string `json:"-"`
|
||||
Search string `json:"search"`
|
||||
}
|
||||
|
||||
type FilterDto struct {
|
||||
|
||||
@@ -15,6 +15,7 @@ type ReadListDto struct {
|
||||
FilterDto
|
||||
Includes string `json:"includes"`
|
||||
Preloads []string `json:"-"`
|
||||
Search string `json:"search"`
|
||||
}
|
||||
|
||||
type FilterDto struct {
|
||||
|
||||
@@ -2,6 +2,8 @@ package medicine
|
||||
|
||||
import (
|
||||
e "simrs-vx/internal/domain/main-entities/medicine"
|
||||
|
||||
plh "simrs-vx/pkg/lib-helper"
|
||||
pl "simrs-vx/pkg/logger"
|
||||
pu "simrs-vx/pkg/use-case-helper"
|
||||
|
||||
@@ -57,6 +59,8 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.Me
|
||||
}
|
||||
}
|
||||
|
||||
plh.SearchCodeOrName(input.Search, tx)
|
||||
|
||||
tx = tx.
|
||||
Model(&e.Medicine{}).
|
||||
Scopes(gh.Filter(input.FilterDto)).
|
||||
|
||||
@@ -2,6 +2,8 @@ package specialist
|
||||
|
||||
import (
|
||||
e "simrs-vx/internal/domain/main-entities/specialist"
|
||||
|
||||
plh "simrs-vx/pkg/lib-helper"
|
||||
pl "simrs-vx/pkg/logger"
|
||||
pu "simrs-vx/pkg/use-case-helper"
|
||||
|
||||
@@ -57,6 +59,8 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.Sp
|
||||
}
|
||||
}
|
||||
|
||||
plh.SearchCodeOrName(input.Search, tx)
|
||||
|
||||
tx = tx.
|
||||
Model(&e.Specialist{}).
|
||||
Scopes(gh.Filter(input.FilterDto)).
|
||||
|
||||
@@ -2,6 +2,8 @@ package subspecialist
|
||||
|
||||
import (
|
||||
e "simrs-vx/internal/domain/main-entities/subspecialist"
|
||||
|
||||
plh "simrs-vx/pkg/lib-helper"
|
||||
pl "simrs-vx/pkg/logger"
|
||||
pu "simrs-vx/pkg/use-case-helper"
|
||||
|
||||
@@ -57,6 +59,8 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.Su
|
||||
}
|
||||
}
|
||||
|
||||
plh.SearchCodeOrName(input.Search, tx)
|
||||
|
||||
tx = tx.
|
||||
Model(&e.Subspecialist{}).
|
||||
Scopes(gh.Filter(input.FilterDto)).
|
||||
|
||||
@@ -2,6 +2,8 @@ package unit
|
||||
|
||||
import (
|
||||
e "simrs-vx/internal/domain/main-entities/unit"
|
||||
|
||||
plh "simrs-vx/pkg/lib-helper"
|
||||
pl "simrs-vx/pkg/logger"
|
||||
pu "simrs-vx/pkg/use-case-helper"
|
||||
|
||||
@@ -57,6 +59,8 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.Un
|
||||
}
|
||||
}
|
||||
|
||||
plh.SearchCodeOrName(input.Search, tx)
|
||||
|
||||
tx = tx.
|
||||
Model(&e.Unit{}).
|
||||
Preload("Installation").
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package libhelper
|
||||
|
||||
import "gorm.io/gorm"
|
||||
|
||||
func SearchCodeOrName(search string, tx *gorm.DB) {
|
||||
if search != "" {
|
||||
tx.Where("\"Code\" LIKE ? OR \"Name\" LIKE ?", "%"+search+"%", "%"+search+"%")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user