From 651f21adde0aeb409e24fa22aef46ca3c60b43c8 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 14 Jun 2024 13:45:49 +0800 Subject: [PATCH] 1 --- server/marketserver/api/v1/market/market.go | 11 ++++-- server/marketserver/mt/Contract.go | 22 ++++++++++++ server/marketserver/mt/export.go | 6 ++++ server/marketserver/mtb/mtb.auto_gen.go | 39 +++++++++++++++++++++ server/marketserver/proto/mt.proto | 7 ++++ 5 files changed, 83 insertions(+), 2 deletions(-) create mode 100644 server/marketserver/mt/Contract.go diff --git a/server/marketserver/api/v1/market/market.go b/server/marketserver/api/v1/market/market.go index e16d8d29..37c5cb5a 100644 --- a/server/marketserver/api/v1/market/market.go +++ b/server/marketserver/api/v1/market/market.go @@ -26,8 +26,8 @@ func (this *MarketApi) ProductList(c *gin.Context) { Filter struct { PriceMin interface{} `json:"price_min"` PriceMax interface{} `json:"price_max"` - ItemIds []int32 `json:"item_ids"` - HeroRanks []int32 `json:"hero_ranks"` + ItemIds []interface{} `json:"item_ids"` + HeroRanks []interface{} `json:"hero_ranks"` } `json:"filter"` Sort struct { Fields [] struct { @@ -101,6 +101,13 @@ SELECT * FROM t_order A WHERE idx > %d AND net_id = %d AND status="%s" } { itemIds := map[int32]int32{} + if reqJson.Search.Name != "" { + mt.Table.Item.Search(reqJson.Search.Name, itemIds) + } + for _, val := range(reqJson.Filter.ItemIds) { + itemId := q5.SafeToInt32(val) + itemIds[itemId] = 1 + } if len(itemIds) > 0 { inSub := `item_id IN (` i := 0 diff --git a/server/marketserver/mt/Contract.go b/server/marketserver/mt/Contract.go new file mode 100644 index 00000000..7c4537f3 --- /dev/null +++ b/server/marketserver/mt/Contract.go @@ -0,0 +1,22 @@ +package mt + +import ( + "f5" + "mtb" + "sync" +) + +type Contract struct { + mtb.Contract +} + +type ContractTable struct { + f5.NameMetaTable[Contract] + itemHash sync.Map //string => Contract +} + +func (this *Contract) Init1() { +} + +func (this *ContractTable) Search(name string, itemIds map[int32]int32) { +} diff --git a/server/marketserver/mt/export.go b/server/marketserver/mt/export.go index ef5d7bb0..4c360a3c 100644 --- a/server/marketserver/mt/export.go +++ b/server/marketserver/mt/export.go @@ -9,6 +9,7 @@ type table struct { NftDb *NftDbTable Config *ConfigTable Item *ItemTable + Contract *ContractTable } var Table = f5.New(func(this *table) { @@ -32,4 +33,9 @@ var Table = f5.New(func(this *table) { this.PrimKey = "" }) + this.Contract = f5.New(func(this *ContractTable) { + this.FileName = "../config/contract.json" + this.PrimKey = "name" + }) + }) diff --git a/server/marketserver/mtb/mtb.auto_gen.go b/server/marketserver/mtb/mtb.auto_gen.go index cc63d716..ad457d9c 100644 --- a/server/marketserver/mtb/mtb.auto_gen.go +++ b/server/marketserver/mtb/mtb.auto_gen.go @@ -39,6 +39,15 @@ type Item struct { _flags2_ uint64 } +type Contract struct { + name string + json string + address string + + _flags1_ uint64 + _flags2_ uint64 +} + func (this *MarketServerCluster) GetInstanceId() int32 { return this.instance_id } @@ -127,6 +136,30 @@ func (this *Item) HasItemId() bool { return (this._flags1_ & (uint64(1) << 2)) > 0 } +func (this *Contract) GetName() string { + return this.name +} + +func (this *Contract) HasName() bool { + return (this._flags1_ & (uint64(1) << 1)) > 0 +} + +func (this *Contract) GetJson() string { + return this.json +} + +func (this *Contract) HasJson() bool { + return (this._flags1_ & (uint64(1) << 3)) > 0 +} + +func (this *Contract) GetAddress() string { + return this.address +} + +func (this *Contract) HasAddress() bool { + return (this._flags1_ & (uint64(1) << 4)) > 0 +} + func (this *MarketServerCluster) LoadFromKv(kv map[string]interface{}) { f5.ReadMetaTableField(&this.instance_id, "instance_id", &this._flags1_, 1, kv) @@ -150,3 +183,9 @@ func (this *Item) LoadFromKv(kv map[string]interface{}) { f5.ReadMetaTableField(&this.name, "name", &this._flags1_, 1, kv) f5.ReadMetaTableField(&this.item_id, "item_id", &this._flags1_, 2, kv) } + +func (this *Contract) LoadFromKv(kv map[string]interface{}) { + f5.ReadMetaTableField(&this.name, "name", &this._flags1_, 1, kv) + f5.ReadMetaTableField(&this.json, "json", &this._flags1_, 3, kv) + f5.ReadMetaTableField(&this.address, "address", &this._flags1_, 4, kv) +} diff --git a/server/marketserver/proto/mt.proto b/server/marketserver/proto/mt.proto index 72e47998..d4c200b8 100644 --- a/server/marketserver/proto/mt.proto +++ b/server/marketserver/proto/mt.proto @@ -28,3 +28,10 @@ message Item optional string name = 1; optional int32 item_id = 2; } + +message Contract +{ + optional string name = 1; + optional string json = 3; + optional string address = 4; +}