Time filter
This commit is contained in:
18
app/main.go
18
app/main.go
@ -8,6 +8,7 @@ import (
|
||||
"repo-pattern/app/models"
|
||||
"repo-pattern/app/repository"
|
||||
"repo-pattern/app/repository/smartfilter"
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
@ -21,17 +22,20 @@ func doMagic(db *gorm.DB) {
|
||||
var err error
|
||||
query := db
|
||||
|
||||
// id, _ := uuid.FromBytes([]byte("6dc096ab-5c03-427e-b808-c669f7446131"))
|
||||
// id := "6dc096ab-5c03-427e-b808-c669f7446131"
|
||||
// serialNumber := "222"
|
||||
// serialNumberContains := "323"
|
||||
issuer := "FINA"
|
||||
// issuer := "FINA"
|
||||
location, _ := time.LoadLocation("UTC")
|
||||
createdTime := time.Date(2024, 5, 26, 16, 8, 0, 0, location)
|
||||
|
||||
f := smartfilter.SmartCertFilter[models.Cert]{
|
||||
Alive: &FALSE,
|
||||
// Id: &id,
|
||||
// Alive: &FALSE,
|
||||
// Id: &id,
|
||||
// SerialNumber: &serialNumber,
|
||||
// SerialNumberContains: &serialNumberContains,
|
||||
IssuerContains: &issuer,
|
||||
// IssuerContains: &issuer,
|
||||
CreatedAt_Lt: &createdTime,
|
||||
}
|
||||
|
||||
query, err = f.ToQuery(query)
|
||||
@ -41,9 +45,9 @@ func doMagic(db *gorm.DB) {
|
||||
|
||||
var certs []models.Cert
|
||||
|
||||
query.Find(&certs)
|
||||
query.Order("created_at").Find(&certs)
|
||||
for n, cert := range certs {
|
||||
fmt.Printf(">> [%d] %+v\n", n, cert.Id)
|
||||
fmt.Printf(">> [%d] %+v %s\n", n, cert.Id, cert.CreatedAt)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user