Added kmb and refactored query.Parse

This commit is contained in:
2022-09-17 04:33:47 +08:00
parent 292665c49b
commit 3376d9eb96
21 changed files with 762 additions and 241 deletions

40
query/Searchable.go Normal file
View File

@@ -0,0 +1,40 @@
package query
import (
"strings"
)
type ISearchable interface {
Test( string ) bool
GetKey() *string
}
type Searchable struct {
Key *string
SearchData *[] *string
}
func ( this *Searchable ) Test( val string ) bool {
data := this.SearchData
if data == nil {
return false
}
for _, v := range *data {
if strings.Contains( *v, val ) {
return true
}
}
return false
}
func ( this *Searchable ) GetKey() *string {
return this.Key
}
type ByKey [] ISearchable
func (a ByKey) Len() int { return len(a) }
func (a ByKey) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a ByKey) Less(i, j int) bool { return *a[i].GetKey() < *a[j].GetKey() }