This commit is contained in:
aozhiwei 2024-06-03 17:00:56 +08:00
parent 6cefb75ae8
commit bc4e93b5c4
37 changed files with 1062 additions and 0 deletions

View File

@ -0,0 +1,20 @@
package ca
import (
"github.com/gin-gonic/gin"
)
type AnncApi struct {
}
func (this *AnncApi) GetAnnouncement(c *gin.Context) {
rspObj := struct {
ErrCode int32 `json:"errcode"`
ErrMsg string `json:"errmsg"`
}{
ErrCode: 0,
ErrMsg: "",
}
c.JSON(200, rspObj)
}

View File

@ -0,0 +1,9 @@
package ca
type ApiGroup struct {
LoginApi
AnncApi
ServerSwitchApi
}
var ApiGroupApp = new(ApiGroup)

View File

@ -0,0 +1,31 @@
package ca
import (
"github.com/gin-gonic/gin"
)
type LoginApi struct {
}
func (this *LoginApi) GetNonce(c *gin.Context) {
rspObj := struct {
ErrCode int32 `json:"errcode"`
ErrMsg string `json:"errmsg"`
}{
ErrCode: 0,
ErrMsg: "",
}
c.JSON(200, rspObj)
}
func (this *LoginApi) Auth(c *gin.Context) {
rspObj := struct {
ErrCode int32 `json:"errcode"`
ErrMsg string `json:"errmsg"`
}{
ErrCode: 0,
ErrMsg: "",
}
c.JSON(200, rspObj)
}

View File

@ -0,0 +1,31 @@
package ca
import (
"github.com/gin-gonic/gin"
)
type ServerSwitchApi struct {
}
func (this *ServerSwitchApi) GetSwitch(c *gin.Context) {
rspObj := struct {
ErrCode int32 `json:"errcode"`
ErrMsg string `json:"errmsg"`
}{
ErrCode: 0,
ErrMsg: "",
}
c.JSON(200, rspObj)
}
func (this *ServerSwitchApi) GetWhiteList(c *gin.Context) {
rspObj := struct {
ErrCode int32 `json:"errcode"`
ErrMsg string `json:"errmsg"`
}{
ErrCode: 0,
ErrMsg: "",
}
c.JSON(200, rspObj)
}

View File

@ -0,0 +1,11 @@
package v1
import (
"main/api/v1/nft"
)
type ApiGroup struct {
NftApiGroup nft.ApiGroup
}
var ApiGroupApp = new(ApiGroup)

View File

@ -0,0 +1,5 @@
package nft
type ApiGroup struct {
NftMetaApi
}

View File

@ -0,0 +1,31 @@
package nft
import (
"github.com/gin-gonic/gin"
)
type NftMetaApi struct {
}
func (this *NftMetaApi) Hero(c *gin.Context) {
rspObj := struct {
ErrCode int32 `json:"errcode"`
ErrMsg string `json:"errmsg"`
}{
ErrCode: 0,
ErrMsg: "",
}
c.JSON(200, rspObj)
}
func (this *NftMetaApi) GoldBullion(c *gin.Context) {
rspObj := struct {
ErrCode int32 `json:"errcode"`
ErrMsg string `json:"errmsg"`
}{
ErrCode: 0,
ErrMsg: "",
}
c.JSON(200, rspObj)
}

View File

@ -0,0 +1,45 @@
package app
import (
"f5"
"mt"
)
type app struct {
initCb func()
unInitCb func()
}
func (this *app) GetPkgName() string {
return "mailserver"
}
func (this *app) GetHttpListenPort() int32 {
return mt.Table.LoginCluster.GetHttpListenPort()
}
func (this *app) Run(initCb func(), unInitCb func()) {
this.initCb = initCb
this.unInitCb = unInitCb
f5.Run(this)
}
func (this *app) Init() {
f5.LoadMetaTable(mt.Table)
this.registerDataSources()
this.initCb()
}
func (this *app) UnInit() {
this.unInitCb()
}
func (this *app) Update() {
}
func (this *app) registerDataSources() {
}
func (this *app) HasTask() bool {
return false
}

View File

