Merge pull request #39 from dikstub-rssa/feat/medicine-mix-prescription-37
add search on several data source
This commit is contained in:
@@ -25,6 +25,7 @@ type ReadListDto struct {
|
|||||||
FilterDto
|
FilterDto
|
||||||
Includes string `json:"includes"`
|
Includes string `json:"includes"`
|
||||||
Preloads []string `json:"-"`
|
Preloads []string `json:"-"`
|
||||||
|
Search string `json:"search"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type FilterDto struct {
|
type FilterDto struct {
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ type ReadListDto struct {
|
|||||||
FilterDto
|
FilterDto
|
||||||
Includes string `json:"includes"`
|
Includes string `json:"includes"`
|
||||||
Preloads []string `json:"-"`
|
Preloads []string `json:"-"`
|
||||||
|
Search string `json:"search"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type FilterDto struct {
|
type FilterDto struct {
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ type ReadListDto struct {
|
|||||||
FilterDto
|
FilterDto
|
||||||
Includes string `json:"includes"`
|
Includes string `json:"includes"`
|
||||||
Preloads []string `json:"-"`
|
Preloads []string `json:"-"`
|
||||||
|
Search string `json:"search"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type FilterDto struct {
|
type FilterDto struct {
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ type ReadListDto struct {
|
|||||||
FilterDto
|
FilterDto
|
||||||
Includes string `json:"includes"`
|
Includes string `json:"includes"`
|
||||||
Preloads []string `json:"-"`
|
Preloads []string `json:"-"`
|
||||||
|
Search string `json:"search"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type FilterDto struct {
|
type FilterDto struct {
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package medicine
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
e "simrs-vx/internal/domain/main-entities/medicine"
|
e "simrs-vx/internal/domain/main-entities/medicine"
|
||||||
|
|
||||||
|
plh "simrs-vx/pkg/lib-helper"
|
||||||
pl "simrs-vx/pkg/logger"
|
pl "simrs-vx/pkg/logger"
|
||||||
pu "simrs-vx/pkg/use-case-helper"
|
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.
|
tx = tx.
|
||||||
Model(&e.Medicine{}).
|
Model(&e.Medicine{}).
|
||||||
Scopes(gh.Filter(input.FilterDto)).
|
Scopes(gh.Filter(input.FilterDto)).
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package specialist
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
e "simrs-vx/internal/domain/main-entities/specialist"
|
e "simrs-vx/internal/domain/main-entities/specialist"
|
||||||
|
|
||||||
|
plh "simrs-vx/pkg/lib-helper"
|
||||||
pl "simrs-vx/pkg/logger"
|
pl "simrs-vx/pkg/logger"
|
||||||
pu "simrs-vx/pkg/use-case-helper"
|
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.
|
tx = tx.
|
||||||
Model(&e.Specialist{}).
|
Model(&e.Specialist{}).
|
||||||
Scopes(gh.Filter(input.FilterDto)).
|
Scopes(gh.Filter(input.FilterDto)).
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package subspecialist
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
e "simrs-vx/internal/domain/main-entities/subspecialist"
|
e "simrs-vx/internal/domain/main-entities/subspecialist"
|
||||||
|
|
||||||
|
plh "simrs-vx/pkg/lib-helper"
|
||||||
pl "simrs-vx/pkg/logger"
|
pl "simrs-vx/pkg/logger"
|
||||||
pu "simrs-vx/pkg/use-case-helper"
|
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.
|
tx = tx.
|
||||||
Model(&e.Subspecialist{}).
|
Model(&e.Subspecialist{}).
|
||||||
Scopes(gh.Filter(input.FilterDto)).
|
Scopes(gh.Filter(input.FilterDto)).
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package unit
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
e "simrs-vx/internal/domain/main-entities/unit"
|
e "simrs-vx/internal/domain/main-entities/unit"
|
||||||
|
|
||||||
|
plh "simrs-vx/pkg/lib-helper"
|
||||||
pl "simrs-vx/pkg/logger"
|
pl "simrs-vx/pkg/logger"
|
||||||
pu "simrs-vx/pkg/use-case-helper"
|
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.
|
tx = tx.
|
||||||
Model(&e.Unit{}).
|
Model(&e.Unit{}).
|
||||||
Preload("Installation").
|
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