23 lines
511 B
Go
23 lines
511 B
Go
package query
|
|
|
|
import (
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type AssignmentFilter struct {
|
|
ClientID string `form:"client_id"`
|
|
DocumentType string `form:"document_type"`
|
|
PerPage int `form:"per_page"`
|
|
Page int `form:"page"`
|
|
}
|
|
|
|
func ApplyAssignmentFilters(db *gorm.DB, filter AssignmentFilter) *gorm.DB {
|
|
if filter.ClientID != "" {
|
|
db = db.Where("client_id = ?", filter.ClientID)
|
|
}
|
|
if filter.DocumentType != "" {
|
|
db = db.Where("document_type ILIKE ?", "%"+filter.DocumentType+"%")
|
|
}
|
|
return db
|
|
}
|