一波更新
This commit is contained in:
parent
22ac6c1fed
commit
5f3a40a50e
@ -1,38 +0,0 @@
|
|||||||
module admincenter
|
|
||||||
|
|
||||||
go 1.22.2
|
|
||||||
|
|
||||||
replace (
|
|
||||||
common => ../common
|
|
||||||
framework => ../../framework
|
|
||||||
goutil => ../../goutil
|
|
||||||
)
|
|
||||||
|
|
||||||
require (
|
|
||||||
common v0.0.0-00010101000000-000000000000
|
|
||||||
goutil v0.0.0-20230425160006-b2d0b0a0b0b0
|
|
||||||
)
|
|
||||||
|
|
||||||
require (
|
|
||||||
filippo.io/edwards25519 v1.1.0 // indirect
|
|
||||||
framework v0.0.0-20230425160006-b2d0b0a0b0b0 // indirect
|
|
||||||
github.com/cespare/xxhash/v2 v2.1.2 // indirect
|
|
||||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
|
||||||
github.com/elastic/go-elasticsearch/v8 v8.0.0-20210916085751-c2fb55d91ba4 // indirect
|
|
||||||
github.com/fatih/color v1.15.0 // indirect
|
|
||||||
github.com/go-redis/redis/v8 v8.11.5 // indirect
|
|
||||||
github.com/go-sql-driver/mysql v1.8.1 // indirect
|
|
||||||
github.com/gomodule/redigo v1.8.9 // indirect
|
|
||||||
github.com/gorilla/websocket v1.4.2 // indirect
|
|
||||||
github.com/jinzhu/gorm v1.9.12 // indirect
|
|
||||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
|
||||||
github.com/jinzhu/now v1.1.5 // indirect
|
|
||||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
|
||||||
github.com/mattn/go-isatty v0.0.17 // indirect
|
|
||||||
golang.org/x/net v0.0.0-20210916014120-12bc252f5db8 // indirect
|
|
||||||
golang.org/x/sys v0.6.0 // indirect
|
|
||||||
golang.org/x/text v0.21.0 // indirect
|
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
|
|
||||||
gorm.io/driver/mysql v1.5.7 // indirect
|
|
||||||
gorm.io/gorm v1.25.12 // indirect
|
|
||||||
)
|
|
||||||
@ -1,17 +0,0 @@
|
|||||||
module Framework
|
|
||||||
|
|
||||||
go 1.22.2
|
|
||||||
|
|
||||||
replace goutil => ../goutil
|
|
||||||
|
|
||||||
require (
|
|
||||||
github.com/Shopify/sarama v1.29.1
|
|
||||||
github.com/go-sql-driver/mysql v1.5.0
|
|
||||||
github.com/gorilla/websocket v1.4.2
|
|
||||||
github.com/jinzhu/gorm v1.9.12
|
|
||||||
github.com/rabbitmq/amqp091-go v1.8.1
|
|
||||||
github.com/samuel/go-zookeeper v0.0.0-20201211165307-7117e9ea2414
|
|
||||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.230
|
|
||||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vms v1.0.230
|
|
||||||
goutil v0.0.0-00010101000000-000000000000
|
|
||||||
)
|
|
||||||
@ -1,46 +0,0 @@
|
|||||||
package user
|
|
||||||
|
|
||||||
import (
|
|
||||||
"common/connection"
|
|
||||||
"goutil/logUtilPlus"
|
|
||||||
)
|
|
||||||
|
|
||||||
// AddUser 添加用户
|
|
||||||
// AddUser 添加新的用户到数据库中。
|
|
||||||
// 参数 User: 包含用户信息的对象。
|
|
||||||
// 返回值: 插入操作影响的行数和可能发生的错误。
|
|
||||||
func AddUser(User *User) (int64, error) {
|
|
||||||
|
|
||||||
//处理一些验证
|
|
||||||
|
|
||||||
// 写入到数据库
|
|
||||||
result := connection.GetUserDB().Create(&User) // 通过数据的指针来创建
|
|
||||||
|
|
||||||
if result.Error != nil {
|
|
||||||
logUtilPlus.ErrorLog("添加用户失败 错误信息:", result.Error.Error())
|
|
||||||
}
|
|
||||||
return User.ID, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetUserByID 根据用户ID获取用户信息
|
|
||||||
func GetUserByID(UserID int64) (*User, error) {
|
|
||||||
var User User
|
|
||||||
|
|
||||||
//缓存判断等一些设置
|
|
||||||
|
|
||||||
result := connection.GetUserDB().First(&User, UserID)
|
|
||||||
if result.Error != nil {
|
|
||||||
return nil, result.Error
|
|
||||||
}
|
|
||||||
return &User, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// 用户登录
|
|
||||||
func Login(account string, password string) (*User, error) {
|
|
||||||
var User User
|
|
||||||
result := connection.GetUserDB().Where("account = ? AND password = ?", account, password).First(&User)
|
|
||||||
if result.Error != nil {
|
|
||||||
return nil, result.Error
|
|
||||||
}
|
|
||||||
return &User, nil
|
|
||||||
}
|
|
||||||
@ -1 +0,0 @@
|
|||||||
package user
|
|
||||||
@ -1,36 +0,0 @@
|
|||||||
module logincenter
|
|
||||||
|
|
||||||
go 1.22.10
|
|
||||||
|
|
||||||
replace (
|
|
||||||
common => ../common
|
|
||||||
framework => ../framework
|
|
||||||
goutil => ../goutil
|
|
||||||
)
|
|
||||||
|
|
||||||
require common v0.0.0-00010101000000-000000000000
|
|
||||||
|
|
||||||
require (
|
|
||||||
filippo.io/edwards25519 v1.1.0 // indirect
|
|
||||||
framework v0.0.0-20230425160006-b2d0b0a0b0b0 // indirect
|
|
||||||
github.com/cespare/xxhash/v2 v2.1.2 // indirect
|
|
||||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
|
||||||
github.com/elastic/go-elasticsearch/v8 v8.0.0-20210916085751-c2fb55d91ba4 // indirect
|
|
||||||
github.com/fatih/color v1.15.0 // indirect
|
|
||||||
github.com/go-redis/redis/v8 v8.11.5 // indirect
|
|
||||||
github.com/go-sql-driver/mysql v1.8.1 // indirect
|
|
||||||
github.com/gomodule/redigo v1.8.9 // indirect
|
|
||||||
github.com/gorilla/websocket v1.4.2 // indirect
|
|
||||||
github.com/jinzhu/gorm v1.9.12 // indirect
|
|
||||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
|
||||||
github.com/jinzhu/now v1.1.5 // indirect
|
|
||||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
|
||||||
github.com/mattn/go-isatty v0.0.17 // indirect
|
|
||||||
golang.org/x/net v0.0.0-20210916014120-12bc252f5db8 // indirect
|
|
||||||
golang.org/x/sys v0.6.0 // indirect
|
|
||||||
golang.org/x/text v0.21.0 // indirect
|
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
|
|
||||||
gorm.io/driver/mysql v1.5.7 // indirect
|
|
||||||
gorm.io/gorm v1.25.12 // indirect
|
|
||||||
goutil v0.0.0-20230425160006-b2d0b0a0b0b0 // indirect
|
|
||||||
)
|
|
||||||
Binary file not shown.
@ -1,31 +0,0 @@
|
|||||||
package connection
|
|
||||||
|
|
||||||
var (
|
|
||||||
// 存放实体结构
|
|
||||||
dbModelMap = make([]interface{}, 0)
|
|
||||||
)
|
|
||||||
|
|
||||||
// RegisterDBModel 注册数据库模型到全局变量dbModelMap中。
|
|
||||||
// 这个函数接受一个interface{}类型的参数dbModel,表示数据库模型。
|
|
||||||
// 函数的目的是将传入的数据库模型添加到全局变量dbModelMap中,
|
|
||||||
// 以便在其他地方可以访问和使用这些数据库模型。
|
|
||||||
func RegisterDBModel(dbModel interface{}) {
|
|
||||||
// 将dbModel的地址添加到dbModelMap中。
|
|
||||||
// 这里使用地址是因为数据库模型可能比较大,通过引用存储可以提高效率。
|
|
||||||
dbModelMap = append(dbModelMap, &dbModel)
|
|
||||||
}
|
|
||||||
|
|
||||||
// BuildDB 用于遍历dbModelMap中的所有数据库模型,并检查每个模型对应的表是否存在于数据库中。
|
|
||||||
// 如果表不存在,则自动迁移(创建)该表。这样可以确保数据库模式与程序中的模型保持同步。
|
|
||||||
func BuildDB() {
|
|
||||||
// 遍历dbModelMap中的每个元素
|
|
||||||
for _, dbModel := range dbModelMap {
|
|
||||||
|
|
||||||
// 检查数据库中是否存在与dbModel对应的表
|
|
||||||
tableExists := GetAdminDB().Migrator().HasTable(dbModel)
|
|
||||||
if !tableExists {
|
|
||||||
// 如果表不存在,则进行自动迁移
|
|
||||||
GetAdminDB().AutoMigrate(dbModel)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,188 +0,0 @@
|
|||||||
package configYaml
|
|
||||||
|
|
||||||
import (
|
|
||||||
"goutil/logUtilPlus"
|
|
||||||
"goutil/mysqlUtil"
|
|
||||||
"goutil/redisUtil"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
// DbConfig
|
|
||||||
//
|
|
||||||
// @description: mysql配置对象
|
|
||||||
type DbConfig struct {
|
|
||||||
|
|
||||||
// 管理员数据库链接字符串
|
|
||||||
adminConfig *mysqlUtil.DBConfig
|
|
||||||
|
|
||||||
// 用户数据库链接字符串
|
|
||||||
userConfig *mysqlUtil.DBConfig
|
|
||||||
|
|
||||||
// 游戏模型数据库链接字符串
|
|
||||||
gameModelConfig *mysqlUtil.DBConfig
|
|
||||||
|
|
||||||
// 游戏数据库链接字符串
|
|
||||||
gameConfig *mysqlUtil.DBConfig
|
|
||||||
|
|
||||||
// 游戏数据库链接字符串
|
|
||||||
playerConfig *mysqlUtil.DBConfig
|
|
||||||
|
|
||||||
// redis配置对象
|
|
||||||
redisConfig *redisUtil.RedisConfig
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
// 数据库配置对象
|
|
||||||
dbConfigObj *DbConfig
|
|
||||||
)
|
|
||||||
|
|
||||||
// GetAdminConfig
|
|
||||||
// @description: 获取admin库配置
|
|
||||||
// parameter:
|
|
||||||
//
|
|
||||||
// @receiver config:config
|
|
||||||
//
|
|
||||||
// return:
|
|
||||||
//
|
|
||||||
// @*mysqlUtil.DBConfig:admin库配置
|
|
||||||
func (config *DbConfig) GetAdminConfig() *mysqlUtil.DBConfig {
|
|
||||||
return config.adminConfig
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetUserConfig
|
|
||||||
// @description: 获取user库配置
|
|
||||||
// parameter:
|
|
||||||
//
|
|
||||||
// @receiver config:config
|
|
||||||
//
|
|
||||||
// return:
|
|
||||||
//
|
|
||||||
// @*mysqlUtil.DBConfig:user库配置
|
|
||||||
func (config *DbConfig) GetUserConfig() *mysqlUtil.DBConfig {
|
|
||||||
return config.adminConfig
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetGameModelConfig
|
|
||||||
// @description: 获取model库配置
|
|
||||||
// parameter:
|
|
||||||
//
|
|
||||||
// @receiver config:config
|
|
||||||
//
|
|
||||||
// return:
|
|
||||||
//
|
|
||||||
// @*mysqlUtil.DBConfig:model库配置
|
|
||||||
func (config *DbConfig) GetGameModelConfig() *mysqlUtil.DBConfig {
|
|
||||||
return config.gameModelConfig
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetGameConfig
|
|
||||||
// @description: 获取Game库配置
|
|
||||||
// parameter:
|
|
||||||
//
|
|
||||||
// @receiver config:config
|
|
||||||
//
|
|
||||||
// return:
|
|
||||||
//
|
|
||||||
// @*mysqlUtil.DBConfig:Game库配置
|
|
||||||
func (config *DbConfig) GetGameConfig() *mysqlUtil.DBConfig {
|
|
||||||
return config.gameConfig
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetPlayerConfig
|
|
||||||
// @description: 获取玩家库配置
|
|
||||||
// parameter:
|
|
||||||
//
|
|
||||||
// @receiver config:config
|
|
||||||
//
|
|
||||||
// return:
|
|
||||||
//
|
|
||||||
// @*mysqlUtil.DBConfig:玩家库配置
|
|
||||||
func (config *DbConfig) GetPlayerConfig() *mysqlUtil.DBConfig {
|
|
||||||
return config.playerConfig
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetRedisConfig
|
|
||||||
// @description: 获取redis配置对象
|
|
||||||
// parameter:
|
|
||||||
//
|
|
||||||
// @receiver config:config
|
|
||||||
//
|
|
||||||
// return:
|
|
||||||
//
|
|
||||||
// @*redisUtil.RedisConfig:redis配置
|
|
||||||
func (config *DbConfig) GetRedisConfig() *redisUtil.RedisConfig {
|
|
||||||
return config.redisConfig
|
|
||||||
}
|
|
||||||
|
|
||||||
// newMysqlConfig
|
|
||||||
//
|
|
||||||
// @description: 创建新的Mysql配置对象
|
|
||||||
//
|
|
||||||
// parameter:
|
|
||||||
//
|
|
||||||
// @_gameModelConfig:
|
|
||||||
// @_gameConfig:
|
|
||||||
// @_playerConfig:
|
|
||||||
// @_redisConfig:
|
|
||||||
//
|
|
||||||
// return:
|
|
||||||
//
|
|
||||||
// @*DbConfig:
|
|
||||||
func newMysqlConfig(_adminConfig *mysqlUtil.DBConfig, _userConfig *mysqlUtil.DBConfig, _gameModelConfig *mysqlUtil.DBConfig,
|
|
||||||
_gameConfig *mysqlUtil.DBConfig,
|
|
||||||
_playerConfig *mysqlUtil.DBConfig,
|
|
||||||
_redisConfig *redisUtil.RedisConfig) *DbConfig {
|
|
||||||
return &DbConfig{
|
|
||||||
adminConfig: _adminConfig,
|
|
||||||
userConfig: _userConfig,
|
|
||||||
gameModelConfig: _gameModelConfig,
|
|
||||||
gameConfig: _gameConfig,
|
|
||||||
redisConfig: _redisConfig,
|
|
||||||
playerConfig: _playerConfig,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// initDbConfig
|
|
||||||
//
|
|
||||||
// @description: 初始化数据库配置
|
|
||||||
//
|
|
||||||
// parameter:
|
|
||||||
//
|
|
||||||
// @configObj: 数据库配置
|
|
||||||
//
|
|
||||||
// return:
|
|
||||||
//
|
|
||||||
// @error: 错误数据
|
|
||||||
func initDbConfig() error {
|
|
||||||
|
|
||||||
logUtilPlus.DebugLog("开始加载DbConfig")
|
|
||||||
|
|
||||||
redisConfig := ConfigYaml.Root.DbConfig.RedisConfig
|
|
||||||
|
|
||||||
//if redisConfig == nil {
|
|
||||||
// logUtilPlus.DebugLog("redis配置为空")
|
|
||||||
// return nil
|
|
||||||
//}
|
|
||||||
|
|
||||||
// 初始化mysql配置对象
|
|
||||||
dbConfigObj = newMysqlConfig(
|
|
||||||
mysqlUtil.NewDBConfig(ConfigYaml.Root.DbConfig.AdminDB.ConnectionString, ConfigYaml.Root.DbConfig.AdminDB.MaxOpenConns, ConfigYaml.Root.DbConfig.AdminDB.MaxIdleConns),
|
|
||||||
mysqlUtil.NewDBConfig(ConfigYaml.Root.DbConfig.UserDB.ConnectionString, ConfigYaml.Root.DbConfig.UserDB.MaxOpenConns, ConfigYaml.Root.DbConfig.UserDB.MaxIdleConns),
|
|
||||||
mysqlUtil.NewDBConfig(ConfigYaml.Root.DbConfig.GameModel.ConnectionString, ConfigYaml.Root.DbConfig.GameModel.MaxOpenConns, ConfigYaml.Root.DbConfig.GameModel.MaxIdleConns),
|
|
||||||
mysqlUtil.NewDBConfig(ConfigYaml.Root.DbConfig.GameDB.ConnectionString, ConfigYaml.Root.DbConfig.GameDB.MaxOpenConns, ConfigYaml.Root.DbConfig.GameDB.MaxIdleConns),
|
|
||||||
mysqlUtil.NewDBConfig(ConfigYaml.Root.DbConfig.PlayerDB.ConnectionString, ConfigYaml.Root.DbConfig.PlayerDB.MaxOpenConns, ConfigYaml.Root.DbConfig.PlayerDB.MaxIdleConns),
|
|
||||||
redisUtil.NewRedisConfig2(redisConfig.ConnectionString, redisConfig.Password, redisConfig.Database, redisConfig.MaxActive, redisConfig.MaxIdle, time.Duration(redisConfig.IdleTimeout)*time.Second, time.Duration(redisConfig.DialConnectTimeout)*time.Second))
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetDbConfig
|
|
||||||
//
|
|
||||||
// @description: 获取mysql配置
|
|
||||||
//
|
|
||||||
// parameter:
|
|
||||||
// return:
|
|
||||||
//
|
|
||||||
// @*DbConfig: mysql配置对象
|
|
||||||
func GetDbConfig() *DbConfig {
|
|
||||||
return dbConfigObj
|
|
||||||
}
|
|
||||||
@ -1,33 +0,0 @@
|
|||||||
module common
|
|
||||||
|
|
||||||
go 1.22.2
|
|
||||||
|
|
||||||
replace (
|
|
||||||
framework => ../../framework
|
|
||||||
goutil => ../../goutil
|
|
||||||
)
|
|
||||||
|
|
||||||
require (
|
|
||||||
github.com/go-redis/redis/v8 v8.11.5
|
|
||||||
gorm.io/driver/mysql v1.5.7
|
|
||||||
gorm.io/gorm v1.25.12
|
|
||||||
goutil v0.0.0-20230425160006-b2d0b0a0b0b0
|
|
||||||
framework v0.0.0-20230425160006-b2d0b0a0b0b0
|
|
||||||
)
|
|
||||||
|
|
||||||
require (
|
|
||||||
github.com/cespare/xxhash/v2 v2.1.2 // indirect
|
|
||||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
|
||||||
github.com/elastic/go-elasticsearch/v8 v8.0.0-20210916085751-c2fb55d91ba4 // indirect
|
|
||||||
github.com/fatih/color v1.15.0 // indirect
|
|
||||||
github.com/go-sql-driver/mysql v1.7.0 // indirect
|
|
||||||
github.com/gomodule/redigo v1.8.9 // indirect
|
|
||||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
|
||||||
github.com/jinzhu/now v1.1.5 // indirect
|
|
||||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
|
||||||
github.com/mattn/go-isatty v0.0.17 // indirect
|
|
||||||
github.com/stretchr/testify v1.8.0 // indirect
|
|
||||||
golang.org/x/net v0.0.0-20210916014120-12bc252f5db8 // indirect
|
|
||||||
golang.org/x/sys v0.6.0 // indirect
|
|
||||||
golang.org/x/text v0.14.0 // indirect
|
|
||||||
)
|
|
||||||
@ -1,43 +0,0 @@
|
|||||||
<root>
|
|
||||||
<!-- 是否是调试模式 -->
|
|
||||||
<DEBUG>true</DEBUG>
|
|
||||||
<!-- web服务监听地址和端口 -->
|
|
||||||
<WerbServerAddress>192.168.50.85:10051</WerbServerAddress>
|
|
||||||
<!-- es地址 -->
|
|
||||||
<EsUrls>http://10.252.0.70:18099</EsUrls>
|
|
||||||
<!-- 数据库配置 -->
|
|
||||||
<DbConfig>
|
|
||||||
<AdminDB>
|
|
||||||
<!-- 最大处于开启状态的连接数 -->
|
|
||||||
<MaxOpenConns>0</MaxOpenConns>
|
|
||||||
<!-- 最大处于空闲状态的连接数 -->
|
|
||||||
<MaxIdleConns>0</MaxIdleConns>
|
|
||||||
<!-- 数据库连接字符串 -->
|
|
||||||
<ConnectionString><![CDATA[root:Qq5201530300@tcp(192.168.50.110:3306)/admin?charset=utf8&parseTime=true&loc=Local&timeout=30s&multiStatements=true]]></ConnectionString>
|
|
||||||
</AdminDB>
|
|
||||||
<UserDB>
|
|
||||||
<!-- 最大处于开启状态的连接数 -->
|
|
||||||
<MaxOpenConns>0</MaxOpenConns>
|
|
||||||
<!-- 最大处于空闲状态的连接数 -->
|
|
||||||
<MaxIdleConns>0</MaxIdleConns>
|
|
||||||
<!-- 数据库连接字符串 -->
|
|
||||||
<ConnectionString><![CDATA[root:Qq5201530300@tcp(192.168.50.110:3306)/user?charset=utf8&parseTime=true&loc=Local&timeout=30s&multiStatements=true]]></ConnectionString>
|
|
||||||
</UserDB>
|
|
||||||
<RedisConfig>
|
|
||||||
<!-- 数据库连接字符串 -->
|
|
||||||
<ConnectionString>192.168.50.110:6379</ConnectionString>
|
|
||||||
<!-- 密码,如果要设置用户Id,则密码设置为:"UserId:Password" -->
|
|
||||||
<Password></Password>
|
|
||||||
<!-- 数据库序号 -->
|
|
||||||
<Database>5</Database>
|
|
||||||
<!-- 最大活跃连接数 -->
|
|
||||||
<MaxActive>500</MaxActive>
|
|
||||||
<!-- 最大空闲的连接数 -->
|
|
||||||
<MaxIdle>200</MaxIdle>
|
|
||||||
<!-- 连接空闲超时时间,单位:秒 -->
|
|
||||||
<IdleTimeout>300</IdleTimeout>
|
|
||||||
<!-- 连接超时时间,单位:秒 -->
|
|
||||||
<DialConnectTimeout>10</DialConnectTimeout>
|
|
||||||
</RedisConfig>
|
|
||||||
</DbConfig>
|
|
||||||
</root>
|
|
||||||
@ -1,38 +0,0 @@
|
|||||||
module admincenter
|
|
||||||
|
|
||||||
go 1.22.10
|
|
||||||
|
|
||||||
replace (
|
|
||||||
common => ../common
|
|
||||||
framework => ../framework
|
|
||||||
goutil => ../goutil
|
|
||||||
)
|
|
||||||
|
|
||||||
require (
|
|
||||||
common v0.0.0-00010101000000-000000000000
|
|
||||||
goutil v0.0.0-20230425160006-b2d0b0a0b0b0
|
|
||||||
)
|
|
||||||
|
|
||||||
require (
|
|
||||||
filippo.io/edwards25519 v1.1.0 // indirect
|
|
||||||
framework v0.0.0-20230425160006-b2d0b0a0b0b0 // indirect
|
|
||||||
github.com/cespare/xxhash/v2 v2.1.2 // indirect
|
|
||||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
|
||||||
github.com/elastic/go-elasticsearch/v8 v8.0.0-20210916085751-c2fb55d91ba4 // indirect
|
|
||||||
github.com/fatih/color v1.15.0 // indirect
|
|
||||||
github.com/go-redis/redis/v8 v8.11.5 // indirect
|
|
||||||
github.com/go-sql-driver/mysql v1.8.1 // indirect
|
|
||||||
github.com/gomodule/redigo v1.8.9 // indirect
|
|
||||||
github.com/gorilla/websocket v1.4.2 // indirect
|
|
||||||
github.com/jinzhu/gorm v1.9.12 // indirect
|
|
||||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
|
||||||
github.com/jinzhu/now v1.1.5 // indirect
|
|
||||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
|
||||||
github.com/mattn/go-isatty v0.0.17 // indirect
|
|
||||||
golang.org/x/net v0.0.0-20210916014120-12bc252f5db8 // indirect
|
|
||||||
golang.org/x/sys v0.6.0 // indirect
|
|
||||||
golang.org/x/text v0.21.0 // indirect
|
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
|
|
||||||
gorm.io/driver/mysql v1.5.7 // indirect
|
|
||||||
gorm.io/gorm v1.25.12 // indirect
|
|
||||||
)
|
|
||||||
@ -1,25 +0,0 @@
|
|||||||
module goutil
|
|
||||||
|
|
||||||
go 1.22.2
|
|
||||||
|
|
||||||
require (
|
|
||||||
github.com/bkaradzic/go-lz4 v1.0.0
|
|
||||||
github.com/elastic/go-elasticsearch/v8 v8.0.0-20210916085751-c2fb55d91ba4
|
|
||||||
github.com/fatih/color v1.15.0
|
|
||||||
github.com/go-sql-driver/mysql v1.5.0
|
|
||||||
github.com/gomodule/redigo v1.8.9
|
|
||||||
github.com/gorilla/websocket v1.4.2
|
|
||||||
golang.org/x/net v0.0.0-20210916014120-12bc252f5db8
|
|
||||||
google.golang.org/grpc v1.45.0
|
|
||||||
google.golang.org/protobuf v1.26.0
|
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c
|
|
||||||
)
|
|
||||||
|
|
||||||
require (
|
|
||||||
github.com/golang/protobuf v1.5.2 // indirect
|
|
||||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
|
||||||
github.com/mattn/go-isatty v0.0.17 // indirect
|
|
||||||
golang.org/x/sys v0.6.0 // indirect
|
|
||||||
golang.org/x/text v0.3.6 // indirect
|
|
||||||
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 // indirect
|
|
||||||
)
|
|
||||||
BIN
.svn/wc.db
BIN
.svn/wc.db
Binary file not shown.
@ -5,14 +5,67 @@
|
|||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="2037df1b-9ccc-4caa-9145-2d6722712612" name="更改" comment="">
|
<list default="true" id="2037df1b-9ccc-4caa-9145-2d6722712612" name="更改" comment="">
|
||||||
|
<change afterPath="$PROJECT_DIR$/center/common/rabbitmq/send_data.go" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/center/admincenter/config.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/center/admincenter/config.yaml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/center/admincenter/config.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/center/admincenter/config.yaml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/center/common/configsYaml/baseConfig.go" beforeDir="false" afterPath="$PROJECT_DIR$/center/common/configsYaml/baseConfig.go" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/center/admincenter/go.mod" beforeDir="false" afterPath="$PROJECT_DIR$/center/admincenter/go.mod" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/center/common/configsYaml/configYaml.go" beforeDir="false" afterPath="$PROJECT_DIR$/center/common/configsYaml/configYaml.go" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/center/admincenter/go.sum" beforeDir="false" afterPath="$PROJECT_DIR$/center/admincenter/go.sum" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/center/admincenter/internal/admin/admin.go" beforeDir="false" afterPath="$PROJECT_DIR$/center/admincenter/internal/admin/admin.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/center/admincenter/internal/admin/api.go" beforeDir="false" afterPath="$PROJECT_DIR$/center/admincenter/internal/admin/api.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/center/admincenter/internal/admin/logic.go" beforeDir="false" afterPath="$PROJECT_DIR$/center/admincenter/internal/admin/logic.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/center/admincenter/main.go" beforeDir="false" afterPath="$PROJECT_DIR$/center/admincenter/main.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/center/common/configsYaml/baseConfig.go" beforeDir="false" afterPath="$PROJECT_DIR$/center/common/configsyaml/baseConfig.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/center/common/configsYaml/configYaml.go" beforeDir="false" afterPath="$PROJECT_DIR$/center/common/configsyaml/configYaml.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/center/common/configsYaml/dbConfig.go" beforeDir="false" afterPath="$PROJECT_DIR$/center/common/configsyaml/dbConfig.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/center/common/configsYaml/functionConfig.go" beforeDir="false" afterPath="$PROJECT_DIR$/center/common/configsyaml/functionConfig.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/center/common/configsYaml/init.go" beforeDir="false" afterPath="$PROJECT_DIR$/center/common/configsyaml/init.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/center/common/configsYaml/logMgrConfig.go" beforeDir="false" afterPath="$PROJECT_DIR$/center/common/configsyaml/logMgrConfig.go" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/center/common/connection/dal.go" beforeDir="false" afterPath="$PROJECT_DIR$/center/common/connection/dal.go" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/center/common/connection/dal.go" beforeDir="false" afterPath="$PROJECT_DIR$/center/common/connection/dal.go" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/center/common/go.mod" beforeDir="false" afterPath="$PROJECT_DIR$/center/common/go.mod" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/center/common/connection/dal_test.go" beforeDir="false" afterPath="$PROJECT_DIR$/center/common/connection/dal_test.go" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/center/common/go.sum" beforeDir="false" afterPath="$PROJECT_DIR$/center/common/go.sum" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/center/common/connection/dbHead.go" beforeDir="false" afterPath="$PROJECT_DIR$/center/common/connection/dbHead.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/center/common/httpServer/apiContext.go" beforeDir="false" afterPath="$PROJECT_DIR$/center/common/httpServer/apiContext.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/center/common/httpServer/apiHandler.go" beforeDir="false" afterPath="$PROJECT_DIR$/center/common/httpServer/apiHandler.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/center/common/httpServer/start.go" beforeDir="false" afterPath="$PROJECT_DIR$/center/common/httpServer/start.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/center/common/rebbitMQ/config.go" beforeDir="false" afterPath="$PROJECT_DIR$/center/common/rabbitmq/config.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/center/common/rebbitMQ/sendData.go" beforeDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/center/common/remark/remarkMgr.go" beforeDir="false" afterPath="$PROJECT_DIR$/center/common/remark/remarkMgr.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/center/common/resultStatus/resultStatus.go" beforeDir="false" afterPath="$PROJECT_DIR$/center/common/resultstatus/resultStatus.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/center/common/resultStatus/resultStatusCode.go" beforeDir="false" afterPath="$PROJECT_DIR$/center/common/resultstatus/resultStatusCode.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/center/common/webServer/apiContext.go" beforeDir="false" afterPath="$PROJECT_DIR$/center/common/webserver/apiContext.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/center/common/webServer/apiHandler.go" beforeDir="false" afterPath="$PROJECT_DIR$/center/common/webserver/apiHandler.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/center/common/webServer/apiHandlerMgr.go" beforeDir="false" afterPath="$PROJECT_DIR$/center/common/webserver/apiHandlerMgr.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/center/common/webServer/reflect.go" beforeDir="false" afterPath="$PROJECT_DIR$/center/common/webserver/reflect.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/center/common/webServer/reflectMethod.go" beforeDir="false" afterPath="$PROJECT_DIR$/center/common/webserver/reflectMethod.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/center/common/webServer/reflectRequestObject.go" beforeDir="false" afterPath="$PROJECT_DIR$/center/common/webserver/reflectRequestObject.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/center/common/webServer/responseObject.go" beforeDir="false" afterPath="$PROJECT_DIR$/center/common/webserver/responseObject.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/center/common/webServer/result.go" beforeDir="false" afterPath="$PROJECT_DIR$/center/common/webserver/result.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/center/common/webServer/serverMux.go" beforeDir="false" afterPath="$PROJECT_DIR$/center/common/webserver/serverMux.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/center/common/webServer/start.go" beforeDir="false" afterPath="$PROJECT_DIR$/center/common/webserver/start.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/center/common/webServer/tokenHandler.go" beforeDir="false" afterPath="$PROJECT_DIR$/center/common/webserver/tokenHandler.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/center/dbcenter/01_test.go" beforeDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/center/dbcenter/go.mod" beforeDir="false" afterPath="$PROJECT_DIR$/center/dbcenter/go.mod" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/center/dbcenter/go.sum" beforeDir="false" afterPath="$PROJECT_DIR$/center/dbcenter/go.sum" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/center/dbcenter/main.go" beforeDir="false" afterPath="$PROJECT_DIR$/center/dbcenter/main.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/center/paycenter/config.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/center/paycenter/config.yaml" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/center/paycenter/internal/pay.go" beforeDir="false" afterPath="$PROJECT_DIR$/center/paycenter/internal/pay.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/center/paycenter/internal/pay/api.go" beforeDir="false" afterPath="$PROJECT_DIR$/center/paycenter/internal/pay/api.go" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/center/paycenter/internal/pay/logic.go" beforeDir="false" afterPath="$PROJECT_DIR$/center/paycenter/internal/pay/logic.go" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/center/paycenter/internal/pay/logic.go" beforeDir="false" afterPath="$PROJECT_DIR$/center/paycenter/internal/pay/logic.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/center/paycenter/internal/pay/order.go" beforeDir="false" afterPath="$PROJECT_DIR$/center/paycenter/internal/pay/order.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/center/paycenter/internal/wxpaycofnig/payconfig.go" beforeDir="false" afterPath="$PROJECT_DIR$/center/paycenter/internal/wxpaycofnig/payconfig.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/center/paycenter/main.go" beforeDir="false" afterPath="$PROJECT_DIR$/center/paycenter/main.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/center/paycenter/payconfig/wxpayconfig.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/center/paycenter/payconfig/wxpayconfig.yml" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/center/usercenter/LOG/2025/1/2025-01-02.tar.gz" beforeDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/center/usercenter/LOG/2025/1/2025-01-03-10.debug.txt" beforeDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/center/usercenter/LOG/2025/1/2025-01-03-10.warn.txt" beforeDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/center/usercenter/config.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/center/usercenter/config.yaml" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/center/usercenter/go.mod" beforeDir="false" afterPath="$PROJECT_DIR$/center/usercenter/go.mod" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/center/usercenter/go.sum" beforeDir="false" afterPath="$PROJECT_DIR$/center/usercenter/go.sum" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/center/usercenter/internal/game/api.go" beforeDir="false" afterPath="$PROJECT_DIR$/center/usercenter/internal/game/api.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/center/usercenter/internal/game/logic.go" beforeDir="false" afterPath="$PROJECT_DIR$/center/usercenter/internal/game/logic.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/center/usercenter/internal/user.go" beforeDir="false" afterPath="$PROJECT_DIR$/center/usercenter/internal/user.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/center/usercenter/internal/user/api.go" beforeDir="false" afterPath="$PROJECT_DIR$/center/usercenter/internal/user/api.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/center/usercenter/internal/user/user.go" beforeDir="false" afterPath="$PROJECT_DIR$/center/usercenter/internal/user/user.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/center/usercenter/main.go" beforeDir="false" afterPath="$PROJECT_DIR$/center/usercenter/main.go" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
@ -52,9 +105,14 @@
|
|||||||
"Docker.admincenter.redis: Compose 部署.executor": "Run",
|
"Docker.admincenter.redis: Compose 部署.executor": "Run",
|
||||||
"Docker.center/admincenter/Dockerfile builder.executor": "Run",
|
"Docker.center/admincenter/Dockerfile builder.executor": "Run",
|
||||||
"Go 构建.go build admincenter.executor": "Run",
|
"Go 构建.go build admincenter.executor": "Run",
|
||||||
|
"Go 构建.go build dbcenter.executor": "Debug",
|
||||||
"Go 构建.go build logincenter.executor": "Debug",
|
"Go 构建.go build logincenter.executor": "Debug",
|
||||||
"Go 构建.go build usercenter.executor": "Debug",
|
"Go 构建.go build usercenter.executor": "Run",
|
||||||
|
"Go 测试.common/connection 中的 TestGetDBName.executor": "Run",
|
||||||
|
"Go 测试.dbcenter 中的 Test000.executor": "Debug",
|
||||||
|
"Go 测试.dbcenter 中的 Test001 (1).executor": "Debug",
|
||||||
"Go 测试.dbcenter 中的 Test001.executor": "Run",
|
"Go 测试.dbcenter 中的 Test001.executor": "Run",
|
||||||
|
"Go 测试.dbcenter 中的 Test002 (1).executor": "Run",
|
||||||
"Go 测试.dbcenter 中的 Test002.executor": "Run",
|
"Go 测试.dbcenter 中的 Test002.executor": "Run",
|
||||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||||
"RunOnceActivity.go.formatter.settings.were.checked": "true",
|
"RunOnceActivity.go.formatter.settings.were.checked": "true",
|
||||||
@ -63,23 +121,28 @@
|
|||||||
"git-widget-placeholder": "master",
|
"git-widget-placeholder": "master",
|
||||||
"go.import.settings.migrated": "true",
|
"go.import.settings.migrated": "true",
|
||||||
"go.sdk.automatically.set": "true",
|
"go.sdk.automatically.set": "true",
|
||||||
"last_opened_file_path": "D:/workspace/e2023/goProject/trunk/game/common",
|
"last_opened_file_path": "D:/workspace/e2023/goProject/trunk/center/usercenter/internal/wxuser2",
|
||||||
"node.js.detected.package.eslint": "true",
|
"node.js.detected.package.eslint": "true",
|
||||||
"node.js.selected.package.eslint": "(autodetect)",
|
"node.js.selected.package.eslint": "(autodetect)",
|
||||||
"nodejs_package_manager_path": "npm",
|
"nodejs_package_manager_path": "npm",
|
||||||
"settings.editor.selected.configurable": "org.intellij.sdk.editor.settings.AppSettingsConfigurable"
|
"settings.editor.selected.configurable": "org.intellij.sdk.editor.settings.AppSettingsConfigurable"
|
||||||
|
},
|
||||||
|
"keyToStringList": {
|
||||||
|
"DatabaseDriversLRU": [
|
||||||
|
"mysql_aurora"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}]]></component>
|
}]]></component>
|
||||||
<component name="RecentsManager">
|
<component name="RecentsManager">
|
||||||
<key name="CopyFile.RECENT_KEYS">
|
<key name="CopyFile.RECENT_KEYS">
|
||||||
|
<recent name="D:\workspace\e2023\goProject\trunk\center\usercenter\internal\wxuser2" />
|
||||||
|
<recent name="D:\workspace\e2023\goProject\trunk\center\dbcenter\internal" />
|
||||||
|
<recent name="D:\workspace\e2023\goProject\trunk\center\dbcenter" />
|
||||||
<recent name="D:\workspace\e2023\goProject\trunk\game\common" />
|
<recent name="D:\workspace\e2023\goProject\trunk\game\common" />
|
||||||
<recent name="D:\workspace\e2023\goProject\trunk\game\common\model" />
|
<recent name="D:\workspace\e2023\goProject\trunk\game\common\model" />
|
||||||
<recent name="D:\workspace\e2023\goProject\trunk\center\logincenter\internal\game" />
|
|
||||||
<recent name="D:\workspace\e2023\goProject\trunk\center\logincenter" />
|
|
||||||
<recent name="D:\workspace\e2023\goProject\trunk\center" />
|
|
||||||
</key>
|
</key>
|
||||||
</component>
|
</component>
|
||||||
<component name="RunManager" selected="Go 测试.dbcenter 中的 Test002">
|
<component name="RunManager" selected="Go 测试.common/connection 中的 TestGetDBName">
|
||||||
<configuration name="go build admincenter" type="GoApplicationRunConfiguration" factoryName="Go Application" temporary="true" nameIsGenerated="true">
|
<configuration name="go build admincenter" type="GoApplicationRunConfiguration" factoryName="Go Application" temporary="true" nameIsGenerated="true">
|
||||||
<module name="trunk" />
|
<module name="trunk" />
|
||||||
<working_directory value="$PROJECT_DIR$/center/admincenter" />
|
<working_directory value="$PROJECT_DIR$/center/admincenter" />
|
||||||
@ -89,7 +152,37 @@
|
|||||||
<filePath value="$PROJECT_DIR$/center/admincenter/main.go" />
|
<filePath value="$PROJECT_DIR$/center/admincenter/main.go" />
|
||||||
<method v="2" />
|
<method v="2" />
|
||||||
</configuration>
|
</configuration>
|
||||||
<configuration name="dbcenter 中的 Test001" type="GoTestRunConfiguration" factoryName="Go Test" temporary="true" nameIsGenerated="true">
|
<configuration name="go build dbcenter" type="GoApplicationRunConfiguration" factoryName="Go Application" temporary="true" nameIsGenerated="true">
|
||||||
|
<module name="trunk" />
|
||||||
|
<working_directory value="$PROJECT_DIR$/center/dbcenter" />
|
||||||
|
<kind value="PACKAGE" />
|
||||||
|
<package value="dbcenter" />
|
||||||
|
<directory value="$PROJECT_DIR$" />
|
||||||
|
<filePath value="$PROJECT_DIR$/center/dbcenter/main.go" />
|
||||||
|
<method v="2" />
|
||||||
|
</configuration>
|
||||||
|
<configuration name="go build usercenter" type="GoApplicationRunConfiguration" factoryName="Go Application" temporary="true" nameIsGenerated="true">
|
||||||
|
<module name="trunk" />
|
||||||
|
<working_directory value="$PROJECT_DIR$/center/usercenter" />
|
||||||
|
<kind value="PACKAGE" />
|
||||||
|
<package value="usercenter" />
|
||||||
|
<directory value="$PROJECT_DIR$" />
|
||||||
|
<filePath value="$PROJECT_DIR$/center/usercenter/main.go" />
|
||||||
|
<method v="2" />
|
||||||
|
</configuration>
|
||||||
|
<configuration name="common/connection 中的 TestGetDBName" type="GoTestRunConfiguration" factoryName="Go Test" temporary="true" nameIsGenerated="true">
|
||||||
|
<module name="trunk" />
|
||||||
|
<working_directory value="$PROJECT_DIR$/center/common/connection" />
|
||||||
|
<root_directory value="$PROJECT_DIR$/center/common" />
|
||||||
|
<kind value="PACKAGE" />
|
||||||
|
<package value="common/connection" />
|
||||||
|
<directory value="$PROJECT_DIR$" />
|
||||||
|
<filePath value="$PROJECT_DIR$" />
|
||||||
|
<framework value="gotest" />
|
||||||
|
<pattern value="^\QTestGetDBName\E$" />
|
||||||
|
<method v="2" />
|
||||||
|
</configuration>
|
||||||
|
<configuration name="dbcenter 中的 Test001 (1)" type="GoTestRunConfiguration" factoryName="Go Test" temporary="true" nameIsGenerated="true">
|
||||||
<module name="trunk" />
|
<module name="trunk" />
|
||||||
<working_directory value="$PROJECT_DIR$/center/dbcenter" />
|
<working_directory value="$PROJECT_DIR$/center/dbcenter" />
|
||||||
<kind value="PACKAGE" />
|
<kind value="PACKAGE" />
|
||||||
@ -100,17 +193,6 @@
|
|||||||
<pattern value="^\QTest001\E$" />
|
<pattern value="^\QTest001\E$" />
|
||||||
<method v="2" />
|
<method v="2" />
|
||||||
</configuration>
|
</configuration>
|
||||||
<configuration name="dbcenter 中的 Test002" type="GoTestRunConfiguration" factoryName="Go Test" temporary="true" nameIsGenerated="true">
|
|
||||||
<module name="trunk" />
|
|
||||||
<working_directory value="$PROJECT_DIR$/center/dbcenter" />
|
|
||||||
<kind value="PACKAGE" />
|
|
||||||
<package value="dbcenter" />
|
|
||||||
<directory value="$PROJECT_DIR$" />
|
|
||||||
<filePath value="$PROJECT_DIR$" />
|
|
||||||
<framework value="gotest" />
|
|
||||||
<pattern value="^\QTest002\E$" />
|
|
||||||
<method v="2" />
|
|
||||||
</configuration>
|
|
||||||
<configuration default="true" type="docker-deploy" factoryName="docker-compose.yml" temporary="true">
|
<configuration default="true" type="docker-deploy" factoryName="docker-compose.yml" temporary="true">
|
||||||
<deployment type="docker-compose.yml">
|
<deployment type="docker-compose.yml">
|
||||||
<settings />
|
<settings />
|
||||||
@ -123,36 +205,13 @@
|
|||||||
</deployment>
|
</deployment>
|
||||||
<method v="2" />
|
<method v="2" />
|
||||||
</configuration>
|
</configuration>
|
||||||
<configuration name="admincenter.redis: Compose 部署" type="docker-deploy" factoryName="docker-compose.yml" temporary="true" server-name="Docker">
|
|
||||||
<deployment type="docker-compose.yml">
|
|
||||||
<settings>
|
|
||||||
<option name="services">
|
|
||||||
<list>
|
|
||||||
<option value="redis" />
|
|
||||||
</list>
|
|
||||||
</option>
|
|
||||||
<option name="sourceFilePath" value="center/admincenter/docker-compose.yml" />
|
|
||||||
</settings>
|
|
||||||
</deployment>
|
|
||||||
<method v="2" />
|
|
||||||
</configuration>
|
|
||||||
<configuration name="center/admincenter/Dockerfile builder" type="docker-deploy" factoryName="dockerfile" temporary="true" server-name="Docker">
|
|
||||||
<deployment type="dockerfile">
|
|
||||||
<settings>
|
|
||||||
<option name="imageTag" value="golang1.20_builder" />
|
|
||||||
<option name="buildCliOptions" value="--target builder" />
|
|
||||||
<option name="sourceFilePath" value="center/admincenter/Dockerfile" />
|
|
||||||
</settings>
|
|
||||||
</deployment>
|
|
||||||
<method v="2" />
|
|
||||||
</configuration>
|
|
||||||
<recent_temporary>
|
<recent_temporary>
|
||||||
<list>
|
<list>
|
||||||
<item itemvalue="Go 测试.dbcenter 中的 Test002" />
|
<item itemvalue="Go 测试.common/connection 中的 TestGetDBName" />
|
||||||
<item itemvalue="Go 测试.dbcenter 中的 Test001" />
|
|
||||||
<item itemvalue="Go 构建.go build admincenter" />
|
<item itemvalue="Go 构建.go build admincenter" />
|
||||||
<item itemvalue="Docker.center/admincenter/Dockerfile builder" />
|
<item itemvalue="Go 构建.go build usercenter" />
|
||||||
<item itemvalue="Docker.admincenter.redis: Compose 部署" />
|
<item itemvalue="Go 构建.go build dbcenter" />
|
||||||
|
<item itemvalue="Go 测试.dbcenter 中的 Test001 (1)" />
|
||||||
</list>
|
</list>
|
||||||
</recent_temporary>
|
</recent_temporary>
|
||||||
</component>
|
</component>
|
||||||
@ -179,11 +238,6 @@
|
|||||||
<line>68</line>
|
<line>68</line>
|
||||||
<option name="timeStamp" value="8" />
|
<option name="timeStamp" value="8" />
|
||||||
</line-breakpoint>
|
</line-breakpoint>
|
||||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
|
||||||
<url>file://$PROJECT_DIR$/center/usercenter/internal/user/logic.go</url>
|
|
||||||
<line>104</line>
|
|
||||||
<option name="timeStamp" value="23" />
|
|
||||||
</line-breakpoint>
|
|
||||||
</breakpoints>
|
</breakpoints>
|
||||||
</breakpoint-manager>
|
</breakpoint-manager>
|
||||||
</component>
|
</component>
|
||||||
|
|||||||
@ -10,13 +10,20 @@ root:
|
|||||||
es_urls: "http://10.252.0.70:18099"
|
es_urls: "http://10.252.0.70:18099"
|
||||||
|
|
||||||
# RabbitMQ 配置
|
# RabbitMQ 配置
|
||||||
rabbitmq_config: "amqp://guest:guest@localhost:5672/"
|
rabbitmq_address: "amqp://admin:admin@192.168.50.85:5672/"
|
||||||
|
|
||||||
# mq队列名称
|
# mq队列名称
|
||||||
mq_queue_name: "admin_center"
|
mq_queue_name: "admin_center"
|
||||||
|
|
||||||
|
# 是否通过mq执行sql
|
||||||
|
sql_use_mq: true
|
||||||
|
|
||||||
# 数据库配置
|
# 数据库配置
|
||||||
db_config:
|
db_config:
|
||||||
|
|
||||||
|
# 实时更新数据库数量{玩家库/用户库}
|
||||||
|
db_num: [0]
|
||||||
|
|
||||||
admin_db:
|
admin_db:
|
||||||
# 最大处于开启状态的连接数
|
# 最大处于开启状态的连接数
|
||||||
max_open_conns: 0
|
max_open_conns: 0
|
||||||
|
|||||||
@ -29,10 +29,11 @@ require (
|
|||||||
github.com/jinzhu/now v1.1.5 // indirect
|
github.com/jinzhu/now v1.1.5 // indirect
|
||||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||||
github.com/mattn/go-isatty v0.0.17 // indirect
|
github.com/mattn/go-isatty v0.0.17 // indirect
|
||||||
|
github.com/streadway/amqp v1.1.0 // indirect
|
||||||
golang.org/x/net v0.0.0-20210916014120-12bc252f5db8 // indirect
|
golang.org/x/net v0.0.0-20210916014120-12bc252f5db8 // indirect
|
||||||
golang.org/x/sys v0.6.0 // indirect
|
golang.org/x/sys v0.6.0 // indirect
|
||||||
golang.org/x/text v0.21.0 // indirect
|
golang.org/x/text v0.21.0 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
gorm.io/driver/mysql v1.5.7 // indirect
|
gorm.io/driver/mysql v1.5.7 // indirect
|
||||||
gorm.io/gorm v1.25.12 // indirect
|
gorm.io/gorm v1.25.12 // indirect
|
||||||
)
|
)
|
||||||
|
|||||||
@ -53,6 +53,8 @@ github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE=
|
|||||||
github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs=
|
github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
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/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
|
github.com/streadway/amqp v1.1.0 h1:py12iX8XSyI7aN/3dUT8DFIDJazNJsVJdxNVEpnQTZM=
|
||||||
|
github.com/streadway/amqp v1.1.0/go.mod h1:WYSrTEYHOXHd0nwFeUXAe2G2hRnQT+deZJJf88uS9Bg=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
|
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
|
||||||
@ -80,8 +82,9 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkep
|
|||||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
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.7 h1:MndhOPYOfEp2rHKgkZIhJ16eVUIRf2HmzgoPmh7FCWo=
|
gorm.io/driver/mysql v1.5.7 h1:MndhOPYOfEp2rHKgkZIhJ16eVUIRf2HmzgoPmh7FCWo=
|
||||||
gorm.io/driver/mysql v1.5.7/go.mod h1:sEtPWMiqiN1N1cMXoXmBbd8C6/l+TESwriotuRRpkDM=
|
gorm.io/driver/mysql v1.5.7/go.mod h1:sEtPWMiqiN1N1cMXoXmBbd8C6/l+TESwriotuRRpkDM=
|
||||||
gorm.io/gorm v1.25.7/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8=
|
gorm.io/gorm v1.25.7/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8=
|
||||||
|
|||||||
@ -2,11 +2,14 @@ package admin
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"common/connection"
|
"common/connection"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
//注册数据库
|
//注册数据库
|
||||||
connection.RegisterDBModel(&Admin{})
|
connection.RegisterDBModel(&Admin{})
|
||||||
|
connection.RegisterDBModel(&RecordLoginOfWxUser{})
|
||||||
|
connection.RegisterDBModel(&RecordWatchADOfWxUser{})
|
||||||
}
|
}
|
||||||
|
|
||||||
type Admin struct {
|
type Admin struct {
|
||||||
@ -29,6 +32,32 @@ type Admin struct {
|
|||||||
Describe string `gorm:"column:describe;comment:备注" json:"describe"`
|
Describe string `gorm:"column:describe;comment:备注" json:"describe"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 登录相关的记录
|
||||||
|
type RecordLoginOfWxUser struct {
|
||||||
|
ID int64 `gorm:"column:id;primary_key;comment:自增索引;autoIncrementIncrement" json:"id"`
|
||||||
|
Uid int64 `gorm:"column:uid;comment:用户唯一Id" json:"uid"`
|
||||||
|
LoginInTime int64 `gorm:"column:loginintime;comment:登录时间" json:"loginintime"`
|
||||||
|
LoginOutTime int64 `gorm:"column:loginouttime;comment:登出时间" json:"loginouttime"`
|
||||||
|
PlayTimes int64 `gorm:"column:playtimes;comment:游玩时长" json:"playtimes"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// 看广告相关记录
|
||||||
|
// 记录日期便于按天统计
|
||||||
|
type RecordWatchADOfWxUser struct {
|
||||||
|
ID int64 `gorm:"column:id;primary_key;comment:自增索引;autoIncrementIncrement" json:"id"`
|
||||||
|
RecordDate time.Time `gorm:"column:recorddate;type:date;comment:记录日期" json:"recorddate"`
|
||||||
|
Uid int64 `gorm:"column:uid;comment:用户唯一Id" json:"uid"`
|
||||||
|
WatchADNum int32 `gorm:"column:watchadnum;comment:看广告次数" json:"watchadnum"`
|
||||||
|
}
|
||||||
|
|
||||||
func (Admin) TableName() string {
|
func (Admin) TableName() string {
|
||||||
return "admin"
|
return "admin"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (RecordLoginOfWxUser) TableName() string {
|
||||||
|
return "recordloginofwxuser"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (RecordWatchADOfWxUser) TableName() string {
|
||||||
|
return "recordwatchadofwxuser"
|
||||||
|
}
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package admin
|
package admin
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"common/mytime"
|
||||||
"common/remark"
|
"common/remark"
|
||||||
"common/resultStatus"
|
"common/resultStatus"
|
||||||
"common/webServer"
|
"common/webServer"
|
||||||
@ -201,3 +202,56 @@ func (a *AdminApi) Login(account string, password string) (responseObj *webServe
|
|||||||
responseObj.SetData(resultMap)
|
responseObj.SetData(resultMap)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 查询玩家登录相关记录
|
||||||
|
func init() {
|
||||||
|
moduleName := "AdminApi"
|
||||||
|
methodName := "QueryloginRecord"
|
||||||
|
skipVerifyTokenPage := true
|
||||||
|
methodDesc := "查询玩家登录相关记录"
|
||||||
|
methodAuthor := "youjinlan"
|
||||||
|
methodMendor := ""
|
||||||
|
methodDate := "2025-01-21 16:00:00"
|
||||||
|
methodInParam := []string{"int64:uid"}
|
||||||
|
methodOutParam := `
|
||||||
|
{
|
||||||
|
"Code '类型:int'": "响应结果的状态值",
|
||||||
|
"Message '类型:string'": "响应结果的状态值所对应的描述信息",
|
||||||
|
"Data '类型:interface{}'": "响应结果的数据"
|
||||||
|
{
|
||||||
|
"FirstLoginTime '类型:int64'": "首次登录时间",
|
||||||
|
"PlayDayNum '类型:int32'": "生命周期",
|
||||||
|
"PlayTimes '类型:int64'": "在线时长",
|
||||||
|
}
|
||||||
|
}`
|
||||||
|
|
||||||
|
remark.RegisterMethodRemark(moduleName, methodName, methodDesc, methodAuthor, methodMendor, methodDate, methodInParam, methodOutParam, skipVerifyTokenPage)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *AdminApi) QueryloginRecord(uid int64) (responseObj *webServer.ResponseObject) {
|
||||||
|
responseObj = webServer.GetInitResponseObj()
|
||||||
|
//验证参数
|
||||||
|
if uid == 0 {
|
||||||
|
responseObj.SetResultStatus(resultStatus.APIDataError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var userfirstRecord *RecordLoginOfWxUser
|
||||||
|
if userfirstRecord, _ = GetUserFirstRecord(uid); userfirstRecord == nil {
|
||||||
|
responseObj.SetResultStatus(resultStatus.PlayerNotExist)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
userLastRecord, _ := GetUserLastRecord(uid)
|
||||||
|
firstLoginInTime := userfirstRecord.LoginInTime
|
||||||
|
var lastLoginOutTime int64
|
||||||
|
if userLastRecord.LoginOutTime == 0 {
|
||||||
|
lastLoginOutTime = userLastRecord.LoginInTime
|
||||||
|
}
|
||||||
|
lastLoginOutTime = userLastRecord.LoginOutTime
|
||||||
|
playDayNum := mytime.DiffDays(lastLoginOutTime, firstLoginInTime)
|
||||||
|
resultMap := make(map[string]any)
|
||||||
|
resultMap["FirstLoginTime"] = firstLoginInTime
|
||||||
|
resultMap["PlayDayNum"] = playDayNum
|
||||||
|
resultMap["PlayTimes"] = GetUserTotalPlayTime(uid)
|
||||||
|
responseObj.SetData(resultMap)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|||||||
@ -14,7 +14,7 @@ func AddAdmin(admin *Admin) (int64, error) {
|
|||||||
//处理一些验证
|
//处理一些验证
|
||||||
|
|
||||||
// 写入到数据库
|
// 写入到数据库
|
||||||
result := connection.GetAdminDB().Create(&admin) // 通过数据的指针来创建
|
result := connection.Create(connection.GetAdminDB(), &admin, 0) // 通过数据的指针来创建
|
||||||
|
|
||||||
if result.Error != nil {
|
if result.Error != nil {
|
||||||
logUtilPlus.ErrorLog("添加管理员失败 错误信息:", result.Error.Error())
|
logUtilPlus.ErrorLog("添加管理员失败 错误信息:", result.Error.Error())
|
||||||
@ -41,3 +41,29 @@ func Login(account string, password string) (*Admin, error) {
|
|||||||
}
|
}
|
||||||
return &admin, nil
|
return &admin, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 查询玩家首次登录登出记录
|
||||||
|
func GetUserFirstRecord(uid int64) (*RecordLoginOfWxUser, error) {
|
||||||
|
var userRecord *RecordLoginOfWxUser
|
||||||
|
result := connection.GetUserDB().Where("uid = ?", uid).First(&userRecord)
|
||||||
|
if result.Error != nil {
|
||||||
|
return nil, result.Error
|
||||||
|
}
|
||||||
|
return userRecord, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询玩家最新登录登出记录
|
||||||
|
func GetUserLastRecord(uid int64) (*RecordLoginOfWxUser, error) {
|
||||||
|
var userRecord *RecordLoginOfWxUser
|
||||||
|
result := connection.GetUserDB().Where("uid = ?", uid).Last(&userRecord)
|
||||||
|
if result.Error != nil {
|
||||||
|
return nil, result.Error
|
||||||
|
}
|
||||||
|
return userRecord, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetUserTotalPlayTime(uid int64) int64 {
|
||||||
|
var totalPlayTime int64
|
||||||
|
connection.GetUserDB().Table("recordloginofwxuser").Where("uid = ?", uid).Select("SUM(playtimes)").Scan(&totalPlayTime)
|
||||||
|
return totalPlayTime
|
||||||
|
}
|
||||||
|
|||||||
@ -37,6 +37,7 @@ func loadConfig() {
|
|||||||
|
|
||||||
//设置数据类型
|
//设置数据类型
|
||||||
connection.SetModelDB(connection.GetAdminDB())
|
connection.SetModelDB(connection.GetAdminDB())
|
||||||
|
connection.SetModelDB(connection.GetUserDB())
|
||||||
|
|
||||||
//构建数据库
|
//构建数据库
|
||||||
connection.BuildDB()
|
connection.BuildDB()
|
||||||
|
|||||||
@ -42,6 +42,12 @@ var (
|
|||||||
|
|
||||||
// RabbitMQName mq队列名称
|
// RabbitMQName mq队列名称
|
||||||
RabbitMQName string
|
RabbitMQName string
|
||||||
|
|
||||||
|
// SqlUseMQ 是否使用mq执行sql
|
||||||
|
SqlUseMQ bool
|
||||||
|
|
||||||
|
//微信登录相关配置
|
||||||
|
Wxconfig WxConfig
|
||||||
)
|
)
|
||||||
|
|
||||||
// initBaseConfig
|
// initBaseConfig
|
||||||
@ -80,6 +86,11 @@ func initBaseConfig() {
|
|||||||
Rabbitmq = root.RabbitMQAddress
|
Rabbitmq = root.RabbitMQAddress
|
||||||
|
|
||||||
RabbitMQName = root.RabbitMQName
|
RabbitMQName = root.RabbitMQName
|
||||||
|
|
||||||
|
SqlUseMQ = root.SqlUseMQ
|
||||||
|
|
||||||
|
Wxconfig = root.Wxconfig
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDebug
|
// GetDebug
|
||||||
@ -98,6 +109,10 @@ func GetWebServerAddress() string {
|
|||||||
return WebServerAddress
|
return WebServerAddress
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetWxconfig() WxConfig {
|
||||||
|
return Wxconfig
|
||||||
|
}
|
||||||
|
|
||||||
// GetEsUrls 返回配置文件中 Elasticsearch 的 URL 地址。
|
// GetEsUrls 返回配置文件中 Elasticsearch 的 URL 地址。
|
||||||
//
|
//
|
||||||
// 该函数通过访问全局变量 ConfigYaml,获取其 Root 字段下的 EsUrls 属性,
|
// 该函数通过访问全局变量 ConfigYaml,获取其 Root 字段下的 EsUrls 属性,
|
||||||
@ -114,3 +129,7 @@ func GetRabbitMQAddress() string {
|
|||||||
func GetRabbitMQName() string {
|
func GetRabbitMQName() string {
|
||||||
return RabbitMQName
|
return RabbitMQName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetSqlUseMQ() bool {
|
||||||
|
return SqlUseMQ
|
||||||
|
}
|
||||||
@ -21,6 +21,9 @@ type Root struct {
|
|||||||
// logmgr 配置
|
// logmgr 配置
|
||||||
LogMgr LogMgr `yaml:"log_mgr"`
|
LogMgr LogMgr `yaml:"log_mgr"`
|
||||||
|
|
||||||
|
// 微信登录配置
|
||||||
|
Wxconfig WxConfig `yaml:"wx_config"`
|
||||||
|
|
||||||
// Web 服务监听地址和端口
|
// Web 服务监听地址和端口
|
||||||
WebServerAddress string `yaml:"web_server_address"`
|
WebServerAddress string `yaml:"web_server_address"`
|
||||||
|
|
||||||
@ -49,6 +52,9 @@ type Root struct {
|
|||||||
// mq队列名称
|
// mq队列名称
|
||||||
RabbitMQName string `yaml:"mq_queue_name"`
|
RabbitMQName string `yaml:"mq_queue_name"`
|
||||||
|
|
||||||
|
// 是否使用mq执行sql
|
||||||
|
SqlUseMQ bool `yaml:"sql_use_mq"`
|
||||||
|
|
||||||
// 数据库配置
|
// 数据库配置
|
||||||
DbConfig DBConfig `yaml:"db_config"`
|
DbConfig DBConfig `yaml:"db_config"`
|
||||||
|
|
||||||
@ -59,6 +65,14 @@ type Root struct {
|
|||||||
FunctionConfig FunctionConf `yaml:"function_config"`
|
FunctionConfig FunctionConf `yaml:"function_config"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type WxConfig struct {
|
||||||
|
|
||||||
|
//微信移动应用appId
|
||||||
|
AppId string `yaml:"appId"`
|
||||||
|
//微信移动应用appSecret
|
||||||
|
AppSecret string `yaml:"appSecret"`
|
||||||
|
}
|
||||||
|
|
||||||
// ManagerCenterConf 是 ManagerCenter 的配置结构体
|
// ManagerCenterConf 是 ManagerCenter 的配置结构体
|
||||||
type ManagerCenterConf struct {
|
type ManagerCenterConf struct {
|
||||||
// ManagerCenter API 的 URL
|
// ManagerCenter API 的 URL
|
||||||
@ -86,6 +100,9 @@ type LogMgr struct {
|
|||||||
// DBConfig 包含数据库和 Redis 的配置
|
// DBConfig 包含数据库和 Redis 的配置
|
||||||
type DBConfig struct {
|
type DBConfig struct {
|
||||||
|
|
||||||
|
// 实时更新数据库数量{玩家库/用户库}
|
||||||
|
DBNum []int `yaml:"db_num"`
|
||||||
|
|
||||||
//管理员数据库配置
|
//管理员数据库配置
|
||||||
AdminDB DatabaseConfig `yaml:"admin_db"`
|
AdminDB DatabaseConfig `yaml:"admin_db"`
|
||||||
|
|
||||||
@ -12,6 +12,9 @@ import (
|
|||||||
// @description: mysql配置对象
|
// @description: mysql配置对象
|
||||||
type DbConfig struct {
|
type DbConfig struct {
|
||||||
|
|
||||||
|
// 实时更新数据库数量{玩家库/用户库}
|
||||||
|
dbNum []int
|
||||||
|
|
||||||
// 管理员数据库链接字符串
|
// 管理员数据库链接字符串
|
||||||
adminConfig *mysqlUtil.DBConfig
|
adminConfig *mysqlUtil.DBConfig
|
||||||
|
|
||||||
@ -144,11 +147,12 @@ func (config *DbConfig) GetRedisConfig() *redisUtil.RedisConfig {
|
|||||||
// return:
|
// return:
|
||||||
//
|
//
|
||||||
// @*DbConfig:
|
// @*DbConfig:
|
||||||
func newMysqlConfig(_adminConfig *mysqlUtil.DBConfig, _userConfig *mysqlUtil.DBConfig, _payConfig *mysqlUtil.DBConfig, _gameModelConfig *mysqlUtil.DBConfig,
|
func newMysqlConfig(_dbNum []int, _adminConfig *mysqlUtil.DBConfig, _userConfig *mysqlUtil.DBConfig, _payConfig *mysqlUtil.DBConfig, _gameModelConfig *mysqlUtil.DBConfig,
|
||||||
_gameConfig *mysqlUtil.DBConfig,
|
_gameConfig *mysqlUtil.DBConfig,
|
||||||
_playerConfig *mysqlUtil.DBConfig,
|
_playerConfig *mysqlUtil.DBConfig,
|
||||||
_redisConfig *redisUtil.RedisConfig) *DbConfig {
|
_redisConfig *redisUtil.RedisConfig) *DbConfig {
|
||||||
return &DbConfig{
|
return &DbConfig{
|
||||||
|
dbNum: _dbNum,
|
||||||
adminConfig: _adminConfig,
|
adminConfig: _adminConfig,
|
||||||
userConfig: _userConfig,
|
userConfig: _userConfig,
|
||||||
payConfig: _payConfig,
|
payConfig: _payConfig,
|
||||||
@ -183,7 +187,7 @@ func initDbConfig() error {
|
|||||||
//}
|
//}
|
||||||
|
|
||||||
// 初始化mysql配置对象
|
// 初始化mysql配置对象
|
||||||
dbConfigObj = newMysqlConfig(
|
dbConfigObj = newMysqlConfig(dbConfig.DBNum,
|
||||||
mysqlUtil.NewDBConfig(dbConfig.AdminDB.ConnectionString, dbConfig.AdminDB.MaxOpenConns, dbConfig.AdminDB.MaxIdleConns),
|
mysqlUtil.NewDBConfig(dbConfig.AdminDB.ConnectionString, dbConfig.AdminDB.MaxOpenConns, dbConfig.AdminDB.MaxIdleConns),
|
||||||
mysqlUtil.NewDBConfig(dbConfig.UserDB.ConnectionString, dbConfig.UserDB.MaxOpenConns, dbConfig.UserDB.MaxIdleConns),
|
mysqlUtil.NewDBConfig(dbConfig.UserDB.ConnectionString, dbConfig.UserDB.MaxOpenConns, dbConfig.UserDB.MaxIdleConns),
|
||||||
mysqlUtil.NewDBConfig(dbConfig.PayDB.ConnectionString, dbConfig.PayDB.MaxOpenConns, dbConfig.PayDB.MaxIdleConns),
|
mysqlUtil.NewDBConfig(dbConfig.PayDB.ConnectionString, dbConfig.PayDB.MaxOpenConns, dbConfig.PayDB.MaxIdleConns),
|
||||||
@ -205,3 +209,7 @@ func initDbConfig() error {
|
|||||||
func GetDbConfig() *DbConfig {
|
func GetDbConfig() *DbConfig {
|
||||||
return dbConfigObj
|
return dbConfigObj
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetDBNum() []int {
|
||||||
|
return dbConfigObj.dbNum
|
||||||
|
}
|
||||||
@ -4,11 +4,12 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"framework/sqlAsyncMgr"
|
"framework/sqlAsyncMgr"
|
||||||
|
"goutil/logUtilPlus"
|
||||||
|
"time"
|
||||||
|
|
||||||
goredis "github.com/go-redis/redis/v8"
|
goredis "github.com/go-redis/redis/v8"
|
||||||
"gorm.io/driver/mysql"
|
"gorm.io/driver/mysql"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
"goutil/logUtilPlus"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
// _ "github.com/go-sql-driver/mysql"
|
// _ "github.com/go-sql-driver/mysql"
|
||||||
config "common/configsYaml"
|
config "common/configsYaml"
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package connection
|
package connection
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@ -29,3 +30,7 @@ func TestExecute(t *testing.T) {
|
|||||||
_ = result.Error // 返回 error
|
_ = result.Error // 返回 error
|
||||||
_ = result.RowsAffected // 返回插入记录的条数
|
_ = result.RowsAffected // 返回插入记录的条数
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestGetDBName(t *testing.T) {
|
||||||
|
fmt.Print(time.Now().Format("200601"))
|
||||||
|
}
|
||||||
|
|||||||
@ -1,6 +1,13 @@
|
|||||||
package connection
|
package connection
|
||||||
|
|
||||||
import "gorm.io/gorm"
|
import (
|
||||||
|
config "common/configsYaml"
|
||||||
|
"common/rabbitmq"
|
||||||
|
"gorm.io/gorm"
|
||||||
|
"goutil/logUtilPlus"
|
||||||
|
"strconv"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// 存放实体结构
|
// 存放实体结构
|
||||||
@ -32,10 +39,137 @@ func BuildDB() {
|
|||||||
for _, dbModel := range dbModelMap {
|
for _, dbModel := range dbModelMap {
|
||||||
|
|
||||||
// 检查数据库中是否存在与dbModel对应的表
|
// 检查数据库中是否存在与dbModel对应的表
|
||||||
tableExists := modelDB.Migrator().HasTable(dbModel)
|
CheckTableExists(modelDB, dbModel)
|
||||||
if !tableExists {
|
|
||||||
// 如果表不存在,则进行自动迁移
|
|
||||||
modelDB.AutoMigrate(dbModel)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CheckTableExists 检查表是否存在,不存在则添加
|
||||||
|
func CheckTableExists(db *gorm.DB, value interface{}) bool {
|
||||||
|
|
||||||
|
// 检查数据库中是否存在与dbModel对应的表
|
||||||
|
tableExists := db.Migrator().HasTable(value)
|
||||||
|
if !tableExists {
|
||||||
|
// 如果表不存在,则进行自动迁移
|
||||||
|
err := db.AutoMigrate(value)
|
||||||
|
if err != nil {
|
||||||
|
logUtilPlus.ErrorLog("CheckTableExists is err: %v", err.Error())
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetMonth 获取当前月份
|
||||||
|
func GetMonth() int32 {
|
||||||
|
month, err := strconv.Atoi(time.Now().Format("200601"))
|
||||||
|
if err != nil {
|
||||||
|
logUtilPlus.ErrorLog("GetMonth is err: %v", err.Error())
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
return int32(month)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetToMonthAdd 获取当前月份 加上指定个月
|
||||||
|
func GetToMonthAdd(monthCount int32) int32 {
|
||||||
|
month, err := strconv.Atoi(time.Now().AddDate(0, int(monthCount), 0).Format("200601"))
|
||||||
|
if err != nil {
|
||||||
|
logUtilPlus.ErrorLog("GetToMonthAdd is err: %v", err.Error())
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
return int32(month)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create 添加数据
|
||||||
|
// @param db 数据库连接
|
||||||
|
// @param value 值
|
||||||
|
// @param dbIndex mq队列索引
|
||||||
|
func Create(db *gorm.DB, value interface{}, dbIndex int32) *gorm.DB {
|
||||||
|
|
||||||
|
result := &gorm.DB{Error: nil}
|
||||||
|
|
||||||
|
//检查表是否存在
|
||||||
|
CheckTableExists(db, value)
|
||||||
|
|
||||||
|
//转换sql mq远程执行
|
||||||
|
if config.GetSqlUseMQ() {
|
||||||
|
sql := db.ToSQL(func(tx *gorm.DB) *gorm.DB {
|
||||||
|
return tx.Model(value).Create(value)
|
||||||
|
})
|
||||||
|
|
||||||
|
//推送数据到mq
|
||||||
|
rabbitmq.SendMqData(dbIndex, sql)
|
||||||
|
|
||||||
|
//直接返回
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
result = db.Create(value)
|
||||||
|
if result.Error != nil {
|
||||||
|
logUtilPlus.ErrorLog("数据创建失败:", result.Error.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save 保存数据
|
||||||
|
func Save(db *gorm.DB, value interface{}, dbIndex int32) *gorm.DB {
|
||||||
|
|
||||||
|
result := &gorm.DB{Error: nil}
|
||||||
|
|
||||||
|
//转换sql mq远程执行
|
||||||
|
if config.GetSqlUseMQ() {
|
||||||
|
sql := db.ToSQL(func(tx *gorm.DB) *gorm.DB {
|
||||||
|
return tx.Model(value).Save(value)
|
||||||
|
})
|
||||||
|
|
||||||
|
//推送数据到mq
|
||||||
|
rabbitmq.SendMqData(dbIndex, sql)
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
result = db.Save(value)
|
||||||
|
|
||||||
|
if result.Error != nil {
|
||||||
|
logUtilPlus.ErrorLog("数据保存失败:", result.Error.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
// AsyncCreate 异步创建数据
|
||||||
|
func AsyncCreate(db *gorm.DB, value interface{}) {
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
|
||||||
|
//检查表是否存在
|
||||||
|
CheckTableExists(db, value)
|
||||||
|
result := db.Create(value)
|
||||||
|
if result.Error != nil {
|
||||||
|
logUtilPlus.ErrorLog("AsyncCreate is err: %v", result.Error)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
|
// AsyncSave 异步保存数据
|
||||||
|
func AsyncSave(db *gorm.DB, value interface{}) {
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
result := db.Save(value)
|
||||||
|
if result.Error != nil {
|
||||||
|
logUtilPlus.ErrorLog("AsyncSave is err : %v", result.Error)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
|
// AsyncDelete 异步删除数据
|
||||||
|
func AsyncDelete(db *gorm.DB, value interface{}) {
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
result := db.Delete(value)
|
||||||
|
if result.Error != nil {
|
||||||
|
logUtilPlus.ErrorLog("AsyncDelete is err : %v", result.Error)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|||||||
@ -3,11 +3,11 @@ package httpServer
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"goutil/logUtilPlus"
|
||||||
|
"goutil/typeUtil"
|
||||||
|
"goutil/zlibUtil"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"goutil/logUtilPlus"
|
|
||||||
"goutil/typeUtil"
|
|
||||||
"goutil/zlibUtil"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// ApiContext
|
// ApiContext
|
||||||
@ -184,6 +184,7 @@ func NewApiContext(_request *http.Request, _responseWriter http.ResponseWriter,
|
|||||||
// 读取数据
|
// 读取数据
|
||||||
_, errMsg := context.readContent(isZlib)
|
_, errMsg := context.readContent(isZlib)
|
||||||
if errMsg != nil {
|
if errMsg != nil {
|
||||||
|
|
||||||
return nil, errMsg
|
return nil, errMsg
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
package httpServer
|
package httpServer
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"common/webServer"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"common/resultStatus"
|
"common/resultStatus"
|
||||||
|
"common/webServer"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 处理函数
|
// 处理函数
|
||||||
@ -59,7 +59,7 @@ func (this *ApiHandler) FuncParamNames() []string {
|
|||||||
// @receiver this: this
|
// @receiver this: this
|
||||||
// @r:
|
// @r:
|
||||||
// return:
|
// return:
|
||||||
// @resultStatus.ResultStatus: 状态码数据
|
// @resultstatus.ResultStatus: 状态码数据
|
||||||
func (this *ApiHandler) CheckParam(r *http.Request) resultStatus.ResultStatus {
|
func (this *ApiHandler) CheckParam(r *http.Request) resultStatus.ResultStatus {
|
||||||
for _, name := range this.funcParamNames {
|
for _, name := range this.funcParamNames {
|
||||||
if r.Form[name] == nil || len(r.Form[name]) == 0 {
|
if r.Form[name] == nil || len(r.Form[name]) == 0 {
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import (
|
|||||||
|
|
||||||
"goutil/logUtil"
|
"goutil/logUtil"
|
||||||
"goutil/logUtilPlus"
|
"goutil/logUtilPlus"
|
||||||
|
|
||||||
// "log"
|
// "log"
|
||||||
"net/http/pprof"
|
"net/http/pprof"
|
||||||
|
|
||||||
|
|||||||
29
trunk/center/common/mytime/timefuncs.go
Normal file
29
trunk/center/common/mytime/timefuncs.go
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
package mytime
|
||||||
|
|
||||||
|
import (
|
||||||
|
"goutil/logUtilPlus"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
/*func GetZeroTime(t int64, timezone int) int64 {
|
||||||
|
return t - (t+int64(timezone))%86400
|
||||||
|
}
|
||||||
|
|
||||||
|
func IsDiffDay(second, first int64, timezone int) int {
|
||||||
|
secondZeroTime := GetZeroTime(second, timezone)
|
||||||
|
firstZeroTime := GetZeroTime(first, timezone)
|
||||||
|
return int(secondZeroTime/86400 - firstZeroTime/86400)
|
||||||
|
}*/
|
||||||
|
|
||||||
|
func DiffDays(new, old int64) int64 {
|
||||||
|
newZeroTime := ZeroTime(new, 0)
|
||||||
|
oldZeroTime := ZeroTime(old, 0)
|
||||||
|
logUtilPlus.ErrorLog("newZeroTime=%d,oldZeroTime=%d", newZeroTime, oldZeroTime)
|
||||||
|
return newZeroTime/86400 - oldZeroTime/86400
|
||||||
|
}
|
||||||
|
|
||||||
|
func ZeroTime(sec, nsec int64) int64 {
|
||||||
|
dateStr := time.Unix(sec, nsec).Format("2006-01-02")
|
||||||
|
t, _ := time.ParseInLocation("2006-01-02", dateStr, time.Local)
|
||||||
|
return t.Unix()
|
||||||
|
}
|
||||||
59
trunk/center/common/rabbitmq/config.go
Normal file
59
trunk/center/common/rabbitmq/config.go
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
package rabbitmq
|
||||||
|
|
||||||
|
import (
|
||||||
|
configYaml "common/configsYaml"
|
||||||
|
"goutil/logUtil"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/streadway/amqp"
|
||||||
|
)
|
||||||
|
|
||||||
|
var RabbitMQConn *amqp.Connection
|
||||||
|
var RabbitMQChannel *amqp.Channel
|
||||||
|
|
||||||
|
// 初始化rabbitMQ
|
||||||
|
func init() {
|
||||||
|
|
||||||
|
rabbitMQAddress := configYaml.GetRabbitMQAddress()
|
||||||
|
|
||||||
|
//是否有mq配置
|
||||||
|
if rabbitMQAddress == "" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 连接到 RabbitMQ 服务器
|
||||||
|
var err error
|
||||||
|
RabbitMQConn, err = amqp.Dial(rabbitMQAddress)
|
||||||
|
if err != nil {
|
||||||
|
|
||||||
|
//抛出一个异常
|
||||||
|
logUtil.FatalLog("Failed to connect to RabbitMQ: %s,err:%s", rabbitMQAddress, err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
// 打开一个通道
|
||||||
|
RabbitMQChannel, err = RabbitMQConn.Channel()
|
||||||
|
if err != nil {
|
||||||
|
|
||||||
|
//抛出一个异常
|
||||||
|
logUtil.FatalLog("Failed to open a channel,err:%s", err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
//循环数据库数量
|
||||||
|
for _, index := range configYaml.GetDBNum() {
|
||||||
|
//队列名称
|
||||||
|
queueName := configYaml.GetRabbitMQName() + ":" + strconv.Itoa(index)
|
||||||
|
|
||||||
|
// 声明一个队列
|
||||||
|
_, err = RabbitMQChannel.QueueDeclare(
|
||||||
|
queueName, // 队列名称
|
||||||
|
true, // 是否持久化
|
||||||
|
false, // 是否在使用后删除
|
||||||
|
false, // 是否排他
|
||||||
|
false, // 是否阻塞
|
||||||
|
nil, // 其他参数
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
logUtil.FatalLog("Failed to declare a queue,queueName:%s,err:%s", queueName, err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
55
trunk/center/common/rabbitmq/consume_data.go
Normal file
55
trunk/center/common/rabbitmq/consume_data.go
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
package rabbitmq
|
||||||
|
|
||||||
|
import (
|
||||||
|
configYaml "common/configsYaml"
|
||||||
|
"goutil/logUtilPlus"
|
||||||
|
"strconv"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ConsumeData 消费mq数据
|
||||||
|
func ConsumeData(handler func(data string) error) {
|
||||||
|
|
||||||
|
// 确保通道启用了 Publisher Confirms
|
||||||
|
if err := RabbitMQChannel.Confirm(false); err != nil {
|
||||||
|
logUtilPlus.ErrorLog("channel could not be put into confirm mode: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
//循环数据库数量
|
||||||
|
for _, index := range configYaml.GetDBNum() {
|
||||||
|
|
||||||
|
rabbitMQName := configYaml.GetRabbitMQName() + ":" + strconv.Itoa(index)
|
||||||
|
|
||||||
|
// 注册一个消费者
|
||||||
|
msgs, err := RabbitMQChannel.Consume(
|
||||||
|
rabbitMQName, // 队列名称
|
||||||
|
"", // 消费者名称
|
||||||
|
false, // 是否自动确认
|
||||||
|
false, // 是否排他
|
||||||
|
false, // 是否本地
|
||||||
|
false, // 是否阻塞
|
||||||
|
nil, // 其他参数
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
logUtilPlus.ErrorLog("Failed to register a consumer,err:%s", err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
// 启动一个 goroutine 来处理消息
|
||||||
|
go func() {
|
||||||
|
for d := range msgs {
|
||||||
|
|
||||||
|
// 消息处理
|
||||||
|
if err = handler(string(d.Body)); err != nil {
|
||||||
|
|
||||||
|
// 消息处理失败,记录错误日志
|
||||||
|
|
||||||
|
logUtilPlus.ErrorLog("Failed to handle message, err:%s", err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
// 消息处理完成后手动确认
|
||||||
|
if err := d.Ack(false); err != nil {
|
||||||
|
logUtilPlus.ErrorLog("Failed to acknowledge message, err:%s", err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
}
|
||||||
34
trunk/center/common/rabbitmq/send_data.go
Normal file
34
trunk/center/common/rabbitmq/send_data.go
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
package rabbitmq
|
||||||
|
|
||||||
|
import (
|
||||||
|
configYaml "common/configsYaml"
|
||||||
|
"goutil/logUtilPlus"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/streadway/amqp"
|
||||||
|
)
|
||||||
|
|
||||||
|
// SendMqData 发送单挑mq消息
|
||||||
|
func SendMqData(dbIndex int32, data string) {
|
||||||
|
|
||||||
|
rabbitMQName := configYaml.GetRabbitMQName() + ":" + strconv.Itoa(int(dbIndex))
|
||||||
|
|
||||||
|
// 确保通道启用了 Publisher Confirms
|
||||||
|
if err := RabbitMQChannel.Confirm(false); err != nil {
|
||||||
|
logUtilPlus.ErrorLog("channel could not be put into confirm mode: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 发布消息到队列
|
||||||
|
err := RabbitMQChannel.Publish(
|
||||||
|
"", // 交换机名称
|
||||||
|
rabbitMQName, // 路由键
|
||||||
|
false, // 是否强制
|
||||||
|
false, // 是否立即
|
||||||
|
amqp.Publishing{
|
||||||
|
ContentType: "text/plain",
|
||||||
|
Body: []byte(data),
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
logUtilPlus.ErrorLog("Failed to publish a message,err:%s", err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,910 +0,0 @@
|
|||||||
package resultStatus
|
|
||||||
|
|
||||||
// 系统错误码
|
|
||||||
var (
|
|
||||||
// 成功
|
|
||||||
Success = NewResultStatus(0, "Success")
|
|
||||||
|
|
||||||
// 数据库错误
|
|
||||||
DBError = NewResultStatus(-2, "DBError")
|
|
||||||
|
|
||||||
// 方法未定义
|
|
||||||
MethodNotDefined = NewResultStatus(-3, "MethodNotDefined")
|
|
||||||
|
|
||||||
// 参数无效
|
|
||||||
ParamInValid = NewResultStatus(-4, "ParamInValid")
|
|
||||||
|
|
||||||
// 参数不匹配
|
|
||||||
ParamNotMatch = NewResultStatus(-5, "ParamNotMatch")
|
|
||||||
|
|
||||||
// 功能未开启
|
|
||||||
ModuleNotOpen = NewResultStatus(-6, "ModuleNotOpen")
|
|
||||||
|
|
||||||
// 只支持Post
|
|
||||||
OnlySupportPOST = NewResultStatus(-7, "OnlySupportPOST")
|
|
||||||
|
|
||||||
// API未定义
|
|
||||||
APINotDefined = NewResultStatus(-8, "APINotDefined")
|
|
||||||
|
|
||||||
// API数据错误
|
|
||||||
APIDataError = NewResultStatus(-9, "APIDataError")
|
|
||||||
|
|
||||||
// API参数错误
|
|
||||||
APIParamError = NewResultStatus(-10, "APIParamError")
|
|
||||||
|
|
||||||
// IP被禁用
|
|
||||||
IPForbid = NewResultStatus(-11, "IPForbid")
|
|
||||||
|
|
||||||
// 没有有效的服务器
|
|
||||||
NoAvailableServer = NewResultStatus(-12, "NoAvailableServer")
|
|
||||||
|
|
||||||
// 服务器组不存在
|
|
||||||
ServerGroupNotExists = NewResultStatus(-13, "ServerGroupNotExists")
|
|
||||||
|
|
||||||
// 测试接口只能debug下调用
|
|
||||||
DebugInterface = NewResultStatus(-14, "DebugInterface")
|
|
||||||
|
|
||||||
// 模块不存在
|
|
||||||
ModuleNotExists = NewResultStatus(-15, "ModuleNotExists")
|
|
||||||
|
|
||||||
// 未能找到指定方法
|
|
||||||
NotSpecificMethod = NewResultStatus(-16, "NotSpecificMethod")
|
|
||||||
|
|
||||||
// 非指定区域
|
|
||||||
NotMatchRegion = NewResultStatus(-17, "NotMatchRegion")
|
|
||||||
|
|
||||||
// 发送空数据
|
|
||||||
SendNullData = NewResultStatus(-18, "SendNullData")
|
|
||||||
|
|
||||||
// 序列化失败
|
|
||||||
MarshalDataError = NewResultStatus(-19, "MarshalDataError")
|
|
||||||
|
|
||||||
//未登录
|
|
||||||
NotLogin = NewResultStatus(-20, "NotLogin")
|
|
||||||
|
|
||||||
// 数据错误
|
|
||||||
DataError = NewResultStatus(-31, "DataError")
|
|
||||||
|
|
||||||
// 战区合并维护中,敬请期待
|
|
||||||
MergeDataRunning = NewResultStatus(-67, "MergeDataRunning")
|
|
||||||
|
|
||||||
// 下载器内容未配置
|
|
||||||
QcDownloadConfigNotExists = NewResultStatus(-68, "QcDownloadConfigNotExists")
|
|
||||||
|
|
||||||
// 下载器奖励已领取
|
|
||||||
QcDownloadHasReward = NewResultStatus(-69, "QcDownloadHasReward")
|
|
||||||
|
|
||||||
// 下载器奖励没有奖励可领取
|
|
||||||
QcDownloadNotReward = NewResultStatus(-70, "QcDownloadNotReward")
|
|
||||||
|
|
||||||
// 下载器奖励积分不足
|
|
||||||
QcDownloadNotScore = NewResultStatus(-71, "QcDownloadNotScore")
|
|
||||||
)
|
|
||||||
|
|
||||||
// 玩家
|
|
||||||
var (
|
|
||||||
|
|
||||||
// 玩家不存在
|
|
||||||
PlayerNotExist = NewResultStatus(-1110, "PlayerNotExist")
|
|
||||||
|
|
||||||
// 没有合适的玩家
|
|
||||||
NotSuitablePlayer = NewResultStatus(-1155, "NotSuitablePlayer")
|
|
||||||
|
|
||||||
// 玩家阵容不存在
|
|
||||||
PlayerSlotFormationNotExist = NewResultStatus(-1156, "PlayerSlotFormationNotExist")
|
|
||||||
)
|
|
||||||
|
|
||||||
// 仙盟和GS保持同步
|
|
||||||
var (
|
|
||||||
// 玩家不在仙盟中
|
|
||||||
GuildNotIn = NewResultStatus(-9401, "玩家不在仙盟中")
|
|
||||||
|
|
||||||
// 仙盟不存在
|
|
||||||
GuildNotExist = NewResultStatus(-9402, "仙盟不存在")
|
|
||||||
|
|
||||||
// 玩家已在仙盟中
|
|
||||||
GuildHasIn = NewResultStatus(-9403, "玩家已在仙盟中")
|
|
||||||
|
|
||||||
// 玩家操作目标和所在仙盟不一致
|
|
||||||
TargetGuildNotMatch = NewResultStatus(-9404, "玩家操作目标和所在仙盟不一致")
|
|
||||||
|
|
||||||
// 仙盟不存在成员
|
|
||||||
GuildMemberNotExist = NewResultStatus(-9405, "仙盟不存在成员")
|
|
||||||
|
|
||||||
// vip等级不足
|
|
||||||
GuildNeedVip = NewResultStatus(-9406, "vip等级不足")
|
|
||||||
|
|
||||||
// 仙盟权限不足
|
|
||||||
GuildNeedAuth = NewResultStatus(-9407, "仙盟权限不足")
|
|
||||||
|
|
||||||
// boss节点今日未开放
|
|
||||||
GuildBossTodayNotOpen = NewResultStatus(-9411, "boss节点今日未开放")
|
|
||||||
|
|
||||||
// 职位人数已满
|
|
||||||
GuildPostEnough = NewResultStatus(-9415, "职位人数已满")
|
|
||||||
|
|
||||||
// boss开启错误
|
|
||||||
GuildBossOpenError = NewResultStatus(-9416, "boss开启错误")
|
|
||||||
|
|
||||||
// boss开启条件不足
|
|
||||||
GuildBossOpenEnough = NewResultStatus(-9417, "boss开启条件不足")
|
|
||||||
|
|
||||||
// 仙盟名称已存在
|
|
||||||
GuildNameHasExist = NewResultStatus(-9419, "仙盟名称已存在")
|
|
||||||
|
|
||||||
// 该职位人数达上限
|
|
||||||
GuildPostLimit = NewResultStatus(-9420, "该职位人数达上限")
|
|
||||||
|
|
||||||
// 世界喊话CD中
|
|
||||||
GuildShareCd = NewResultStatus(-9423, "世界喊话CD中")
|
|
||||||
|
|
||||||
// 弹劾条件不足
|
|
||||||
GuildImpeachNotEnough = NewResultStatus(-9424, "弹劾条件不足")
|
|
||||||
|
|
||||||
// 不是成员或者长老
|
|
||||||
GuildIsNotMember = NewResultStatus(-9428, "不是成员或者长老")
|
|
||||||
|
|
||||||
// boss已开启
|
|
||||||
GuildBossHasOpen = NewResultStatus(-9429, "boss已开启")
|
|
||||||
|
|
||||||
// 盟主不允许退盟
|
|
||||||
GuildLeaderNotAllowedExit = NewResultStatus(-9430, "盟主不允许退盟")
|
|
||||||
|
|
||||||
// 盟主公告锁定
|
|
||||||
GuildNoticeIsLock = NewResultStatus(-9431, "盟主公告锁定")
|
|
||||||
|
|
||||||
// 仙盟次数不足
|
|
||||||
GuildMiniGameNumNotAllow = NewResultStatus(-9439, "仙盟次数不足")
|
|
||||||
|
|
||||||
// 仙盟名称已被占用
|
|
||||||
GuildNameIsNotValid = NewResultStatus(-9445, "仙盟名称已存在")
|
|
||||||
|
|
||||||
// 不是盟主
|
|
||||||
GuildPlayerNotLeader = NewResultStatus(-9454, "不是盟主")
|
|
||||||
|
|
||||||
// 模式切换未到冷却时间
|
|
||||||
GuildSwitchModeNotCool = NewResultStatus(-9455, "模式切换未到冷却时间")
|
|
||||||
|
|
||||||
// 该玩家职位变更还在冷却中
|
|
||||||
GuildChangePostNotCool = NewResultStatus(-9460, "该玩家职位变更还在冷却中")
|
|
||||||
|
|
||||||
// 当前仙盟管理模式不可任命
|
|
||||||
GuildModeCanNotAppoint = NewResultStatus(-9461, "当前仙盟管理模式不可任命")
|
|
||||||
|
|
||||||
// 当前仙盟管理模式不可挑战
|
|
||||||
GuildModeCanNotFight = NewResultStatus(-9463, "当前仙盟管理模式不可挑战")
|
|
||||||
|
|
||||||
// 玩家等级不满足仙盟等级要求
|
|
||||||
GuildPlayerLvLessThanNeedLv = NewResultStatus(-9465, "玩家等级不满足仙盟等级要求")
|
|
||||||
|
|
||||||
// 玩家未申请
|
|
||||||
GuildPlayerNotApply = NewResultStatus(-9466, "玩家未申请")
|
|
||||||
|
|
||||||
// 仙盟信息未变更
|
|
||||||
GuildInfoNotChange = NewResultStatus(-9483, "仙盟信息未变更")
|
|
||||||
|
|
||||||
// 战略编辑次数不足,明日再来
|
|
||||||
GuildStrategyEditNum = NewResultStatus(-9486, "战略编辑次数不足,明日再来")
|
|
||||||
|
|
||||||
// 建筑不存在
|
|
||||||
GuildBuildNotExist = NewResultStatus(-9489, "建筑不存在")
|
|
||||||
|
|
||||||
// 礼包已采购
|
|
||||||
GuildWelfarePurchased = NewResultStatus(-9490, "该礼包已采购")
|
|
||||||
|
|
||||||
// 礼包已采购
|
|
||||||
GuildWelfareCaptailNotEnough = NewResultStatus(-9491, "采购礼包所需资金不足")
|
|
||||||
|
|
||||||
// 礼包已采购
|
|
||||||
GuildWelfareLvNotEnough = NewResultStatus(-9492, "仙盟等级不足,无法采购")
|
|
||||||
|
|
||||||
// 建筑经验超过最大值
|
|
||||||
GuildBuildExpOverMax = NewResultStatus(-9496, "建筑经验超过最大值")
|
|
||||||
|
|
||||||
// 未能设置该类型职位信息
|
|
||||||
GuildSetPostTypeNot = NewResultStatus(-9497, "未能设置该类型职位信息")
|
|
||||||
|
|
||||||
// 仙盟成员已达上限
|
|
||||||
GuildNumMax = NewResultStatus(-9499, "仙盟成员已达上限")
|
|
||||||
|
|
||||||
// 建筑尚未开启
|
|
||||||
GuildBuildIsLock = NewResultStatus(-109013, "建筑尚未开启")
|
|
||||||
|
|
||||||
// 建筑配置未获取
|
|
||||||
GuildBuildConfigNotExist = NewResultStatus(-109014, "未获取到建筑配置")
|
|
||||||
|
|
||||||
// 等级不匹配
|
|
||||||
GuildWelfareLvNotMatch = NewResultStatus(-109015, "等级不匹配")
|
|
||||||
|
|
||||||
// 建筑等级已达到满级
|
|
||||||
GuildBuildHasMaxLv = NewResultStatus(-109017, "建筑等级已达到满级")
|
|
||||||
|
|
||||||
// 采购礼包ID不存在
|
|
||||||
GuildGiftIdNotExist = NewResultStatus(-109018, "采购礼包ID不存在")
|
|
||||||
|
|
||||||
// 盟主令次数不足
|
|
||||||
GuildLeaderOrderCount = NewResultStatus(-109019, "盟主令次数不足")
|
|
||||||
|
|
||||||
// 仙盟每日可踢出人数已达上限
|
|
||||||
GuildTodayKickOutCountIsMax = NewResultStatus(-109020, "仙盟每日可踢出人数已达上限")
|
|
||||||
|
|
||||||
// 已申请该仙盟,请耐心等待审核
|
|
||||||
GuildHasApply = NewResultStatus(-109499, "已申请该仙盟,请耐心等待审核")
|
|
||||||
)
|
|
||||||
|
|
||||||
// 仙盟试炼
|
|
||||||
var (
|
|
||||||
GuildTrainBoxRewardDrawed = NewResultStatus(-109001, "仙盟试炼宝箱已领取")
|
|
||||||
|
|
||||||
// 仙盟boss战报不存在
|
|
||||||
GuildTimeBossReportNotExists = NewResultStatus(-109002, "仙盟boss战报不存在")
|
|
||||||
|
|
||||||
// 仙盟试炼节点不存在
|
|
||||||
GuildTrainNodeNotExists = NewResultStatus(-109003, "仙盟试炼节点不存在")
|
|
||||||
|
|
||||||
// 仙盟试炼奖励槽位不存在
|
|
||||||
GuildTrainBoxSlotNotExists = NewResultStatus(-109004, "仙盟试炼奖励槽位不存在")
|
|
||||||
|
|
||||||
// 仙盟试炼目标位置奖励信息已变化
|
|
||||||
GuildTrainBoxSlotHasRefresh = NewResultStatus(-109005, "仙盟试炼目标位置奖励信息已变化")
|
|
||||||
|
|
||||||
// 仙盟限时boss开启积分不足
|
|
||||||
GuildTimedOpenNotEnougth = NewResultStatus(-109006, "仙盟限时boss开启积分不足")
|
|
||||||
|
|
||||||
// 仙盟限时boss开启积分不足
|
|
||||||
GuildTrainNotKill = NewResultStatus(-109007, "BOSS未镇压,无法领奖")
|
|
||||||
|
|
||||||
// 试炼章节暂未开启
|
|
||||||
GuildTrainNodeNotOpen = NewResultStatus(-109010, "试炼章节暂未开启")
|
|
||||||
|
|
||||||
// 试炼已经镇压
|
|
||||||
GuildTrainIsKilled = NewResultStatus(-109011, "BOSS已镇压,不可挑战")
|
|
||||||
)
|
|
||||||
|
|
||||||
// 仙盟红包
|
|
||||||
var (
|
|
||||||
// 仙盟红包不存在
|
|
||||||
GuildRedPacketNotExist = NewResultStatus(-9950, "仙盟红包不存在")
|
|
||||||
|
|
||||||
// 仙盟玩家红包不存在
|
|
||||||
GuildPlayerRedPacketNotExist = NewResultStatus(-9959, "仙盟玩家红包不存在")
|
|
||||||
|
|
||||||
// 仙盟红包已过期
|
|
||||||
GuildRedPacketIsExpire = NewResultStatus(-9953, "仙盟红包已过期")
|
|
||||||
|
|
||||||
// 仙盟红包没有奖励可以领取
|
|
||||||
GuildRedPacketNotReward = NewResultStatus(-9960, "仙盟红包没有奖励可以领取")
|
|
||||||
|
|
||||||
// 仙盟红包奖励已领取
|
|
||||||
GuildRedPacketHasRewarded = NewResultStatus(-9954, "仙盟红包奖励已领取")
|
|
||||||
)
|
|
||||||
|
|
||||||
// 组队副本
|
|
||||||
var (
|
|
||||||
// 房间不存在
|
|
||||||
TeamCopyRoomNotExists = NewResultStatus(-9612, "TeamCopyRoomNotExists")
|
|
||||||
|
|
||||||
// 成员不存在
|
|
||||||
TeamCopyMemberNotExists = NewResultStatus(-9613, "TeamCopyMemberNotExists")
|
|
||||||
|
|
||||||
// 不是房主
|
|
||||||
TeamCopyNotIsLeader = NewResultStatus(-9614, "TeamCopyNotIsLeader")
|
|
||||||
|
|
||||||
// 战斗失败
|
|
||||||
TeamCopyFigthFail = NewResultStatus(-9615, "TeamCopyFigthFail")
|
|
||||||
|
|
||||||
// 房间玩家未准备
|
|
||||||
TeamCopyNotAllReady = NewResultStatus(-9616, "TeamCopyNotAllReady")
|
|
||||||
|
|
||||||
// 玩家人数不足
|
|
||||||
TeamCopyNotEnough = NewResultStatus(-9617, "TeamCopyNotEnough")
|
|
||||||
|
|
||||||
// 玩家战力不足
|
|
||||||
TeamCopyFapNotEnough = NewResultStatus(-9618, "TeamCopyFapNotEnough")
|
|
||||||
|
|
||||||
// 仍有奖励未领取
|
|
||||||
TeamCopyHasReward = NewResultStatus(-9619, "TeamCopyHasReward")
|
|
||||||
|
|
||||||
// 未被邀请
|
|
||||||
TeamCopyNotShare = NewResultStatus(-9620, "TeamCopyNotShare")
|
|
||||||
|
|
||||||
// 目标节点尚未开启
|
|
||||||
TeamCopyNodeNotOpen = NewResultStatus(-9622, "TeamCopyNodeNotOpen")
|
|
||||||
|
|
||||||
// 人数已满
|
|
||||||
TeamCopyIsMax = NewResultStatus(-9624, "TeamCopyIsMax")
|
|
||||||
|
|
||||||
// 没有权限进入房间
|
|
||||||
TeamCopyNotAuth = NewResultStatus(-9625, "TeamCopyNotAuth")
|
|
||||||
|
|
||||||
// 组队战斗已开始
|
|
||||||
TeamCopyIsFighting = NewResultStatus(-9626, "TeamCopyIsFighting")
|
|
||||||
|
|
||||||
// 邀请已存在
|
|
||||||
TeamCopyIsExistShare = NewResultStatus(-9627, "TeamCopyIsExistShare")
|
|
||||||
|
|
||||||
// 队伍不能为全部助战状态
|
|
||||||
TeamCopyIsAllHelp = NewResultStatus(-9633, "TeamCopyIsAllHelp")
|
|
||||||
|
|
||||||
// 您已被踢出
|
|
||||||
TeamCopyKickOut = NewResultStatus(-9638, "TeamCopyKickOut")
|
|
||||||
|
|
||||||
// 房间已经解散
|
|
||||||
TeamCopyRoomRemove = NewResultStatus(-9639, "房间已经解散")
|
|
||||||
|
|
||||||
// 玩家不在房间中
|
|
||||||
TeamCopyRoomMemberNotIn = NewResultStatus(-9644, "玩家不在房间中")
|
|
||||||
|
|
||||||
// 玩家战力不足
|
|
||||||
TeamCopyPlayerFapLimit = NewResultStatus(-9647, "玩家战力不足")
|
|
||||||
|
|
||||||
// 布阵阵容错误
|
|
||||||
TeamCopyFormationError = NewResultStatus(-212603, "布阵阵容错误")
|
|
||||||
|
|
||||||
// 单人模式不允许加入
|
|
||||||
TeamCopySingleNotJoin = NewResultStatus(-212604, "单人模式不允许加入")
|
|
||||||
|
|
||||||
// 队员未准备
|
|
||||||
PlayerNotReady = NewResultStatus(-212605, "队员未准备")
|
|
||||||
)
|
|
||||||
|
|
||||||
// 矿战
|
|
||||||
var (
|
|
||||||
// 矿战玩家信息不存在
|
|
||||||
KuangzhanPlayerNotExist = NewResultStatus(-36131, "KuangzhanPlayerNotExist")
|
|
||||||
|
|
||||||
// 占领节点错误
|
|
||||||
KuangzhanOccupyNode = NewResultStatus(-36113, "KuangzhanOccupyNode")
|
|
||||||
|
|
||||||
// 矿战节点不存在
|
|
||||||
NodeConfigNotExist = NewResultStatus(-36132, "NodeConfigNotExist")
|
|
||||||
|
|
||||||
// 此洞府正在被攻击
|
|
||||||
TheOtherPlayerFighting = NewResultStatus(-36114, "TheOtherPlayerFighting")
|
|
||||||
|
|
||||||
// 该节点已经被占领
|
|
||||||
KuangzhanoverOccupyNode = NewResultStatus(-36113, "KuangzhanoverOccupyNode")
|
|
||||||
|
|
||||||
// 占领节点玩家无阵容
|
|
||||||
KuangzhanPlayerNoFormation = NewResultStatus(-36133, "KuangzhanPlayerNoFormation")
|
|
||||||
|
|
||||||
// 获取阵容失败
|
|
||||||
KuangzhanPlayerGetFormationFail = NewResultStatus(-36134, "KuangzhanPlayerGetFormationFail")
|
|
||||||
|
|
||||||
// 已占领洞府节点
|
|
||||||
KuangzhanOverLoad = NewResultStatus(-36115, "KuangzhanOverLoad")
|
|
||||||
|
|
||||||
// 今日抢夺次数已经用完
|
|
||||||
KuangzhanDailyLootOver = NewResultStatus(-36117, "KuangzhanDailyLootOver")
|
|
||||||
|
|
||||||
// 此洞府今日已无法被抢夺
|
|
||||||
KuangzhanDailyRobbedOver = NewResultStatus(-36118, "KuangzhanDailyRobbedOver")
|
|
||||||
|
|
||||||
// 洞天抢夺暂未开启
|
|
||||||
KuangzhanRobbedTimeNotOpen = NewResultStatus(-36119, "KuangzhanRobbedTimeNotOpen")
|
|
||||||
|
|
||||||
// 剩余洞天宝石不可抢夺
|
|
||||||
KuangzhanGemIsOver = NewResultStatus(-36120, "KuangzhanGemIsOver")
|
|
||||||
|
|
||||||
// 玩家不匹配
|
|
||||||
KuangzhanPlayerNotMatching = NewResultStatus(-36122, "KuangzhanPlayerNotMatching")
|
|
||||||
|
|
||||||
// 不是被邀请的玩家
|
|
||||||
KuangzhanInviteFailed = NewResultStatus(-36123, "邀请好友失败")
|
|
||||||
|
|
||||||
// 不是被邀请的玩家
|
|
||||||
KuangzhanNotInvited = NewResultStatus(-36124, "不是被邀请的玩家")
|
|
||||||
|
|
||||||
// 协助信息已失效
|
|
||||||
KuangzhanInviteExpired = NewResultStatus(-36125, "协助信息已失效")
|
|
||||||
|
|
||||||
// 已经帮助过该玩家
|
|
||||||
KuangzhanAlreadyHelped = NewResultStatus(-36135, "已经帮助过该玩家")
|
|
||||||
|
|
||||||
// 对方任务已经完成
|
|
||||||
KuangzhanTaskFinished = NewResultStatus(-36136, "对方任务已经完成")
|
|
||||||
)
|
|
||||||
|
|
||||||
// 蜀山论剑
|
|
||||||
var (
|
|
||||||
// 战斗校验出现异常
|
|
||||||
FightException = NewResultStatus(-1354, "FightException")
|
|
||||||
|
|
||||||
// 比武大会玩家信息不存在
|
|
||||||
HegeMonyPlayerInfoNotExist = NewResultStatus(-9701, "HegeMonyPlayerInfoNotExist")
|
|
||||||
|
|
||||||
// 比武大会玩家已有匹配
|
|
||||||
HegeMonyHasMatch = NewResultStatus(-9702, "HegeMonyHasMatch")
|
|
||||||
|
|
||||||
// 比武大会玩家未找到匹配
|
|
||||||
HegeMonyNotMatch = NewResultStatus(-9703, "HegeMonyNotMatch")
|
|
||||||
|
|
||||||
// 比武大会玩家未找到阵容
|
|
||||||
HegeMonyFormationNotExist = NewResultStatus(-9704, "HegeMonyFormationNotExist")
|
|
||||||
|
|
||||||
// 比武大会对手玩家信息不存在
|
|
||||||
HegeMonyTargetPlayerInfoNotExist = NewResultStatus(-9705, "HegeMonyTargetPlayerInfoNotExist")
|
|
||||||
|
|
||||||
// 比武大会玩家未匹配
|
|
||||||
HegeMonyPlayerNotMatch = NewResultStatus(-9706, "HegeMonyPlayerNotMatch")
|
|
||||||
|
|
||||||
// 比武大会赛季不匹配
|
|
||||||
SeasonNotMatch = NewResultStatus(-9707, "SeasonNotMatch")
|
|
||||||
|
|
||||||
// 比武大会战报信息不存在
|
|
||||||
HegeMonyReportNotExist = NewResultStatus(-9730, "HegeMonyReportNotExist")
|
|
||||||
|
|
||||||
// 比武大会战斗未能找到匹配对手
|
|
||||||
HegeMonyFightNotMatch = NewResultStatus(-9731, "HegeMonyFightNotMatch")
|
|
||||||
|
|
||||||
// 比武大会荣耀玩家不存在
|
|
||||||
HegeMonyHonorPlayerNotExist = NewResultStatus(-9732, "HegeMonyHonorPlayerNotExist")
|
|
||||||
)
|
|
||||||
|
|
||||||
// 战报
|
|
||||||
var (
|
|
||||||
// 战报信息不存在
|
|
||||||
FightReportNotExist = NewResultStatus(-9707, "FightReportNotExist")
|
|
||||||
|
|
||||||
// 数据解析错误
|
|
||||||
JsonDecodeDataError = NewResultStatus(-9708, "JsonDecodeDataError")
|
|
||||||
)
|
|
||||||
|
|
||||||
// 喜信
|
|
||||||
var (
|
|
||||||
// 信息Id错误
|
|
||||||
HappyNewsIdError = NewResultStatus(-40103, "HappyNewsIdError")
|
|
||||||
|
|
||||||
// 信息序号错误
|
|
||||||
HappyNewsOrderIdError = NewResultStatus(-40104, "HappyNewsOrderIdError")
|
|
||||||
|
|
||||||
// 喜信获取好友失败
|
|
||||||
HappyNewsGetFriendsError = NewResultStatus(-40105, "HappyNewsGetFriendsError")
|
|
||||||
|
|
||||||
// 没有好友
|
|
||||||
NoFriend = NewResultStatus(-8565, "NoFriend")
|
|
||||||
)
|
|
||||||
|
|
||||||
// 仙盟远征
|
|
||||||
var (
|
|
||||||
// 仙盟远征错误
|
|
||||||
GuildExpeditionError = NewResultStatus(-29900, "GuildExpeditionError")
|
|
||||||
|
|
||||||
// 仙盟远征活动未开启
|
|
||||||
GuildExpeditionActivityNotOpen = NewResultStatus(-29906, "GuildExpeditionActivityNotOpen")
|
|
||||||
|
|
||||||
// 仙盟远征公会未匹配
|
|
||||||
GuildExpeditionGuildNotMatch = NewResultStatus(-29908, "GuildExpeditionGuildNotMatch")
|
|
||||||
|
|
||||||
// 仙盟远征阵容无法解析
|
|
||||||
GuildExpeditionFormationUnknow = NewResultStatus(-29909, "GuildExpeditionFormationUnknow")
|
|
||||||
|
|
||||||
// 仙盟远征房间信息不存在
|
|
||||||
GuildExpeditionRoomInfoError = NewResultStatus(-29912, "GuildExpeditionRoomInfoError")
|
|
||||||
|
|
||||||
// 仙盟远征阶段一挑战次数不足
|
|
||||||
GuildExpeditionFirstStepTimesIsNotEnough = NewResultStatus(-29913, "GuildExpeditionfirstStepTimesIsNotEnough")
|
|
||||||
|
|
||||||
// 仙盟远征阶段一挑战次数不足
|
|
||||||
GuildExpeditionSecondStepTimesIsNotEnough = NewResultStatus(-29914, "GuildExpeditionSecondStepTimesIsNotEnough")
|
|
||||||
|
|
||||||
// 仙盟远征房间已锁定
|
|
||||||
GuildExpeditionRoomIsLock = NewResultStatus(-29915, "GuildExpeditionRoomIsLock")
|
|
||||||
|
|
||||||
// 不是参与远征的仙盟成员
|
|
||||||
GuildExpeditionIsNotJoinMember = NewResultStatus(-29916, "GuildExpeditionIsNotJoinMember")
|
|
||||||
|
|
||||||
// 目标没有防御阵容
|
|
||||||
GuildExpeditionTargetNoDefenceFormation = NewResultStatus(-29917, "GuildExpeditionTargetNoDefenceFormation")
|
|
||||||
|
|
||||||
// 仙盟远征战斗验证失败
|
|
||||||
GuildExpeditionFightValidFail = NewResultStatus(-29918, "GuildExpeditionFightValidFail")
|
|
||||||
)
|
|
||||||
|
|
||||||
// 义结金兰
|
|
||||||
var (
|
|
||||||
// 玩家未结交,标记g_yjjl对象
|
|
||||||
YjjlPlayerNotExist = NewResultStatus(-33501, "YjjlPlayerNotExist")
|
|
||||||
|
|
||||||
// 玩家未结义,标记g_yjjl_player对象
|
|
||||||
YjjlPlayerNotExistForPlayer = NewResultStatus(-33588, "YjjlPlayerNotExistForPlayer")
|
|
||||||
|
|
||||||
// 玩家未结义,标记玩家对象属于第三者
|
|
||||||
YjjlPlayerNotMatch = NewResultStatus(-33589, "YjjlPlayerNotMatch")
|
|
||||||
|
|
||||||
// 玩家已结交
|
|
||||||
YjjlPlayerHasExist = NewResultStatus(-33502, "YjjlPlayerHasExist")
|
|
||||||
|
|
||||||
// 玩家已设置本特效
|
|
||||||
QingyiLvSpecialeffectsIsExists = NewResultStatus(-33515, "QingyiLvSpecialeffectsIsExists")
|
|
||||||
|
|
||||||
// 亲密付已达月上限
|
|
||||||
HelpPayIsLimit = NewResultStatus(-33571, "HelpPayIsLimit")
|
|
||||||
|
|
||||||
// 玩家当前未培养花卉
|
|
||||||
FlowerNotExist = NewResultStatus(-33523, "FlowerNotExist")
|
|
||||||
|
|
||||||
// 玩家当前花卉经验值已满
|
|
||||||
FlowerExpIsMax = NewResultStatus(-33524, "FlowerExpIsMax")
|
|
||||||
|
|
||||||
// 玩家当前花卉经验值未满
|
|
||||||
FlowerExpNotEnough = NewResultStatus(-33525, "FlowerExpNotEnough")
|
|
||||||
|
|
||||||
// 玩家已培养花卉
|
|
||||||
FlowerIsExists = NewResultStatus(-33530, "FlowerIsExists")
|
|
||||||
|
|
||||||
// 培养的花卉不匹配
|
|
||||||
FlowerNotMatch = NewResultStatus(-33531, "FlowerNotMatch")
|
|
||||||
|
|
||||||
// 花卉可收获,不能重置
|
|
||||||
FlowerCanGet = NewResultStatus(-33532, "FlowerCanGet")
|
|
||||||
|
|
||||||
// 同心榜CP组唯一标识错误
|
|
||||||
RankGroupIdError = NewResultStatus(-33541, "RankGroupIdError")
|
|
||||||
|
|
||||||
// 暂无留言
|
|
||||||
RankTipNotExists = NewResultStatus(-33542, "RankTipNotExists")
|
|
||||||
|
|
||||||
// 结交好友匹配错误
|
|
||||||
RankCpMatchError = NewResultStatus(-33544, "RankCpMatchError")
|
|
||||||
|
|
||||||
// 留言点赞和玩家结义数据不匹配
|
|
||||||
RankCpMessageZanNotMatch = NewResultStatus(-33545, "RankCpMessageZanNotMatch")
|
|
||||||
|
|
||||||
// 该玩家今日已点赞!
|
|
||||||
PlayerGood = NewResultStatus(-212301, "PlayerGood")
|
|
||||||
|
|
||||||
// 义结金兰没有任务数据
|
|
||||||
YjjlTaskNoData = NewResultStatus(-33547, "YjjlTaskNoData")
|
|
||||||
|
|
||||||
// 金兰契奖励节点错误
|
|
||||||
YjjlRewardNodeError = NewResultStatus(-33568, "YjjlRewardNodeError")
|
|
||||||
|
|
||||||
// 亲密等级不足
|
|
||||||
IntimacyLvNotEnough = NewResultStatus(-33569, "IntimacyLvNotEnough")
|
|
||||||
|
|
||||||
// 活动期间获取的亲密度不足
|
|
||||||
AddIntimacyNotEnough = NewResultStatus(-33583, "活动期间获取的亲密度不足")
|
|
||||||
|
|
||||||
// 亲密度奖励已经领取
|
|
||||||
HasAddIntimacyReward = NewResultStatus(-33584, "亲密度奖励已经领取")
|
|
||||||
|
|
||||||
// 亲密等级不足,未解锁
|
|
||||||
YjjlShowIsLock = NewResultStatus(-33586, "亲密等级不足,未解锁")
|
|
||||||
|
|
||||||
// 活动还没结束
|
|
||||||
TimedActivityNotClose = NewResultStatus(-2006, "活动还没结束")
|
|
||||||
)
|
|
||||||
|
|
||||||
// 蜀山之巅(跨服Pvp冠军赛)
|
|
||||||
var (
|
|
||||||
// 赛季未开启
|
|
||||||
WeekChampionSeasonNotOpen = NewResultStatus(-4000, "WeekChampionSeasonNotOpen")
|
|
||||||
|
|
||||||
// 赛季分组数据不存在
|
|
||||||
WeekChampionNoExistGroupMatch = NewResultStatus(-4007, "WeekChampionNoExistGroupMatch")
|
|
||||||
|
|
||||||
// 跨服蜀山之巅竞猜玩家错误
|
|
||||||
WeekChampionBetPlayerError = NewResultStatus(-4008, "WeekChampionBetPlayerError")
|
|
||||||
|
|
||||||
// 战报信息不存在
|
|
||||||
WeekChampionFightReportNotExist = NewResultStatus(-4009, "WeekChampionFightReportNotExist")
|
|
||||||
|
|
||||||
// 战报信息解析错误
|
|
||||||
WeekChampionFightReportJsonDecodeDataError = NewResultStatus(-4010, "WeekChampionFightReportJsonDecodeDataError")
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
// SocialSquareGiftNotExist 礼物不存在
|
|
||||||
SocialSquareGiftNotExist = NewResultStatus(-40400, "SocialSquareGiftNotExist")
|
|
||||||
|
|
||||||
// SocialSquarePlayerNotExist 社交广场玩家不存在
|
|
||||||
SocialSquarePlayerNotExist = NewResultStatus(-40401, "SocialSquarePlayerNotExist")
|
|
||||||
|
|
||||||
// SocialSquarePhotoNotExist 社交广场玩家不存在
|
|
||||||
SocialSquarePhotoNotExist = NewResultStatus(-40402, "SocialSquarePhotoNotExist")
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
// 模块错误
|
|
||||||
VideoModuleError = NewResultStatus(-38183, "VideoModuleError")
|
|
||||||
|
|
||||||
// 未检测到该战报
|
|
||||||
VideoIdError = NewResultStatus(-38184, "VideoIdError")
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
// 金兰宴玩家对象不是举办方
|
|
||||||
YjjlFeastIsNotHost = NewResultStatus(-44108, "YjjlFeastIsNotHost")
|
|
||||||
|
|
||||||
// 宴会还在准备中
|
|
||||||
YjjlFeastIsPreraring = NewResultStatus(-44111, "YjjlFeastIsPreraring")
|
|
||||||
|
|
||||||
// 金兰宴宴会已开始
|
|
||||||
YjjlFeastRandomIsStart = NewResultStatus(-44112, "YjjlFeastRandomIsStart")
|
|
||||||
|
|
||||||
// 金兰宴房间类型错误
|
|
||||||
YjjlFeastRoomTypeError = NewResultStatus(-44116, "YjjlFeastRoomTypeError")
|
|
||||||
|
|
||||||
// 金兰宴房间不存在
|
|
||||||
YjjlFeastRoomNotExist = NewResultStatus(-44118, "YjjlFeastRoomNotExist")
|
|
||||||
|
|
||||||
// 金兰宴玩家不能加入该房间
|
|
||||||
YjjlFeastPlayerCantEnterThisRoom = NewResultStatus(-44119, "YjjlFeastPlayerCantEnterThisRoom")
|
|
||||||
|
|
||||||
// 金兰宴玩家不能同时主办两场及以上的宴会
|
|
||||||
YjjlFeastHostBuySamePlayer = NewResultStatus(-44120, "YjjlFeastHostBuySamePlayer")
|
|
||||||
|
|
||||||
// 金兰宴宾客人数达到上限
|
|
||||||
YjjlFeastRoomGuestMax = NewResultStatus(-44121, "YjjlFeastRoomGuestMax")
|
|
||||||
|
|
||||||
// 金兰宴玩家不在房间
|
|
||||||
YjjlFeastIsNotInScene = NewResultStatus(-44122, "YjjlFeastIsNotInScene")
|
|
||||||
|
|
||||||
// 金兰宴不是来宾
|
|
||||||
YjjlFeastIsHost = NewResultStatus(-44123, "YjjlFeastIsHost")
|
|
||||||
|
|
||||||
// 金兰宴红包不存在
|
|
||||||
YjjlFeastRedPacketNotExist = NewResultStatus(-44124, "YjjlFeastRedPacketNotExist")
|
|
||||||
|
|
||||||
// 金兰宴红包已领取或已领完
|
|
||||||
YjjlFeastRedPacketHadDraw = NewResultStatus(-44125, "YjjlFeastRedPacketHadDraw")
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
// 全服红包id错误
|
|
||||||
RedPacketIdError = NewResultStatus(-40501, "RedPacketIdError")
|
|
||||||
|
|
||||||
// 全服红包已经领取完
|
|
||||||
RedPacketHaveOver = NewResultStatus(-40502, "RedPacketHaveOver")
|
|
||||||
|
|
||||||
// 全服红包不可领取
|
|
||||||
RedPacketCanNotDraw = NewResultStatus(-40503, "RedPacketCanNotDraw")
|
|
||||||
|
|
||||||
// 已经领取该红包
|
|
||||||
RedPacketHaveDraw = NewResultStatus(-40504, "RedPacketHaveDraw")
|
|
||||||
|
|
||||||
// 红包领取失败
|
|
||||||
RedPacketDrawError = NewResultStatus(-40505, "RedPacketDrawError")
|
|
||||||
)
|
|
||||||
|
|
||||||
// 跨服昆仑神虚
|
|
||||||
var (
|
|
||||||
// 昆仑之墟尚未开启
|
|
||||||
GlobalCitywarMapNotOpen = NewResultStatus(-45003, "昆仑之墟尚未开启")
|
|
||||||
|
|
||||||
// 仙盟未参与
|
|
||||||
CitywarCsGuildNotParticipate = NewResultStatus(-50000, "CitywarCsGuildNotParticipate")
|
|
||||||
|
|
||||||
// 跨服昆仑神虚地图不存在
|
|
||||||
CitywarCsMapNotExist = NewResultStatus(-50001, "CitywarCsMapNotExist")
|
|
||||||
|
|
||||||
// 跨服昆仑神虚城池不存在
|
|
||||||
CitywarCsLandNotExist = NewResultStatus(-50002, "CitywarCsLandNotExist")
|
|
||||||
|
|
||||||
// 跨服昆仑神虚城池未占领
|
|
||||||
CitywarCsLandNotOccupy = NewResultStatus(-50003, "CitywarCsLandNotOccupy")
|
|
||||||
|
|
||||||
// 跨服昆仑神虚城池正在战斗中
|
|
||||||
CitywarCsLandIsFighting = NewResultStatus(-50004, "CitywarCsLandIsFighting")
|
|
||||||
|
|
||||||
// 昆仑之墟节点坐标不匹配
|
|
||||||
CitywarCsAxisNotRight = NewResultStatus(-50011, "CitywarCsAxisNotRight")
|
|
||||||
|
|
||||||
// 昆仑之墟玩家队伍不存在
|
|
||||||
CitywarCsPlayerTeamNotExist = NewResultStatus(-50012, "CitywarCsPlayerTeamNotExist")
|
|
||||||
|
|
||||||
// 昆仑之墟玩家队伍复活中
|
|
||||||
CitywarCsPlayerTeamReviving = NewResultStatus(-50013, "CitywarCsPlayerTeamReviving")
|
|
||||||
|
|
||||||
// 昆仑之墟玩家已派遣
|
|
||||||
CitywarCsPlayerTeamIsMoving = NewResultStatus(-50014, "CitywarCsPlayerTeamIsMoving")
|
|
||||||
|
|
||||||
// 昆仑之墟玩家未派遣
|
|
||||||
CitywarCsPlayerTeamNoMoving = NewResultStatus(-50015, "CitywarCsPlayerTeamNoMoving")
|
|
||||||
|
|
||||||
// 昆仑之墟玩家玩家队伍已经死亡
|
|
||||||
CitywarCsTeamIdDead = NewResultStatus(-50016, "CitywarCsTeamIdDead")
|
|
||||||
|
|
||||||
// 没有奖励可以领取
|
|
||||||
CitywarCsNotDrawReward = NewResultStatus(-50017, "CitywarCsNotDrawReward")
|
|
||||||
|
|
||||||
// 昆仑之墟休战中
|
|
||||||
CitywarCsNotFightTime = NewResultStatus(-50018, "CitywarCsNotFightTime")
|
|
||||||
|
|
||||||
// 昆仑之墟已经结束
|
|
||||||
CitywarCsIsEnd = NewResultStatus(-50019, "CitywarCsIsEnd")
|
|
||||||
|
|
||||||
// 玩家昆仑之墟出征次数不足
|
|
||||||
CitywarCsFightNumNotEnough = NewResultStatus(-50020, "CitywarCsFightNumNotEnough")
|
|
||||||
|
|
||||||
// 昆仑之墟出生地无法操作
|
|
||||||
CitywarCsLandIsBirth = NewResultStatus(-50021, "CitywarCsLandIsBirth")
|
|
||||||
|
|
||||||
// 昆仑之墟队伍已放入仙盟大营中
|
|
||||||
CitywarCsPlayerTeamInGuildTeam = NewResultStatus(-50022, "CitywarCsPlayerTeamInGuildTeam")
|
|
||||||
|
|
||||||
// 昆仑之墟队伍不在仙盟大营中
|
|
||||||
CitywarCsPlayerTeamNotInGuildTeam = NewResultStatus(-50023, "CitywarCsPlayerTeamNotInGuildTeam")
|
|
||||||
|
|
||||||
// 昆仑神墟未选择仙盟大营中队伍
|
|
||||||
CitywarCsGuildTeamNotExist = NewResultStatus(-50024, "CitywarCsGuildTeamNotExist")
|
|
||||||
|
|
||||||
// 昆仑神墟地块正在燃烧
|
|
||||||
CitywarCsLandIsFire = NewResultStatus(-50025, "CitywarCsLandIsFire")
|
|
||||||
|
|
||||||
// 非相邻地不允许攻击
|
|
||||||
CitywarCsLandNotAdjoinNotAtk = NewResultStatus(-50027, "CitywarCsLandNotAdjoinNotAtk")
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
// 巅峰对决信息不存在
|
|
||||||
PeakInfoNotExist = NewResultStatus(-40804, "PeakInfoNotExist")
|
|
||||||
|
|
||||||
// 该位置不是空位置
|
|
||||||
PeakRankNotEmpty = NewResultStatus(-40805, "PeakRankNotEmpty")
|
|
||||||
|
|
||||||
// 不能挑战低于自己的对手
|
|
||||||
PeakCantFight = NewResultStatus(-40806, "PeakCantFight")
|
|
||||||
|
|
||||||
// 排位已经变化
|
|
||||||
PeakNeedRefresh = NewResultStatus(-40808, "PeakNeedRefresh")
|
|
||||||
|
|
||||||
// 当前排名不可挑战,挑战列表已刷新
|
|
||||||
PeakNeedRefreshTwo = NewResultStatus(-40814, "PeakNeedRefreshTwo")
|
|
||||||
|
|
||||||
// 不可挑战前三
|
|
||||||
PeakCantFightTopThree = NewResultStatus(-40815, "PeakCantFightTopThree")
|
|
||||||
)
|
|
||||||
|
|
||||||
// 蜀山论剑PvpTournament
|
|
||||||
var (
|
|
||||||
// 玩家信息不存在
|
|
||||||
PvpTournamentInfoNotExist = NewResultStatus(-40901, "PvpTournamentInfoNotExist")
|
|
||||||
|
|
||||||
// 玩家未找到阵容
|
|
||||||
PvpTournamentFormationNotExist = NewResultStatus(-40902, "PvpTournamentFormationNotExist")
|
|
||||||
|
|
||||||
// 排位已经变化
|
|
||||||
PvpTournamentNeedRefresh = NewResultStatus(-40903, "PvpTournamentNeedRefresh")
|
|
||||||
|
|
||||||
// 不能挑战太靠前的玩家
|
|
||||||
PvpTournamentCantFight = NewResultStatus(-40907, "PvpTournamentCantFight")
|
|
||||||
)
|
|
||||||
|
|
||||||
// 幸运彩卡luckyCard
|
|
||||||
var (
|
|
||||||
// 幸运彩卡奖励配置不存在
|
|
||||||
LuckyCardRewardConfigNotExist = NewResultStatus(-42610, "LuckyCardRewardConfigNotExist")
|
|
||||||
|
|
||||||
// 幸运彩卡奖励不足
|
|
||||||
LuckyCardRewardNotEnough = NewResultStatus(-42611, "LuckyCardRewardNotEnough")
|
|
||||||
|
|
||||||
// 幸运彩卡青钻奖励不足
|
|
||||||
LuckyCardRewardQingzuanNotEnough = NewResultStatus(-42612, "LuckyCardRewardQingzuanNotEnough")
|
|
||||||
|
|
||||||
// 用户青钻额度不足
|
|
||||||
LuckyCardQingzuanNotEnough = NewResultStatus(-42613, "LuckyCardQingzuanNotEnough")
|
|
||||||
|
|
||||||
// 交换信息不存在
|
|
||||||
LuckyCardExchangeMessageNotExist = NewResultStatus(-42615, "LuckyCardExchangeMessageNotExist")
|
|
||||||
)
|
|
||||||
|
|
||||||
// 新版金兰宴
|
|
||||||
var (
|
|
||||||
// NewFeastHaveAppointment 已经预约过
|
|
||||||
NewFeastHaveAppointment = NewResultStatus(-41101, "NewFeastHaveAppointment")
|
|
||||||
|
|
||||||
// NewFeastAppointmentTimeOut 时间已过
|
|
||||||
NewFeastAppointmentTimeOut = NewResultStatus(-41102, "NewFeastAppointmentTimeOut")
|
|
||||||
|
|
||||||
// NotAppointment 没有预约
|
|
||||||
NewFeastNotAppointment = NewResultStatus(-41103, "NewFeastNotAppointment")
|
|
||||||
|
|
||||||
// NewFeastHaveInvite 已经邀请
|
|
||||||
NewFeastHaveInvite = NewResultStatus(-41104, "NewFeastHaveInvite")
|
|
||||||
|
|
||||||
// NewFeastAppointmentOverdue 宴会已过期
|
|
||||||
NewFeastAppointmentOverdue = NewResultStatus(-41105, "NewFeastAppointmentOverdue")
|
|
||||||
|
|
||||||
// 金兰宴房间不存在
|
|
||||||
NewFeastRoomNotExist = NewResultStatus(-41106, "NewFeastRoomNotExist")
|
|
||||||
|
|
||||||
// 金兰宴玩家不存在
|
|
||||||
NewFeastPlayerNotInRoom = NewResultStatus(-41107, "NewFeastPlayerNotInRoom")
|
|
||||||
|
|
||||||
// 金兰宴对方玩家不存在
|
|
||||||
NewFeastTargetPlayerPlayerNotInRoom = NewResultStatus(-41108, "NewFeastTargetPlayerPlayerNotInRoom")
|
|
||||||
|
|
||||||
// 道具已被抢
|
|
||||||
NewFeastPropBeRobbed = NewResultStatus(-41109, "NewFeastPropBeRobbed")
|
|
||||||
|
|
||||||
// 变身球数量不足
|
|
||||||
NewFeastBallNotEnough = NewResultStatus(-41110, "NewFeastBallNotEnough")
|
|
||||||
|
|
||||||
// 已拥有烟花
|
|
||||||
NewFeastHaveFirework = NewResultStatus(-41111, "NewFeastHaveFirework")
|
|
||||||
|
|
||||||
// 宴会已结束
|
|
||||||
NewFeastEnd = NewResultStatus(-41112, "NewFeastEnd")
|
|
||||||
|
|
||||||
// 已经品菜过了
|
|
||||||
NewFeastHaveEatFood = NewResultStatus(-41113, "NewFeastHaveEatFood")
|
|
||||||
|
|
||||||
// 不在品菜时间内
|
|
||||||
NewFeastNotEatFoodTime = NewResultStatus(-41114, "NewFeastNotEatFoodTime")
|
|
||||||
|
|
||||||
// 房间人气不足
|
|
||||||
NewFeastRoomPopularNotEnough = NewResultStatus(-41115, "NewFeastRoomPopularNotEnough")
|
|
||||||
|
|
||||||
// 密码不正确
|
|
||||||
NewFeastBoxPasswordError = NewResultStatus(-41116, "NewFeastBoxPasswordError")
|
|
||||||
|
|
||||||
// 不是房主
|
|
||||||
NewFeastNotHsot = NewResultStatus(-41117, "NewFeastNotHsot")
|
|
||||||
|
|
||||||
// 已经领取
|
|
||||||
NewFeastBoxHaveDraw = NewResultStatus(-41118, "NewFeastBoxHaveDraw")
|
|
||||||
|
|
||||||
// 房间人数已满
|
|
||||||
NewFeastRoomPlayerMax = NewResultStatus(-41119, "NewFeastRoomPlayerMax")
|
|
||||||
|
|
||||||
// 不能邀请
|
|
||||||
NewFeastCantInvite = NewResultStatus(-41120, "NewFeastCantInvite")
|
|
||||||
|
|
||||||
// 被其他人预约
|
|
||||||
NewFeastAppointmentByOthers = NewResultStatus(-41121, "NewFeastAppointmentByOthers")
|
|
||||||
)
|
|
||||||
|
|
||||||
// NoWorldBossDamageData 世界boss1.0
|
|
||||||
var (
|
|
||||||
NoWorldBossDamageData = NewResultStatus(-41200, "NoWorldBossDamageData")
|
|
||||||
)
|
|
||||||
var (
|
|
||||||
// 拍卖行商品不存在
|
|
||||||
AuctionGoodsNotExist = NewResultStatus(-41301, "AuctionGoodsNotExist")
|
|
||||||
|
|
||||||
// 拍卖行加价失败
|
|
||||||
AuctionAddPriceErr = NewResultStatus(-41302, "AuctionAddPriceErr")
|
|
||||||
|
|
||||||
// 仙盟拍卖暂无商品
|
|
||||||
AuctionGuildNoGoods = NewResultStatus(-41303, "AuctionGuildNoGoods")
|
|
||||||
|
|
||||||
// 仙盟拍卖未结束
|
|
||||||
AuctionGuildNotEnd = NewResultStatus(-41304, "AuctionGuildNotEnd")
|
|
||||||
|
|
||||||
// 分红已经领取
|
|
||||||
AuctionBonusHaveDraw = NewResultStatus(-41305, "AuctionBonusHaveDraw")
|
|
||||||
|
|
||||||
// 暂无分红
|
|
||||||
AuctionNoBonus = NewResultStatus(-41306, "AuctionNoBonus")
|
|
||||||
|
|
||||||
// 不能取消关注
|
|
||||||
AuctionCantCancelFollow = NewResultStatus(-41307, "AuctionCantCancelFollow")
|
|
||||||
|
|
||||||
// 拍卖未开始
|
|
||||||
AuctionNotStart = NewResultStatus(-41308, "AuctionNotStart")
|
|
||||||
|
|
||||||
// 该商品已经售出
|
|
||||||
AuctionGoodsHaveAuction = NewResultStatus(-41309, "AuctionGoodsHaveAuction")
|
|
||||||
|
|
||||||
// 该商品已经流拍
|
|
||||||
AuctionGoodsHaveNoPrice = NewResultStatus(-41310, "AuctionGoodsHaveNoPrice")
|
|
||||||
|
|
||||||
// 玩家金龙不足
|
|
||||||
AuctionPlayerGoldNotEnough = NewResultStatus(-41311, "AuctionPlayerGoldNotEnough")
|
|
||||||
|
|
||||||
//该商品拍卖时间已结束
|
|
||||||
AuctionGoodsEnd = NewResultStatus(-41312, "AuctionGoodsEnd")
|
|
||||||
|
|
||||||
//未参与决战神虚,不可分红
|
|
||||||
AuctionCantBonus = NewResultStatus(-41313, "AuctionCantBonus")
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
// 交易行商品不存在
|
|
||||||
TradeProductNotExistInfoNotExist = NewResultStatus(-41500, "TradeProductNotExistInfoNotExist")
|
|
||||||
|
|
||||||
// 交易行审核类型不存在
|
|
||||||
TradeAuditTypeNotExist = NewResultStatus(-41501, "TradeAuditTypeNotExist")
|
|
||||||
)
|
|
||||||
@ -7,6 +7,7 @@ import (
|
|||||||
type StatusCode int
|
type StatusCode int
|
||||||
|
|
||||||
// ResultStatus
|
// ResultStatus
|
||||||
|
//
|
||||||
// @description: 状态码数据
|
// @description: 状态码数据
|
||||||
type ResultStatus struct {
|
type ResultStatus struct {
|
||||||
// 状态码
|
// 状态码
|
||||||
@ -17,31 +18,46 @@ type ResultStatus struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Code
|
// Code
|
||||||
|
//
|
||||||
// @description: 状态码
|
// @description: 状态码
|
||||||
|
//
|
||||||
// parameter:
|
// parameter:
|
||||||
|
//
|
||||||
// @receiver this: this
|
// @receiver this: this
|
||||||
|
//
|
||||||
// return:
|
// return:
|
||||||
|
//
|
||||||
// @StatusCode: 状态码
|
// @StatusCode: 状态码
|
||||||
func (this *ResultStatus) Code() StatusCode {
|
func (this *ResultStatus) Code() StatusCode {
|
||||||
return this.code
|
return this.code
|
||||||
}
|
}
|
||||||
|
|
||||||
// Message
|
// Message
|
||||||
|
//
|
||||||
// @description: 错误信息
|
// @description: 错误信息
|
||||||
|
//
|
||||||
// parameter:
|
// parameter:
|
||||||
|
//
|
||||||
// @receiver this: this
|
// @receiver this: this
|
||||||
|
//
|
||||||
// return:
|
// return:
|
||||||
|
//
|
||||||
// @string:
|
// @string:
|
||||||
func (this *ResultStatus) Message() string {
|
func (this *ResultStatus) Message() string {
|
||||||
return this.message
|
return this.message
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewResultStatus
|
// NewResultStatus
|
||||||
|
//
|
||||||
// @description: 创建新的状态码对象
|
// @description: 创建新的状态码对象
|
||||||
|
//
|
||||||
// parameter:
|
// parameter:
|
||||||
|
//
|
||||||
// @_code: 错误码
|
// @_code: 错误码
|
||||||
// @_message: 提示消息
|
// @_message: 提示消息
|
||||||
|
//
|
||||||
// return:
|
// return:
|
||||||
|
//
|
||||||
// @ResultStatus: 状态码对象
|
// @ResultStatus: 状态码对象
|
||||||
func NewResultStatus(_code StatusCode, _message string) ResultStatus {
|
func NewResultStatus(_code StatusCode, _message string) ResultStatus {
|
||||||
return ResultStatus{
|
return ResultStatus{
|
||||||
@ -51,20 +67,30 @@ func NewResultStatus(_code StatusCode, _message string) ResultStatus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// IsSuccess
|
// IsSuccess
|
||||||
|
//
|
||||||
// @description: 是否是成功
|
// @description: 是否是成功
|
||||||
|
//
|
||||||
// parameter:
|
// parameter:
|
||||||
|
//
|
||||||
// @receiver this: this
|
// @receiver this: this
|
||||||
|
//
|
||||||
// return:
|
// return:
|
||||||
|
//
|
||||||
// @bool: true:成功 false:失败
|
// @bool: true:成功 false:失败
|
||||||
func (this *ResultStatus) IsSuccess() bool {
|
func (this *ResultStatus) IsSuccess() bool {
|
||||||
return this.code == Success.Code()
|
return this.code == Success.Code()
|
||||||
}
|
}
|
||||||
|
|
||||||
// String
|
// String
|
||||||
|
//
|
||||||
// @description: 打印状态码信息
|
// @description: 打印状态码信息
|
||||||
|
//
|
||||||
// parameter:
|
// parameter:
|
||||||
|
//
|
||||||
// @receiver this: this
|
// @receiver this: this
|
||||||
|
//
|
||||||
// return:
|
// return:
|
||||||
|
//
|
||||||
// @string: 状态码信息
|
// @string: 状态码信息
|
||||||
func (this *ResultStatus) String() string {
|
func (this *ResultStatus) String() string {
|
||||||
return fmt.Sprintf("Code:%d,Message:%s", this.code, this.message)
|
return fmt.Sprintf("Code:%d,Message:%s", this.code, this.message)
|
||||||
105
trunk/center/common/resultstatus/resultStatusCode.go
Normal file
105
trunk/center/common/resultstatus/resultStatusCode.go
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
package resultStatus
|
||||||
|
|
||||||
|
// 系统错误码
|
||||||
|
var (
|
||||||
|
// 成功
|
||||||
|
Success = NewResultStatus(0, "Success")
|
||||||
|
|
||||||
|
// 数据库错误
|
||||||
|
DBError = NewResultStatus(-2, "DBError")
|
||||||
|
|
||||||
|
// 方法未定义
|
||||||
|
MethodNotDefined = NewResultStatus(-3, "MethodNotDefined")
|
||||||
|
|
||||||
|
// 参数无效
|
||||||
|
ParamInValid = NewResultStatus(-4, "ParamInValid")
|
||||||
|
|
||||||
|
// 参数不匹配
|
||||||
|
ParamNotMatch = NewResultStatus(-5, "ParamNotMatch")
|
||||||
|
|
||||||
|
// 功能未开启
|
||||||
|
ModuleNotOpen = NewResultStatus(-6, "ModuleNotOpen")
|
||||||
|
|
||||||
|
// 只支持Post
|
||||||
|
OnlySupportPOST = NewResultStatus(-7, "OnlySupportPOST")
|
||||||
|
|
||||||
|
// API未定义
|
||||||
|
APINotDefined = NewResultStatus(-8, "APINotDefined")
|
||||||
|
|
||||||
|
// API数据错误
|
||||||
|
APIDataError = NewResultStatus(-9, "APIDataError")
|
||||||
|
|
||||||
|
// API参数错误
|
||||||
|
APIParamError = NewResultStatus(-10, "APIParamError")
|
||||||
|
|
||||||
|
// IP被禁用
|
||||||
|
IPForbid = NewResultStatus(-11, "IPForbid")
|
||||||
|
|
||||||
|
// 没有有效的服务器
|
||||||
|
NoAvailableServer = NewResultStatus(-12, "NoAvailableServer")
|
||||||
|
|
||||||
|
// 服务器组不存在
|
||||||
|
ServerGroupNotExists = NewResultStatus(-13, "ServerGroupNotExists")
|
||||||
|
|
||||||
|
// 测试接口只能debug下调用
|
||||||
|
DebugInterface = NewResultStatus(-14, "DebugInterface")
|
||||||
|
|
||||||
|
// 模块不存在
|
||||||
|
ModuleNotExists = NewResultStatus(-15, "ModuleNotExists")
|
||||||
|
|
||||||
|
// 未能找到指定方法
|
||||||
|
NotSpecificMethod = NewResultStatus(-16, "NotSpecificMethod")
|
||||||
|
|
||||||
|
// 非指定区域
|
||||||
|
NotMatchRegion = NewResultStatus(-17, "NotMatchRegion")
|
||||||
|
|
||||||
|
// 发送空数据
|
||||||
|
SendNullData = NewResultStatus(-18, "SendNullData")
|
||||||
|
|
||||||
|
// 序列化失败
|
||||||
|
MarshalDataError = NewResultStatus(-19, "MarshalDataError")
|
||||||
|
|
||||||
|
//未登录
|
||||||
|
NotLogin = NewResultStatus(-20, "NotLogin")
|
||||||
|
|
||||||
|
// 数据错误
|
||||||
|
DataError = NewResultStatus(-31, "DataError")
|
||||||
|
|
||||||
|
// 战区合并维护中,敬请期待
|
||||||
|
MergeDataRunning = NewResultStatus(-67, "MergeDataRunning")
|
||||||
|
|
||||||
|
// 下载器内容未配置
|
||||||
|
QcDownloadConfigNotExists = NewResultStatus(-68, "QcDownloadConfigNotExists")
|
||||||
|
|
||||||
|
// 下载器奖励已领取
|
||||||
|
QcDownloadHasReward = NewResultStatus(-69, "QcDownloadHasReward")
|
||||||
|
|
||||||
|
// 下载器奖励没有奖励可领取
|
||||||
|
QcDownloadNotReward = NewResultStatus(-70, "QcDownloadNotReward")
|
||||||
|
|
||||||
|
// 下载器奖励积分不足
|
||||||
|
QcDownloadNotScore = NewResultStatus(-71, "QcDownloadNotScore")
|
||||||
|
)
|
||||||
|
|
||||||
|
// 微信登录
|
||||||
|
var (
|
||||||
|
RequestError = NewResultStatus(-60001, "WrongRequeststatus")
|
||||||
|
EmptyResp = NewResultStatus(-60002, "The result is empty")
|
||||||
|
UnmarshalError = NewResultStatus(-60003, "Unmarshal is error")
|
||||||
|
)
|
||||||
|
|
||||||
|
// 玩家
|
||||||
|
var (
|
||||||
|
|
||||||
|
// 玩家不存在
|
||||||
|
PlayerNotExist = NewResultStatus(-1110, "PlayerNotExist")
|
||||||
|
|
||||||
|
// 没有合适的玩家
|
||||||
|
NotSuitablePlayer = NewResultStatus(-1155, "NotSuitablePlayer")
|
||||||
|
|
||||||
|
// 玩家阵容不存在
|
||||||
|
PlayerSlotFormationNotExist = NewResultStatus(-1156, "PlayerSlotFormationNotExist")
|
||||||
|
|
||||||
|
//玩家已经下线
|
||||||
|
PlayerIsLoginOut = NewResultStatus(-1157, "PlayerIsLoginOut")
|
||||||
|
)
|
||||||
@ -7,7 +7,7 @@ import (
|
|||||||
"goutil/logUtilPlus"
|
"goutil/logUtilPlus"
|
||||||
"goutil/typeUtil"
|
"goutil/typeUtil"
|
||||||
"goutil/zlibUtil"
|
"goutil/zlibUtil"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ func (this *ApiContext) readContent(isZlib bool) (content []byte, err error) {
|
|||||||
var buffer []byte
|
var buffer []byte
|
||||||
|
|
||||||
defer this.request.Body.Close()
|
defer this.request.Body.Close()
|
||||||
if buffer, err = ioutil.ReadAll(this.request.Body); err != nil {
|
if buffer, err = io.ReadAll(this.request.Body); err != nil {
|
||||||
logUtilPlus.ErrorLog(fmt.Sprintf("url:%s,读取数据出错,错误信息为:%s", this.request.RequestURI, err))
|
logUtilPlus.ErrorLog(fmt.Sprintf("url:%s,读取数据出错,错误信息为:%s", this.request.RequestURI, err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -80,7 +80,7 @@ func (this *ApiContext) readContent(isZlib bool) (content []byte, err error) {
|
|||||||
// 不压缩,则直接返回
|
// 不压缩,则直接返回
|
||||||
if isZlib == false {
|
if isZlib == false {
|
||||||
this.requestBytes = buffer
|
this.requestBytes = buffer
|
||||||
|
logUtilPlus.ErrorLog(fmt.Sprintf("buffer=%v", buffer))
|
||||||
return buffer, err
|
return buffer, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ func (this *ApiHandler) FuncParamNames() []string {
|
|||||||
//
|
//
|
||||||
// return:
|
// return:
|
||||||
//
|
//
|
||||||
// @resultStatus.ResultStatus: 状态码数据
|
// @resultstatus.ResultStatus: 状态码数据
|
||||||
func (this *ApiHandler) CheckParam(r *http.Request) resultStatus.ResultStatus {
|
func (this *ApiHandler) CheckParam(r *http.Request) resultStatus.ResultStatus {
|
||||||
for _, name := range this.funcParamNames {
|
for _, name := range this.funcParamNames {
|
||||||
if r.Form[name] == nil || len(r.Form[name]) == 0 {
|
if r.Form[name] == nil || len(r.Form[name]) == 0 {
|
||||||
@ -15,20 +15,28 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// RegisterRemarkFunc
|
// RegisterRemarkFunc
|
||||||
|
//
|
||||||
// @description: 注册文档api方法
|
// @description: 注册文档api方法
|
||||||
|
//
|
||||||
// parameter:
|
// parameter:
|
||||||
|
//
|
||||||
// @_remarkFunc: _remarkFunc
|
// @_remarkFunc: _remarkFunc
|
||||||
|
//
|
||||||
// return:
|
// return:
|
||||||
func RegisterRemarkFunc(_remarkFunc func(w http.ResponseWriter, r *http.Request)) {
|
func RegisterRemarkFunc(_remarkFunc func(w http.ResponseWriter, r *http.Request)) {
|
||||||
remarkFunc = _remarkFunc
|
remarkFunc = _remarkFunc
|
||||||
}
|
}
|
||||||
|
|
||||||
// RegisterHandleFunc
|
// RegisterHandleFunc
|
||||||
|
//
|
||||||
// @description: 注册处理方法
|
// @description: 注册处理方法
|
||||||
|
//
|
||||||
// parameter:
|
// parameter:
|
||||||
|
//
|
||||||
// @apiName: API名称
|
// @apiName: API名称
|
||||||
// @callback: 回调方法
|
// @callback: 回调方法
|
||||||
// @paramNames: 参数名称集合
|
// @paramNames: 参数名称集合
|
||||||
|
//
|
||||||
// return:
|
// return:
|
||||||
func RegisterHandleFunc(apiName string, callback HandleFunc, paramNames ...string) {
|
func RegisterHandleFunc(apiName string, callback HandleFunc, paramNames ...string) {
|
||||||
apiFullName := fmt.Sprintf("/API/%s", apiName)
|
apiFullName := fmt.Sprintf("/API/%s", apiName)
|
||||||
@ -41,10 +49,15 @@ func RegisterHandleFunc(apiName string, callback HandleFunc, paramNames ...strin
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetHandleFunc
|
// GetHandleFunc
|
||||||
|
//
|
||||||
// @description: 获取请求方法
|
// @description: 获取请求方法
|
||||||
|
//
|
||||||
// parameter:
|
// parameter:
|
||||||
|
//
|
||||||
// @apiFullName: 方法名称
|
// @apiFullName: 方法名称
|
||||||
|
//
|
||||||
// return:
|
// return:
|
||||||
|
//
|
||||||
// @*ApiHandler: 请求方法
|
// @*ApiHandler: 请求方法
|
||||||
// @bool: 是否存在
|
// @bool: 是否存在
|
||||||
func GetHandleFunc(apiFullName string) (*ApiHandler, bool) {
|
func GetHandleFunc(apiFullName string) (*ApiHandler, bool) {
|
||||||
@ -5,6 +5,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// methodAndInOutTypes
|
// methodAndInOutTypes
|
||||||
|
//
|
||||||
// @description: 反射的方法和输入、输出参数类型组合类型
|
// @description: 反射的方法和输入、输出参数类型组合类型
|
||||||
type methodAndInOutTypes struct {
|
type methodAndInOutTypes struct {
|
||||||
// 反射出来的对应方法对象
|
// 反射出来的对应方法对象
|
||||||
@ -18,12 +19,17 @@ type methodAndInOutTypes struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// newmethodAndInOutTypes
|
// newmethodAndInOutTypes
|
||||||
|
//
|
||||||
// @description: newmethodAndInOutTypes
|
// @description: newmethodAndInOutTypes
|
||||||
|
//
|
||||||
// parameter:
|
// parameter:
|
||||||
|
//
|
||||||
// @_method: _method
|
// @_method: _method
|
||||||
// @_inTypes: _inTypes
|
// @_inTypes: _inTypes
|
||||||
// @_outTypes: _outTypes
|
// @_outTypes: _outTypes
|
||||||
|
//
|
||||||
// return:
|
// return:
|
||||||
|
//
|
||||||
// @*methodAndInOutTypes: methodAndInOutTypes
|
// @*methodAndInOutTypes: methodAndInOutTypes
|
||||||
func newmethodAndInOutTypes(_method reflect.Value, _inTypes []reflect.Type, _outTypes []reflect.Type) *methodAndInOutTypes {
|
func newmethodAndInOutTypes(_method reflect.Value, _inTypes []reflect.Type, _outTypes []reflect.Type) *methodAndInOutTypes {
|
||||||
return &methodAndInOutTypes{
|
return &methodAndInOutTypes{
|
||||||
@ -1,6 +1,7 @@
|
|||||||
package webServer
|
package webServer
|
||||||
|
|
||||||
// RequestObject
|
// RequestObject
|
||||||
|
//
|
||||||
// @description: 请求对象
|
// @description: 请求对象
|
||||||
type RequestObject struct {
|
type RequestObject struct {
|
||||||
// 以下属性是由客户端直接传入的,可以直接反序列化直接得到的
|
// 以下属性是由客户端直接传入的,可以直接反序列化直接得到的
|
||||||
@ -15,12 +16,17 @@ type RequestObject struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewRequestObject
|
// NewRequestObject
|
||||||
|
//
|
||||||
// @description: NewRequestObject
|
// @description: NewRequestObject
|
||||||
|
//
|
||||||
// parameter:
|
// parameter:
|
||||||
|
//
|
||||||
// @_ModuleName: _ModuleName
|
// @_ModuleName: _ModuleName
|
||||||
// @_MethodName: _MethodName
|
// @_MethodName: _MethodName
|
||||||
// @_Parameters: _Parameters
|
// @_Parameters: _Parameters
|
||||||
|
//
|
||||||
// return:
|
// return:
|
||||||
|
//
|
||||||
// @*RequestObject: RequestObject
|
// @*RequestObject: RequestObject
|
||||||
func NewRequestObject(_ModuleName string, _MethodName string, _Parameters []interface{}) *RequestObject {
|
func NewRequestObject(_ModuleName string, _MethodName string, _Parameters []interface{}) *RequestObject {
|
||||||
return &RequestObject{
|
return &RequestObject{
|
||||||
@ -115,6 +115,13 @@ func (mux *selfDefineMux) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
params = append([]interface{}{tokenData.UserInfo}, params...)
|
params = append([]interface{}{tokenData.UserInfo}, params...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//是否需要请求信息
|
||||||
|
if IsNeedGetRequestInfo(strs[0], strs[1]) {
|
||||||
|
|
||||||
|
//添加请求信息到最后一个参数
|
||||||
|
params = append(params, r)
|
||||||
|
}
|
||||||
|
|
||||||
resquestData := NewRequestObject(strs[0], strs[1], params)
|
resquestData := NewRequestObject(strs[0], strs[1], params)
|
||||||
resp := CallFunction(resquestData)
|
resp := CallFunction(resquestData)
|
||||||
if isJson {
|
if isJson {
|
||||||
@ -14,6 +14,9 @@ var (
|
|||||||
|
|
||||||
//跳过验证token的页面
|
//跳过验证token的页面
|
||||||
skipVerifyTokenPage = make(map[string]bool)
|
skipVerifyTokenPage = make(map[string]bool)
|
||||||
|
|
||||||
|
//需要获取请求信息
|
||||||
|
needGetRequestInfo = make(map[string]bool)
|
||||||
)
|
)
|
||||||
|
|
||||||
type TokenInfo struct {
|
type TokenInfo struct {
|
||||||
@ -97,10 +100,12 @@ func CheckToken(token int64) (bool, *TokenInfo) {
|
|||||||
return true, tokenInfo
|
return true, tokenInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AddSkipVerifyTokenPage 添加跳过验证token的页面
|
||||||
func AddSkipVerifyTokenPage(moduleName, methodName string) {
|
func AddSkipVerifyTokenPage(moduleName, methodName string) {
|
||||||
skipVerifyTokenPage[moduleName+"_"+methodName] = true
|
skipVerifyTokenPage[moduleName+"_"+methodName] = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsSkipVerifyTokenPage 判断是否跳过验证token的页面
|
||||||
func IsSkipVerifyTokenPage(moduleName, methodName string) bool {
|
func IsSkipVerifyTokenPage(moduleName, methodName string) bool {
|
||||||
exist, ok := skipVerifyTokenPage[moduleName+"_"+methodName]
|
exist, ok := skipVerifyTokenPage[moduleName+"_"+methodName]
|
||||||
if !exist {
|
if !exist {
|
||||||
@ -108,3 +113,17 @@ func IsSkipVerifyTokenPage(moduleName, methodName string) bool {
|
|||||||
}
|
}
|
||||||
return ok
|
return ok
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AddNeedGetRequestInfo 添加需要获取请求信息的页面
|
||||||
|
func AddNeedGetRequestInfo(moduleName, methodName string) {
|
||||||
|
needGetRequestInfo[moduleName+"_"+methodName] = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsNeedGetRequestInfo 判断是否需要获取请求信息的页面
|
||||||
|
func IsNeedGetRequestInfo(moduleName, methodName string) bool {
|
||||||
|
exist, ok := needGetRequestInfo[moduleName+"_"+methodName]
|
||||||
|
if !exist {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return ok
|
||||||
|
}
|
||||||
40
trunk/center/dbcenter/Dockerfile
Normal file
40
trunk/center/dbcenter/Dockerfile
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
# 使用官方的 Go 镜像作为构建环境
|
||||||
|
FROM golang:1.22.10-alpine AS builder
|
||||||
|
|
||||||
|
# 设置工作目录
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# 设置 Go 代理
|
||||||
|
ENV GOPROXY=https://goproxy.cn,direct
|
||||||
|
|
||||||
|
# 禁用 CGO
|
||||||
|
ENV CGO_ENABLED=0
|
||||||
|
|
||||||
|
# 复制所有源代码文件
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
WORKDIR /app/dbServer
|
||||||
|
|
||||||
|
# 构建应用程序,并确认生成的文件
|
||||||
|
RUN go build -o dbServer -ldflags="-s -w"
|
||||||
|
|
||||||
|
# 使用官方的 Alpine 镜像作为运行环境
|
||||||
|
FROM alpine:latest
|
||||||
|
|
||||||
|
# 设置作者标签
|
||||||
|
LABEL authors="tp"
|
||||||
|
|
||||||
|
# 设置工作目录
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# 从构建阶段复制编译好的可执行文件
|
||||||
|
COPY --from=builder /app/dbServer/dbServer .
|
||||||
|
|
||||||
|
# 复制配置文件
|
||||||
|
COPY --from=builder /app/dbServer/config.yaml .
|
||||||
|
|
||||||
|
# 暴露端口(假设 adminserver 监听 10051 端口)
|
||||||
|
EXPOSE 10051
|
||||||
|
|
||||||
|
# 设置容器启动时运行 adminserver
|
||||||
|
ENTRYPOINT ["./dbServer"]
|
||||||
21
trunk/center/dbcenter/buildLiunx.sh
Normal file
21
trunk/center/dbcenter/buildLiunx.sh
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# 设置 Go 环境变量,确保使用 Linux 架构
|
||||||
|
export GOOS=linux
|
||||||
|
export GOARCH=amd64
|
||||||
|
|
||||||
|
echo "开始编译..."
|
||||||
|
|
||||||
|
# 编译 Go 代码
|
||||||
|
go build -o dbServer
|
||||||
|
|
||||||
|
# 检查编译是否成功
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo "编译成功!"
|
||||||
|
else
|
||||||
|
echo "编译失败!"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 等待用户输入任意键
|
||||||
|
read -p "编译完成,按任意键继续..."
|
||||||
|
exit 1
|
||||||
63
trunk/center/dbcenter/config.yaml
Normal file
63
trunk/center/dbcenter/config.yaml
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
# 配置根节点
|
||||||
|
root:
|
||||||
|
# 是否是调试模式
|
||||||
|
debug: true
|
||||||
|
|
||||||
|
# Web服务监听地址和端口
|
||||||
|
web_server_address: "192.168.50.85:10051"
|
||||||
|
|
||||||
|
# Elasticsearch 地址
|
||||||
|
es_urls: "http://10.252.0.70:18099"
|
||||||
|
|
||||||
|
# RabbitMQ 配置
|
||||||
|
rabbitmq_address: "amqp://admin:admin@192.168.50.85:5672/"
|
||||||
|
|
||||||
|
# mq队列名称
|
||||||
|
mq_queue_name: "admin_center"
|
||||||
|
|
||||||
|
# 数据库配置
|
||||||
|
db_config:
|
||||||
|
# 实时更新数据库数量{玩家库/用户库}
|
||||||
|
db_num: [ 0 ]
|
||||||
|
|
||||||
|
admin_db:
|
||||||
|
# 最大处于开启状态的连接数
|
||||||
|
max_open_conns: 0
|
||||||
|
|
||||||
|
# 最大处于空闲状态的连接数
|
||||||
|
max_idle_conns: 0
|
||||||
|
|
||||||
|
# 数据库连接字符串
|
||||||
|
connection_string: "root:Qq5201530300@tcp(192.168.50.110:3306)/admin?charset=utf8&parseTime=true&loc=Local&timeout=30s&multiStatements=true"
|
||||||
|
|
||||||
|
user_db:
|
||||||
|
# 最大处于开启状态的连接数
|
||||||
|
max_open_conns: 0
|
||||||
|
|
||||||
|
# 最大处于空闲状态的连接数
|
||||||
|
max_idle_conns: 0
|
||||||
|
|
||||||
|
# 数据库连接字符串
|
||||||
|
connection_string: "root:Qq5201530300@tcp(192.168.50.110:3306)/user?charset=utf8&parseTime=true&loc=Local&timeout=30s&multiStatements=true"
|
||||||
|
|
||||||
|
redis_config:
|
||||||
|
# 数据库连接字符串
|
||||||
|
connection_string: "192.168.50.110:6379"
|
||||||
|
|
||||||
|
# 密码, 如果要设置用户Id,则密码设置为:"UserId:Password"
|
||||||
|
password: ""
|
||||||
|
|
||||||
|
# 数据库序号
|
||||||
|
database: 5
|
||||||
|
|
||||||
|
# 最大活跃连接数
|
||||||
|
max_active: 500
|
||||||
|
|
||||||
|
# 最大空闲的连接数
|
||||||
|
max_idle: 200
|
||||||
|
|
||||||
|
# 连接空闲超时时间,单位:秒
|
||||||
|
idle_timeout: 300
|
||||||
|
|
||||||
|
# 连接超时时间, 单位:秒
|
||||||
|
dial_connect_timeout: 10
|
||||||
BIN
trunk/center/dbcenter/dbServer
Normal file
BIN
trunk/center/dbcenter/dbServer
Normal file
Binary file not shown.
28
trunk/center/dbcenter/dockerRun.sh
Normal file
28
trunk/center/dbcenter/dockerRun.sh
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# 导航到 Dockerfile 所在目录
|
||||||
|
#cd D:\workspace\e2023\goProject\trunk\center\admincenter
|
||||||
|
|
||||||
|
# 构建 Docker 镜像
|
||||||
|
echo "开始构建 Docker 镜像..."
|
||||||
|
docker build -t adminserver-image .
|
||||||
|
|
||||||
|
# 检查构建是否成功
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "构建失败!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "镜像构建成功!"
|
||||||
|
|
||||||
|
# 运行 Docker 容器
|
||||||
|
echo "开始运行 Docker 容器..."
|
||||||
|
docker run -d -p 10051:10051 --name adminserver-container adminserver-image
|
||||||
|
|
||||||
|
# 检查容器是否成功运行
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "容器启动失败!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "容器启动成功!"
|
||||||
@ -2,4 +2,37 @@ module dbcenter
|
|||||||
|
|
||||||
go 1.22.10
|
go 1.22.10
|
||||||
|
|
||||||
require github.com/streadway/amqp v1.1.0 // indirect
|
replace (
|
||||||
|
common => ../common
|
||||||
|
framework => ../../framework
|
||||||
|
goutil => ../../goutil
|
||||||
|
)
|
||||||
|
|
||||||
|
require (
|
||||||
|
common v0.0.0-00010101000000-000000000000
|
||||||
|
goutil v0.0.0-20230425160006-b2d0b0a0b0b0
|
||||||
|
)
|
||||||
|
|
||||||
|
require (
|
||||||
|
framework v0.0.0-20230425160006-b2d0b0a0b0b0 // indirect
|
||||||
|
github.com/cespare/xxhash/v2 v2.1.2 // indirect
|
||||||
|
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||||
|
github.com/elastic/go-elasticsearch/v8 v8.0.0-20210916085751-c2fb55d91ba4 // indirect
|
||||||
|
github.com/fatih/color v1.15.0 // indirect
|
||||||
|
github.com/go-redis/redis/v8 v8.11.5 // indirect
|
||||||
|
github.com/go-sql-driver/mysql v1.7.0 // indirect
|
||||||
|
github.com/gomodule/redigo v1.8.9 // indirect
|
||||||
|
github.com/gorilla/websocket v1.4.2 // indirect
|
||||||
|
github.com/jinzhu/gorm v1.9.12 // indirect
|
||||||
|
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||||
|
github.com/jinzhu/now v1.1.5 // indirect
|
||||||
|
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||||
|
github.com/mattn/go-isatty v0.0.17 // indirect
|
||||||
|
github.com/streadway/amqp v1.1.0
|
||||||
|
golang.org/x/net v0.0.0-20210916014120-12bc252f5db8 // indirect
|
||||||
|
golang.org/x/sys v0.6.0 // indirect
|
||||||
|
golang.org/x/text v0.14.0 // indirect
|
||||||
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
|
gorm.io/driver/mysql v1.5.7 // indirect
|
||||||
|
gorm.io/gorm v1.25.12 // indirect
|
||||||
|
)
|
||||||
|
|||||||
@ -1,2 +1,89 @@
|
|||||||
|
github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE=
|
||||||
|
github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||||
|
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
||||||
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd h1:83Wprp6ROGeiHFAP8WJdI2RoxALQYgdllERc3N5N2DM=
|
||||||
|
github.com/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
|
||||||
|
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
|
||||||
|
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
|
||||||
|
github.com/elastic/go-elasticsearch/v8 v8.0.0-20210916085751-c2fb55d91ba4 h1:OoL469zqSNrTLSz5zeVF/I6VOO7fiw2bzSzQe4J557c=
|
||||||
|
github.com/elastic/go-elasticsearch/v8 v8.0.0-20210916085751-c2fb55d91ba4/go.mod h1:xe9a/L2aeOgFKKgrO3ibQTnMdpAeL0GC+5/HpGScSa4=
|
||||||
|
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5 h1:Yzb9+7DPaBjB8zlTR87/ElzFsnQfuHnVUVqpZZIcV5Y=
|
||||||
|
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0=
|
||||||
|
github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs=
|
||||||
|
github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw=
|
||||||
|
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
|
||||||
|
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||||
|
github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI=
|
||||||
|
github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo=
|
||||||
|
github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
|
||||||
|
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/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY=
|
||||||
|
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
|
||||||
|
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
|
github.com/gomodule/redigo v1.8.9 h1:Sl3u+2BI/kk+VEatbj0scLdrFhjPmbxOc1myhDP41ws=
|
||||||
|
github.com/gomodule/redigo v1.8.9/go.mod h1:7ArFNvsTjH8GMMzB4uy1snslv2BwmginuMs06a1uzZE=
|
||||||
|
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
|
||||||
|
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||||
|
github.com/jinzhu/gorm v1.9.12 h1:Drgk1clyWT9t9ERbzHza6Mj/8FY/CqMyVzOiHviMo6Q=
|
||||||
|
github.com/jinzhu/gorm v1.9.12/go.mod h1:vhTjlKSJUTWNtcbQtrMBFCxy7eXTzeCAzfL5fBZT/Qs=
|
||||||
|
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.0.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||||
|
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
|
||||||
|
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||||
|
github.com/lib/pq v1.1.1 h1:sJZmqHoEaY7f+NPP8pgLB/WxulyR3fewgCM2qaSlBb4=
|
||||||
|
github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||||
|
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||||
|
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
||||||
|
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||||
|
github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=
|
||||||
|
github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||||
|
github.com/mattn/go-sqlite3 v2.0.1+incompatible h1:xQ15muvnzGBHpIpdrNi1DA5x0+TcBZzsIDwmw9uTHzw=
|
||||||
|
github.com/mattn/go-sqlite3 v2.0.1+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
|
||||||
|
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
|
||||||
|
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
|
||||||
|
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
|
||||||
|
github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU=
|
||||||
|
github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE=
|
||||||
|
github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs=
|
||||||
|
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/streadway/amqp v1.1.0 h1:py12iX8XSyI7aN/3dUT8DFIDJazNJsVJdxNVEpnQTZM=
|
github.com/streadway/amqp v1.1.0 h1:py12iX8XSyI7aN/3dUT8DFIDJazNJsVJdxNVEpnQTZM=
|
||||||
github.com/streadway/amqp v1.1.0/go.mod h1:WYSrTEYHOXHd0nwFeUXAe2G2hRnQT+deZJJf88uS9Bg=
|
github.com/streadway/amqp v1.1.0/go.mod h1:WYSrTEYHOXHd0nwFeUXAe2G2hRnQT+deZJJf88uS9Bg=
|
||||||
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
|
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
|
||||||
|
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||||
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
|
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
|
golang.org/x/crypto v0.0.0-20191205180655-e7c4368fe9dd h1:GGJVjV8waZKRHrgwvtH66z9ZGVurTD1MT0n1Bb+q4aM=
|
||||||
|
golang.org/x/crypto v0.0.0-20191205180655-e7c4368fe9dd/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
|
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
|
golang.org/x/net v0.0.0-20210916014120-12bc252f5db8 h1:/6y1LfuqNuQdHAm0jjtPtgRcxIxjVZgm5OTu8/QhZvk=
|
||||||
|
golang.org/x/net v0.0.0-20210916014120-12bc252f5db8/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
|
||||||
|
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
|
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
||||||
|
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||||
|
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||||
|
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/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
|
||||||
|
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||||
|
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||||
|
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||||
|
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.7 h1:MndhOPYOfEp2rHKgkZIhJ16eVUIRf2HmzgoPmh7FCWo=
|
||||||
|
gorm.io/driver/mysql v1.5.7/go.mod h1:sEtPWMiqiN1N1cMXoXmBbd8C6/l+TESwriotuRRpkDM=
|
||||||
|
gorm.io/gorm v1.25.7/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8=
|
||||||
|
gorm.io/gorm v1.25.12 h1:I0u8i2hWQItBq1WfE0o2+WuL9+8L21K9e2HHSTE/0f8=
|
||||||
|
gorm.io/gorm v1.25.12/go.mod h1:xh7N7RHfYlNc5EmcI/El95gXusucDrQnHXe0+CgWcLQ=
|
||||||
|
|||||||
37
trunk/center/dbcenter/internal/db_heandler.go
Normal file
37
trunk/center/dbcenter/internal/db_heandler.go
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
package internal
|
||||||
|
|
||||||
|
import (
|
||||||
|
"common/connection"
|
||||||
|
"goutil/logUtilPlus"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ExecSql 执行sql
|
||||||
|
func ExecSql(sql string) error {
|
||||||
|
|
||||||
|
defer func() error {
|
||||||
|
if err := recover(); err != nil {
|
||||||
|
logUtilPlus.ErrorLog("mq远程执行sql异常,对应sql:%s", sql)
|
||||||
|
|
||||||
|
//写入失败的文件,便于后续排查
|
||||||
|
AddSqlErr(sql)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}()
|
||||||
|
|
||||||
|
//获取数据库连接
|
||||||
|
db := connection.GetAdminDB()
|
||||||
|
|
||||||
|
logUtilPlus.InfoLog("执行sql:%s", sql)
|
||||||
|
|
||||||
|
//执行sql
|
||||||
|
err := db.Exec(sql).Error
|
||||||
|
|
||||||
|
//判断错误
|
||||||
|
if err != nil {
|
||||||
|
|
||||||
|
//记录错误
|
||||||
|
logUtilPlus.ErrorLog("ExecSql error:", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
60
trunk/center/dbcenter/internal/sql_err.go
Normal file
60
trunk/center/dbcenter/internal/sql_err.go
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
package internal
|
||||||
|
|
||||||
|
import (
|
||||||
|
"goutil/fileUtil"
|
||||||
|
"sync"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
sqlErrList []string
|
||||||
|
sqlErrListLock sync.RWMutex
|
||||||
|
|
||||||
|
fileName = "ErrSql"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
go func() {
|
||||||
|
for {
|
||||||
|
|
||||||
|
//休息一秒
|
||||||
|
time.Sleep(time.Second)
|
||||||
|
|
||||||
|
WriteErrSql()
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddSqlErr 添加异常sql
|
||||||
|
func AddSqlErr(sql string) {
|
||||||
|
|
||||||
|
//数据库过大就不再写入
|
||||||
|
if len(sqlErrList) > 10000 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func() {
|
||||||
|
sqlErrListLock.Lock()
|
||||||
|
defer sqlErrListLock.Unlock()
|
||||||
|
sqlErrList = append(sqlErrList, sql)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
|
// WriteErrSql 获取异常sql 写入文件
|
||||||
|
func WriteErrSql() {
|
||||||
|
sqlErrListLock.RLock()
|
||||||
|
defer sqlErrListLock.RUnlock()
|
||||||
|
|
||||||
|
//文件名拼接
|
||||||
|
filePath := fileName + "/" + time.Now().Format("2006-01-02")
|
||||||
|
fileName := time.Now().Format("2006-01-02 09") + ".txt"
|
||||||
|
|
||||||
|
for _, sql := range sqlErrList {
|
||||||
|
//sql 添加换行符
|
||||||
|
sql += ";\r\n"
|
||||||
|
fileUtil.WriteFile(filePath, fileName, true, sql)
|
||||||
|
|
||||||
|
//删除已经执行的sql
|
||||||
|
sqlErrList = sqlErrList[1:]
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,5 +1,43 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"common/connection"
|
||||||
|
"common/rabbitmq"
|
||||||
|
"dbcenter/internal"
|
||||||
|
"sync"
|
||||||
|
|
||||||
|
_ "common/resultstatus"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
wg sync.WaitGroup
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
// 设置WaitGroup需要等待的数量,只要有一个服务器出现错误都停止服务器
|
||||||
|
wg.Add(1)
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
|
//加载配置
|
||||||
|
loadConfig()
|
||||||
|
|
||||||
|
// 启动mq监听
|
||||||
|
rabbitmq.ConsumeData(internal.ExecSql)
|
||||||
|
|
||||||
|
// 阻塞等待,以免main线程退出
|
||||||
|
wg.Wait()
|
||||||
|
}
|
||||||
|
|
||||||
|
// loadConfig 用于加载配置信息。
|
||||||
|
// 该函数会读取配置文件或环境变量中的设置,并根据这些设置初始化程序所需的配置。
|
||||||
|
// 目前函数的实现为空,需要根据实际的配置加载逻辑进行填充。
|
||||||
|
func loadConfig() {
|
||||||
|
|
||||||
|
//设置数据类型
|
||||||
|
connection.SetModelDB(connection.GetAdminDB())
|
||||||
|
|
||||||
|
//构建数据库
|
||||||
|
connection.BuildDB()
|
||||||
}
|
}
|
||||||
|
|||||||
20
trunk/center/dbcenter/run.sh
Normal file
20
trunk/center/dbcenter/run.sh
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# 赋予可执行权限
|
||||||
|
chmod +x dbServer
|
||||||
|
|
||||||
|
echo "启动中..."
|
||||||
|
|
||||||
|
# 接受命令行传入一个参数
|
||||||
|
case "$1" in
|
||||||
|
d)
|
||||||
|
# 使用 nohup 将进程放到后台运行,并将输出重定向到 nohup.out 文件
|
||||||
|
nohup ./dbServer > nohup.out 2>&1 &
|
||||||
|
echo "启动完成"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
./dbServer
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
echo "启动完成"
|
||||||
16
trunk/center/dbcenter/stop.sh
Normal file
16
trunk/center/dbcenter/stop.sh
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# 查找 dbServer 的 PID
|
||||||
|
PID=$(pgrep dbServer)
|
||||||
|
|
||||||
|
if [ -z "$PID" ]; then
|
||||||
|
echo "dbServer 进程未找到"
|
||||||
|
else
|
||||||
|
echo "停止中... (PID: $PID)"
|
||||||
|
kill $PID
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo "dbServer 进程已终止 (PID: $PID)"
|
||||||
|
else
|
||||||
|
echo "无法终止 dbServer 进程 (PID: $PID)"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
@ -52,3 +52,11 @@ root:
|
|||||||
|
|
||||||
# 连接超时时间, 单位:秒
|
# 连接超时时间, 单位:秒
|
||||||
dial_connect_timeout: 10
|
dial_connect_timeout: 10
|
||||||
|
|
||||||
|
# 微信相关配置
|
||||||
|
wx_config:
|
||||||
|
|
||||||
|
# 微信移动应用appId
|
||||||
|
appId: "45678"
|
||||||
|
# 微信移动应用appSecret
|
||||||
|
appSecret: "954821"
|
||||||
125
trunk/center/paycenter/internal/mesqueue/game_msg.go
Normal file
125
trunk/center/paycenter/internal/mesqueue/game_msg.go
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
package mesqueue
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"goutil/fileUtil"
|
||||||
|
"goutil/logUtilPlus"
|
||||||
|
"goutil/webUtil"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type GameMsg struct {
|
||||||
|
|
||||||
|
//订单id
|
||||||
|
OrderID int64
|
||||||
|
|
||||||
|
//玩家id
|
||||||
|
PlayerID string
|
||||||
|
|
||||||
|
//区服id
|
||||||
|
ServerID int64
|
||||||
|
|
||||||
|
//游戏id
|
||||||
|
GameId string
|
||||||
|
|
||||||
|
//充值金额
|
||||||
|
price int64
|
||||||
|
|
||||||
|
// 充值商品id
|
||||||
|
storeId int64
|
||||||
|
|
||||||
|
// 推送次数
|
||||||
|
pushCount int32
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
//消息队列
|
||||||
|
msgQueue chan GameMsg = make(chan GameMsg, 100)
|
||||||
|
|
||||||
|
fileName = "ErrPushMsg"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
ConsumeQueue()
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddQueue 添加消息队列
|
||||||
|
func AddQueue(gameMsg GameMsg) {
|
||||||
|
msgQueue <- gameMsg
|
||||||
|
}
|
||||||
|
|
||||||
|
// ConsumeQueue 消费消息队列
|
||||||
|
func ConsumeQueue() {
|
||||||
|
go func() {
|
||||||
|
//捕获异常
|
||||||
|
defer func() {
|
||||||
|
if err := recover(); err != nil {
|
||||||
|
//TODO 捕获异常
|
||||||
|
logUtilPlus.ErrorLog("推送充值信息到game异常 err:%s", err)
|
||||||
|
|
||||||
|
//重新开启
|
||||||
|
restartConsumer()
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
for {
|
||||||
|
gameMsg := <-msgQueue
|
||||||
|
|
||||||
|
url := fmt.Sprintf("http://www.game.com/pay %s", gameMsg.GameId)
|
||||||
|
|
||||||
|
//消费消息队列 推送重置信息到game
|
||||||
|
result, err := webUtil.GetWebData(url, map[string]string{})
|
||||||
|
if err != nil {
|
||||||
|
logUtilPlus.ErrorLog("推送充值信息到game异常 err:%s", err)
|
||||||
|
|
||||||
|
//放入消息队列重新推送
|
||||||
|
if gameMsg.pushCount < 3 {
|
||||||
|
msgQueue <- gameMsg
|
||||||
|
gameMsg.pushCount++
|
||||||
|
} else { //加入文件放弃推送
|
||||||
|
WriteErrPushMsg(url)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if string(result) != "" {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
|
// WriteErrPushMsg 推送异常消息 写入文件
|
||||||
|
func WriteErrPushMsg(messages string) {
|
||||||
|
|
||||||
|
//文件名拼接
|
||||||
|
filePath := fileName + "/" + time.Now().Format("2006-01-02")
|
||||||
|
fileName := time.Now().Format("2006-01-02 09") + ".txt"
|
||||||
|
|
||||||
|
//消息 添加换行符
|
||||||
|
messages += ";\r\n"
|
||||||
|
err := fileUtil.WriteFile(filePath, fileName, true, messages)
|
||||||
|
if err != nil {
|
||||||
|
logUtilPlus.ErrorLog(" MegPush 写入文件失败 err:%s", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// restartConsumer 重启消费者
|
||||||
|
func restartConsumer() {
|
||||||
|
// 设置重试次数
|
||||||
|
maxRetries := 5
|
||||||
|
retryCount := 0
|
||||||
|
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case <-time.After(5 * time.Second): // 等待5秒后重试
|
||||||
|
if retryCount >= maxRetries {
|
||||||
|
logUtilPlus.ErrorLog("消费者重启失败,达到最大重试次数")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
logUtilPlus.InfoLog("重新启动消费者,重试次数: %d", retryCount+1)
|
||||||
|
ConsumeQueue()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
retryCount++
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -21,11 +21,25 @@ var (
|
|||||||
mchID string = wxpaycofnig.GetWxPayConfig().MchID // 商户号
|
mchID string = wxpaycofnig.GetWxPayConfig().MchID // 商户号
|
||||||
mchCertificateSerialNumber string = wxpaycofnig.GetWxPayConfig().MchCertificateSerialNumber // 商户证书序列号
|
mchCertificateSerialNumber string = wxpaycofnig.GetWxPayConfig().MchCertificateSerialNumber // 商户证书序列号
|
||||||
mchAPIv3Key string = wxpaycofnig.GetWxPayConfig().MchAPIv3Key // 商户APIv3密钥
|
mchAPIv3Key string = wxpaycofnig.GetWxPayConfig().MchAPIv3Key // 商户APIv3密钥
|
||||||
|
appId string = wxpaycofnig.GetWxPayConfig().AppId // 应用ID
|
||||||
|
Address string = "成都市XXXXXXXXXXXXXXXXXXXXXXX" //公司地址
|
||||||
|
wxPayApiUrl string = wxpaycofnig.GetWxPayConfig().NotifyUrl //支付成功回调地址
|
||||||
)
|
)
|
||||||
|
|
||||||
// Prepay 预支付
|
// Prepay 函数用于发起预支付请求。
|
||||||
func Prepay(outTradeNo int64, description string) (string, error) {
|
// 参数:
|
||||||
|
//
|
||||||
|
// outTradeNo: 商户订单号。
|
||||||
|
// currency: 订单金额,单位为分。
|
||||||
|
// storeId: 商户门店编号。
|
||||||
|
// clientIp: 用户的客户端IP。
|
||||||
|
// description: 订单描述。
|
||||||
|
//
|
||||||
|
// 返回值:
|
||||||
|
//
|
||||||
|
// 成功时返回预支付ID和nil错误。
|
||||||
|
// 失败时返回空字符串和错误对象。
|
||||||
|
func Prepay(outTradeNo int64, currency int64, storeId string, clientIp string, description string) (string, error) {
|
||||||
|
|
||||||
// 使用 utils 提供的函数从本地文件中加载商户私钥,商户私钥会用来生成请求的签名
|
// 使用 utils 提供的函数从本地文件中加载商户私钥,商户私钥会用来生成请求的签名
|
||||||
mchPrivateKey, err := utils.LoadPrivateKeyWithPath("/path/to/merchant/apiclient_key.pem")
|
mchPrivateKey, err := utils.LoadPrivateKeyWithPath("/path/to/merchant/apiclient_key.pem")
|
||||||
@ -48,39 +62,39 @@ func Prepay(outTradeNo int64, description string) (string, error) {
|
|||||||
svc := app.AppApiService{Client: client}
|
svc := app.AppApiService{Client: client}
|
||||||
resp, result, err := svc.Prepay(ctx,
|
resp, result, err := svc.Prepay(ctx,
|
||||||
app.PrepayRequest{
|
app.PrepayRequest{
|
||||||
Appid: core.String("wxd678efh567hg6787"),
|
Appid: core.String(appId),
|
||||||
Mchid: core.String("1230000109"),
|
Mchid: core.String(mchID),
|
||||||
Description: core.String(description),
|
Description: core.String(description),
|
||||||
OutTradeNo: core.String(strconv.FormatInt(outTradeNo, 10)),
|
OutTradeNo: core.String(strconv.FormatInt(outTradeNo, 10)),
|
||||||
TimeExpire: core.Time(time.Now()),
|
TimeExpire: core.Time(time.Now().Add(time.Hour * 2)), //支付时效时间 2 小时后失效
|
||||||
Attach: core.String("自定义数据说明"),
|
Attach: core.String(""), //附加数据 这里不需要,有个订单id 可以获取订单详细信息
|
||||||
NotifyUrl: core.String("https://www.weixin.qq.com/wxpay/pay.php"),
|
NotifyUrl: core.String(fmt.Sprintf(wxPayApiUrl, strconv.FormatInt(outTradeNo, 10))), //回调地址
|
||||||
GoodsTag: core.String("WXG"),
|
//GoodsTag: core.String("WXG"),//优惠标记 这里没用
|
||||||
LimitPay: []string{"LimitPay_example"},
|
//LimitPay: []string{"LimitPay_example"},
|
||||||
SupportFapiao: core.Bool(false),
|
SupportFapiao: core.Bool(false),
|
||||||
Amount: &app.Amount{
|
Amount: &app.Amount{
|
||||||
Currency: core.String("CNY"),
|
Currency: core.String("CNY"),
|
||||||
Total: core.Int64(100),
|
Total: core.Int64(currency),
|
||||||
},
|
},
|
||||||
Detail: &app.Detail{
|
Detail: &app.Detail{
|
||||||
CostPrice: core.Int64(608800),
|
//CostPrice: core.Int64(608800),
|
||||||
GoodsDetail: []app.GoodsDetail{app.GoodsDetail{
|
GoodsDetail: []app.GoodsDetail{app.GoodsDetail{
|
||||||
GoodsName: core.String("iPhoneX 256G"),
|
GoodsName: core.String(storeId), //商品编号
|
||||||
MerchantGoodsId: core.String("ABC"),
|
MerchantGoodsId: core.String(description),
|
||||||
Quantity: core.Int64(1),
|
Quantity: core.Int64(1),
|
||||||
UnitPrice: core.Int64(828800),
|
UnitPrice: core.Int64(currency),
|
||||||
WechatpayGoodsId: core.String("1001"),
|
//WechatpayGoodsId: core.String("1001"),
|
||||||
}},
|
}},
|
||||||
InvoiceId: core.String("wx123"),
|
//InvoiceId: core.String("wx123"),
|
||||||
},
|
},
|
||||||
SceneInfo: &app.SceneInfo{
|
SceneInfo: &app.SceneInfo{
|
||||||
DeviceId: core.String("013467007045764"),
|
//DeviceId: core.String("013467007045764"),
|
||||||
PayerClientIp: core.String("14.23.150.211"),
|
PayerClientIp: core.String(clientIp),
|
||||||
StoreInfo: &app.StoreInfo{
|
StoreInfo: &app.StoreInfo{
|
||||||
Address: core.String("广东省深圳市南山区科技中一道10000号"),
|
Address: core.String(Address),
|
||||||
AreaCode: core.String("440305"),
|
//AreaCode: core.String("440305"),
|
||||||
Id: core.String("0001"),
|
//Id: core.String("0001"),
|
||||||
Name: core.String("腾讯大厦分店"),
|
//Name: core.String("腾讯大厦分店"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
SettleInfo: &app.SettleInfo{
|
SettleInfo: &app.SettleInfo{
|
||||||
@ -105,7 +119,7 @@ func Prepay(outTradeNo int64, description string) (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CloseOrder 关闭订单
|
// CloseOrder 关闭订单
|
||||||
func CloseOrder() {
|
func CloseOrder(outTradeNo int64) error {
|
||||||
|
|
||||||
// 使用 utils 提供的函数从本地文件中加载商户私钥,商户私钥会用来生成请求的签名
|
// 使用 utils 提供的函数从本地文件中加载商户私钥,商户私钥会用来生成请求的签名
|
||||||
mchPrivateKey, err := utils.LoadPrivateKeyWithPath("/path/to/merchant/apiclient_key.pem")
|
mchPrivateKey, err := utils.LoadPrivateKeyWithPath("/path/to/merchant/apiclient_key.pem")
|
||||||
@ -124,24 +138,23 @@ func CloseOrder() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
svc := app.AppApiService{Client: client}
|
svc := app.AppApiService{Client: client}
|
||||||
result, err := svc.CloseOrder(ctx,
|
_, err = svc.CloseOrder(ctx,
|
||||||
app.CloseOrderRequest{
|
app.CloseOrderRequest{
|
||||||
|
|
||||||
//商户系统内部订单号,只能是数字、大小写字母_-*且在同一个商户号下唯
|
//商户系统内部订单号,只能是数字、大小写字母_-*且在同一个商户号下唯
|
||||||
OutTradeNo: core.String("OutTradeNo_example"),
|
OutTradeNo: core.String(strconv.FormatInt(outTradeNo, 10)),
|
||||||
|
|
||||||
//直连商户的商户号,由微信支付生成并下发。
|
//直连商户的商户号,由微信支付生成并下发。
|
||||||
Mchid: core.String("1230000109"),
|
Mchid: core.String(mchID),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// 处理错误
|
// 处理错误
|
||||||
log.Printf("call CloseOrder err:%s", err)
|
logUtilPlus.ErrorLog("call CloseOrder err:%s", err)
|
||||||
} else {
|
return err
|
||||||
// 处理返回结果
|
|
||||||
log.Printf("status=%d", result.Response.StatusCode)
|
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// QueryOrderById 根据商户订单号查询订单
|
// QueryOrderById 根据商户订单号查询订单
|
||||||
@ -181,11 +194,18 @@ func QueryOrderById() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// QueryOrderByOutTradeNo 根据商户订单号查询订单
|
// QueryOrderByOutTradeNo 根据商户订单号查询订单
|
||||||
func QueryOrderByOutTradeNo() {
|
func QueryOrderByOutTradeNo(outTradeNo int64) (string, error) {
|
||||||
|
|
||||||
|
//循环查询次数
|
||||||
|
var count int = 0
|
||||||
|
|
||||||
|
loop:
|
||||||
|
|
||||||
// 使用 utils 提供的函数从本地文件中加载商户私钥,商户私钥会用来生成请求的签名
|
// 使用 utils 提供的函数从本地文件中加载商户私钥,商户私钥会用来生成请求的签名
|
||||||
mchPrivateKey, err := utils.LoadPrivateKeyWithPath("/path/to/merchant/apiclient_key.pem")
|
mchPrivateKey, err := utils.LoadPrivateKeyWithPath("/path/to/merchant/apiclient_key.pem")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Print("load merchant private key error")
|
log.Print("load merchant private key error")
|
||||||
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
@ -196,21 +216,37 @@ func QueryOrderByOutTradeNo() {
|
|||||||
client, err := core.NewClient(ctx, opts...)
|
client, err := core.NewClient(ctx, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("new wechat pay client err:%s", err)
|
log.Printf("new wechat pay client err:%s", err)
|
||||||
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
svc := app.AppApiService{Client: client}
|
svc := app.AppApiService{Client: client}
|
||||||
resp, result, err := svc.QueryOrderByOutTradeNo(ctx,
|
resp, result, err := svc.QueryOrderByOutTradeNo(ctx,
|
||||||
app.QueryOrderByOutTradeNoRequest{
|
app.QueryOrderByOutTradeNoRequest{
|
||||||
OutTradeNo: core.String("OutTradeNo_example"),
|
OutTradeNo: core.String(strconv.FormatInt(outTradeNo, 10)),
|
||||||
Mchid: core.String("Mchid_example"),
|
Mchid: &mchID,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// 处理错误
|
// 处理错误
|
||||||
log.Printf("call QueryOrderByOutTradeNo err:%s", err)
|
log.Printf("call QueryOrderByOutTradeNo err:%s", err)
|
||||||
|
return "", err
|
||||||
} else {
|
} else {
|
||||||
// 处理返回结果
|
// 处理返回结果
|
||||||
log.Printf("status=%d resp=%s", result.Response.StatusCode, resp)
|
log.Printf("status=%d resp=%s", result.Response.StatusCode, resp)
|
||||||
|
|
||||||
|
//支付成功
|
||||||
|
if resp.TradeState == core.String("SUCCESS") {
|
||||||
|
return "SUCCESS", nil
|
||||||
|
|
||||||
|
} else if resp.TradeState == core.String("NOTPAY") && count < 3 { //未支付,循环查找订单
|
||||||
|
//休息200毫秒
|
||||||
|
time.Sleep(200 * time.Millisecond)
|
||||||
|
count++
|
||||||
|
goto loop
|
||||||
|
}
|
||||||
|
|
||||||
|
//支付失败
|
||||||
|
return *resp.TradeState, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,11 @@ import (
|
|||||||
"common/resultStatus"
|
"common/resultStatus"
|
||||||
"common/webServer"
|
"common/webServer"
|
||||||
"goutil/intUtil"
|
"goutil/intUtil"
|
||||||
|
"goutil/logUtilPlus"
|
||||||
|
"goutil/webUtil"
|
||||||
|
"net/http"
|
||||||
"paycenter/internal"
|
"paycenter/internal"
|
||||||
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -24,7 +28,7 @@ func init() {
|
|||||||
remark.RegisterModuleRemark(moduleName, desc, author, mendor, date)
|
remark.RegisterModuleRemark(moduleName, desc, author, mendor, date)
|
||||||
}
|
}
|
||||||
|
|
||||||
// PayApi 用户接口
|
// PayApi 支付接口
|
||||||
type PayApi struct {
|
type PayApi struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,7 +41,7 @@ func init() {
|
|||||||
methodAuthor := "tangping"
|
methodAuthor := "tangping"
|
||||||
methodMendor := ""
|
methodMendor := ""
|
||||||
methodDate := "2025年1月8日15:51:34"
|
methodDate := "2025年1月8日15:51:34"
|
||||||
methodInParam := []string{"int32:充值模版id,string:玩家id,int32:区服id"}
|
methodInParam := []string{"int64:订单id(由服务器生成),int32:充值模版id,int64:充值金额,string:商品id, string:客户端IP地址,string:玩家id,int32:区服id"}
|
||||||
methodOutParam := `
|
methodOutParam := `
|
||||||
{
|
{
|
||||||
"Code '类型:int'": "响应结果的状态值",
|
"Code '类型:int'": "响应结果的状态值",
|
||||||
@ -50,7 +54,14 @@ func init() {
|
|||||||
}`
|
}`
|
||||||
remark.RegisterMethodRemark(moduleName, methodName, methodDesc, methodAuthor, methodMendor, methodDate, methodInParam, methodOutParam, skipVerifyTokenPage)
|
remark.RegisterMethodRemark(moduleName, methodName, methodDesc, methodAuthor, methodMendor, methodDate, methodInParam, methodOutParam, skipVerifyTokenPage)
|
||||||
}
|
}
|
||||||
func (a *PayApi) PlaceAnOrder(modelID int32, playerID string, serverID int64) (responseObj *webServer.ResponseObject) {
|
|
||||||
|
// 需要获取请求信息
|
||||||
|
func init() {
|
||||||
|
moduleName := "PayApi"
|
||||||
|
methodName := "PlaceAnOrder"
|
||||||
|
webServer.AddNeedGetRequestInfo(moduleName, methodName)
|
||||||
|
}
|
||||||
|
func (a *PayApi) PlaceAnOrder(orderId int64, modelID int32, currency int64, storeId string, playerID string, serverID int64, r *http.Request) (responseObj *webServer.ResponseObject) {
|
||||||
responseObj = webServer.GetInitResponseObj()
|
responseObj = webServer.GetInitResponseObj()
|
||||||
|
|
||||||
//校验参数
|
//校验参数
|
||||||
@ -67,23 +78,17 @@ func (a *PayApi) PlaceAnOrder(modelID int32, playerID string, serverID int64) (r
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//客户端请求ip
|
||||||
|
clientIp := webUtil.GetRequestIP(r)
|
||||||
|
|
||||||
//下微信订单
|
//下微信订单
|
||||||
prepayId, err := internal.Prepay(orderId, "描述!!!!!!!!!!")
|
prepayId, err := internal.Prepay(orderId, currency, storeId, clientIp, "描述!!!!!!!!!!")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
responseObj.SetResultStatus(resultStatus.APIDataError)
|
responseObj.SetResultStatus(resultStatus.APIDataError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
//处理数据
|
//处理数据
|
||||||
order := &Order{
|
order := NewOrder(orderId, prepayId, playerID, serverID, 1)
|
||||||
OrderID: orderId,
|
|
||||||
PrepayId: prepayId,
|
|
||||||
OrderMoney: 100,
|
|
||||||
OrderStatus: 1,
|
|
||||||
PlayerID: playerID,
|
|
||||||
ServerID: serverID,
|
|
||||||
UserID: playerID,
|
|
||||||
OrderDate: time.Now(),
|
|
||||||
}
|
|
||||||
|
|
||||||
//添加到数据库
|
//添加到数据库
|
||||||
AddOrder(order)
|
AddOrder(order)
|
||||||
@ -94,3 +99,71 @@ func (a *PayApi) PlaceAnOrder(modelID int32, playerID string, serverID int64) (r
|
|||||||
responseObj.SetData(resultMap)
|
responseObj.SetData(resultMap)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
moduleName := "PayApi"
|
||||||
|
methodName := "CallBack"
|
||||||
|
skipVerifyTokenPage := true
|
||||||
|
methodDesc := "支付成功回调"
|
||||||
|
methodAuthor := "tangping"
|
||||||
|
methodMendor := ""
|
||||||
|
methodDate := "2025年1月21日16:40:57"
|
||||||
|
methodInParam := []string{"string:订单id"}
|
||||||
|
methodOutParam := `
|
||||||
|
{
|
||||||
|
"Code '类型:int'": "响应结果的状态值",
|
||||||
|
"Message '类型:string'": "响应结果的状态值所对应的描述信息",
|
||||||
|
"Data '类型:interface{}'": "响应结果的数据"
|
||||||
|
{
|
||||||
|
"OrderID '类型:int64'": "订单id",
|
||||||
|
"prepayId '类型:int64'": "预支付会话id",
|
||||||
|
}
|
||||||
|
}`
|
||||||
|
remark.RegisterMethodRemark(moduleName, methodName, methodDesc, methodAuthor, methodMendor, methodDate, methodInParam, methodOutParam, skipVerifyTokenPage)
|
||||||
|
}
|
||||||
|
func (a *PayApi) CallBack(orderIDStr string) (responseObj *webServer.ResponseObject) {
|
||||||
|
responseObj = webServer.GetInitResponseObj()
|
||||||
|
|
||||||
|
//参数错误
|
||||||
|
if orderIDStr == "" {
|
||||||
|
responseObj.SetResultStatus(resultStatus.APIDataError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//orderID 转换成string
|
||||||
|
orderID, err := strconv.ParseInt(orderIDStr, 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
logUtilPlus.ErrorLog("订单id转换失败", err.Error())
|
||||||
|
responseObj.SetResultStatus(resultStatus.APIParamError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//是否已经处理
|
||||||
|
order, err := GetUserByID(orderID)
|
||||||
|
|
||||||
|
//支付成功
|
||||||
|
if err == nil && order != nil && order.OrderStatus == 1 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//查询订单状态
|
||||||
|
statusStr, err := internal.QueryOrderByOutTradeNo(orderID)
|
||||||
|
if err != nil {
|
||||||
|
responseObj.SetResultStatus(resultStatus.DataError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//状态错误
|
||||||
|
if statusStr != "SUCCESS" {
|
||||||
|
logUtilPlus.WarnLog("订单状态错误", statusStr)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
err = ChangeOrderStatus(orderID, 1)
|
||||||
|
if err != nil {
|
||||||
|
responseObj.SetResultStatus(resultStatus.DataError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return responseObj
|
||||||
|
}
|
||||||
|
|||||||
95
trunk/center/paycenter/internal/pay/check_order.go
Normal file
95
trunk/center/paycenter/internal/pay/check_order.go
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
package pay
|
||||||
|
|
||||||
|
import (
|
||||||
|
"common/connection"
|
||||||
|
"goutil/logUtilPlus"
|
||||||
|
"paycenter/internal"
|
||||||
|
"strconv"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
go CheckOrderStatus()
|
||||||
|
}
|
||||||
|
|
||||||
|
// CheckOrderStatus 查询订单状态
|
||||||
|
func CheckOrderStatus() {
|
||||||
|
|
||||||
|
//捕获异常
|
||||||
|
defer func() {
|
||||||
|
if err := recover(); err != nil {
|
||||||
|
logUtilPlus.ErrorLog("CheckOrderStatus panic:", err)
|
||||||
|
restartConsumer()
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
for {
|
||||||
|
//检索最近一个月的订单
|
||||||
|
for i := 0; i < 2; i++ {
|
||||||
|
|
||||||
|
//取i的负数
|
||||||
|
dbDate := connection.GetToMonthAdd(int32(-i))
|
||||||
|
var orders []Order // 使用切片存储查询结果
|
||||||
|
|
||||||
|
//这里使用原始sql
|
||||||
|
sql := "select * from order_" + strconv.Itoa(int(dbDate)) + " where order_status = 0"
|
||||||
|
dbResult := connection.GetPayDB().Exec(sql).Find(&orders)
|
||||||
|
if dbResult.Error != nil {
|
||||||
|
logUtilPlus.ErrorLog("查询订单状态失败", dbResult.Error.Error())
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理查询结果
|
||||||
|
for _, order := range orders {
|
||||||
|
|
||||||
|
//查询订单状态
|
||||||
|
statusStr, err := internal.QueryOrderByOutTradeNo(order.OrderID)
|
||||||
|
if err != nil {
|
||||||
|
logUtilPlus.ErrorLog("查询订单状态失败", err.Error())
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if statusStr == "SUCCESS" {
|
||||||
|
//修改订单状态
|
||||||
|
err = ChangeOrderStatus(order.OrderID, 1)
|
||||||
|
if err != nil {
|
||||||
|
logUtilPlus.ErrorLog("修改订单状态失败", err.Error())
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
} else if statusStr == "CLOSED" { //已关闭
|
||||||
|
order.OrderStatus = 2
|
||||||
|
//修改订单状态
|
||||||
|
connection.AsyncSave(connection.GetPayDB(), &order)
|
||||||
|
} else if order.OrderTime.Add(time.Hour * 1).Before(time.Now()) { //超一个小时未支付 直接关闭订单
|
||||||
|
//直接关闭订单
|
||||||
|
internal.CloseOrder(order.OrderID)
|
||||||
|
order.OrderStatus = 2
|
||||||
|
connection.AsyncSave(connection.GetPayDB(), &order)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//休息30分钟
|
||||||
|
time.Sleep(time.Minute * 30)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// restartConsumer 重启消费者
|
||||||
|
func restartConsumer() {
|
||||||
|
// 设置重试次数
|
||||||
|
maxRetries := 5
|
||||||
|
retryCount := 0
|
||||||
|
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case <-time.After(5 * time.Second): // 等待5秒后重试
|
||||||
|
if retryCount >= maxRetries {
|
||||||
|
logUtilPlus.ErrorLog("查询订单状态,达到最大重试次数")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
logUtilPlus.InfoLog("查询订单状态,重试次数: %d", retryCount+1)
|
||||||
|
go CheckOrderStatus()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
retryCount++
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -2,7 +2,8 @@ package pay
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"common/connection"
|
"common/connection"
|
||||||
"goutil/logUtilPlus"
|
"fmt"
|
||||||
|
"paycenter/internal/mesqueue"
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -59,14 +60,41 @@ func AddOrder(order *Order) (int64, error) {
|
|||||||
|
|
||||||
//处理一些验证
|
//处理一些验证
|
||||||
|
|
||||||
// 写入到数据库
|
// 异步 写入到数据库
|
||||||
result := connection.GetPayDB().Create(&order) // 通过数据的指针来创建
|
connection.AsyncCreate(connection.GetPayDB(), &order)
|
||||||
if result.Error != nil {
|
|
||||||
logUtilPlus.ErrorLog("添加支付订单失败 错误信息:", result.Error.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
//添加缓存
|
//添加缓存
|
||||||
AddOrderCache(order)
|
AddOrderCache(order)
|
||||||
|
|
||||||
return order.OrderID, nil
|
return order.OrderID, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ChangeOrderStatus 改变订单状态
|
||||||
|
func ChangeOrderStatus(orderID int64, status int32) error {
|
||||||
|
|
||||||
|
//根据订单id获取订单
|
||||||
|
order, err := GetUserByID(orderID)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
//判断订单是否存在
|
||||||
|
if order == nil {
|
||||||
|
return fmt.Errorf("订单不存在,订单id %d", orderID)
|
||||||
|
}
|
||||||
|
|
||||||
|
if status == 1 {
|
||||||
|
mesqueue.AddQueue(mesqueue.GameMsg{
|
||||||
|
GameId: "",
|
||||||
|
OrderID: orderID,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
//更新订单状态
|
||||||
|
order.OrderStatus = status
|
||||||
|
order.IsNotifyGameServer = 1
|
||||||
|
|
||||||
|
//异步更新数据库
|
||||||
|
connection.AsyncSave(connection.GetPayDB(), &order)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package pay
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"common/connection"
|
"common/connection"
|
||||||
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -13,13 +14,11 @@ func init() {
|
|||||||
type Order struct {
|
type Order struct {
|
||||||
//订单id
|
//订单id
|
||||||
OrderID int64 `gorm:"column:order_id;primary_key;comment:订单id" json:"order_id"`
|
OrderID int64 `gorm:"column:order_id;primary_key;comment:订单id" json:"order_id"`
|
||||||
//订单日期
|
|
||||||
OrderDate time.Time `gorm:"column:order_date;comment:订单日期" json:"order_date"`
|
|
||||||
//订单号
|
//订单号
|
||||||
PrepayId string `gorm:"column:prepay_id;comment:预支付交易会话标识" json:"prepay_id"`
|
PrepayId string `gorm:"column:prepay_id;comment:预支付交易会话标识" json:"prepay_id"`
|
||||||
//订单金额
|
//订单金额
|
||||||
OrderMoney int64 `gorm:"column:order_money;comment:订单金额" json:"order_money"`
|
OrderMoney int64 `gorm:"column:order_money;comment:订单金额" json:"order_money"`
|
||||||
//订单状态
|
//订单状态 0:未支付 1:已支付 2:已关闭
|
||||||
OrderStatus int32 `gorm:"column:order_status;comment:订单状态" json:"order_status"`
|
OrderStatus int32 `gorm:"column:order_status;comment:订单状态" json:"order_status"`
|
||||||
//用户id
|
//用户id
|
||||||
UserID string `gorm:"column:user_id;comment:用户id" json:"user_id"`
|
UserID string `gorm:"column:user_id;comment:用户id" json:"user_id"`
|
||||||
@ -27,8 +26,42 @@ type Order struct {
|
|||||||
ServerID int64 `gorm:"column:server_id;comment:区服id" json:"server_id"`
|
ServerID int64 `gorm:"column:server_id;comment:区服id" json:"server_id"`
|
||||||
//玩家标识
|
//玩家标识
|
||||||
PlayerID string `gorm:"column:player_id;comment:玩家标识" json:"player_id"`
|
PlayerID string `gorm:"column:player_id;comment:玩家标识" json:"player_id"`
|
||||||
|
//是否通知游戏服 0:未通知 1:已通知
|
||||||
|
IsNotifyGameServer int32 `gorm:"column:is_notify_game_server;comment:是否通知游戏服" json:"is_notify_game_server"`
|
||||||
|
//订单日期
|
||||||
|
OrderDate time.Time `gorm:"column:order_date;comment:订单日期" json:"order_date"`
|
||||||
|
//订单时间
|
||||||
|
OrderTime time.Time `gorm:"column:order_time;type:date;comment:订单时间" json:"order_time"`
|
||||||
|
//订单类型 1:微信支付 2:支付宝支付
|
||||||
|
OrderType int32 `gorm:"column:order_type;comment:订单类型" json:"order_type"`
|
||||||
|
|
||||||
|
//表的名字 这里是表的后缀
|
||||||
|
TableNameData int32 `gorm:"column:table_name;comment:表的名字 这里是表的后缀" json:"table_name"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TableName 表名
|
||||||
func (order *Order) TableName() string {
|
func (order *Order) TableName() string {
|
||||||
return "order"
|
return "order_" + strconv.Itoa(int(order.TableNameData))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewOrder 创建订单
|
||||||
|
// @param orderId 订单id
|
||||||
|
// @param prepayId 预支付id
|
||||||
|
// @param playerID 玩家id
|
||||||
|
// @param serverID 服务器id
|
||||||
|
// @param orderType 订单类型
|
||||||
|
func NewOrder(orderId int64, prepayId string, playerID string, serverID int64, orderType int32) *Order {
|
||||||
|
return &Order{
|
||||||
|
OrderID: orderId,
|
||||||
|
PrepayId: prepayId,
|
||||||
|
OrderMoney: 100,
|
||||||
|
OrderStatus: 1,
|
||||||
|
PlayerID: playerID,
|
||||||
|
ServerID: serverID,
|
||||||
|
UserID: playerID,
|
||||||
|
OrderDate: time.Now(),
|
||||||
|
OrderTime: time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC),
|
||||||
|
OrderType: orderType,
|
||||||
|
TableNameData: connection.GetMonth(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,6 +10,8 @@ type WxPayConfig struct {
|
|||||||
MchID string
|
MchID string
|
||||||
MchCertificateSerialNumber string
|
MchCertificateSerialNumber string
|
||||||
MchAPIv3Key string
|
MchAPIv3Key string
|
||||||
|
AppId string
|
||||||
|
NotifyUrl string
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -35,7 +37,7 @@ func init() {
|
|||||||
// @error: 错误信息
|
// @error: 错误信息
|
||||||
func reloadConfig() error {
|
func reloadConfig() error {
|
||||||
|
|
||||||
yamlFile, err := yamlUtil.LoadFromFile("payconfig/wxpayconfig.yaml.yaml")
|
yamlFile, err := yamlUtil.LoadFromFile("payconfig/wxpayconfig.yml")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import (
|
|||||||
"common/connection"
|
"common/connection"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
_ "common/resultStatus"
|
_ "common/resultstatus"
|
||||||
"common/webServer"
|
"common/webServer"
|
||||||
_ "paycenter/internal"
|
_ "paycenter/internal"
|
||||||
)
|
)
|
||||||
|
|||||||
15
trunk/center/paycenter/payconfig/wxpayconfig.yml
Normal file
15
trunk/center/paycenter/payconfig/wxpayconfig.yml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#微信支付相关配置
|
||||||
|
#商户id
|
||||||
|
MchID: '1900000109'
|
||||||
|
|
||||||
|
#商户证书序列号
|
||||||
|
MchCertificateSerialNumber: '3775D15B3B9A7F6D'
|
||||||
|
|
||||||
|
#商户APIv3密钥
|
||||||
|
MchAPIv3Key: 'X5g0l1vL9kRvP0VB2WlhtyVwqEG9zvGf'
|
||||||
|
|
||||||
|
# appId
|
||||||
|
AppID: 'wx8888888888888888'
|
||||||
|
|
||||||
|
# 微信回调地址
|
||||||
|
NotifyUrl: 'https://www.example.com/wxpay/notify?orderId=%s'
|
||||||
Binary file not shown.
@ -1,48 +0,0 @@
|
|||||||
2025-01-03 10:17:22---->
|
|
||||||
开始加载DbConfig
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:17:22---->
|
|
||||||
开始加载LogMgr
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:21:53---->
|
|
||||||
开始加载DbConfig
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:21:53---->
|
|
||||||
开始加载LogMgr
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:26:46---->
|
|
||||||
开始加载DbConfig
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:26:46---->
|
|
||||||
开始加载LogMgr
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:27:18---->
|
|
||||||
开始加载DbConfig
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:27:18---->
|
|
||||||
开始加载LogMgr
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:27:57---->
|
|
||||||
开始加载DbConfig
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:27:57---->
|
|
||||||
开始加载LogMgr
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:28:06---->
|
|
||||||
开始加载DbConfig
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:28:06---->
|
|
||||||
开始加载LogMgr
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:30:37---->
|
|
||||||
开始加载DbConfig
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:30:37---->
|
|
||||||
开始加载LogMgr
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:31:16---->
|
|
||||||
开始加载DbConfig
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:31:16---->
|
|
||||||
开始加载LogMgr
|
|
||||||
------------------------------------------------------
|
|
||||||
@ -1,165 +0,0 @@
|
|||||||
2025-01-03 10:17:22---->
|
|
||||||
开始连接mysql:root:Qq5201530300@tcp(192.168.50.110:3306)/admin?charset=utf8&parseTime=true&loc=Local&timeout=30s&multiStatements=true
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:17:22---->
|
|
||||||
连接mysql:root:Qq5201530300@tcp(192.168.50.110:3306)/admin?charset=utf8&parseTime=true&loc=Local&timeout=30s&multiStatements=true成功
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:17:22---->
|
|
||||||
开始连接mysql:root:Qq5201530300@tcp(192.168.50.110:3306)/admin?charset=utf8&parseTime=true&loc=Local&timeout=30s&multiStatements=true
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:17:22---->
|
|
||||||
连接mysql:root:Qq5201530300@tcp(192.168.50.110:3306)/admin?charset=utf8&parseTime=true&loc=Local&timeout=30s&multiStatements=true成功
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:17:22---->
|
|
||||||
ping->redis:192.168.50.110:6379成功,信息为:PONG
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:17:22---->
|
|
||||||
Web服务器开始监听:192.168.50.85:10052
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:17:32---->
|
|
||||||
monitorNewMgr没有初始化参数,请调用SetParam进行初始化
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:21:53---->
|
|
||||||
开始连接mysql:root:Qq5201530300@tcp(192.168.50.110:3306)/admin?charset=utf8&parseTime=true&loc=Local&timeout=30s&multiStatements=true
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:21:53---->
|
|
||||||
连接mysql:root:Qq5201530300@tcp(192.168.50.110:3306)/admin?charset=utf8&parseTime=true&loc=Local&timeout=30s&multiStatements=true成功
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:21:53---->
|
|
||||||
开始连接mysql:root:Qq5201530300@tcp(192.168.50.110:3306)/admin?charset=utf8&parseTime=true&loc=Local&timeout=30s&multiStatements=true
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:21:53---->
|
|
||||||
连接mysql:root:Qq5201530300@tcp(192.168.50.110:3306)/admin?charset=utf8&parseTime=true&loc=Local&timeout=30s&multiStatements=true成功
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:21:53---->
|
|
||||||
ping->redis:192.168.50.110:6379成功,信息为:PONG
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:21:53---->
|
|
||||||
Web服务器开始监听:192.168.50.85:10052
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:22:03---->
|
|
||||||
monitorNewMgr没有初始化参数,请调用SetParam进行初始化
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:26:46---->
|
|
||||||
开始连接mysql:root:Qq5201530300@tcp(192.168.50.110:3306)/admin?charset=utf8&parseTime=true&loc=Local&timeout=30s&multiStatements=true
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:26:46---->
|
|
||||||
连接mysql:root:Qq5201530300@tcp(192.168.50.110:3306)/admin?charset=utf8&parseTime=true&loc=Local&timeout=30s&multiStatements=true成功
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:26:46---->
|
|
||||||
开始连接mysql:root:Qq5201530300@tcp(192.168.50.110:3306)/admin?charset=utf8&parseTime=true&loc=Local&timeout=30s&multiStatements=true
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:26:46---->
|
|
||||||
连接mysql:root:Qq5201530300@tcp(192.168.50.110:3306)/admin?charset=utf8&parseTime=true&loc=Local&timeout=30s&multiStatements=true成功
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:26:46---->
|
|
||||||
ping->redis:192.168.50.110:6379成功,信息为:PONG
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:26:46---->
|
|
||||||
Web服务器开始监听:192.168.50.85:10052
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:26:56---->
|
|
||||||
monitorNewMgr没有初始化参数,请调用SetParam进行初始化
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:27:18---->
|
|
||||||
开始连接mysql:root:Qq5201530300@tcp(192.168.50.110:3306)/admin?charset=utf8&parseTime=true&loc=Local&timeout=30s&multiStatements=true
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:27:18---->
|
|
||||||
连接mysql:root:Qq5201530300@tcp(192.168.50.110:3306)/admin?charset=utf8&parseTime=true&loc=Local&timeout=30s&multiStatements=true成功
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:27:18---->
|
|
||||||
开始连接mysql:root:Qq5201530300@tcp(192.168.50.110:3306)/admin?charset=utf8&parseTime=true&loc=Local&timeout=30s&multiStatements=true
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:27:18---->
|
|
||||||
连接mysql:root:Qq5201530300@tcp(192.168.50.110:3306)/admin?charset=utf8&parseTime=true&loc=Local&timeout=30s&multiStatements=true成功
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:27:18---->
|
|
||||||
ping->redis:192.168.50.110:6379成功,信息为:PONG
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:27:18---->
|
|
||||||
Web服务器开始监听:192.168.50.85:10052
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:27:28---->
|
|
||||||
monitorNewMgr没有初始化参数,请调用SetParam进行初始化
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:27:57---->
|
|
||||||
开始连接mysql:root:Qq5201530300@tcp(192.168.50.110:3306)/admin?charset=utf8&parseTime=true&loc=Local&timeout=30s&multiStatements=true
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:27:57---->
|
|
||||||
连接mysql:root:Qq5201530300@tcp(192.168.50.110:3306)/admin?charset=utf8&parseTime=true&loc=Local&timeout=30s&multiStatements=true成功
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:27:57---->
|
|
||||||
开始连接mysql:root:Qq5201530300@tcp(192.168.50.110:3306)/admin?charset=utf8&parseTime=true&loc=Local&timeout=30s&multiStatements=true
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:27:57---->
|
|
||||||
连接mysql:root:Qq5201530300@tcp(192.168.50.110:3306)/admin?charset=utf8&parseTime=true&loc=Local&timeout=30s&multiStatements=true成功
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:27:57---->
|
|
||||||
ping->redis:192.168.50.110:6379成功,信息为:PONG
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:27:57---->
|
|
||||||
Web服务器开始监听:192.168.50.85:10052
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:28:06---->
|
|
||||||
开始连接mysql:root:Qq5201530300@tcp(192.168.50.110:3306)/admin?charset=utf8&parseTime=true&loc=Local&timeout=30s&multiStatements=true
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:28:06---->
|
|
||||||
连接mysql:root:Qq5201530300@tcp(192.168.50.110:3306)/admin?charset=utf8&parseTime=true&loc=Local&timeout=30s&multiStatements=true成功
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:28:06---->
|
|
||||||
开始连接mysql:root:Qq5201530300@tcp(192.168.50.110:3306)/admin?charset=utf8&parseTime=true&loc=Local&timeout=30s&multiStatements=true
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:28:06---->
|
|
||||||
连接mysql:root:Qq5201530300@tcp(192.168.50.110:3306)/admin?charset=utf8&parseTime=true&loc=Local&timeout=30s&multiStatements=true成功
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:28:06---->
|
|
||||||
ping->redis:192.168.50.110:6379成功,信息为:PONG
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:28:56---->
|
|
||||||
monitorNewMgr没有初始化参数,请调用SetParam进行初始化
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:30:02---->
|
|
||||||
Web服务器开始监听:192.168.50.85:10052
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:30:37---->
|
|
||||||
开始连接mysql:root:Qq5201530300@tcp(192.168.50.110:3306)/admin?charset=utf8&parseTime=true&loc=Local&timeout=30s&multiStatements=true
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:30:37---->
|
|
||||||
连接mysql:root:Qq5201530300@tcp(192.168.50.110:3306)/admin?charset=utf8&parseTime=true&loc=Local&timeout=30s&multiStatements=true成功
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:30:42---->
|
|
||||||
开始连接mysql:root:Qq5201530300@tcp(192.168.50.110:3306)/admin?charset=utf8&parseTime=true&loc=Local&timeout=30s&multiStatements=true
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:30:42---->
|
|
||||||
连接mysql:root:Qq5201530300@tcp(192.168.50.110:3306)/admin?charset=utf8&parseTime=true&loc=Local&timeout=30s&multiStatements=true成功
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:31:04---->
|
|
||||||
monitorNewMgr没有初始化参数,请调用SetParam进行初始化
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:31:04---->
|
|
||||||
ping->redis:192.168.50.110:6379成功,信息为:PONG
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:31:04---->
|
|
||||||
Web服务器开始监听:192.168.50.85:10052
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:31:16---->
|
|
||||||
开始连接mysql:root:Qq5201530300@tcp(192.168.50.110:3306)/admin?charset=utf8&parseTime=true&loc=Local&timeout=30s&multiStatements=true
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:31:16---->
|
|
||||||
连接mysql:root:Qq5201530300@tcp(192.168.50.110:3306)/admin?charset=utf8&parseTime=true&loc=Local&timeout=30s&multiStatements=true成功
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:31:19---->
|
|
||||||
开始连接mysql:root:Qq5201530300@tcp(192.168.50.110:3306)/user?charset=utf8&parseTime=true&loc=Local&timeout=30s&multiStatements=true
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:31:19---->
|
|
||||||
连接mysql:root:Qq5201530300@tcp(192.168.50.110:3306)/user?charset=utf8&parseTime=true&loc=Local&timeout=30s&multiStatements=true成功
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:31:19---->
|
|
||||||
ping->redis:192.168.50.110:6379成功,信息为:PONG
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:31:21---->
|
|
||||||
Web服务器开始监听:192.168.50.85:10052
|
|
||||||
------------------------------------------------------
|
|
||||||
2025-01-03 10:31:26---->
|
|
||||||
monitorNewMgr没有初始化参数,请调用SetParam进行初始化
|
|
||||||
------------------------------------------------------
|
|
||||||
@ -4,13 +4,15 @@ root:
|
|||||||
debug: true
|
debug: true
|
||||||
|
|
||||||
# Web服务监听地址和端口
|
# Web服务监听地址和端口
|
||||||
web_server_address: "192.168.50.85:10052"
|
web_server_address: "192.168.50.169:10052"
|
||||||
|
|
||||||
# Elasticsearch 地址
|
# Elasticsearch 地址
|
||||||
es_urls: "http://10.252.0.70:18099"
|
es_urls: "http://10.252.0.70:18099"
|
||||||
|
|
||||||
|
|
||||||
# 数据库配置
|
# 数据库配置
|
||||||
db_config:
|
db_config:
|
||||||
|
|
||||||
admin_db:
|
admin_db:
|
||||||
# 最大处于开启状态的连接数
|
# 最大处于开启状态的连接数
|
||||||
max_open_conns: 0
|
max_open_conns: 0
|
||||||
@ -29,7 +31,7 @@ root:
|
|||||||
max_idle_conns: 0
|
max_idle_conns: 0
|
||||||
|
|
||||||
# 数据库连接字符串
|
# 数据库连接字符串
|
||||||
connection_string: "root:Qq5201530300@tcp(192.168.50.110:3306)/pay?charset=utf8&parseTime=true&loc=Local&timeout=30s&multiStatements=true"
|
connection_string: "root:Qq5201530300@tcp(192.168.50.110:3306)/user?charset=utf8&parseTime=true&loc=Local&timeout=30s&multiStatements=true"
|
||||||
|
|
||||||
redis_config:
|
redis_config:
|
||||||
# 数据库连接字符串
|
# 数据库连接字符串
|
||||||
@ -52,3 +54,11 @@ root:
|
|||||||
|
|
||||||
# 连接超时时间, 单位:秒
|
# 连接超时时间, 单位:秒
|
||||||
dial_connect_timeout: 10
|
dial_connect_timeout: 10
|
||||||
|
|
||||||
|
# 微信相关配置
|
||||||
|
wx_config:
|
||||||
|
|
||||||
|
# 微信移动应用appId
|
||||||
|
appId: "45678"
|
||||||
|
# 微信移动应用appSecret
|
||||||
|
appSecret: "954821"
|
||||||
|
|||||||
@ -29,10 +29,11 @@ require (
|
|||||||
github.com/jinzhu/now v1.1.5 // indirect
|
github.com/jinzhu/now v1.1.5 // indirect
|
||||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||||
github.com/mattn/go-isatty v0.0.17 // indirect
|
github.com/mattn/go-isatty v0.0.17 // indirect
|
||||||
|
github.com/streadway/amqp v1.1.0 // indirect
|
||||||
golang.org/x/net v0.0.0-20210916014120-12bc252f5db8 // indirect
|
golang.org/x/net v0.0.0-20210916014120-12bc252f5db8 // indirect
|
||||||
golang.org/x/sys v0.6.0 // indirect
|
golang.org/x/sys v0.6.0 // indirect
|
||||||
golang.org/x/text v0.21.0 // indirect
|
golang.org/x/text v0.21.0 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
gorm.io/driver/mysql v1.5.7 // indirect
|
gorm.io/driver/mysql v1.5.7 // indirect
|
||||||
gorm.io/gorm v1.25.12 // indirect
|
gorm.io/gorm v1.25.12 // indirect
|
||||||
)
|
)
|
||||||
|
|||||||
@ -53,6 +53,8 @@ github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE=
|
|||||||
github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs=
|
github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
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/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
|
github.com/streadway/amqp v1.1.0 h1:py12iX8XSyI7aN/3dUT8DFIDJazNJsVJdxNVEpnQTZM=
|
||||||
|
github.com/streadway/amqp v1.1.0/go.mod h1:WYSrTEYHOXHd0nwFeUXAe2G2hRnQT+deZJJf88uS9Bg=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
|
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
|
||||||
@ -80,8 +82,9 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkep
|
|||||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
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.7 h1:MndhOPYOfEp2rHKgkZIhJ16eVUIRf2HmzgoPmh7FCWo=
|
gorm.io/driver/mysql v1.5.7 h1:MndhOPYOfEp2rHKgkZIhJ16eVUIRf2HmzgoPmh7FCWo=
|
||||||
gorm.io/driver/mysql v1.5.7/go.mod h1:sEtPWMiqiN1N1cMXoXmBbd8C6/l+TESwriotuRRpkDM=
|
gorm.io/driver/mysql v1.5.7/go.mod h1:sEtPWMiqiN1N1cMXoXmBbd8C6/l+TESwriotuRRpkDM=
|
||||||
gorm.io/gorm v1.25.7/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8=
|
gorm.io/gorm v1.25.7/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8=
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import (
|
|||||||
"common/remark"
|
"common/remark"
|
||||||
"common/resultStatus"
|
"common/resultStatus"
|
||||||
"common/webServer"
|
"common/webServer"
|
||||||
"logincenter/internal/user"
|
"usercenter/internal/user"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|||||||
@ -4,8 +4,8 @@ import (
|
|||||||
"common/cache"
|
"common/cache"
|
||||||
"common/connection"
|
"common/connection"
|
||||||
"goutil/logUtilPlus"
|
"goutil/logUtilPlus"
|
||||||
. "logincenter/internal/user"
|
|
||||||
"sync"
|
"sync"
|
||||||
|
. "usercenter/internal/user"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 包名称(功能名称)
|
// 包名称(功能名称)
|
||||||
@ -32,7 +32,7 @@ func AddGame(user *User, game *Game) (int64, error) {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
//写入缓存
|
//写入缓存
|
||||||
cache.SetData[*Game](user.Cache, packageName, gameMap)
|
cache.SetData(user.Cache, packageName, gameMap)
|
||||||
|
|
||||||
// 写入到数据库
|
// 写入到数据库
|
||||||
result := connection.GetUserDB().Create(&game) // 通过数据的指针来创建
|
result := connection.GetUserDB().Create(&game) // 通过数据的指针来创建
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package internal
|
package internal
|
||||||
|
|
||||||
import (
|
import (
|
||||||
_ "logincenter/internal/game"
|
_ "usercenter/internal/game"
|
||||||
_ "logincenter/internal/user"
|
_ "usercenter/internal/user"
|
||||||
|
_ "usercenter/internal/wxuser"
|
||||||
)
|
)
|
||||||
|
|||||||
@ -32,5 +32,5 @@ type User struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (User) TableName() string {
|
func (User) TableName() string {
|
||||||
return "pay"
|
return "user"
|
||||||
}
|
}
|
||||||
|
|||||||
164
trunk/center/usercenter/internal/wxuser/api.go
Normal file
164
trunk/center/usercenter/internal/wxuser/api.go
Normal file
@ -0,0 +1,164 @@
|
|||||||
|
package wxuser
|
||||||
|
|
||||||
|
import (
|
||||||
|
"common/remark"
|
||||||
|
"common/resultStatus"
|
||||||
|
"common/webServer"
|
||||||
|
"goutil/logUtilPlus"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
|
||||||
|
//注册接口
|
||||||
|
webServer.RegisterFunction(new(WxuserApi))
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
moduleName := "WxuserApi"
|
||||||
|
desc := "用户接口"
|
||||||
|
author := "youjinlan"
|
||||||
|
mendor := ""
|
||||||
|
date := "2025-12-21 09:40:00"
|
||||||
|
remark.RegisterModuleRemark(moduleName, desc, author, mendor, date)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserApi 用户接口
|
||||||
|
type WxuserApi struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------- 接口 --------------------------------------------------
|
||||||
|
func init() {
|
||||||
|
moduleName := "WxuserApi"
|
||||||
|
methodName := "LoginByWechat"
|
||||||
|
skipVerifyTokenPage := true
|
||||||
|
methodDesc := "微信登录"
|
||||||
|
methodAuthor := "youjinlan"
|
||||||
|
methodMendor := ""
|
||||||
|
methodDate := "2025-01-21 09:40:00"
|
||||||
|
methodInParam := []string{"string code int32 severId"}
|
||||||
|
methodOutParam := `
|
||||||
|
{
|
||||||
|
"Code '类型:int'": "响应结果的状态值",
|
||||||
|
"Message '类型:string'": "响应结果的状态值所对应的描述信息",
|
||||||
|
"Data '类型:interface{}'": "响应结果的数据"
|
||||||
|
{
|
||||||
|
"Uid '类型:int64'": "用户对应区服的唯一Id",
|
||||||
|
}
|
||||||
|
}`
|
||||||
|
remark.RegisterMethodRemark(moduleName, methodName, methodDesc, methodAuthor, methodMendor, methodDate, methodInParam, methodOutParam, skipVerifyTokenPage)
|
||||||
|
}
|
||||||
|
func (a *WxuserApi) LoginByWechat(code string, severId int32) (responseObj *webServer.ResponseObject) {
|
||||||
|
responseObj = webServer.GetInitResponseObj()
|
||||||
|
if code == "" {
|
||||||
|
logUtilPlus.ErrorLog("Wrongcode,code为空")
|
||||||
|
responseObj.SetResultStatus(resultStatus.APIDataError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
res, uid := GetWechatsdkService().GetAccessToken(code)
|
||||||
|
if res != resultStatus.Success {
|
||||||
|
responseObj.SetResultStatus(res)
|
||||||
|
}
|
||||||
|
if uid != 0 {
|
||||||
|
resultMap := make(map[string]any)
|
||||||
|
resultMap["Uid"] = uid
|
||||||
|
responseObj.SetData(resultMap)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
moduleName := "WxuserApi"
|
||||||
|
methodName := "LoginOut"
|
||||||
|
skipVerifyTokenPage := true
|
||||||
|
methodDesc := "下线通知"
|
||||||
|
methodAuthor := "youjinlan"
|
||||||
|
methodMendor := ""
|
||||||
|
methodDate := "2025-01-21 11:00:00"
|
||||||
|
methodInParam := []string{"string openid,int32 severId"}
|
||||||
|
methodOutParam := `
|
||||||
|
{
|
||||||
|
"Code '类型:int'": "响应结果的状态值",
|
||||||
|
"Message '类型:string'": "响应结果的状态值所对应的描述信息",
|
||||||
|
"Data '类型:interface{}'": "响应结果的数据"
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}`
|
||||||
|
remark.RegisterMethodRemark(moduleName, methodName, methodDesc, methodAuthor, methodMendor, methodDate, methodInParam, methodOutParam, skipVerifyTokenPage)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *WxuserApi) LoginOut(uid int64) (responseObj *webServer.ResponseObject) {
|
||||||
|
responseObj = webServer.GetInitResponseObj()
|
||||||
|
if uid == 0 {
|
||||||
|
logUtilPlus.ErrorLog("uid=0")
|
||||||
|
responseObj.SetResultStatus(resultStatus.APIDataError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
RecordLoginOut(uid)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
moduleName := "WxuserApi"
|
||||||
|
methodName := "SwitchSever"
|
||||||
|
skipVerifyTokenPage := true
|
||||||
|
methodDesc := "切服通知"
|
||||||
|
methodAuthor := "youjinlan"
|
||||||
|
methodMendor := ""
|
||||||
|
methodDate := "2025-01-21 14:40:00"
|
||||||
|
methodInParam := []string{"string openid,int32 oldseverId,int32 newseverId"}
|
||||||
|
methodOutParam := `
|
||||||
|
{
|
||||||
|
"Code '类型:int'": "响应结果的状态值",
|
||||||
|
"Message '类型:string'": "响应结果的状态值所对应的描述信息",
|
||||||
|
"Data '类型:interface{}'": "响应结果的数据"
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}`
|
||||||
|
remark.RegisterMethodRemark(moduleName, methodName, methodDesc, methodAuthor, methodMendor, methodDate, methodInParam, methodOutParam, skipVerifyTokenPage)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *WxuserApi) SwitchSever(uid int64, oldseverId, newseverId int32) (responseObj *webServer.ResponseObject) {
|
||||||
|
responseObj = webServer.GetInitResponseObj()
|
||||||
|
if uid == 0 {
|
||||||
|
logUtilPlus.ErrorLog("uid=0")
|
||||||
|
responseObj.SetResultStatus(resultStatus.APIDataError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// RecordLoginOut(openid, oldseverId)
|
||||||
|
// RecordLoginIn(openid, newseverId)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
moduleName := "WxuserApi"
|
||||||
|
methodName := "WatchAD"
|
||||||
|
skipVerifyTokenPage := true
|
||||||
|
methodDesc := "看广告通知"
|
||||||
|
methodAuthor := "youjinlan"
|
||||||
|
methodMendor := ""
|
||||||
|
methodDate := "2025-01-22 10:40:00"
|
||||||
|
methodInParam := []string{"string openid,int32 severId"}
|
||||||
|
methodOutParam := `
|
||||||
|
{
|
||||||
|
"Code '类型:int'": "响应结果的状态值",
|
||||||
|
"Message '类型:string'": "响应结果的状态值所对应的描述信息",
|
||||||
|
"Data '类型:interface{}'": "响应结果的数据"
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}`
|
||||||
|
remark.RegisterMethodRemark(moduleName, methodName, methodDesc, methodAuthor, methodMendor, methodDate, methodInParam, methodOutParam, skipVerifyTokenPage)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *WxuserApi) WatchAD(uid int64) (responseObj *webServer.ResponseObject) {
|
||||||
|
responseObj = webServer.GetInitResponseObj()
|
||||||
|
if uid == 0 {
|
||||||
|
logUtilPlus.ErrorLog("openid,openid为空")
|
||||||
|
responseObj.SetResultStatus(resultStatus.APIDataError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
RecordWatchAD(uid)
|
||||||
|
return
|
||||||
|
}
|
||||||
217
trunk/center/usercenter/internal/wxuser/logic.go
Normal file
217
trunk/center/usercenter/internal/wxuser/logic.go
Normal file
@ -0,0 +1,217 @@
|
|||||||
|
package wxuser
|
||||||
|
|
||||||
|
import (
|
||||||
|
"common/connection"
|
||||||
|
"goutil/logUtilPlus"
|
||||||
|
"sync"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
// 用户缓存对象
|
||||||
|
userInfoMap = make(map[string]*WxUserInfo)
|
||||||
|
rwmu sync.RWMutex
|
||||||
|
userRecordMap = make(map[int64]*RecordLoginOfWxUser)
|
||||||
|
rwmu2 sync.RWMutex
|
||||||
|
userADRecordMap = make(map[int64]*RecordWatchADOfWxUser)
|
||||||
|
rwmu3 sync.RWMutex
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetUserByOpenId(openId string) (*WxUserInfo, error) {
|
||||||
|
var userInfo *WxUserInfo
|
||||||
|
func() *WxUserInfo {
|
||||||
|
rwmu.RLock()
|
||||||
|
defer rwmu.RUnlock()
|
||||||
|
ok := true
|
||||||
|
if userInfo, ok = userInfoMap[openId]; ok {
|
||||||
|
return userInfo
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}()
|
||||||
|
if userInfo != nil {
|
||||||
|
return userInfo, nil
|
||||||
|
}
|
||||||
|
result := connection.GetUserDB().Where("openId = ?", openId).First(&userInfo)
|
||||||
|
if result.Error != nil {
|
||||||
|
return nil, result.Error
|
||||||
|
}
|
||||||
|
return userInfo, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddUser 添加用户
|
||||||
|
// AddUser 添加新的用户到数据库中。
|
||||||
|
// 参数 User: 包含用户信息的对象。
|
||||||
|
func AddUser(user *WxUserInfo) {
|
||||||
|
|
||||||
|
//处理一些验证
|
||||||
|
|
||||||
|
// 写入到数据库
|
||||||
|
result := connection.GetUserDB().Create(&user) // 通过数据的指针来创建
|
||||||
|
if result.Error != nil {
|
||||||
|
logUtilPlus.ErrorLog("添加用户失败 错误信息:", result.Error.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func AddUserCache(user *WxUserInfo) {
|
||||||
|
rwmu.Lock()
|
||||||
|
defer rwmu.Unlock()
|
||||||
|
userInfoMap[user.OpenId] = user
|
||||||
|
}
|
||||||
|
|
||||||
|
// 登录登出相关
|
||||||
|
func AddUserRecordCache(userrecord *RecordLoginOfWxUser) {
|
||||||
|
rwmu2.Lock()
|
||||||
|
defer rwmu2.Unlock()
|
||||||
|
userRecordMap[userrecord.Uid] = userrecord
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetUserRecord(uid int64) (*RecordLoginOfWxUser, error) {
|
||||||
|
var userRecord *RecordLoginOfWxUser
|
||||||
|
func() *RecordLoginOfWxUser {
|
||||||
|
rwmu2.RLock()
|
||||||
|
defer rwmu2.RUnlock()
|
||||||
|
ok := true
|
||||||
|
if userRecord, ok = userRecordMap[uid]; ok {
|
||||||
|
return userRecord
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}()
|
||||||
|
if userRecord != nil {
|
||||||
|
return userRecord, nil
|
||||||
|
}
|
||||||
|
result := connection.GetUserDB().Where("uid = ?", uid).Last(&userRecord)
|
||||||
|
if result.Error != nil {
|
||||||
|
return nil, result.Error
|
||||||
|
}
|
||||||
|
//添加缓存
|
||||||
|
func() {
|
||||||
|
rwmu2.Lock()
|
||||||
|
defer rwmu2.Unlock()
|
||||||
|
userRecordMap[userRecord.Uid] = userRecord
|
||||||
|
}()
|
||||||
|
return userRecord, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func AddUserRecord(userrecord *RecordLoginOfWxUser) (int64, error) {
|
||||||
|
|
||||||
|
//处理一些验证
|
||||||
|
|
||||||
|
// 写入到数据库
|
||||||
|
result := connection.GetUserDB().Create(&userrecord) // 通过数据的指针来创建
|
||||||
|
if result.Error != nil {
|
||||||
|
logUtilPlus.ErrorLog("添加用户记录失败 错误信息:", result.Error.Error())
|
||||||
|
}
|
||||||
|
return userrecord.ID, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func SaveUserRecord(userrecord *RecordLoginOfWxUser) (int64, error) {
|
||||||
|
|
||||||
|
//处理一些验证
|
||||||
|
|
||||||
|
// 写入到数据库
|
||||||
|
result := connection.GetUserDB().Save(&userrecord) // 通过数据的指针来创建
|
||||||
|
if result.Error != nil {
|
||||||
|
logUtilPlus.ErrorLog("保存用户记录失败 错误信息:", result.Error.Error())
|
||||||
|
}
|
||||||
|
return userrecord.ID, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// 看广告相关
|
||||||
|
func AddUserADRecordCache(userADrecord *RecordWatchADOfWxUser) {
|
||||||
|
rwmu3.Lock()
|
||||||
|
defer rwmu3.Unlock()
|
||||||
|
userADRecordMap[userADrecord.Uid] = userADrecord
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetUserADRecord(uid int64) (*RecordWatchADOfWxUser, error) {
|
||||||
|
var userADRecord *RecordWatchADOfWxUser
|
||||||
|
func() *RecordWatchADOfWxUser {
|
||||||
|
rwmu3.RLock()
|
||||||
|
defer rwmu3.RUnlock()
|
||||||
|
ok := true
|
||||||
|
if userADRecord, ok = userADRecordMap[uid]; ok {
|
||||||
|
return userADRecord
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}()
|
||||||
|
if userADRecord != nil {
|
||||||
|
return userADRecord, nil
|
||||||
|
}
|
||||||
|
result := connection.GetUserDB().Where("uid = ?", uid).Last(&userADRecord)
|
||||||
|
if result.Error != nil {
|
||||||
|
return nil, result.Error
|
||||||
|
}
|
||||||
|
//添加缓存
|
||||||
|
func() {
|
||||||
|
rwmu3.Lock()
|
||||||
|
defer rwmu3.Unlock()
|
||||||
|
userADRecordMap[userADRecord.Uid] = userADRecord
|
||||||
|
}()
|
||||||
|
return userADRecord, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func AddUserADRecord(userADrecord *RecordWatchADOfWxUser) (int64, error) {
|
||||||
|
|
||||||
|
//处理一些验证
|
||||||
|
|
||||||
|
// 写入到数据库
|
||||||
|
result := connection.GetUserDB().Create(&userADrecord) // 通过数据的指针来创建
|
||||||
|
if result.Error != nil {
|
||||||
|
logUtilPlus.ErrorLog("添加用户看广告记录失败 错误信息:", result.Error.Error())
|
||||||
|
}
|
||||||
|
return userADrecord.ID, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func SaveUserADRecord(userADrecord *RecordWatchADOfWxUser) (int64, error) {
|
||||||
|
|
||||||
|
//处理一些验证
|
||||||
|
|
||||||
|
// 写入到数据库
|
||||||
|
result := connection.GetUserDB().Save(&userADrecord) // 通过数据的指针来创建
|
||||||
|
if result.Error != nil {
|
||||||
|
logUtilPlus.ErrorLog("保存用户看广告记录失败 错误信息:", result.Error.Error())
|
||||||
|
}
|
||||||
|
return userADrecord.ID, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// 区服相关
|
||||||
|
func AddUserSeverInfo(userSeverInfo *WxUserSeverInfo) (int64, error) {
|
||||||
|
|
||||||
|
//处理一些验证
|
||||||
|
|
||||||
|
// 写入到数据库
|
||||||
|
result := connection.GetUserDB().Create(&userSeverInfo) // 通过数据的指针来创建
|
||||||
|
if result.Error != nil {
|
||||||
|
logUtilPlus.ErrorLog("添加用户区服记录失败 错误信息:", result.Error.Error())
|
||||||
|
}
|
||||||
|
return userSeverInfo.ID, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func SaveUserSeverInfo(userSeverInfo *WxUserSeverInfo) (int64, error) {
|
||||||
|
|
||||||
|
//处理一些验证
|
||||||
|
|
||||||
|
// 写入到数据库
|
||||||
|
result := connection.GetUserDB().Save(&userSeverInfo) // 通过数据的指针来创建
|
||||||
|
if result.Error != nil {
|
||||||
|
logUtilPlus.ErrorLog("保存用户区服记录失败 错误信息:", result.Error.Error())
|
||||||
|
}
|
||||||
|
return userSeverInfo.ID, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetUserSeverInfo() (*WxUserSeverInfo, error) {
|
||||||
|
var userSeverInfoRecord *WxUserSeverInfo
|
||||||
|
result := connection.GetUserDB().Last(&userSeverInfoRecord)
|
||||||
|
if result.Error != nil {
|
||||||
|
return nil, result.Error
|
||||||
|
}
|
||||||
|
return userSeverInfoRecord, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetUserSeverInfoByIds(openId string, severId int32) (*WxUserSeverInfo, error) {
|
||||||
|
var userSeverInfoRecord *WxUserSeverInfo
|
||||||
|
result := connection.GetUserDB().Where("openId = ? AND severId = ?", openId, severId).First(&userSeverInfoRecord)
|
||||||
|
if result.Error != nil {
|
||||||
|
return nil, result.Error
|
||||||
|
}
|
||||||
|
return userSeverInfoRecord, nil
|
||||||
|
}
|
||||||
80
trunk/center/usercenter/internal/wxuser/user.go
Normal file
80
trunk/center/usercenter/internal/wxuser/user.go
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
package wxuser
|
||||||
|
|
||||||
|
import (
|
||||||
|
"common/connection"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/jinzhu/gorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
//注册数据库
|
||||||
|
connection.RegisterDBModel(&WxUserInfo{})
|
||||||
|
connection.RegisterDBModel(&RecordLoginOfWxUser{})
|
||||||
|
connection.RegisterDBModel(&RecordWatchADOfWxUser{})
|
||||||
|
connection.RegisterDBModel(&WxUserSeverInfo{})
|
||||||
|
}
|
||||||
|
|
||||||
|
type WechatTokens struct {
|
||||||
|
Errcode int32 `json:"errcode"`
|
||||||
|
Errmsg string `json:"errmsg"`
|
||||||
|
AccessToken string `json:"access_token"`
|
||||||
|
RefreshToken string `json:"refresh_token"`
|
||||||
|
ExpiresIn int64 `json:"expires_in"`
|
||||||
|
OpenId string `json:"openid"`
|
||||||
|
UnionId string `json:"unionid"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type WxUserInfo struct {
|
||||||
|
Nickname string `gorm:"column:nickname;comment:昵称" json:"nickname"`
|
||||||
|
Sex string `gorm:"column:sex;comment:性别" json:"sex"`
|
||||||
|
Language int64 `gorm:"column:language;comment:语言" json:"language"`
|
||||||
|
city string `gorm:"column:city;comment:城市" json:"city"`
|
||||||
|
province string `gorm:"column:province;comment:省份" json:"province"`
|
||||||
|
country string `gorm:"column:country;comment:国籍" json:"country"`
|
||||||
|
headimgurl string `gorm:"column:headimgurl;comment:头像" json:"headimgurl"`
|
||||||
|
OpenId string `gorm:"column:openId;comment:openId;primaryKey" json:"openid"`
|
||||||
|
UnionId string `gorm:"column:unionId;comment:unionId" json:"unionid"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// 同一个玩家在不同的区服Uid是不同的
|
||||||
|
type WxUserSeverInfo struct {
|
||||||
|
ID int64 `gorm:"column:id;primary_key;comment:自增索引;autoIncrementIncrement" json:"id"`
|
||||||
|
OpenId string `gorm:"column:openId;comment:openId" json:"openId"`
|
||||||
|
SeverId int32 `gorm:"column:severId;comment:区服Id" json:"severId"`
|
||||||
|
Uid int64 `gorm:"column:uid;comment:用户唯一Id" json:"uid"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// 登录相关的记录
|
||||||
|
type RecordLoginOfWxUser struct {
|
||||||
|
ID int64 `gorm:"column:id;primary_key;comment:自增索引;autoIncrementIncrement" json:"id"`
|
||||||
|
Uid int64 `gorm:"column:uid;comment:用户唯一Id" json:"uid"`
|
||||||
|
LoginInTime int64 `gorm:"column:loginintime;comment:登录时间" json:"loginintime"`
|
||||||
|
LoginOutTime int64 `gorm:"column:loginouttime;comment:登出时间" json:"loginouttime"`
|
||||||
|
PlayTimes int64 `gorm:"column:playtimes;comment:游玩时长" json:"playtimes"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// 看广告相关记录
|
||||||
|
// 记录日期便于按天统计
|
||||||
|
type RecordWatchADOfWxUser struct {
|
||||||
|
ID int64 `gorm:"column:id;primary_key;comment:自增索引;autoIncrementIncrement" json:"id"`
|
||||||
|
RecordDate time.Time `gorm:"column:recorddate;type:date;comment:记录日期" json:"recorddate"`
|
||||||
|
Uid int64 `gorm:"column:uid;comment:用户唯一Id" json:"uid"`
|
||||||
|
WatchADNum int32 `gorm:"column:watchadnum;comment:看广告次数" json:"watchadnum"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (WxUserInfo) TableName() string {
|
||||||
|
return "wxuserinfo"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r RecordLoginOfWxUser) TableName(db *gorm.DB) string {
|
||||||
|
return "recordloginofwxuser"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (RecordWatchADOfWxUser) TableName() string {
|
||||||
|
return "recordwatchadofwxuser"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (WxUserSeverInfo) TableName() string {
|
||||||
|
return "wxuserseverinfo"
|
||||||
|
}
|
||||||
80
trunk/center/usercenter/internal/wxuser/userrecord.go
Normal file
80
trunk/center/usercenter/internal/wxuser/userrecord.go
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
package wxuser
|
||||||
|
|
||||||
|
import (
|
||||||
|
"common/resultStatus"
|
||||||
|
"goutil/logUtilPlus"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
func RecordLoginIn(uid int64) {
|
||||||
|
nowTime := time.Now().Unix()
|
||||||
|
// if userLastRecord, _ := GetUserRecord(uid); userLastRecord != nil {
|
||||||
|
// if userLastRecord.LoginOutTime == 0 {
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
userRecord := &RecordLoginOfWxUser{}
|
||||||
|
userRecord.LoginInTime = nowTime
|
||||||
|
AddUserRecord(userRecord)
|
||||||
|
AddUserRecordCache(userRecord)
|
||||||
|
}
|
||||||
|
|
||||||
|
func RecordLoginOut(uid int64) resultStatus.ResultStatus {
|
||||||
|
var userRecord *RecordLoginOfWxUser
|
||||||
|
if userRecord, _ = GetUserRecord(uid); userRecord == nil {
|
||||||
|
return resultStatus.PlayerNotExist
|
||||||
|
}
|
||||||
|
if userRecord.LoginOutTime != 0 {
|
||||||
|
logUtilPlus.ErrorLog("PlayerIsLoginOut,uid=%d", uid)
|
||||||
|
return resultStatus.PlayerIsLoginOut
|
||||||
|
}
|
||||||
|
go func() {
|
||||||
|
nowTime := time.Now().Unix()
|
||||||
|
userRecord.LoginOutTime = nowTime
|
||||||
|
playTime := nowTime - userRecord.LoginInTime
|
||||||
|
userRecord.PlayTimes += playTime
|
||||||
|
SaveUserRecord(userRecord)
|
||||||
|
}()
|
||||||
|
return resultStatus.Success
|
||||||
|
}
|
||||||
|
|
||||||
|
func RecordWatchAD(uid int64) resultStatus.ResultStatus {
|
||||||
|
nowTime := time.Now()
|
||||||
|
userADRecord := &RecordWatchADOfWxUser{}
|
||||||
|
if userLastADRecord, _ := GetUserADRecord(uid); userLastADRecord != nil {
|
||||||
|
if nowTime.Format("2006-01-02") == userLastADRecord.RecordDate.Format("2006-01-02") {
|
||||||
|
userLastADRecord.WatchADNum++
|
||||||
|
SaveUserADRecord(userLastADRecord)
|
||||||
|
return resultStatus.Success
|
||||||
|
}
|
||||||
|
}
|
||||||
|
userADRecord.RecordDate = nowTime
|
||||||
|
userADRecord.WatchADNum += 1
|
||||||
|
AddUserADRecord(userADRecord)
|
||||||
|
AddUserADRecordCache(userADRecord)
|
||||||
|
return resultStatus.Success
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreatUid(openId string, severId int32) int64 {
|
||||||
|
var lastId int64
|
||||||
|
if userRecord, _ := GetUserSeverInfoByIds(openId, severId); userRecord != nil {
|
||||||
|
return userRecord.Uid
|
||||||
|
}
|
||||||
|
if userLastRecord, _ := GetUserSeverInfo(); userLastRecord != nil {
|
||||||
|
lastId = userLastRecord.ID
|
||||||
|
}
|
||||||
|
userSeverInfo := &WxUserSeverInfo{}
|
||||||
|
userSeverInfo.OpenId = openId
|
||||||
|
userSeverInfo.SeverId = severId
|
||||||
|
userSeverInfo.Uid = lastId + 1 + 100000000
|
||||||
|
AddUserSeverInfo(userSeverInfo)
|
||||||
|
return userSeverInfo.Uid
|
||||||
|
}
|
||||||
|
|
||||||
|
// func init() {
|
||||||
|
// testRecordWatchAD()
|
||||||
|
// }
|
||||||
|
|
||||||
|
func testRecordWatchAD() {
|
||||||
|
//RecordWatchAD("hell)
|
||||||
|
}
|
||||||
82
trunk/center/usercenter/internal/wxuser/wechatsdkservice.go
Normal file
82
trunk/center/usercenter/internal/wxuser/wechatsdkservice.go
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
package wxuser
|
||||||
|
|
||||||
|
import (
|
||||||
|
configYaml "common/configsYaml"
|
||||||
|
"common/resultStatus"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"goutil/logUtilPlus"
|
||||||
|
"goutil/webUtil"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
Url = "https://api.weixin.qq.com/sns/"
|
||||||
|
)
|
||||||
|
|
||||||
|
type WechatsdkService struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
// 通过code来换取assesstoken
|
||||||
|
func (w *WechatsdkService) GetAccessToken(code string) (resultStatus.ResultStatus, int64) {
|
||||||
|
weburl := fmt.Sprintf("%s%s", Url, "oauth2/access_token") //"https://api.weixin.qq.com/sns/oauth2/access_token"
|
||||||
|
data := make(map[string]string)
|
||||||
|
data["appid"] = configYaml.GetWxconfig().AppId
|
||||||
|
data["secret"] = configYaml.GetWxconfig().AppSecret
|
||||||
|
data["code"] = code
|
||||||
|
data["grant_type"] = "authorization_code"
|
||||||
|
status, resp, err := webUtil.GetWebData2(weburl, data, nil, nil)
|
||||||
|
if status != 200 || err != nil {
|
||||||
|
return resultStatus.RequestError, 0
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(resp) == 0 {
|
||||||
|
logUtilPlus.ErrorLog("The result is empty, but we expect not empty")
|
||||||
|
return resultStatus.EmptyResp, 0
|
||||||
|
}
|
||||||
|
logUtilPlus.ErrorLog("resp=%s", string(resp))
|
||||||
|
tokens := &WechatTokens{}
|
||||||
|
if err := json.Unmarshal(resp, tokens); err != nil {
|
||||||
|
logUtilPlus.ErrorLog("Unmarshal is error, err:%s", err)
|
||||||
|
return resultStatus.UnmarshalError, 0
|
||||||
|
}
|
||||||
|
if tokens.Errcode != 0 || tokens.Errmsg != "" {
|
||||||
|
logUtilPlus.ErrorLog("errcode:%d, msg:%s,", tokens.Errcode, tokens.Errmsg)
|
||||||
|
return resultStatus.RequestError, 0
|
||||||
|
}
|
||||||
|
Uid := CreatUid(tokens.OpenId, 1)
|
||||||
|
go func() {
|
||||||
|
if userInfo, _ := GetUserByOpenId(tokens.OpenId); userInfo == nil {
|
||||||
|
w.GetUserInfo(tokens.AccessToken, tokens.OpenId)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
go RecordLoginIn(Uid)
|
||||||
|
return resultStatus.Success, Uid
|
||||||
|
}
|
||||||
|
|
||||||
|
// 换取用户信息
|
||||||
|
func (w *WechatsdkService) GetUserInfo(accessToken, openid string) {
|
||||||
|
weburl := fmt.Sprintf("%s%s", Url, "userinfo") //"https://api.weixin.qq.com/sns/userinfo"
|
||||||
|
data := make(map[string]string)
|
||||||
|
data["appid"] = configYaml.GetWxconfig().AppId
|
||||||
|
data["access_token"] = accessToken
|
||||||
|
data["openid"] = openid
|
||||||
|
status, resp, err := webUtil.GetWebData2(weburl, data, nil, nil)
|
||||||
|
if status != 200 || err != nil {
|
||||||
|
logUtilPlus.ErrorLog("Wrongstatus. status:%d, err:%s", status, err)
|
||||||
|
}
|
||||||
|
if len(resp) == 0 {
|
||||||
|
logUtilPlus.ErrorLog("The result is empty, but we expect not empty")
|
||||||
|
}
|
||||||
|
var userInfo *WxUserInfo
|
||||||
|
if err := json.Unmarshal(resp, userInfo); err != nil {
|
||||||
|
logUtilPlus.ErrorLog("Unmarshal is error, err:%s", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
AddUser(userInfo)
|
||||||
|
}
|
||||||
|
|
||||||
|
var wechatsdkservice *WechatsdkService
|
||||||
|
|
||||||
|
func GetWechatsdkService() *WechatsdkService {
|
||||||
|
return wechatsdkservice
|
||||||
|
}
|
||||||
@ -1,16 +1,17 @@
|
|||||||
package user
|
package wxuser2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"common/cache"
|
||||||
"common/connection"
|
"common/connection"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
//注册数据库
|
//注册数据库
|
||||||
connection.RegisterDBModel(&User{})
|
connection.RegisterDBModel(&WXUserInfo{})
|
||||||
}
|
}
|
||||||
|
|
||||||
type User struct {
|
type WXUserInfo struct {
|
||||||
ID int64 `gorm:"column:id;primary_key;comment:用户id;autoIncrementIncrement" json:"id"`
|
Openid string `gorm:"column:openid;comment:用户微信标识;autoIncrementIncrement" json:"openid"`
|
||||||
//账号
|
//账号
|
||||||
Account string `gorm:"column:account;comment:账号" json:"account"`
|
Account string `gorm:"column:account;comment:账号" json:"account"`
|
||||||
Name string `gorm:"column:name;comment:用户名称" json:"name"`
|
Name string `gorm:"column:name;comment:用户名称" json:"name"`
|
||||||
@ -25,8 +26,11 @@ type User struct {
|
|||||||
Email string `gorm:"column:email;comment:邮箱" json:"email"`
|
Email string `gorm:"column:email;comment:邮箱" json:"email"`
|
||||||
//备注
|
//备注
|
||||||
Describe string `gorm:"column:describe;comment:备注" json:"describe"`
|
Describe string `gorm:"column:describe;comment:备注" json:"describe"`
|
||||||
|
|
||||||
|
//玩家的缓存对象
|
||||||
|
Cache *cache.Cache `gorm:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (User) TableName() string {
|
func (WXUserInfo) TableName() string {
|
||||||
return "user"
|
return "user"
|
||||||
}
|
}
|
||||||
@ -6,7 +6,7 @@ import (
|
|||||||
|
|
||||||
_ "common/resultStatus"
|
_ "common/resultStatus"
|
||||||
"common/webServer"
|
"common/webServer"
|
||||||
_ "usercenter/internal/user"
|
_ "usercenter/internal"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user