调整英雄查询
This commit is contained in:
parent
b7bb22140f
commit
cad0eae2ad
1
bin/adminserver/config/nets
Symbolic link
1
bin/adminserver/config/nets
Symbolic link
@ -0,0 +1 @@
|
||||
../../backtask/config/nets/
|
1
bin/adminserver/config/nets.json
Symbolic link
1
bin/adminserver/config/nets.json
Symbolic link
@ -0,0 +1 @@
|
||||
../../backtask/config/nets.json
|
@ -3,8 +3,10 @@ package system
|
||||
import (
|
||||
"f5"
|
||||
"fmt"
|
||||
"jccommon"
|
||||
"main/constant"
|
||||
"main/model/system"
|
||||
"main/mt"
|
||||
"net/http"
|
||||
"q5"
|
||||
"strings"
|
||||
@ -161,7 +163,7 @@ func (pai *PlayerApi) HeroesQuery(c *gin.Context) {
|
||||
}
|
||||
|
||||
reqJson := HeroesQueryForm{}
|
||||
if !checkparam(&reqJson, c) {
|
||||
if !checkparam(&reqJson, c) || reqJson.Account_id == "" {
|
||||
return
|
||||
}
|
||||
|
||||
@ -174,8 +176,72 @@ func (pai *PlayerApi) HeroesQuery(c *gin.Context) {
|
||||
}
|
||||
|
||||
cursor := q5.ToInt64(c.DefaultQuery("cursor", ""))
|
||||
filterstr := " account_id = '" + reqJson.Account_id + "' "
|
||||
sql := fmt.Sprintf(`SELECT * FROM t_hero WHERE idx > %d AND %s `, cursor, filterstr)
|
||||
filterstr := "account_id = '" + reqJson.Account_id + "' "
|
||||
{
|
||||
sql := fmt.Sprintf(`SELECT address FROM t_immutable_account WHERE idx > 1 AND account_id = '%s'`, reqJson.Account_id)
|
||||
|
||||
address := ""
|
||||
f5.GetGoStyleDb().RawQuery(
|
||||
constant.ACCOUNT_DB,
|
||||
sql,
|
||||
[]string{},
|
||||
func(err error, ds *f5.DataSet) {
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if ds.Next() {
|
||||
address = ds.GetByIndex(0)
|
||||
}
|
||||
})
|
||||
|
||||
if address != "" {
|
||||
lockaddrlist := []string{}
|
||||
mt.Table.Contract.Traverse(func(mtc *mt.Contract) bool {
|
||||
if mtc.GetName() == jccommon.CONTRACT_NAME_NFTLock {
|
||||
lockaddrlist = append(lockaddrlist, strings.ToLower(mtc.GetAddress()))
|
||||
}
|
||||
return true
|
||||
})
|
||||
sql = fmt.Sprintf(`SELECT token_id FROM t_nft WHERE idx > 1 AND token_type IN (1, 12) AND (owner_address = '%s'`, address)
|
||||
if len(lockaddrlist) > 0 {
|
||||
sql += fmt.Sprintf(" OR (last_lock_address = '%s' AND owner_address IN (", address)
|
||||
for _, addr := range lockaddrlist {
|
||||
sql += "'" + addr + "',"
|
||||
}
|
||||
sql = sql[:len(sql)-1]
|
||||
sql+="))"
|
||||
}
|
||||
sql += ")"
|
||||
f5.GetSysLog().Debug("tokenid sql:%s", sql)
|
||||
tokenidlist := []string{}
|
||||
f5.GetGoStyleDb().RawQuery(
|
||||
constant.BCNFT_DB,
|
||||
sql,
|
||||
[]string{},
|
||||
func(err error, ds *f5.DataSet) {
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
for ds.Next() {
|
||||
tokenidlist = append(tokenidlist, ds.GetByIndex(0))
|
||||
}
|
||||
})
|
||||
if len(tokenidlist) > 0 {
|
||||
tokenfilterstr := "OR token_id IN ("
|
||||
for _, v := range tokenidlist {
|
||||
tokenfilterstr += v + ","
|
||||
}
|
||||
tokenfilterstr = tokenfilterstr[:len(tokenfilterstr)-1]
|
||||
tokenfilterstr += ")"
|
||||
|
||||
filterstr += tokenfilterstr
|
||||
}
|
||||
}
|
||||
}
|
||||
sql := fmt.Sprintf(`SELECT * FROM t_hero WHERE idx > %d AND (%s)`, cursor, filterstr)
|
||||
f5.GetSysLog().Debug("hero sql:%s", sql)
|
||||
|
||||
query(constant.GAME_DB, cursor, sql, c, func(ds *f5.DataSet) interface{} {
|
||||
p := new(system.Hero)
|
||||
@ -300,11 +366,11 @@ func (pai *PlayerApi) RechargeQuery(c *gin.Context) {
|
||||
}
|
||||
|
||||
cursor := q5.ToInt64(c.DefaultQuery("cursor", ""))
|
||||
filterstr :=
|
||||
" (receiver_account_id = '" + reqJson.Identity +
|
||||
"' OR account_address = '" + reqJson.Identity +
|
||||
"' OR passport_address = '" + reqJson.Identity +
|
||||
"' OR lower_case_email = '" + reqJson.Identity + "')"
|
||||
filterstr :=
|
||||
" (receiver_account_id = '" + reqJson.Identity +
|
||||
"' OR account_address = '" + reqJson.Identity +
|
||||
"' OR passport_address = '" + reqJson.Identity +
|
||||
"' OR lower_case_email = '" + reqJson.Identity + "')"
|
||||
sql := fmt.Sprintf(`SELECT * FROM t_recharge_order WHERE idx > %d AND %s `, cursor, filterstr)
|
||||
|
||||
query(constant.BCNFT_DB, cursor, sql, c, func(ds *f5.DataSet) interface{} {
|
||||
|
112
server/adminserver/mt/Contract.go
Normal file
112
server/adminserver/mt/Contract.go
Normal file
@ -0,0 +1,112 @@
|
||||
package mt
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"f5"
|
||||
"fmt"
|
||||
"q5"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Contract struct {
|
||||
name string
|
||||
address string
|
||||
}
|
||||
|
||||
type ContractTable struct {
|
||||
netIdNameHash *q5.ConcurrentMap[string, *Contract]
|
||||
netIdAddressHash *q5.ConcurrentMap[string, *Contract]
|
||||
}
|
||||
|
||||
func (this *Contract) GetName() string {
|
||||
return this.name
|
||||
}
|
||||
|
||||
func (this *Contract) GetAddress() string {
|
||||
return this.address
|
||||
}
|
||||
|
||||
func (this *ContractTable) IsNoLoad() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (this *ContractTable) Load() {
|
||||
this.netIdNameHash = new(q5.ConcurrentMap[string, *Contract])
|
||||
this.netIdAddressHash = new(q5.ConcurrentMap[string, *Contract])
|
||||
nets := []interface{}{}
|
||||
{
|
||||
if jsonStr, err := f5.ReadJsonFile("../config/nets.json"); err == nil {
|
||||
if err := json.Unmarshal([]byte(jsonStr), &nets); err != nil {
|
||||
panic(fmt.Sprintf("load metafile json decode error %s %s", "nets.json", err))
|
||||
}
|
||||
} else {
|
||||
panic(fmt.Sprintf("load metafile error %s %s", "nets.json", err))
|
||||
}
|
||||
}
|
||||
{
|
||||
for _, val := range nets {
|
||||
netId := q5.SafeToInt32(val)
|
||||
fileName := fmt.Sprintf("../config/nets/%d/contract.json", netId)
|
||||
if jsonStr, err := f5.ReadJsonFile(fileName); err == nil {
|
||||
contracts := []struct {
|
||||
Name string `json:"name"`
|
||||
Address string `json:"address"`
|
||||
}{}
|
||||
if err := json.Unmarshal([]byte(jsonStr), &contracts); err != nil {
|
||||
panic(fmt.Sprintf("load metafile json decode error %s %s", "contract.json", err))
|
||||
}
|
||||
for _, val2 := range contracts {
|
||||
p := new(Contract)
|
||||
p.name = q5.SafeToString(val2.Name)
|
||||
p.address = strings.ToLower(q5.SafeToString(val2.Address))
|
||||
{
|
||||
key := fmt.Sprintf("%d_%s", netId, p.name)
|
||||
this.netIdNameHash.Store(key, p)
|
||||
}
|
||||
{
|
||||
key := fmt.Sprintf("%d_%s", netId, p.address)
|
||||
this.netIdAddressHash.Store(key, p)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
panic(fmt.Sprintf("load metafile error %s %s", "contract.json", err))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (this *ContractTable) PreInit1() {
|
||||
|
||||
}
|
||||
|
||||
func (this *ContractTable) ElementsInit(int) {
|
||||
|
||||
}
|
||||
|
||||
func (this *ContractTable) PostInit1() {
|
||||
|
||||
}
|
||||
|
||||
func (this *ContractTable) GetByNetIdName(netId int32, name string) *Contract {
|
||||
key := fmt.Sprintf("%d_%s", netId, name)
|
||||
if v, ok := this.netIdNameHash.Load(key); ok {
|
||||
return *v
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func (this *ContractTable) GetByNetIdAddress(netId int32, address string) *Contract {
|
||||
key := fmt.Sprintf("%d_%s", netId, address)
|
||||
if v, ok := this.netIdAddressHash.Load(key); ok {
|
||||
return *v
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func (this *ContractTable) Traverse(cb func(*Contract) bool) {
|
||||
this.netIdNameHash.Range(func(k string, v *Contract) bool {
|
||||
return cb(v)
|
||||
})
|
||||
}
|
@ -17,6 +17,7 @@ type table struct {
|
||||
Permission *PermissionTable
|
||||
ConfDb *ConfDbTable
|
||||
Item *ItemTable
|
||||
Contract *ContractTable
|
||||
}
|
||||
|
||||
var Table = f5.New(func(this *table) {
|
||||
@ -71,6 +72,8 @@ var Table = f5.New(func(this *table) {
|
||||
|
||||
this.Permission = new(PermissionTable)
|
||||
|
||||
this.Contract = new(ContractTable)
|
||||
|
||||
this.Item = f5.New(func(this *ItemTable) {
|
||||
this.FileName = "../res/item@item.json"
|
||||
this.PrimKey = "id"
|
||||
|
Loading…
x
Reference in New Issue
Block a user