@ -0,0 +1,12 @@
package app
import (
"main/constant"
"main/global"
)
var _app = new(app)
func init() {
global.RegModule(constant.APP_MODULE_IDX, _app)
}

View File

@ -0,0 +1,11 @@
package common
import (
)
type App interface {
Run(func(), func())
}
type RouterMgr interface{
}

View File

@ -0,0 +1,11 @@
package constant
const (
ACCOUNT_DB = "accountdb"
)
const (
APP_MODULE_IDX = iota
ROUTER_MGR_MODULE_IDX
MAX_MODULE_IDX
)

View File

@ -0,0 +1,57 @@
package global
import (
"fmt"
"main/common"
"main/constant"
"q5"
)
var modules [constant.MAX_MODULE_IDX]q5.Module
var initOrders = []int32{
constant.ROUTER_MGR_MODULE_IDX,
}
var app common.App
var routerMgr common.RouterMgr
func GetApp() common.App {
return app
}
func GetRouterMgr() common.RouterMgr {
return routerMgr
}
func RegModule(idx int32, m q5.Module) {
fmt.Printf("RegModule module %d\n", idx)
modules[idx] = m
switch idx {
case constant.APP_MODULE_IDX:
{
app = m.(common.App)
}
case constant.ROUTER_MGR_MODULE_IDX:
{
routerMgr = m.(common.RouterMgr)
}
default:
{
panic("unknow module")
}
}
}
func InitModules() {
for _, val := range initOrders {
fmt.Printf("init module %d\n", val)
modules[val].Init()
}
}
func UnInitModules() {
for _, val := range initOrders {
fmt.Printf("unInit module %d", val)
modules[val].UnInit()
}
}

66
server/nftserver/go.mod Normal file
View File

@ -0,0 +1,66 @@
module nftserver
go 1.20
require q5 v1.0.0
require f5 v1.0.0
require mt v1.0.0
require (
golang.org/x/sync v0.6.0 // indirect
gopkg.in/go-jose/go-jose.v2 v2.6.2 // indirect
mtb v1.0.0 // indirect
)
require main v1.0.0
require github.com/gin-gonic/gin v1.10.0
require (
github.com/auth0/go-jwt-middleware/v2 v2.2.1
github.com/bytedance/sonic v1.11.6 // indirect
github.com/bytedance/sonic/loader v0.1.1 // indirect
github.com/cloudwego/base64x v0.1.4 // indirect
github.com/cloudwego/iasm v0.2.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.20.0 // indirect
github.com/go-sql-driver/mysql v1.7.0 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/gomodule/redigo v1.8.3 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/joho/godotenv v1.5.1
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.12 // indirect
golang.org/x/arch v0.8.0 // indirect
golang.org/x/crypto v0.23.0 // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/text v0.15.0 // indirect
google.golang.org/protobuf v1.34.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gorm.io/driver/mysql v1.5.1 // indirect
gorm.io/gorm v1.25.1 // indirect
)
replace q5 => ../../third_party/q5
replace f5 => ../../third_party/f5
replace mt => ./mt
replace mtb => ./mtb
replace main => ./

113
server/nftserver/go.sum Normal file
View File

