filtering wip

This commit is contained in:
dpurbosakti
2025-09-01 14:58:55 +07:00
parent ba57298f23
commit f25d7c1b09
28 changed files with 147 additions and 10 deletions

No files matched your search

@@ -16,6 +16,12 @@ type CreateDto struct {
} }
type ReadListDto struct { type ReadListDto struct {
FilterDto
Includes string `json:"includes"`
Preloads []string `json:"-"`
}
type FilterDto struct {
Code string `json:"code"` Code string `json:"code"`
Name string `json:"name"` Name string `json:"name"`
Uom_Code string `json:"uom_code"` Uom_Code string `json:"uom_code"`
@@ -12,6 +12,12 @@ type CreateDto struct {
} }
type ReadListDto struct { type ReadListDto struct {
FilterDto
Includes string `json:"includes"`
Preloads []string `json:"-"`
}
type FilterDto struct {
Division_Id *uint16 `json:"division_id"` Division_Id *uint16 `json:"division_id"`
Code string `json:"code"` Code string `json:"code"`
Name string `json:"name"` Name string `json:"name"`
@@ -15,6 +15,12 @@ type CreateDto struct {
} }
type ReadListDto struct { type ReadListDto struct {
FilterDto
Includes string `json:"includes"`
Preloads []string `json:"-"`
}
type FilterDto struct {
Doctor_Id *uint `json:"doctor_id"` Doctor_Id *uint `json:"doctor_id"`
FeeType_Code *ero.DoctorFeeTypeCode `json:"feeType_code"` FeeType_Code *ero.DoctorFeeTypeCode `json:"feeType_code"`
Price *float64 `json:"price"` Price *float64 `json:"price"`
@@ -14,6 +14,12 @@ type CreateDto struct {
} }
type ReadListDto struct { type ReadListDto struct {
FilterDto
Includes string `json:"includes"`
Preloads []string `json:"-"`
}
type FilterDto struct {
Employee_Id *uint `json:"employee_id"` Employee_Id *uint `json:"employee_id"`
IHS_Number *string `json:"ihs_number"` IHS_Number *string `json:"ihs_number"`
SIP_Number *string `json:"sip_number"` SIP_Number *string `json:"sip_number"`
@@ -64,7 +64,9 @@ type MetaDto struct {
type ResponseDto struct { type ResponseDto struct {
ecore.Main ecore.Main
User_Id *uint `json:"user_id"` User_Id *uint `json:"user_id"`
User *eu.User `json:"user,omitempty"`
Person_Id *uint `json:"person_id"` Person_Id *uint `json:"person_id"`
Person *ep.Person `json:"person,omitempty"`
Position_Code ero.EmployeePosisitionCode `json:"position_code"` Position_Code ero.EmployeePosisitionCode `json:"position_code"`
Division_Code *string `json:"division_code"` Division_Code *string `json:"division_code"`
Division *ed.Division `json:"division,omitempty"` Division *ed.Division `json:"division,omitempty"`
@@ -75,6 +77,7 @@ type ResponseDto struct {
func (d Employee) ToResponse() ResponseDto { func (d Employee) ToResponse() ResponseDto {
resp := ResponseDto{ resp := ResponseDto{
User_Id: d.User_Id, User_Id: d.User_Id,
User: d.User,
Person_Id: d.Person_Id, Person_Id: d.Person_Id,
Position_Code: d.Position_Code, Position_Code: d.Position_Code,
Division_Code: d.Division_Code, Division_Code: d.Division_Code,
@@ -16,6 +16,12 @@ type CreateDto struct {
} }
type ReadListDto struct { type ReadListDto struct {
FilterDto
Includes string `json:"includes"`
Preloads []string `json:"-"`
}
type FilterDto struct {
Code string `json:"code"` Code string `json:"code"`
Name string `json:"name"` Name string `json:"name"`
InfraGroup_Code ero.InfraGroupCode `json:"infraGroup_code"` InfraGroup_Code ero.InfraGroupCode `json:"infraGroup_code"`
@@ -14,6 +14,12 @@ type CreateDto struct {
} }
type ReadListDto struct { type ReadListDto struct {
FilterDto
Includes string `json:"includes"`
Preloads []string `json:"-"`
}
type FilterDto struct {
Code string `json:"code"` Code string `json:"code"`
Name string `json:"name"` Name string `json:"name"`
Regency_Code *string `json:"regency_code"` Regency_Code *string `json:"regency_code"`
@@ -13,6 +13,12 @@ type CreateDto struct {
} }
type ReadListDto struct { type ReadListDto struct {
FilterDto
Includes string `json:"includes"`
Preloads []string `json:"-"`
}
type FilterDto struct {
Item_Id *uint `json:"item_id"` Item_Id *uint `json:"item_id"`
Price float64 `json:"price"` Price float64 `json:"price"`
InsuranceCompany_Code *string `json:"insuranceCompany_code"` InsuranceCompany_Code *string `json:"insuranceCompany_code"`
@@ -21,7 +27,6 @@ type ReadListDto struct {
PageSize int `json:"page_size"` PageSize int `json:"page_size"`
NoPagination int `json:"no_pagination"` NoPagination int `json:"no_pagination"`
} }
type ReadDetailDto struct { type ReadDetailDto struct {
Id uint16 `json:"id"` Id uint16 `json:"id"`
Item_Id *uint `json:"item_id"` Item_Id *uint `json:"item_id"`
@@ -16,6 +16,12 @@ type CreateDto struct {
} }
type ReadListDto struct { type ReadListDto struct {
FilterDto
Includes string `json:"includes"`
Preloads []string `json:"-"`
}
type FilterDto struct {
Code string `json:"code"` Code string `json:"code"`
Name string `json:"name"` Name string `json:"name"`
ItemGroup_Code ero.ItemGroupCode `json:"itemGroup_code"` ItemGroup_Code ero.ItemGroupCode `json:"itemGroup_code"`
@@ -17,6 +17,12 @@ type CreateDto struct {
} }
type ReadListDto struct { type ReadListDto struct {
FilterDto
Includes string `json:"includes"`
Preloads []string `json:"-"`
}
type FilterDto struct {
Code string `json:"code"` Code string `json:"code"`
Name string `json:"name"` Name string `json:"name"`
Uom_Code string `json:"uom_code"` Uom_Code string `json:"uom_code"`
@@ -90,6 +90,9 @@ func ReadList(input e.ReadListDto) (*d.Data, error) {
return err return err
} }
if len(input.Includes) > 0 {
input.Preloads = pu.GetPreloads(input.Includes)
}
if dataList, metaList, err = ReadListData(input, &event, tx); err != nil { if dataList, metaList, err = ReadListData(input, &event, tx); err != nil {
return err return err
} }
@@ -51,9 +51,15 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.De
tx = dg.I tx = dg.I
} }
if len(input.Preloads) > 0 {
for _, preload := range input.Preloads {
tx = tx.Preload(preload)
}
}
tx = tx. tx = tx.
Model(&e.Device{}). Model(&e.Device{}).
Scopes(gh.Filter(input)). Scopes(gh.Filter(input.FilterDto)).
Count(&count). Count(&count).
Scopes(gh.Paginate(input, &pagination)). Scopes(gh.Paginate(input, &pagination)).
Order("\"CreatedAt\" DESC") Order("\"CreatedAt\" DESC")
@@ -87,6 +87,9 @@ func ReadList(input e.ReadListDto) (*d.Data, error) {
return err return err
} }
if len(input.Includes) > 0 {
input.Preloads = pu.GetPreloads(input.Includes)
}
if dataList, metaList, err = ReadListData(input, &event, tx); err != nil { if dataList, metaList, err = ReadListData(input, &event, tx); err != nil {
return err return err
} }
@@ -51,10 +51,16 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.Di
tx = dg.I tx = dg.I
} }
if len(input.Preloads) > 0 {
for _, preload := range input.Preloads {
tx = tx.Preload(preload)
}
}
tx = tx. tx = tx.
Model(&e.DivisionPosition{}). Model(&e.DivisionPosition{}).
Preload("Division"). Preload("Division").
Scopes(gh.Filter(input)). Scopes(gh.Filter(input.FilterDto)).
Count(&count). Count(&count).
Scopes(gh.Paginate(input, &pagination)). Scopes(gh.Paginate(input, &pagination)).
Order("\"CreatedAt\" DESC") Order("\"CreatedAt\" DESC")
@@ -87,6 +87,9 @@ func ReadList(input e.ReadListDto) (*d.Data, error) {
return err return err
} }
if len(input.Includes) > 0 {
input.Preloads = pu.GetPreloads(input.Includes)
}
if dataList, metaList, err = ReadListData(input, &event, tx); err != nil { if dataList, metaList, err = ReadListData(input, &event, tx); err != nil {
return err return err
} }
@@ -51,9 +51,15 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.Do
tx = dg.I tx = dg.I
} }
if len(input.Preloads) > 0 {
for _, preload := range input.Preloads {
tx = tx.Preload(preload)
}
}
tx = tx. tx = tx.
Model(&e.DoctorFee{}). Model(&e.DoctorFee{}).
Scopes(gh.Filter(input)). Scopes(gh.Filter(input.FilterDto)).
Count(&count). Count(&count).
Scopes(gh.Paginate(input, &pagination)). Scopes(gh.Paginate(input, &pagination)).
Order("\"CreatedAt\" DESC") Order("\"CreatedAt\" DESC")
@@ -87,6 +87,9 @@ func ReadList(input e.ReadListDto) (*d.Data, error) {
return err return err
} }
if len(input.Includes) > 0 {
input.Preloads = pu.GetPreloads(input.Includes)
}
if dataList, metaList, err = ReadListData(input, &event, tx); err != nil { if dataList, metaList, err = ReadListData(input, &event, tx); err != nil {
return err return err
} }
@@ -51,9 +51,15 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.Do
tx = dg.I tx = dg.I
} }
if len(input.Preloads) > 0 {
for _, preload := range input.Preloads {
tx = tx.Preload(preload)
}
}
tx = tx. tx = tx.
Model(&e.Doctor{}). Model(&e.Doctor{}).
Scopes(gh.Filter(input)). Scopes(gh.Filter(input.FilterDto)).
Count(&count). Count(&count).
Scopes(gh.Paginate(input, &pagination)). Scopes(gh.Paginate(input, &pagination)).
Order("\"CreatedAt\" DESC") Order("\"CreatedAt\" DESC")
@@ -105,6 +105,9 @@ func ReadList(input e.ReadListDto) (*d.Data, error) {
return err return err
} }
if len(input.Includes) > 0 {
input.Preloads = pu.GetPreloads(input.Includes)
}
if dataList, metaList, err = ReadListData(input, &event, tx); err != nil { if dataList, metaList, err = ReadListData(input, &event, tx); err != nil {
return err return err
} }
+7 -1
View File
@@ -51,9 +51,15 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.In
tx = dg.I tx = dg.I
} }
if len(input.Preloads) > 0 {
for _, preload := range input.Preloads {
tx = tx.Preload(preload)
}
}
tx = tx. tx = tx.
Model(&e.Infra{}). Model(&e.Infra{}).
Scopes(gh.Filter(input)). Scopes(gh.Filter(input.FilterDto)).
Count(&count). Count(&count).
Scopes(gh.Paginate(input, &pagination)). Scopes(gh.Paginate(input, &pagination)).
Order("\"CreatedAt\" DESC") Order("\"CreatedAt\" DESC")
@@ -87,6 +87,9 @@ func ReadList(input e.ReadListDto) (*d.Data, error) {
return err return err
} }
if len(input.Includes) > 0 {
input.Preloads = pu.GetPreloads(input.Includes)
}
if dataList, metaList, err = ReadListData(input, &event, tx); err != nil { if dataList, metaList, err = ReadListData(input, &event, tx); err != nil {
return err return err
} }
@@ -51,9 +51,15 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.In
tx = dg.I tx = dg.I
} }
if len(input.Preloads) > 0 {
for _, preload := range input.Preloads {
tx = tx.Preload(preload)
}
}
tx = tx. tx = tx.
Model(&e.InsuranceCompany{}). Model(&e.InsuranceCompany{}).
Scopes(gh.Filter(input)). Scopes(gh.Filter(input.FilterDto)).
Count(&count). Count(&count).
Scopes(gh.Paginate(input, &pagination)). Scopes(gh.Paginate(input, &pagination)).
Order("\"CreatedAt\" DESC") Order("\"CreatedAt\" DESC")
@@ -87,6 +87,9 @@ func ReadList(input e.ReadListDto) (*d.Data, error) {
return err return err
} }
if len(input.Includes) > 0 {
input.Preloads = pu.GetPreloads(input.Includes)
}
if dataList, metaList, err = ReadListData(input, &event, tx); err != nil { if dataList, metaList, err = ReadListData(input, &event, tx); err != nil {
return err return err
} }
@@ -51,9 +51,15 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.It
tx = dg.I tx = dg.I
} }
if len(input.Preloads) > 0 {
for _, preload := range input.Preloads {
tx = tx.Preload(preload)
}
}
tx = tx. tx = tx.
Model(&e.ItemPrice{}). Model(&e.ItemPrice{}).
Scopes(gh.Filter(input)). Scopes(gh.Filter(input.FilterDto)).
Count(&count). Count(&count).
Scopes(gh.Paginate(input, &pagination)). Scopes(gh.Paginate(input, &pagination)).
Order("\"CreatedAt\" DESC") Order("\"CreatedAt\" DESC")
@@ -87,6 +87,9 @@ func ReadList(input e.ReadListDto) (*d.Data, error) {
return err return err
} }
if len(input.Includes) > 0 {
input.Preloads = pu.GetPreloads(input.Includes)
}
if dataList, metaList, err = ReadListData(input, &event, tx); err != nil { if dataList, metaList, err = ReadListData(input, &event, tx); err != nil {
return err return err
} }
+7 -1
View File
@@ -51,9 +51,15 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.It
tx = dg.I tx = dg.I
} }
if len(input.Preloads) > 0 {
for _, preload := range input.Preloads {
tx = tx.Preload(preload)
}
}
tx = tx. tx = tx.
Model(&e.Item{}). Model(&e.Item{}).
Scopes(gh.Filter(input)). Scopes(gh.Filter(input.FilterDto)).
Count(&count). Count(&count).
Scopes(gh.Paginate(input, &pagination)). Scopes(gh.Paginate(input, &pagination)).
Order("\"CreatedAt\" DESC") Order("\"CreatedAt\" DESC")
@@ -90,6 +90,9 @@ func ReadList(input e.ReadListDto) (*d.Data, error) {
return err return err
} }
if len(input.Includes) > 0 {
input.Preloads = pu.GetPreloads(input.Includes)
}
if dataList, metaList, err = ReadListData(input, &event, tx); err != nil { if dataList, metaList, err = ReadListData(input, &event, tx); err != nil {
return err return err
} }
@@ -51,9 +51,15 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.Ma
tx = dg.I tx = dg.I
} }
if len(input.Preloads) > 0 {
for _, preload := range input.Preloads {
tx = tx.Preload(preload)
}
}
tx = tx. tx = tx.
Model(&e.Material{}). Model(&e.Material{}).
Scopes(gh.Filter(input)). Scopes(gh.Filter(input.FilterDto)).
Count(&count). Count(&count).
Scopes(gh.Paginate(input, &pagination)). Scopes(gh.Paginate(input, &pagination)).
Order("\"CreatedAt\" DESC") Order("\"CreatedAt\" DESC")