1
This commit is contained in:
parent
94e1427ac6
commit
596cd7c96f
@ -3,6 +3,8 @@ package mt
|
|||||||
import (
|
import (
|
||||||
"f5"
|
"f5"
|
||||||
"mtb"
|
"mtb"
|
||||||
|
"sync"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Item struct {
|
type Item struct {
|
||||||
@ -11,4 +13,21 @@ type Item struct {
|
|||||||
|
|
||||||
type ItemTable struct {
|
type ItemTable struct {
|
||||||
f5.IdMetaTable[Item]
|
f5.IdMetaTable[Item]
|
||||||
|
itemHash sync.Map //string => item_id
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *Item) Init1() {
|
||||||
|
Table.Item.itemHash.Store(strings.ToLower(this.GetName()), this.GetItemId())
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *ItemTable) Search(name string, itemIds map[int32]int32) {
|
||||||
|
name = strings.ToLower(name)
|
||||||
|
this.itemHash.Range(
|
||||||
|
func (k, v interface{}) bool {
|
||||||
|
key := k.(string)
|
||||||
|
if strings.Contains(key, name) {
|
||||||
|
itemIds[v.(int32)] = 1
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user