@ -0,0 +1,113 @@
github.com/auth0/go-jwt-middleware/v2 v2.2.0/go.mod h1:BFCz+RF+1szSkrGNJLYn2ng2PtfzBiKR6fynTvS2A/k=
github.com/auth0/go-jwt-middleware/v2 v2.2.1 h1:pqxEIwlCztD0T9ZygGfOrw4NK/F9iotnCnPJVADKbkE=
github.com/auth0/go-jwt-middleware/v2 v2.2.1/go.mod h1:CSi0tuu0QrALbWdiQZwqFL8SbBhj4e2MJzkvNfjY0Us=
github.com/bytedance/sonic v1.11.6 h1:oUp34TzMlL+OY1OUWxHqsdkgC/Zfc85zGqw9siXjrc0=
github.com/bytedance/sonic v1.11.6/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4=
github.com/bytedance/sonic/loader v0.1.1 h1:c+e5Pt1k/cy5wMveRDyk2X4B9hF4g7an8N3zCYjJFNM=
github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d/go.mod h1:8EPpVsBuRksnlj1mLy4AWzRNQYxauNi62uWcE3to6eA=
github.com/chenzhuoyu/iasm v0.9.0/go.mod h1:Xjy2NpN3h7aUqeqM+woSuuvxmIe6+DDsiNLIrkAmYog=
github.com/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/0Y=
github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w=
github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg=
github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0=
github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk=
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU=
github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y=
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
github.com/go-playground/validator/v10 v10.20.0 h1:K9ISHbSaI0lyB2eWMPJo+kOS/FBExVwjEviJTixqxL8=
github.com/go-playground/validator/v10 v10.20.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
github.com/go-sql-driver/mysql v1.7.0 h1:ueSltNNllEqE3qcWBTD0iQd3IpL/6U+mJxLkazJ7YPc=
github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/gomodule/redigo v1.8.3 h1:HR0kYDX2RJZvAup8CsiJwxB4dTCSC0AaUq6S4SiLwUc=
github.com/gomodule/redigo v1.8.3/go.mod h1:P9dn9mFrCBvWhGE1wpxx6fgq7BAeLBk+UUUzlpkBYO0=
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM=
github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
golang.org/x/arch v0.8.0 h1:3wRIsP3pM4yUptoR96otTUOXI367OS0+c9eeRi9doIc=
golang.org/x/arch v0.8.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI=
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg=
google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/go-jose/go-jose.v2 v2.6.2 h1:Rl5+9rA0kG3vsO1qhncMPRT5eHICihAMQYJkD7u/i4M=
gopkg.in/go-jose/go-jose.v2 v2.6.2/go.mod h1:zzZDPkNNw/c9IE7Z9jr11mBZQhKQTMzoEEIoEdZlFBI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gorm.io/driver/mysql v1.5.1 h1:WUEH5VF9obL/lTtzjmML/5e6VfFR/788coz2uaVCAZw=
gorm.io/driver/mysql v1.5.1/go.mod h1:Jo3Xu7mMhCyj8dlrb3WoCaRd1FhsVh+yMXb1jUInf5o=
gorm.io/gorm v1.25.1 h1:nsSALe5Pr+cM3V1qwwQ7rOkw+6UeLrX5O4v3llhHa64=
gorm.io/gorm v1.25.1/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k=
nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=

View File

@ -0,0 +1,11 @@
package initialize
import (
_ "main/app"
. "main/global"
_ "main/router"
)
func Init() {
GetApp().Run(InitModules, UnInitModules)
}

9
server/nftserver/main.go Normal file
View File

@ -0,0 +1,9 @@
package main
import (
"main/initialize"
)
func main() {
initialize.Init()
}

17
server/nftserver/makefile Normal file
View File

@ -0,0 +1,17 @@
compile:
@. /etc/profile
@export GOPROXY=https://goproxy.io
@go build -gcflags=all="-N -l" -o ../../bin/nftserver/bin
@echo "compile done"
debug:
@. /etc/profile
@export GOPROXY=https://goproxy.io
@go build -gcflags=all="-N -l" -ldflags "-X q5.optDebug=1" -o ../../bin/nftserver/bin
@echo "compile done"
clean:
@rm -f ../../bin/nftserver/bin
@echo "clean done"

View File

