diff --git a/server/adminserver/api/v1/system/mail.go b/server/adminserver/api/v1/system/mail.go index 7b2c87e6..c9bd3add 100644 --- a/server/adminserver/api/v1/system/mail.go +++ b/server/adminserver/api/v1/system/mail.go @@ -318,6 +318,7 @@ func (this *MailApi) DelMail(c *gin.Context) { } func (this *MailApi) CheckAttachment(list []common.Attachment, c *gin.Context) bool { + return true if data, err := json.Marshal(list); err != nil || len(data) > 0xFF { c.JSON(http.StatusOK, gin.H{ "code": 2, diff --git a/server/marketserver/api/v1/recharge/recharge.go b/server/marketserver/api/v1/recharge/recharge.go index 3146be77..7f9881d9 100644 --- a/server/marketserver/api/v1/recharge/recharge.go +++ b/server/marketserver/api/v1/recharge/recharge.go @@ -30,7 +30,7 @@ func (ea *RechargeApi) RechargeList(c *gin.Context) { }{} currencysMeta := mt.Table.Currency.GetByNetId(netId) - if len(currencysMeta) <= 0 { + if currencysMeta == nil { f5.RspErr(c, 2, "server internal error") return } @@ -57,11 +57,14 @@ func (ea *RechargeApi) RechargeList(c *gin.Context) { Name string `json:"name"` Address string `json:"address"` }{} - for _, currency := range currencysMeta { - p := q5.NewSliceElement(¤cyList) - p.Name = currency.GetCurrencyName() - p.Address = currency.GetContract().GetAddress() - } + currencysMeta.Range( + func (key string, val *mt.Currency) bool { + currency := val + p := q5.NewSliceElement(¤cyList) + p.Name = currency.GetCurrencyName() + p.Address = currency.GetContract().GetAddress() + return true + }) tmpmap["currency_list"] = currencyList rspObj.Rows = append(rspObj.Rows, tmpmap) diff --git a/server/marketserver/mt/Currency.go b/server/marketserver/mt/Currency.go index 3bff6820..2ec2866d 100644 --- a/server/marketserver/mt/Currency.go +++ b/server/marketserver/mt/Currency.go @@ -16,7 +16,7 @@ type Currency struct { type CurrencyTable struct { f5.CustomMetaTable - netIdHash *q5.ConcurrentMap[int32, *Currency] + netIdHash *q5.ConcurrentMap[int32, *q5.ConcurrentMap[string, *Currency]] } func (this *Currency) init(currencyName string, exchangeRate int64, currencyDecimal int64) { @@ -60,11 +60,11 @@ func (this *Currency) check() { } } -func (this *CurrencyTable) GetByNetId(netId int32) []*Currency { +func (this *CurrencyTable) GetByNetId(netId int32) *q5.ConcurrentMap[string, *Currency] { if v, ok := this.netIdHash.Load(netId); ok { - return []*Currency{*v} + return *v } else { - return []*Currency{} + return nil } } @@ -73,7 +73,7 @@ func (this *CurrencyTable) GetByNetIdAddress(netId int32, currencyAddress string } func (this *CurrencyTable) Load() { - this.netIdHash = new(q5.ConcurrentMap[int32, *Currency]) + this.netIdHash = new(q5.ConcurrentMap[int32, *q5.ConcurrentMap[string, *Currency]]) nets := []int32{} { if jsonStr, err := f5.ReadJsonFile("../config/nets.json"); err == nil { @@ -101,7 +101,7 @@ func (this *CurrencyTable) Load() { p := new(Currency) p.init(currencyCfg.CurrencyName, currencyCfg.ExchangeRate, currencyCfg.CurrencyDecimal) p.check() - this.netIdHash.Store(netId, p) + //this.netIdHash.Store(netId, p) } } } @@ -109,20 +109,24 @@ func (this *CurrencyTable) Load() { func (this *CurrencyTable) PostInit1() { this.netIdHash.Range( - func (key int32, val *Currency) bool { + func (key int32, val *q5.ConcurrentMap[string, *Currency]) bool { netId := key - currencyMeta := val - Table.Recharge.Traverse(func(ele *Recharge) bool { - if int64(ele.GetPrice()) * currencyMeta.GetExchangeRate() != int64(ele.GetDiamond()) { - panic(fmt.Sprintf("Currency verifyerror net_id:%d id:%d", netId, ele.GetId())) - } - return true - }) - contractMeta := Table.Contract.GetByNetIdName(netId, currencyMeta.GetCurrencyName()) - if contractMeta == nil { - panic(fmt.Sprintf("currency contract not found")) - } - currencyMeta.contract = contractMeta + val.Range( + func (key2 string, val2 *Currency) bool { + currencyMeta := val2 + Table.Recharge.Traverse(func(ele *Recharge) bool { + if int64(ele.GetPrice()) * currencyMeta.GetExchangeRate() != int64(ele.GetDiamond()) { + panic(fmt.Sprintf("Currency verifyerror net_id:%d id:%d", netId, ele.GetId())) + } + return true + }) + contractMeta := Table.Contract.GetByNetIdName(netId, currencyMeta.GetCurrencyName()) + if contractMeta == nil { + panic(fmt.Sprintf("currency contract not found")) + } + currencyMeta.contract = contractMeta + return true + }); return true }) }