Refactoring codes for more tg message types
This commit is contained in:
@@ -1,40 +1,15 @@
|
||||
package query
|
||||
|
||||
import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
type ISearchable interface {
|
||||
Test( string ) bool
|
||||
GetKey() *string
|
||||
HasWords() bool
|
||||
Test(string) bool
|
||||
GetKey() *string
|
||||
|
||||
HasGeoLocation() bool
|
||||
Lat() float64
|
||||
Lon() float64
|
||||
Dist(lat float64, lon float64) float64
|
||||
|
||||
// Clean() filtering
|
||||
Register(map[string]struct{}) bool
|
||||
}
|
||||
|
||||
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() }
|
||||
|
||||
Reference in New Issue
Block a user