@ -0,0 +1,97 @@
package middleware
import (
"time"
"log"
"context"
"net/http"
"strings"
"github.com/gin-gonic/gin"
jwtmiddleware "github.com/auth0/go-jwt-middleware/v2"
//"github.com/auth0/go-jwt-middleware/v2/jwks"
"github.com/auth0/go-jwt-middleware/v2/validator"
)
var (
// The signing key for the token.
signingKey = []byte("secret")
// The issuer of our token.
issuer = "go-jwt-middleware-example"
// The audience of our token.
audience = []string{"audience-example"}
// Our token must be signed using this data.
keyFunc = func(ctx context.Context) (interface{}, error) {
return signingKey, nil
}
// We want this struct to be filled in with
// our custom claims from the token.
customClaims = func() validator.CustomClaims {
return &CustomClaims{}
}
)
type CustomClaims struct {
Scope string `json:"scope"`
}
func CheckJWT() gin.HandlerFunc {
// Set up the validator.
jwtValidator, err := validator.New(
keyFunc,
validator.HS256,
issuer,
audience,
validator.WithCustomClaims(customClaims),
validator.WithAllowedClockSkew(30*time.Second),
)
if err != nil {
log.Fatalf("failed to set up the validator: %v", err)
}
errorHandler := func(w http.ResponseWriter, r *http.Request, err error) {
log.Printf("Encountered error while validating JWT: %v", err)
}
middleware := jwtmiddleware.New(
jwtValidator.ValidateToken,
jwtmiddleware.WithErrorHandler(errorHandler),
)
return func(ctx *gin.Context) {
encounteredError := true
var handler http.HandlerFunc = func(w http.ResponseWriter, r *http.Request) {
encounteredError = false
ctx.Request = r
ctx.Next()
}
middleware.CheckJWT(handler).ServeHTTP(ctx.Writer, ctx.Request)
if encounteredError {
ctx.AbortWithStatusJSON(
http.StatusUnauthorized,
map[string]string{"message": "JWT is invalid."},
)
}
}
}
func (c CustomClaims) Validate(ctx context.Context) error {
return nil
}
func (c CustomClaims) HasScope(expectedScope string) bool {
result := strings.Split(c.Scope, " ")
for i := range result {
if result[i] == expectedScope {
return true
}
}
return false
}

View File

@ -0,0 +1,69 @@
package model
import (
"q5"
"f5"
"main/constant"
)
type inbox struct {
}
var Inbox = new(inbox)
func (this *inbox) Mark(accountId string, mailId int64, nowTime int64, expireTime int32) error {
var result error
f5.GetGoStyleDb().Upsert(
constant.MAIL_DB,
"t_inbox",
[][]string{
{"account_id", accountId},
{"mail_id", q5.ToString(mailId)},
},
[][]string{
{"state", q5.ToString(constant.INBOX_STATE_READ)},
{"expiretime", q5.ToString(expireTime)},
{"modifytime", q5.ToString(nowTime)},
},
[][]string{
{"account_id", accountId},
{"mail_id", q5.ToString(mailId)},
{"state", q5.ToString(constant.INBOX_STATE_READ)},
{"expiretime", q5.ToString(expireTime)},
{"createtime", q5.ToString(nowTime)},
{"modifytime", q5.ToString(nowTime)},
},
func (err error, lastInsertId int64, rowsAffected int64) {
result = err
})
return result
}
func (this *inbox) Delete(accountId string, mailId int64, nowTime int64, expireTime int32) error {
var result error
f5.GetGoStyleDb().Upsert(
constant.MAIL_DB,
"t_inbox",
[][]string{
{"account_id", accountId},
{"mail_id", q5.ToString(mailId)},
},
[][]string{
{"state", q5.ToString(constant.INBOX_STATE_DELETED)},
{"expiretime", q5.ToString(expireTime)},
{"modifytime", q5.ToString(nowTime)},
},
[][]string{
{"account_id", accountId},
{"mail_id", q5.ToString(mailId)},
{"state", q5.ToString(constant.INBOX_STATE_DELETED)},
{"expiretime", q5.ToString(expireTime)},
{"createtime", q5.ToString(nowTime)},
{"modifytime", q5.ToString(nowTime)},
},
func (err error, lastInsertId int64, rowsAffected int64) {
result = err
})
return result
}

View File

@ -0,0 +1,19 @@
package mt
import (
"f5"
"mtb"
)
type Config struct {
mtb.Config
}
type ConfigTable struct {
f5.IdMetaTable[Config]
selfConf *Config
}
func (this *ConfigTable) GetGameApiUrl() string {
return this.selfConf.GetGameapiUrl()
}

View File

@ -0,0 +1,34 @@
package mt
import (
"f5"
"mtb"
)
type LoginCluster struct {
mtb.LoginCluster
}
type LoginClusterTable struct {
f5.IdMetaTable[LoginCluster]
selfConf *LoginCluster
}
func (this *LoginCluster) Init1() {
}
func (this *LoginClusterTable) GetListenPort() int32 {
return this.selfConf.GetListenPort()
}
func (this *LoginClusterTable) GetHttpListenPort() int32 {
return this.selfConf.GetHttpListenPort()
}
func (this *LoginClusterTable) PostInit1() {
this.selfConf = this.GetById(int64(f5.GetApp().GetInstanceId()))
if this.selfConf == nil {
panic("loginserver集群无法读取本服配置")
}
}

