订单查询,出售信息查询,NFT查询
This commit is contained in:
parent
177a6d35c9
commit
92100acf97
@ -204,3 +204,82 @@ exports.Hero = class {
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
exports.Order = class {
|
||||
constructor()
|
||||
{
|
||||
this.fields = [
|
||||
['idx', 0, ''],
|
||||
['order_id', '', '订单id'],
|
||||
['chain', '', 'chain'],
|
||||
['status', '', 'status'],
|
||||
['net_id', 0, 'net_id'],
|
||||
['token_id', '', 'token_id'],
|
||||
['contract_address', '', 'contract_address'],
|
||||
['item_id', 0, 'item_id'],
|
||||
['hero_quality', 0, 'hero_quality'],
|
||||
['price', '', 'price'],
|
||||
['start_time', 0, 'start_time'],
|
||||
['end_time', 0, 'end_time'],
|
||||
['created_at', 0, 'created_at'],
|
||||
['updated_at', 0, 'updated_at'],
|
||||
['event_id', '', '事件id'],
|
||||
['event_data', '', '事件内容'],
|
||||
['createtime', 0, '创建时间'],
|
||||
['modifytime', 0, '修改时间'],
|
||||
['src_price_exchange_rate', 0, 'src_price_exchange_rate'],
|
||||
['src_price_amount', '', 'src_price_amount'],
|
||||
['src_price_item_type', '', 'src_price_item_type'],
|
||||
['src_price_contract_address', '', 'src_price_contract_address'],
|
||||
['price_len', 0, 'price_len'],
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
exports.Sale = class {
|
||||
constructor()
|
||||
{
|
||||
this.fields = [
|
||||
['idx', 0, ''],
|
||||
['order_id', '', '订单id'],
|
||||
['chain', '', 'chain'],
|
||||
['net_id', 0, 'net_id'],
|
||||
['token_id', '', 'token_id'],
|
||||
['contract_address', '', 'contract_address'],
|
||||
['buyer', '', 'buyer'],
|
||||
['seller', '', 'seller'],
|
||||
['item_id', 0, 'item_id'],
|
||||
['hero_quality', 0, 'hero_quality'],
|
||||
['price', '', 'price'],
|
||||
['indexed_at', 0, 'indexed_at'],
|
||||
['event_id', '', '事件id'],
|
||||
['event_data', '', '事件内容'],
|
||||
['createtime', 0, '创建时间'],
|
||||
['modifytime', 0, '修改时间'],
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
exports.NFT = class {
|
||||
constructor()
|
||||
{
|
||||
this.fields = [
|
||||
['idx', 0, ''],
|
||||
['owner_address', '', 'owner_address'],
|
||||
['creator_address', '', 'creator_address'],
|
||||
['token_id', '', 'token_id'],
|
||||
['token_type', 0, 'nft类型 1:英雄 2:枪支 3:芯片 6:荣誉 7:徽章'],
|
||||
['token_state', 0, '0:正常状态 1:出售中 2:出租中'],
|
||||
['item_id', 0, '道具id'],
|
||||
['deleted', 0, 'deleted'],
|
||||
['confirm_count', 0, 'confirm_count'],
|
||||
['confirm_block_number', 0, 'confirm_block_number'],
|
||||
['tags', '', 'tags'],
|
||||
['net_id', 0, 'net_id'],
|
||||
['contract_address', '', 'contract_address'],
|
||||
['createtime', 0, '创建时间'],
|
||||
['modifytime', 0, '修改时间'],
|
||||
['last_owner_address', '', 'last_owner_address'],
|
||||
]
|
||||
}
|
||||
}
|
||||
|
76
doc/admin/nft.js
Normal file
76
doc/admin/nft.js
Normal file
@ -0,0 +1,76 @@
|
||||
const common = require('../common');
|
||||
|
||||
module.exports = class {
|
||||
|
||||
constructor() {
|
||||
this.apis = [
|
||||
{
|
||||
'method': 'POST',
|
||||
'name': 'orderquery',
|
||||
'desc': '获取订单信息',
|
||||
'group': 'nft',
|
||||
'url': 'api/v1/nft/orderquery',
|
||||
'header': [
|
||||
],
|
||||
'is_json_params': true,
|
||||
'params': [
|
||||
['name', '', '用户名字'],
|
||||
['account_id', '', '账号id'],
|
||||
['address', '', '钱包地址'],
|
||||
],
|
||||
'uri_params': [
|
||||
['cursor', '', '游标'],
|
||||
['page_size', '', '每页数量'],
|
||||
],
|
||||
'response': [
|
||||
new common.RspHead(),
|
||||
['!data', common.Player()]
|
||||
]
|
||||
},
|
||||
{
|
||||
'method': 'POST',
|
||||
'name': 'bagquery',
|
||||
'desc': '获取玩家背包信息',
|
||||
'group': 'nft',
|
||||
'url': 'api/v1/nft/bagquery',
|
||||
'header': [
|
||||
],
|
||||
'is_json_params': true,
|
||||
'params': [
|
||||
['account_id', '', '账号id'],
|
||||
],
|
||||
'uri_params': [
|
||||
['cursor', '', '游标'],
|
||||
['page_size', '', '每页数量'],
|
||||
],
|
||||
'response': [
|
||||
new common.RspHead(),
|
||||
['!data', common.BagItem()]
|
||||
]
|
||||
},
|
||||
{
|
||||
'method': 'POST',
|
||||
'name': 'heroesquery',
|
||||
'desc': '获取玩家英雄信息',
|
||||
'group': 'nft',
|
||||
'url': 'api/v1/nft/heroesquery',
|
||||
'header': [
|
||||
],
|
||||
'is_json_params': true,
|
||||
'params': [
|
||||
['account_id', '', '账号id'],
|
||||
],
|
||||
'uri_params': [
|
||||
['cursor', '', '游标'],
|
||||
['page_size', '', '每页数量'],
|
||||
],
|
||||
'response': [
|
||||
new common.RspHead(),
|
||||
['!data', common.he()]
|
||||
]
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
// ...
|
||||
}
|
57
server/adminserver/api/v1/system/common.go
Normal file
57
server/adminserver/api/v1/system/common.go
Normal file
@ -0,0 +1,57 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"f5"
|
||||
"main/common"
|
||||
"net/http"
|
||||
"q5"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func checkparam(obj any, c *gin.Context) bool {
|
||||
if err := c.ShouldBindJSON(obj); err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"code": 1,
|
||||
"message": err.Error(),
|
||||
})
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func query(dbname string, cursor int64, sql string, c *gin.Context, loadcall func(ds *f5.DataSet) interface{}) {
|
||||
rspObj := struct {
|
||||
ErrCode int32 `json:"errcode"`
|
||||
ErrMsg string `json:"errmsg"`
|
||||
Page common.StreamPagination `json:"page"`
|
||||
Rows []interface{} `json:"rows"`
|
||||
}{
|
||||
Rows: []interface{}{},
|
||||
}
|
||||
|
||||
pageSize := q5.AdjustRangeValue(q5.ToInt32(c.DefaultQuery("page_size", "")), 1, 20)
|
||||
|
||||
params := []string{}
|
||||
subFilters := []f5.DbQueryFilter{}
|
||||
|
||||
orderBy := ""
|
||||
|
||||
f5.GetGoStyleDb().StreamPageQuery(
|
||||
dbname,
|
||||
pageSize,
|
||||
cursor,
|
||||
sql,
|
||||
params,
|
||||
f5.GetDbFilter().Comp(subFilters...),
|
||||
orderBy,
|
||||
func(err error, pagination *f5.StreamPagination) {
|
||||
rspObj.Page.FillPage(pagination)
|
||||
},
|
||||
func(ds *f5.DataSet) {
|
||||
rspObj.Rows = append(rspObj.Rows, loadcall(ds))
|
||||
})
|
||||
|
||||
c.JSON(200, rspObj)
|
||||
}
|
@ -9,4 +9,5 @@ type ApiGroup struct {
|
||||
GroupMemberApi
|
||||
BattleServerApi
|
||||
PlayerApi
|
||||
NFTApi
|
||||
}
|
||||
|
127
server/adminserver/api/v1/system/nft.go
Normal file
127
server/adminserver/api/v1/system/nft.go
Normal file
@ -0,0 +1,127 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"f5"
|
||||
"fmt"
|
||||
|
||||
"main/constant"
|
||||
"main/model/system"
|
||||
"net/http"
|
||||
"q5"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type NFTApi struct {
|
||||
}
|
||||
|
||||
func (this *NFTApi) OrderQuery(c *gin.Context) {
|
||||
type OrderQueryForm struct {
|
||||
Order_id string `json:"order_id"`
|
||||
Contract_address string `json:"contract_address"`
|
||||
Token_id string `json:"token_id"`
|
||||
}
|
||||
|
||||
reqJson := OrderQueryForm{}
|
||||
if !checkparam(&reqJson, c) {
|
||||
return
|
||||
}
|
||||
|
||||
cursor := q5.ToInt64(c.DefaultQuery("cursor", ""))
|
||||
|
||||
filterstr := ""
|
||||
if reqJson.Order_id != "" {
|
||||
filterstr = " order_id = '" + reqJson.Order_id + "' "
|
||||
} else if reqJson.Contract_address != "" {
|
||||
filterstr = " contract_address = '" + reqJson.Contract_address + "'"
|
||||
} else if reqJson.Token_id != "" {
|
||||
filterstr = " token_id = '" + reqJson.Token_id + "'"
|
||||
} else {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"code": 1,
|
||||
"message": "input one of order_id, contract_address, token_id",
|
||||
})
|
||||
return
|
||||
}
|
||||
sql := fmt.Sprintf(`SELECT * FROM t_order WHERE idx > %d AND %s `, cursor, filterstr)
|
||||
|
||||
query(constant.BCNFT_DB, cursor, sql, c, func(ds *f5.DataSet) interface{} {
|
||||
var p system.Order
|
||||
p.LoadFromDs(ds)
|
||||
return p
|
||||
})
|
||||
}
|
||||
|
||||
func (this *NFTApi) SaleQuery(c *gin.Context) {
|
||||
type SaleQueryForm struct {
|
||||
Order_id string `json:"order_id"`
|
||||
Buyer string `json:"buyer"`
|
||||
Seller string `json:"seller"`
|
||||
}
|
||||
|
||||
reqJson := SaleQueryForm{}
|
||||
if !checkparam(&reqJson, c) {
|
||||
return
|
||||
}
|
||||
|
||||
cursor := q5.ToInt64(c.DefaultQuery("cursor", ""))
|
||||
filterstr := ""
|
||||
if reqJson.Order_id != "" {
|
||||
filterstr = " order_id = '" + reqJson.Order_id + "' "
|
||||
} else if reqJson.Buyer != "" {
|
||||
filterstr = " buyer = '" + reqJson.Buyer + "' "
|
||||
} else if reqJson.Seller != "" {
|
||||
filterstr = " seller = '" + reqJson.Seller + "' "
|
||||
} else {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"code": 1,
|
||||
"message": "input one of order_id, buyer, seller",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
sql := fmt.Sprintf(`SELECT * FROM t_sale WHERE idx > %d AND %s `, cursor, filterstr)
|
||||
|
||||
query(constant.BCNFT_DB, cursor, sql, c, func(ds *f5.DataSet) interface{} {
|
||||
var p system.Sale
|
||||
p.LoadFromDs(ds)
|
||||
return p
|
||||
})
|
||||
}
|
||||
|
||||
func (this *NFTApi) NFTQuery(c *gin.Context) {
|
||||
type HeroesQueryForm struct {
|
||||
Owner_address string `json:"owner_address"`
|
||||
Last_owner_address string `json:"last_owner_address"`
|
||||
Net_id int64 `json:"net_id"`
|
||||
}
|
||||
|
||||
reqJson := HeroesQueryForm{}
|
||||
if !checkparam(&reqJson, c) {
|
||||
return
|
||||
}
|
||||
|
||||
cursor := q5.ToInt64(c.DefaultQuery("cursor", ""))
|
||||
filterstr := ""
|
||||
if reqJson.Owner_address != "" {
|
||||
filterstr = " owner_address = '" + reqJson.Owner_address + "' "
|
||||
} else if reqJson.Last_owner_address != "" {
|
||||
filterstr = " last_owner_address = '" + reqJson.Last_owner_address + "' "
|
||||
} else if reqJson.Net_id != 0 {
|
||||
filterstr = " net_id = " + q5.ToString(reqJson.Net_id)
|
||||
} else {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"code": 1,
|
||||
"message": "input one of owner_address, last_owner_address, net_id",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
sql := fmt.Sprintf(`SELECT * FROM t_nft WHERE idx > %d AND %s `, cursor, filterstr)
|
||||
|
||||
query(constant.BCNFT_DB, cursor, sql, c, func(ds *f5.DataSet) interface{} {
|
||||
var p system.NFT
|
||||
p.LoadFromDs(ds)
|
||||
return p
|
||||
})
|
||||
}
|
@ -3,8 +3,6 @@ package system
|
||||
import (
|
||||
"f5"
|
||||
"fmt"
|
||||
|
||||
"main/common"
|
||||
"main/constant"
|
||||
"main/model/system"
|
||||
"net/http"
|
||||
@ -25,7 +23,7 @@ func (this *PlayerApi) Info(c *gin.Context) {
|
||||
}
|
||||
|
||||
reqJson := InfoForm{}
|
||||
if !this.checkparam(&reqJson, c) {
|
||||
if !checkparam(&reqJson, c) {
|
||||
return
|
||||
}
|
||||
|
||||
@ -52,7 +50,7 @@ func (this *PlayerApi) Info(c *gin.Context) {
|
||||
}
|
||||
sql := fmt.Sprintf(`SELECT * FROM t_user WHERE idx > %d AND %s `, cursor, filterstr)
|
||||
|
||||
this.query(cursor, sql, c, func(ds *f5.DataSet) interface{} {
|
||||
query(constant.GAME_DB, cursor, sql, c, func(ds *f5.DataSet) interface{} {
|
||||
var p system.Player
|
||||
p.LoadFromDs(ds)
|
||||
return p
|
||||
@ -65,7 +63,7 @@ func (this *PlayerApi) BagQuery(c *gin.Context) {
|
||||
}
|
||||
|
||||
reqJson := BagQueryForm{}
|
||||
if !this.checkparam(&reqJson, c) {
|
||||
if !checkparam(&reqJson, c) {
|
||||
return
|
||||
}
|
||||
|
||||
@ -73,7 +71,7 @@ func (this *PlayerApi) BagQuery(c *gin.Context) {
|
||||
filterstr := " account_id = '" + reqJson.Account_id + "' "
|
||||
sql := fmt.Sprintf(`SELECT * FROM t_bag WHERE idx > %d AND %s `, cursor, filterstr)
|
||||
|
||||
this.query(cursor, sql, c, func(ds *f5.DataSet) interface{} {
|
||||
query(constant.GAME_DB, cursor, sql, c, func(ds *f5.DataSet) interface{} {
|
||||
var p system.BagItem
|
||||
p.LoadFromDs(ds)
|
||||
return p
|
||||
@ -86,7 +84,7 @@ func (this *PlayerApi) HeroesQuery(c *gin.Context) {
|
||||
}
|
||||
|
||||
reqJson := HeroesQueryForm{}
|
||||
if !this.checkparam(&reqJson, c) {
|
||||
if !checkparam(&reqJson, c) {
|
||||
return
|
||||
}
|
||||
|
||||
@ -94,56 +92,9 @@ func (this *PlayerApi) HeroesQuery(c *gin.Context) {
|
||||
filterstr := " account_id = '" + reqJson.Account_id + "' "
|
||||
sql := fmt.Sprintf(`SELECT * FROM t_hero WHERE idx > %d AND %s `, cursor, filterstr)
|
||||
|
||||
this.query(cursor, sql, c, func(ds *f5.DataSet) interface{} {
|
||||
query(constant.GAME_DB, cursor, sql, c, func(ds *f5.DataSet) interface{} {
|
||||
var p system.Hero
|
||||
p.LoadFromDs(ds)
|
||||
return p
|
||||
})
|
||||
}
|
||||
|
||||
func (this *PlayerApi) checkparam(obj any, c *gin.Context) bool {
|
||||
if err := c.ShouldBindJSON(obj); err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"code": 1,
|
||||
"message": err.Error(),
|
||||
})
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func (this *PlayerApi) query(cursor int64, sql string, c *gin.Context, loadcall func(ds *f5.DataSet) interface{}) {
|
||||
rspObj := struct {
|
||||
ErrCode int32 `json:"errcode"`
|
||||
ErrMsg string `json:"errmsg"`
|
||||
Page common.StreamPagination `json:"page"`
|
||||
Rows []interface{} `json:"rows"`
|
||||
}{
|
||||
Rows: []interface{}{},
|
||||
}
|
||||
|
||||
pageSize := q5.AdjustRangeValue(q5.ToInt32(c.DefaultQuery("page_size", "")), 1, 20)
|
||||
|
||||
params := []string{}
|
||||
subFilters := []f5.DbQueryFilter{}
|
||||
|
||||
orderBy := ""
|
||||
|
||||
f5.GetGoStyleDb().StreamPageQuery(
|
||||
constant.GAME_DB,
|
||||
pageSize,
|
||||
cursor,
|
||||
sql,
|
||||
params,
|
||||
f5.GetDbFilter().Comp(subFilters...),
|
||||
orderBy,
|
||||
func(err error, pagination *f5.StreamPagination) {
|
||||
rspObj.Page.FillPage(pagination)
|
||||
},
|
||||
func(ds *f5.DataSet) {
|
||||
rspObj.Rows = append(rspObj.Rows, loadcall(ds))
|
||||
})
|
||||
|
||||
c.JSON(200, rspObj)
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ func (this *app) registerDataSources() {
|
||||
mt.Table.FriendDb.GetById(0).GetDatabase(),
|
||||
1,
|
||||
mt.Table.FriendDb.GetById(0).GetMaxOpenConns(),
|
||||
mt.Table.FriendDb.GetById(0).GetMaxIdleConns(),)
|
||||
mt.Table.FriendDb.GetById(0).GetMaxIdleConns())
|
||||
f5.GetApp().RegisterOrmDb(
|
||||
constant.ADMIN_DB,
|
||||
mt.Table.AdminDb.GetById(0).GetHost(),
|
||||
@ -117,6 +117,16 @@ func (this *app) registerDataSources() {
|
||||
1,
|
||||
mt.Table.GameDb.GetById(0).GetMaxOpenConns(),
|
||||
mt.Table.GameDb.GetById(0).GetMaxIdleConns())
|
||||
f5.GetGoStyleDb().RegisterDataSource(
|
||||
constant.BCNFT_DB,
|
||||
mt.Table.NFTDb.GetById(0).GetHost(),
|
||||
mt.Table.NFTDb.GetById(0).GetPort(),
|
||||
mt.Table.NFTDb.GetById(0).GetUser(),
|
||||
mt.Table.NFTDb.GetById(0).GetPasswd(),
|
||||
mt.Table.NFTDb.GetById(0).GetDatabase(),
|
||||
1,
|
||||
mt.Table.NFTDb.GetById(0).GetMaxOpenConns(),
|
||||
mt.Table.NFTDb.GetById(0).GetMaxIdleConns())
|
||||
}
|
||||
|
||||
func (this *app) AddSession(accountId string) string {
|
||||
|
@ -10,6 +10,7 @@ const (
|
||||
ADMIN_DB = "admindb"
|
||||
ACCOUNT_DB = "accountdb"
|
||||
MAIL_DB = "maildb"
|
||||
BCNFT_DB = "bcnftdb"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
type BagItem struct {
|
||||
Idx int64 `json:"idx"`
|
||||
Token_id string `gorm:"uniqueIndex;comment:token_id" json:"token_id"`
|
||||
Account_id string `gorm:"uniqueIndex;comment:用户id" json:"account_id"`
|
||||
Account_id string `gorm:"comment:用户id" json:"account_id"`
|
||||
Item_id int `gorm:"comment:物品id" json:"item_id"`
|
||||
Item_num int `gorm:"comment:物品数量" json:"item_num"`
|
||||
Rand_attr string `gorm:"comment:随机属性" json:"rand_attr"`
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
type Hero struct {
|
||||
Idx int64 `json:"idx"`
|
||||
Token_id string `gorm:"uniqueIndex;comment:token_id" json:"token_id"`
|
||||
Account_id string `gorm:"uniqueIndex;comment:用户id" json:"account_id"`
|
||||
Account_id string `gorm:"comment:用户id" json:"account_id"`
|
||||
Hero_id int `gorm:"comment:英雄id" json:"hero_id"`
|
||||
Hero_tili string `gorm:"comment:英雄体力" json:"hero_tili"`
|
||||
State int `gorm:"comment:0:已购买 1:体验中" json:"state"`
|
||||
|
48
server/adminserver/model/system/nft.go
Normal file
48
server/adminserver/model/system/nft.go
Normal file
@ -0,0 +1,48 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"f5"
|
||||
"q5"
|
||||
)
|
||||
|
||||
type NFT struct {
|
||||
Idx int64 `json:"idx"`
|
||||
Owner_address string `gorm:"comment:owner_address" json:"owner_address"`
|
||||
Creator_address string `gorm:"comment:creator_address" json:"creator_address"`
|
||||
Token_id string `gorm:"comment:token_id" json:"token_id"`
|
||||
Token_type int `gorm:"comment:nft类型 1:英雄 2:枪支 3:芯片 6:荣誉 7:徽章" json:"token_type"`
|
||||
Token_state int `gorm:"comment:0:正常状态 1:出售中 2:出租中" json:"token_state"`
|
||||
Item_id int `gorm:"comment:道具id" json:"item_id"`
|
||||
Deleted int `gorm:"comment:deleted" json:"deleted"`
|
||||
Confirm_count int `gorm:"comment:confirm_count" json:"confirm_count"`
|
||||
Confirm_block_number int64 `gorm:"comment:confirm_block_number" json:"confirm_block_number"`
|
||||
Tags string `gorm:"comment:tags" json:"tags"`
|
||||
Net_id int64 `gorm:"comment:net_id" json:"net_id"`
|
||||
Contract_address string `gorm:"comment:contract_address" json:"contract_address"`
|
||||
Createtime int `gorm:"comment:创建时间" json:"createtime"`
|
||||
Modifytime int `gorm:"comment:修改时间" json:"modifytime"`
|
||||
Last_owner_address string `gorm:"comment:last_owner_address" json:"last_owner_address"`
|
||||
}
|
||||
|
||||
func (this *NFT) TableName() string {
|
||||
return "t_nft"
|
||||
}
|
||||
|
||||
func (this *NFT) LoadFromDs(ds *f5.DataSet) {
|
||||
this.Idx = q5.ToInt64(ds.GetByName("idx"))
|
||||
this.Owner_address = ds.GetByName("owner_address")
|
||||
this.Creator_address = ds.GetByName("creator_address")
|
||||
this.Token_id = ds.GetByName("token_id")
|
||||
this.Token_type = q5.ToInt(ds.GetByName("token_type"))
|
||||
this.Token_state = q5.ToInt(ds.GetByName("token_state"))
|
||||
this.Item_id = q5.ToInt(ds.GetByName("item_id"))
|
||||
this.Deleted = q5.ToInt(ds.GetByName("deleted"))
|
||||
this.Confirm_count = q5.ToInt(ds.GetByName("confirm_count"))
|
||||
this.Confirm_block_number = q5.ToInt64(ds.GetByName("confirm_block_number"))
|
||||
this.Tags = ds.GetByName("tags")
|
||||
this.Net_id = q5.ToInt64(ds.GetByName("net_id"))
|
||||
this.Contract_address = ds.GetByName("contract_address")
|
||||
this.Createtime = q5.ToInt(ds.GetByName("createtime"))
|
||||
this.Modifytime = q5.ToInt(ds.GetByName("modifytime"))
|
||||
this.Last_owner_address = ds.GetByName("last_owner_address")
|
||||
}
|
62
server/adminserver/model/system/order.go
Normal file
62
server/adminserver/model/system/order.go
Normal file
@ -0,0 +1,62 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"f5"
|
||||
"q5"
|
||||
)
|
||||
|
||||
type Order struct {
|
||||
Idx int64 `json:"idx"`
|
||||
Order_id string `gorm:"comment:订单id" json:"order_id"`
|
||||
Chain string `gorm:"comment:chain" json:"chain"`
|
||||
Status string `gorm:"comment:status" json:"status"`
|
||||
Net_id int64 `gorm:"comment:net_id" json:"net_id"`
|
||||
Token_id string `gorm:"comment:token_id" json:"token_id"`
|
||||
Contract_address string `gorm:"comment:contract_address" json:"contract_address"`
|
||||
Item_id int `gorm:"comment:item_id" json:"item_id"`
|
||||
Hero_quality int `gorm:"comment:hero_quality" json:"hero_quality"`
|
||||
Price string `gorm:"comment:price" json:"price"`
|
||||
Start_time int `gorm:"comment:start_time" json:"start_time"`
|
||||
End_time int `gorm:"comment:end_time" json:"end_time"`
|
||||
Created_at int `gorm:"comment:created_at" json:"created_at"`
|
||||
Updated_at int `gorm:"comment:updated_at" json:"updated_at"`
|
||||
Event_id string `gorm:"comment:事件id" json:"event_id"`
|
||||
Event_data string `gorm:"comment:事件内容" json:"event_data"`
|
||||
Createtime int `gorm:"comment:创建时间" json:"createtime"`
|
||||
Modifytime int `gorm:"comment:修改时间" json:"modifytime"`
|
||||
Src_price_exchange_rate int64 `gorm:"comment:src_price_exchange_rate" json:"src_price_exchange_rate"`
|
||||
Src_price_amount string `gorm:"comment:src_price_amount" json:"src_price_amount"`
|
||||
Src_price_item_type string `gorm:"comment:src_price_item_type" json:"src_price_item_type"`
|
||||
Src_price_contract_address string `gorm:"comment:src_price_contract_address" json:"src_price_contract_address"`
|
||||
Price_len int `gorm:"comment:price_len" json:"price_len"`
|
||||
}
|
||||
|
||||
func (this *Order) TableName() string {
|
||||
return "t_order"
|
||||
}
|
||||
|
||||
func (this *Order) LoadFromDs(ds *f5.DataSet) {
|
||||
this.Idx = q5.ToInt64(ds.GetByName("idx"))
|
||||
this.Order_id = ds.GetByName("order_id")
|
||||
this.Chain = ds.GetByName("chain")
|
||||
this.Status = ds.GetByName("status")
|
||||
this.Net_id = q5.ToInt64(ds.GetByName("net_id"))
|
||||
this.Token_id = ds.GetByName("token_id")
|
||||
this.Contract_address = ds.GetByName("contract_address")
|
||||
this.Item_id = q5.ToInt(ds.GetByName("item_id"))
|
||||
this.Hero_quality = q5.ToInt(ds.GetByName("hero_quality"))
|
||||
this.Price = ds.GetByName("price")
|
||||
this.Start_time = q5.ToInt(ds.GetByName("start_time"))
|
||||
this.End_time = q5.ToInt(ds.GetByName("end_time"))
|
||||
this.Created_at = q5.ToInt(ds.GetByName("created_at"))
|
||||
this.Updated_at = q5.ToInt(ds.GetByName("updated_at"))
|
||||
this.Event_id = ds.GetByName("event_id")
|
||||
this.Event_data = ds.GetByName("event_data")
|
||||
this.Createtime = q5.ToInt(ds.GetByName("createtime"))
|
||||
this.Modifytime = q5.ToInt(ds.GetByName("modifytime"))
|
||||
this.Src_price_exchange_rate = q5.ToInt64(ds.GetByName("src_price_exchange_rate"))
|
||||
this.Src_price_amount = ds.GetByName("src_price_amount")
|
||||
this.Src_price_item_type = ds.GetByName("src_price_item_type")
|
||||
this.Src_price_contract_address = ds.GetByName("src_price_contract_address")
|
||||
this.Price_len = q5.ToInt(ds.GetByName("price_len"))
|
||||
}
|
48
server/adminserver/model/system/sale.go
Normal file
48
server/adminserver/model/system/sale.go
Normal file
@ -0,0 +1,48 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"f5"
|
||||
"q5"
|
||||
)
|
||||
|
||||
type Sale struct {
|
||||
Idx int64 `json:"idx"`
|
||||
Order_id string `gorm:"uniqueIndex;comment:订单id" json:"order_id"`
|
||||
Chain string `gorm:"comment:chain" json:"chain"`
|
||||
Net_id int64 `gorm:"comment:net_id" json:"net_id"`
|
||||
Token_id string `gorm:"comment:token_id" json:"token_id"`
|
||||
Contract_address string `gorm:"comment:contract_address" json:"contract_address"`
|
||||
Buyer string `gorm:"comment:buyer" json:"buyer"`
|
||||
Seller string `gorm:"comment:seller" json:"seller"`
|
||||
Item_id int `gorm:"comment:item_id" json:"item_id"`
|
||||
Hero_quality int `gorm:"comment:hero_quality" json:"hero_quality"`
|
||||
Price string `gorm:"comment:price" json:"price"`
|
||||
Indexed_at int `gorm:"comment:indexed_at" json:"indexed_at"`
|
||||
Event_id string `gorm:"comment:事件id" json:"event_id"`
|
||||
Event_data string `gorm:"comment:事件内容" json:"event_data"`
|
||||
Createtime int `gorm:"comment:创建时间" json:"createtime"`
|
||||
Modifytime int `gorm:"comment:修改时间" json:"modifytime"`
|
||||
}
|
||||
|
||||
func (this *Sale) TableName() string {
|
||||
return "t_sale"
|
||||
}
|
||||
|
||||
func (this *Sale) LoadFromDs(ds *f5.DataSet) {
|
||||
this.Idx = q5.ToInt64(ds.GetByName("idx"))
|
||||
this.Order_id = ds.GetByName("order_id")
|
||||
this.Chain = ds.GetByName("chain")
|
||||
this.Net_id = q5.ToInt64(ds.GetByName("net_id"))
|
||||
this.Token_id = ds.GetByName("token_id")
|
||||
this.Contract_address = ds.GetByName("contract_address")
|
||||
this.Buyer = ds.GetByName("buyer")
|
||||
this.Seller = ds.GetByName("seller")
|
||||
this.Item_id = q5.ToInt(ds.GetByName("item_id"))
|
||||
this.Hero_quality = q5.ToInt(ds.GetByName("hero_quality"))
|
||||
this.Price = ds.GetByName("price")
|
||||
this.Indexed_at = q5.ToInt(ds.GetByName("indexed_at"))
|
||||
this.Event_id = ds.GetByName("event_id")
|
||||
this.Event_data = ds.GetByName("event_data")
|
||||
this.Createtime = q5.ToInt(ds.GetByName("createtime"))
|
||||
this.Modifytime = q5.ToInt(ds.GetByName("modifytime"))
|
||||
}
|
14
server/adminserver/mt/NFTDb.go
Normal file
14
server/adminserver/mt/NFTDb.go
Normal file
@ -0,0 +1,14 @@
|
||||
package mt
|
||||
|
||||
import (
|
||||
"f5"
|
||||
"mtb"
|
||||
)
|
||||
|
||||
type NFTDb struct {
|
||||
mtb.NFTDb
|
||||
}
|
||||
|
||||
type NFTDbTable struct {
|
||||
f5.IdMetaTable[NFTDb]
|
||||
}
|
@ -12,6 +12,7 @@ type table struct {
|
||||
MailDb *MailDbTable
|
||||
AdminDb *AdminDbTable
|
||||
Config *ConfigTable
|
||||
NFTDb *NFTDbTable
|
||||
}
|
||||
|
||||
var Table = f5.New(func(this *table) {
|
||||
@ -49,4 +50,9 @@ var Table = f5.New(func(this *table) {
|
||||
this.FileName = "../config/config.json"
|
||||
this.PrimKey = ""
|
||||
})
|
||||
|
||||
this.NFTDb = f5.New(func(this *NFTDbTable) {
|
||||
this.FileName = "../config/nftdb.mysql.json"
|
||||
this.PrimKey = ""
|
||||
})
|
||||
})
|
||||
|
@ -85,6 +85,19 @@ type Config struct {
|
||||
_flags2_ uint64
|
||||
}
|
||||
|
||||
type NFTDb struct {
|
||||
host string
|
||||
port int32
|
||||
user string
|
||||
passwd string
|
||||
database string
|
||||
max_open_conns int32
|
||||
max_idle_conns int32
|
||||
|
||||
_flags1_ uint64
|
||||
_flags2_ uint64
|
||||
}
|
||||
|
||||
func (this *AdminCluster) GetInstanceId() int32 {
|
||||
return this.instance_id
|
||||
}
|
||||
@ -397,6 +410,62 @@ func (this *Config) HasGameapiUrl() bool {
|
||||
return (this._flags1_ & (uint64(1) << 1)) > 0
|
||||
}
|
||||
|
||||
func (this *NFTDb) GetHost() string {
|
||||
return this.host
|
||||
}
|
||||
|
||||
func (this *NFTDb) HasHost() bool {
|
||||
return (this._flags1_ & (uint64(1) << 1)) > 0
|
||||
}
|
||||
|
||||
func (this *NFTDb) GetPort() int32 {
|
||||
return this.port
|
||||
}
|
||||
|
||||
func (this *NFTDb) HasPort() bool {
|
||||
return (this._flags1_ & (uint64(1) << 2)) > 0
|
||||
}
|
||||
|
||||
func (this *NFTDb) GetUser() string {
|
||||
return this.user
|
||||
}
|
||||
|
||||
func (this *NFTDb) HasUser() bool {
|
||||
return (this._flags1_ & (uint64(1) << 3)) > 0
|
||||
}
|
||||
|
||||
func (this *NFTDb) GetPasswd() string {
|
||||
return this.passwd
|
||||
}
|
||||
|
||||
func (this *NFTDb) HasPasswd() bool {
|
||||
return (this._flags1_ & (uint64(1) << 4)) > 0
|
||||
}
|
||||
|
||||
func (this *NFTDb) GetDatabase() string {
|
||||
return this.database
|
||||
}
|
||||
|
||||
func (this *NFTDb) HasDatabase() bool {
|
||||
return (this._flags1_ & (uint64(1) << 5)) > 0
|
||||
}
|
||||
|
||||
func (this *NFTDb) GetMaxOpenConns() int32 {
|
||||
return this.max_open_conns
|
||||
}
|
||||
|
||||
func (this *NFTDb) HasMaxOpenConns() bool {
|
||||
return (this._flags1_ & (uint64(1) << 6)) > 0
|
||||
}
|
||||
|
||||
func (this *NFTDb) GetMaxIdleConns() int32 {
|
||||
return this.max_idle_conns
|
||||
}
|
||||
|
||||
func (this *NFTDb) HasMaxIdleConns() bool {
|
||||
return (this._flags1_ & (uint64(1) << 7)) > 0
|
||||
}
|
||||
|
||||
|
||||
func (this *AdminCluster) LoadFromKv(kv map[string]interface{}) {
|
||||
f5.ReadMetaTableField(&this.instance_id, "instance_id", &this._flags1_, 1, kv)
|
||||
@ -457,3 +526,13 @@ func (this *MailDb) LoadFromKv(kv map[string]interface{}) {
|
||||
func (this *Config) LoadFromKv(kv map[string]interface{}) {
|
||||
f5.ReadMetaTableField(&this.gameapi_url, "gameapi_url", &this._flags1_, 1, kv)
|
||||
}
|
||||
|
||||
func (this *NFTDb) LoadFromKv(kv map[string]interface{}) {
|
||||
f5.ReadMetaTableField(&this.host, "host", &this._flags1_, 1, kv)
|
||||
f5.ReadMetaTableField(&this.port, "port", &this._flags1_, 2, kv)
|
||||
f5.ReadMetaTableField(&this.user, "user", &this._flags1_, 3, kv)
|
||||
f5.ReadMetaTableField(&this.passwd, "passwd", &this._flags1_, 4, kv)
|
||||
f5.ReadMetaTableField(&this.database, "database", &this._flags1_, 5, kv)
|
||||
f5.ReadMetaTableField(&this.max_open_conns, "max_open_conns", &this._flags1_, 6, kv)
|
||||
f5.ReadMetaTableField(&this.max_idle_conns, "max_idle_conns", &this._flags1_, 7, kv)
|
||||
}
|
||||
|
@ -68,3 +68,14 @@ message Config
|
||||
{
|
||||
optional string gameapi_url = 1;
|
||||
}
|
||||
|
||||
message NFTDb
|
||||
{
|
||||
optional string host = 1;
|
||||
optional int32 port = 2;
|
||||
optional string user = 3;
|
||||
optional string passwd = 4;
|
||||
optional string database = 5;
|
||||
optional int32 max_open_conns = 6;
|
||||
optional int32 max_idle_conns = 7;
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ func (this *routerMgr) Init() {
|
||||
this.system.InitGroupMemberRouter(priGroup)
|
||||
this.system.InitBattleServerRouter(priGroup)
|
||||
this.system.InitPlayerRouter(priGroup)
|
||||
this.system.InitNFTRouter(priGroup)
|
||||
f5.GetSysLog().Info("routerMgr.init")
|
||||
}
|
||||
|
||||
|
@ -9,4 +9,5 @@ type RouterGroup struct {
|
||||
GroupMemberRoute
|
||||
BattleServerRoute
|
||||
PlayerRouter
|
||||
NFTRouter
|
||||
}
|
||||
|
19
server/adminserver/router/system/sys_nft.go
Normal file
19
server/adminserver/router/system/sys_nft.go
Normal file
@ -0,0 +1,19 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
v1 "main/api/v1"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type NFTRouter struct{}
|
||||
|
||||
func (this *NFTRouter) InitNFTRouter(priRouter *gin.RouterGroup) {
|
||||
group := priRouter.Group("nft")
|
||||
api := v1.ApiGroupApp.SystemApiGroup.NFTApi
|
||||
{
|
||||
group.POST("orderquery", api.OrderQuery)
|
||||
group.POST("salequery", api.SaleQuery)
|
||||
group.POST("nftquery", api.NFTQuery)
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user