This commit is contained in:
aozhiwei 2024-06-14 13:29:27 +08:00
parent 94e1427ac6
commit 596cd7c96f

View File

@ -3,6 +3,8 @@ package mt
import (
"f5"
"mtb"
"sync"
"strings"
)
type Item struct {
@ -11,4 +13,21 @@ type Item struct {
type ItemTable struct {
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
})
}