View File

@ -0,0 +1,17 @@
package mt
import (
"f5"
"mtb"
)
type LoginDb struct {
mtb.LoginDb
}
type LoginDbTable struct {
f5.IdMetaTable[LoginDb]
}
func (this *LoginDb) Init1() {
}

View File

@ -0,0 +1,28 @@
package mt
import (
"f5"
)
type table struct {
LoginCluster *LoginClusterTable
LoginDb *LoginDbTable
Config *ConfigTable
}
var Table = f5.New(func(this *table) {
this.LoginCluster = f5.New(func(this *LoginClusterTable) {
this.FileName = "../config/loginserver.cluster.json"
this.PrimKey = "instance_id"
})
this.LoginDb = f5.New(func(this *LoginDbTable) {
this.FileName = "../config/logindb.mysql.json"
this.PrimKey = ""
})
this.Config = f5.New(func(this *ConfigTable) {
this.FileName = "../config/config.json"
this.PrimKey = ""
})
})

View File

@ -0,0 +1,14 @@
module mt
go 1.20
require q5 v1.0.0
require f5 v1.0.0
require mtb v1.0.0
require (
)
replace q5 => ../../../third_party/q5
replace f5 => ../../../third_party/f5
replace mtb => ../mtb

View File

@ -0,0 +1,16 @@
module mtb
go 1.20
require q5 v1.0.0
require f5 v1.0.0
require (
github.com/golang/protobuf v1.5.0
google.golang.org/protobuf v1.31.0
)
replace q5 => ../../../third_party/q5
replace f5 => ../../../third_party/f5

View File

@ -0,0 +1,23 @@
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0=
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
google.golang.org/protobuf v1.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyzM=
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=

View File

@ -0,0 +1,123 @@
package mtb
import (
"f5"
)
type LoginCluster struct {
instance_id int32
listen_port int32
http_listen_port int32
_flags1_ uint64
_flags2_ uint64
}
type LoginDb struct {
host string
port int32
user string
passwd string
database string
_flags1_ uint64
_flags2_ uint64
}
type Config struct {
gameapi_url string
_flags1_ uint64
_flags2_ uint64
}
func (this *LoginCluster) GetInstanceId() int32 {
return this.instance_id
}
func (this *LoginCluster) HasInstanceId() bool {
return (this._flags1_ & (uint64(1) << 1)) > 0
}
func (this *LoginCluster) GetListenPort() int32 {
return this.listen_port
}
func (this *LoginCluster) HasListenPort() bool {
return (this._flags1_ & (uint64(1) << 2)) > 0
}
func (this *LoginCluster) GetHttpListenPort() int32 {
return this.http_listen_port
}
func (this *LoginCluster) HasHttpListenPort() bool {
return (this._flags1_ & (uint64(1) << 3)) > 0
}
func (this *LoginDb) GetHost() string {
return this.host
}
func (this *LoginDb) HasHost() bool {
return (this._flags1_ & (uint64(1) << 1)) > 0
}
func (this *LoginDb) GetPort() int32 {
return this.port
}
func (this *LoginDb) HasPort() bool {
return (this._flags1_ & (uint64(1) << 2)) > 0
}
func (this *LoginDb) GetUser() string {
return this.user
}
func (this *LoginDb) HasUser() bool {
return (this._flags1_ & (uint64(1) << 3)) > 0
}
func (this *LoginDb) GetPasswd() string {
return this.passwd
}
func (this *LoginDb) HasPasswd() bool {
return (this._flags1_ & (uint64(1) << 4)) > 0
}
func (this *LoginDb) GetDatabase() string {
return this.database
}
func (this *LoginDb) HasDatabase() bool {
return (this._flags1_ & (uint64(1) << 5)) > 0
}
func (this *Config) GetGameapiUrl() string {
return this.gameapi_url
}
func (this *Config) HasGameapiUrl() bool {
return (this._flags1_ & (uint64(1) << 1)) > 0
}
func (this *LoginCluster) LoadFromKv(kv map[string]interface{}) {
f5.ReadMetaTableField(&this.instance_id, "instance_id", &this._flags1_, 1, kv)
f5.ReadMetaTableField(&this.listen_port, "listen_port", &this._flags1_, 2, kv)
f5.ReadMetaTableField(&this.http_listen_port, "http_listen_port", &this._flags1_, 3, kv)
}
func (this *LoginDb) 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)
}
func (this *Config) LoadFromKv(kv map[string]interface{}) {
f5.ReadMetaTableField(&this.gameapi_url, "gameapi_url", &this._flags1_, 1, kv)
}

View File

@ -0,0 +1,24 @@
package mt;
option go_package = ".;mt";
message LoginCluster
{
optional int32 instance_id = 1;
optional int32 listen_port = 2;
optional int32 http_listen_port = 3;
}
message LoginDb
{
optional string host = 1;
optional int32 port = 2;
optional string user = 3;
optional string passwd = 4;
optional string database = 5;
}
message Config
{
optional string gameapi_url = 1;
}

View File

@ -0,0 +1,2 @@
protoc --go_out=..\cs .\cs_*.proto
protoc --go_out=..\ss .\ss_*.proto

View File

@ -0,0 +1,12 @@
package ca
import (
"f5"
"main/api/ca"
)
type AnncRouter struct{}
func (this *AnncRouter) InitAnncRouter() {
f5.GetApp().RegisterCaHandle("Annc", "getAnnouncement", ca.ApiGroupApp.AnncApi.GetAnnouncement)
}

View File

@ -0,0 +1,7 @@
package ca
type RouterGroup struct {
LoginRouter
AnncRouter
ServerSwitchRouter
}

View File

@ -0,0 +1,13 @@
package ca
import (
"f5"
"main/api/ca"
)
type LoginRouter struct{}
func (this *LoginRouter) InitLoginRouter() {
f5.GetApp().RegisterCaHandle("Login", "getNonce", ca.ApiGroupApp.LoginApi.GetNonce)
f5.GetApp().RegisterCaHandle("Login", "auth", ca.ApiGroupApp.LoginApi.Auth)
}

View File

@ -0,0 +1,13 @@
package ca
import (
"f5"
"main/api/ca"
)
type ServerSwitchRouter struct{}
func (this *ServerSwitchRouter) InitServerSwitchRouter() {
f5.GetApp().RegisterCaHandle("ServerSwitch", "getSwitch", ca.ApiGroupApp.ServerSwitchApi.GetSwitch)
f5.GetApp().RegisterCaHandle("ServerSwitch", "getWhiteList", ca.ApiGroupApp.ServerSwitchApi.GetWhiteList)
}

View File

@ -0,0 +1,12 @@
package router
import (
"main/constant"
"main/global"
)
var _routerMgr = new(routerMgr)
func init() {
global.RegModule(constant.ROUTER_MGR_MODULE_IDX, _routerMgr)
}

View File

@ -0,0 +1,5 @@
package nft
type RouterGroup struct {
NftMetaRouter
}

View File

@ -0,0 +1,14 @@
package nft
import (
"f5"
"main/api/v1"
)
type NftMetaRouter struct{}
func (this *NftMetaRouter) InitRouter() {
api := v1.ApiGroupApp.NftApiGroup
f5.GetApp().GetGinEngine().GET("hero/meta/:tokenId", api.NftMetaApi.Hero)
f5.GetApp().GetGinEngine().GET("gold_bullion/meta/:tokenId", api.NftMetaApi.GoldBullion)
}

View File

@ -0,0 +1,30 @@
package router
import (
"f5"
"main/router/ca"
"main/router/nft"
)
type routerMgr struct {
ca ca.RouterGroup
nft nft.RouterGroup
}
func (this *routerMgr) Init() {
/*
f5.GetApp().GetGinEngine().Use(middleware.Cors())
*/
this.ca.InitLoginRouter()
this.ca.InitAnncRouter()
this.ca.InitServerSwitchRouter()
this.nft.NftMetaRouter.InitRouter()
f5.GetSysLog().Info("routerMgr.init")
}
func (this *routerMgr) UnInit() {
}