初始化项目
This commit is contained in:
69
trunk/framework/managecenterModel/area.go
Normal file
69
trunk/framework/managecenterModel/area.go
Normal file
@@ -0,0 +1,69 @@
|
||||
package managecenterModel
|
||||
|
||||
import "goutil/stringUtil"
|
||||
|
||||
// 大区对象
|
||||
type Area struct {
|
||||
// 大区Id
|
||||
AreaId int32 `json:"AreaId"`
|
||||
|
||||
//大区名字
|
||||
AreaName string `json:"AreaName"`
|
||||
|
||||
//客户端显示名字
|
||||
ClientName string `json:"ClientName"`
|
||||
|
||||
//区服范围
|
||||
ServerRange string `json:"ServerRange"`
|
||||
|
||||
//资源包下载地址
|
||||
ResourceURL string `json:"ResourceURL"`
|
||||
|
||||
//推荐服开关:0关闭,1:打开
|
||||
RecommendStitch int32 `json:"RecommendStitch"`
|
||||
|
||||
//推荐最大注册人数
|
||||
MaxRegistration int32 `json:"MaxRegistration"`
|
||||
|
||||
//限制注册的开关
|
||||
RegRestrictionSwitch int32 `json:"RegRestrictionSwitch"`
|
||||
|
||||
//玩家数量大于该数量,自动开服
|
||||
AutoOpenServerPlayers int32 `json:"AutoOpenServerPlayers"`
|
||||
|
||||
//大区维护状态(1:正常;2:维护)
|
||||
AreaMaintainStatus int32 `json:"AreaMaintainStatus"`
|
||||
|
||||
//维护消息
|
||||
AreaMaintainMsg string `json:"AreaMaintainMsg"`
|
||||
|
||||
//大区页签集合
|
||||
AreaLabelList []*AreaLabel `json:"AreaLabelList"`
|
||||
}
|
||||
|
||||
//
|
||||
//检测服务器是否在大区的区间范围
|
||||
func (this *Area) CheckServerIdIsInRange(serverId int32) (isVaild bool) {
|
||||
isVaild = false
|
||||
for _, serverRangeItem := range stringUtil.Split(this.ServerRange, []string{","}) {
|
||||
serverRange, _ := stringUtil.SplitToInt32Slice(serverRangeItem, "-")
|
||||
lower := serverRange[0]
|
||||
upper := serverRange[1]
|
||||
|
||||
//如果范围大小顺序不对,则换位
|
||||
if lower > upper {
|
||||
temp := lower
|
||||
lower = upper
|
||||
upper = temp
|
||||
}
|
||||
|
||||
//如果服务器在该大区的任意区服区间,则返回true
|
||||
if serverId >= lower && serverId <= upper {
|
||||
isVaild = true
|
||||
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
45
trunk/framework/managecenterModel/areaLabel.go
Normal file
45
trunk/framework/managecenterModel/areaLabel.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package managecenterModel
|
||||
|
||||
import "goutil/stringUtil"
|
||||
|
||||
//大区页签对象
|
||||
type AreaLabel struct {
|
||||
// 大区Id
|
||||
AreaId int32 `json:"AreaID"`
|
||||
//标签ID
|
||||
LabelID int32 `json:"LabelID"`
|
||||
//标签名字
|
||||
LabelName string `json:"LabelName"`
|
||||
//客户端显示名字
|
||||
ClientName string `json:"ClientName"`
|
||||
//标签区间字符串1-100,200-300
|
||||
LabelServerRange string `json:"LabelServerRange"`
|
||||
//渠道列表
|
||||
PartnerIdList []int64 `json:"PartnerIdList"`
|
||||
}
|
||||
|
||||
//检测服务器是否在大区页签的区间范围
|
||||
func (this *AreaLabel) CheckServerIdIsInLabelRange(serverId int32) (isVaild bool) {
|
||||
isVaild = false
|
||||
for _, serverRangeItem := range stringUtil.Split(this.LabelServerRange, []string{","}) {
|
||||
serverRange, _ := stringUtil.SplitToInt32Slice(serverRangeItem, "-")
|
||||
lower := serverRange[0]
|
||||
upper := serverRange[1]
|
||||
|
||||
//如果范围大小顺序不对,则换位
|
||||
if lower > upper {
|
||||
temp := lower
|
||||
lower = upper
|
||||
upper = temp
|
||||
}
|
||||
|
||||
//如果服务器在该大区的任意区服区间,则返回true
|
||||
if serverId >= lower && serverId <= upper {
|
||||
isVaild = true
|
||||
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
44
trunk/framework/managecenterModel/chargeConfig.go
Normal file
44
trunk/framework/managecenterModel/chargeConfig.go
Normal file
@@ -0,0 +1,44 @@
|
||||
package managecenterModel
|
||||
|
||||
// 充值配置
|
||||
type ChargeConfig struct {
|
||||
// 产品Id
|
||||
ProductId string
|
||||
|
||||
// 充值点数(以元为单位;如果是人民币是整数,但如果是美元,或者其它货币可能为小数)
|
||||
ChargePoint float64
|
||||
|
||||
// 游戏内货币点数(元宝/钻石等,必定是整数)
|
||||
GamePoint int
|
||||
|
||||
// 充值金额与游戏内货币的兑换比率
|
||||
Ratio float64
|
||||
|
||||
// 赠送的游戏内货币点数(必定是整数)
|
||||
GiveGamePoint int
|
||||
|
||||
// 赠送的比率
|
||||
GiveRatio float64
|
||||
|
||||
// 首充时赠送的游戏内货币点数
|
||||
FirstGiveGamePoint int
|
||||
|
||||
// 所需的vip等级
|
||||
VipLv byte
|
||||
|
||||
// 首充时是否显示
|
||||
IfFirstShow byte
|
||||
|
||||
// 第二次(及以后)充值时是否显示
|
||||
IfSecondShow byte
|
||||
|
||||
// 是否为月卡
|
||||
IsMonthCard bool
|
||||
}
|
||||
|
||||
// 按照充值金额进行升序排序
|
||||
// target:另一个充值配置对象
|
||||
// 是否是小于
|
||||
func (this *ChargeConfig) SortByChargePointAsc(target *ChargeConfig) bool {
|
||||
return this.ChargePoint < target.ChargePoint
|
||||
}
|
||||
57
trunk/framework/managecenterModel/dbConnectionConfig.go
Normal file
57
trunk/framework/managecenterModel/dbConnectionConfig.go
Normal file
@@ -0,0 +1,57 @@
|
||||
package managecenterModel
|
||||
|
||||
import (
|
||||
. "goutil/mysqlUtil"
|
||||
. "goutil/redisUtil"
|
||||
)
|
||||
|
||||
// 数据库连接字符串配置
|
||||
type DBConnectionConfig struct {
|
||||
// 模型数据库内网连接字符串
|
||||
GameModelDB string
|
||||
|
||||
// 游戏数据库内网连接字符串
|
||||
GameDB string
|
||||
|
||||
// 日志数据库内网连接字符串
|
||||
LogDB string
|
||||
|
||||
// Redis连接字符串
|
||||
RedisConfig string
|
||||
}
|
||||
|
||||
// 获取游戏模型数据库连接
|
||||
// 返回值:
|
||||
// 数据库连接配置对象
|
||||
// 错误对象
|
||||
func (this *DBConnectionConfig) GetGameModelDBConn() (dbConfig *DBConfig, err error) {
|
||||
dbConfig, err = NewDBConfig2(this.GameModelDB)
|
||||
return
|
||||
}
|
||||
|
||||
// 获取游戏数据库连接
|
||||
// 返回值:
|
||||
// 数据库连接配置对象
|
||||
// 错误对象
|
||||
func (this *DBConnectionConfig) GetGameDBConn() (dbConfig *DBConfig, err error) {
|
||||
dbConfig, err = NewDBConfig2(this.GameDB)
|
||||
return
|
||||
}
|
||||
|
||||
// 获取游戏日志数据库连接
|
||||
// 返回值:
|
||||
// 数据库连接配置对象
|
||||
// 错误对象
|
||||
func (this *DBConnectionConfig) GetLogDBConn() (dbConfig *DBConfig, err error) {
|
||||
dbConfig, err = NewDBConfig2(this.LogDB)
|
||||
return
|
||||
}
|
||||
|
||||
// 获取Redis配置
|
||||
// 返回值:
|
||||
// redis配置对象
|
||||
// 错误对象
|
||||
func (this *DBConnectionConfig) GetRedisConfig() (redisConfig *RedisConfig, err error) {
|
||||
redisConfig, err = NewRedisConfig(this.RedisConfig)
|
||||
return
|
||||
}
|
||||
3
trunk/framework/managecenterModel/doc.go
Normal file
3
trunk/framework/managecenterModel/doc.go
Normal file
@@ -0,0 +1,3 @@
|
||||
package managecenterModel
|
||||
|
||||
// 与ManageCenter共享的模型对象定义
|
||||
10
trunk/framework/managecenterModel/gameVersion.go
Normal file
10
trunk/framework/managecenterModel/gameVersion.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package managecenterModel
|
||||
|
||||
// 游戏版本
|
||||
type GameVersion struct {
|
||||
// Id
|
||||
Id int32 `json:"GameVersionID"`
|
||||
|
||||
// 名称
|
||||
Name string `json:"GameVersionName"`
|
||||
}
|
||||
15
trunk/framework/managecenterModel/maintainType.go
Normal file
15
trunk/framework/managecenterModel/maintainType.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package managecenterModel
|
||||
|
||||
// 服务器状态
|
||||
type MaintainType int32
|
||||
|
||||
const (
|
||||
// 计划维护
|
||||
Con_MaintainType_PlanMaintain MaintainType = 1
|
||||
|
||||
// 开始维护
|
||||
Con_MaintainType_BeginMaintain MaintainType = 2
|
||||
|
||||
// 结束维护
|
||||
Con_MaintainType_EndMaintain MaintainType = 3
|
||||
)
|
||||
26
trunk/framework/managecenterModel/mcDataType.go
Normal file
26
trunk/framework/managecenterModel/mcDataType.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package managecenterModel
|
||||
|
||||
type MCDataType int
|
||||
|
||||
const (
|
||||
// 服务器
|
||||
ServerData MCDataType = 1
|
||||
|
||||
// 服务器组
|
||||
ServerGroupData MCDataType = 2
|
||||
|
||||
// 合作商
|
||||
PartnerData MCDataType = 3
|
||||
|
||||
// 资源
|
||||
ResourceVersionData MCDataType = 4
|
||||
|
||||
// 白名单
|
||||
UserWhiteListData MCDataType = 5
|
||||
|
||||
// 公告
|
||||
GameNoticeData MCDataType = 6
|
||||
|
||||
// 大区
|
||||
AreaData MCDataType = 7
|
||||
)
|
||||
11
trunk/framework/managecenterModel/officialOrTest.go
Normal file
11
trunk/framework/managecenterModel/officialOrTest.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package managecenterModel
|
||||
|
||||
type OfficialOrTest int32
|
||||
|
||||
const (
|
||||
// 正式服
|
||||
Con_Official OfficialOrTest = 1
|
||||
|
||||
// 测试服
|
||||
Con_Test OfficialOrTest = 2
|
||||
)
|
||||
55
trunk/framework/managecenterModel/partner.go
Normal file
55
trunk/framework/managecenterModel/partner.go
Normal file
@@ -0,0 +1,55 @@
|
||||
package managecenterModel
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
// 合作商
|
||||
type Partner struct {
|
||||
// 合作商Id
|
||||
Id int32 `json:"PartnerID"`
|
||||
|
||||
// 合作商名称
|
||||
Name string `json:"PartnerName"`
|
||||
|
||||
// 合作商别名
|
||||
Alias string `json:"PartnerAlias"`
|
||||
|
||||
// 应用Id
|
||||
AppId string `json:"AppID"`
|
||||
|
||||
// 登陆加密Key
|
||||
LoginKey string `json:"LoginKey"`
|
||||
|
||||
// 充值配置
|
||||
ChargeConfig string `json:"ChargeConfig"`
|
||||
|
||||
// 其它配置
|
||||
OtherConfigInfo string `json:"OtherConfigInfo"`
|
||||
|
||||
// 游戏版本下载Url
|
||||
GameVersionUrl string `json:"GameVersionUrl"`
|
||||
|
||||
// 充值服务器Url
|
||||
ChargeServerUrl string `json:"ChargeServerUrl"`
|
||||
|
||||
// 合作商类型
|
||||
PartnerType int32 `json:"PartnerType"`
|
||||
|
||||
// 权重
|
||||
Weight int32 `json:"Weight"`
|
||||
|
||||
// 资源包所属类型
|
||||
ResourceType int32 `json:"ResourceType"`
|
||||
}
|
||||
|
||||
// 解析其它配置信息
|
||||
func (this *Partner) ResolveOtherConfig() (otherConfigMap map[string]string, err error) {
|
||||
otherConfigMap = make(map[string]string, 8)
|
||||
if this.OtherConfigInfo == "" {
|
||||
return
|
||||
}
|
||||
|
||||
err = json.Unmarshal([]byte(this.OtherConfigInfo), &otherConfigMap)
|
||||
return
|
||||
}
|
||||
15
trunk/framework/managecenterModel/partnerType.go
Normal file
15
trunk/framework/managecenterModel/partnerType.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package managecenterModel
|
||||
|
||||
// 合作商类型
|
||||
type PartnerType int32
|
||||
|
||||
const (
|
||||
// IOS
|
||||
Con_IOS PartnerType = 0
|
||||
|
||||
// Android
|
||||
Con_Android PartnerType = 1
|
||||
|
||||
// 越狱
|
||||
Con_JailBreak PartnerType = 2
|
||||
)
|
||||
210
trunk/framework/managecenterModel/resourceVersion.go
Normal file
210
trunk/framework/managecenterModel/resourceVersion.go
Normal file
@@ -0,0 +1,210 @@
|
||||
package managecenterModel
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"goutil/stringUtil"
|
||||
"goutil/typeUtil"
|
||||
)
|
||||
|
||||
// 游戏版本
|
||||
type ResourceVersion struct {
|
||||
// 资源版本唯一标识
|
||||
Id int32 `json:"ResourceVersionID"`
|
||||
|
||||
// 资源版本名称
|
||||
Name string `json:"ResourceVersionName"`
|
||||
|
||||
// 资源版本的url地址
|
||||
Url string `json:"ResourceVersionUrl"`
|
||||
|
||||
// 资源大小
|
||||
Size int32 `json:"Size"`
|
||||
|
||||
// 资源文件MD5加密的结果
|
||||
MD5 string `json:"MD5"`
|
||||
|
||||
//大区Id
|
||||
AreaID int32 `json:"AreaID"`
|
||||
|
||||
// 资源生效时间
|
||||
StartTime string `json:"StartTime"`
|
||||
StartTimeTick int64 `json:"StartTimeTick"`
|
||||
|
||||
// 资源失效时间
|
||||
EndTime string `json:"EndTime"`
|
||||
EndTimeTick int64 `json:"EndTimeTick"`
|
||||
|
||||
// 添加时间
|
||||
Crdate string `json:"Crdate"`
|
||||
CrdateTick int64 `json:"CrdateTick"`
|
||||
|
||||
// 更新时间
|
||||
UpdateTime string `json:"UpdateTime"`
|
||||
UpdateTimeTick int64 `json:"UpdateTimeTick"`
|
||||
|
||||
// 是否重启客户端
|
||||
IfRestart int32 `json:"IfRestart"`
|
||||
|
||||
// 是否禁用
|
||||
IfDelete int32 `json:"IfDelete"`
|
||||
|
||||
// 是否审核服下载
|
||||
IfAuditServiceDownload int32 `json:"IfAuditServiceDownload"`
|
||||
|
||||
// 资源所属的合作商ID集合
|
||||
PartnerIds string `json:"PartnerIDs"`
|
||||
|
||||
// 资源所属的游戏版本ID集合
|
||||
GameVersionIds string `json:"GameVersionIDs"`
|
||||
}
|
||||
|
||||
// 判断资源是否包含指定合作商
|
||||
// partnerId:合作商Id
|
||||
// 返回值
|
||||
// 是否包含
|
||||
func (this *ResourceVersion) ContainsPartner(partnerId int32) bool {
|
||||
partnerIdList, _ := stringUtil.SplitToInt32Slice(this.PartnerIds, ",")
|
||||
for _, item := range partnerIdList {
|
||||
if item == partnerId {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// 判断资源是否包含指定游戏版本
|
||||
// gameVersionId:游戏版本Id
|
||||
// 返回值
|
||||
// 是否包含
|
||||
func (this *ResourceVersion) ContainsGameVersion(gameVersionId int32) bool {
|
||||
gameVersionIdList, _ := stringUtil.SplitToInt32Slice(this.GameVersionIds, ",")
|
||||
for _, item := range gameVersionIdList {
|
||||
if item == gameVersionId {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// 获取有效资源包
|
||||
func GetAvailableResource(resourceVersionList []*ResourceVersion, partnerId, gameVersionId int32, resourceVersionName string, offTest OfficialOrTest) (availableResourceVersion map[string]interface{}) {
|
||||
|
||||
if len(resourceVersionList) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
//判断资源是否有效
|
||||
_, hashCode, isVaild := IsResourceVersionNameValid(resourceVersionName)
|
||||
if !isVaild {
|
||||
return
|
||||
}
|
||||
|
||||
//根据合作商Id和游戏版本Id和开始时间来过滤
|
||||
var targetResourceVersionList []*ResourceVersion
|
||||
for _, resourceVersion := range resourceVersionList {
|
||||
startime, err := typeUtil.DateTime(resourceVersion.StartTimeTick)
|
||||
if resourceVersion.ContainsPartner(partnerId) && resourceVersion.ContainsGameVersion(gameVersionId) && err == nil && startime.Before(time.Now()) {
|
||||
targetResourceVersionList = append(targetResourceVersionList, resourceVersion)
|
||||
}
|
||||
}
|
||||
|
||||
if len(targetResourceVersionList) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
//组装数据
|
||||
|
||||
//按照资源Id进行降序排列
|
||||
sort.Slice(targetResourceVersionList, func(i, j int) bool {
|
||||
return targetResourceVersionList[i].SortByIdDesc(targetResourceVersionList[j])
|
||||
})
|
||||
|
||||
//取出资源号最大的资源,如果与传入的资源名称相等,则表示没有新资源
|
||||
availableResourceVersion = make(map[string]interface{}, 0)
|
||||
newResource := targetResourceVersionList[0]
|
||||
availableResourceVersion["ResourceVersionName"] = newResource.Name
|
||||
availableResourceVersion["Url"] = strings.Replace(newResource.Url, ".zip", "", -1)
|
||||
|
||||
if newResource.Name == resourceVersionName {
|
||||
|
||||
//是否有新资源,如果为fasle,也需要返回project.manifest.temp.zip 用于子包验证
|
||||
availableResourceVersion["IsNewResource"] = false
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
//判断资源号中的HashCode是否相等,如果相等,则表示没有新资源;如果传入的timeTick>最新的timeTick说明服务器没有被刷新,表示没有新资源
|
||||
_, newHashCode, newIsVaild := IsResourceVersionNameValid(newResource.Name)
|
||||
if !newIsVaild {
|
||||
return
|
||||
}
|
||||
|
||||
if compareRes := strings.Compare(hashCode, newHashCode); compareRes == 0 {
|
||||
//是否有新资源,如果为fasle,也需要返回project.manifest.temp.zip 用于子包验证
|
||||
availableResourceVersion["IsNewResource"] = false
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if offTest == Con_Test && newResource.IfAuditServiceDownload == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
availableResourceVersion["IsNewResource"] = true
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// 按照Id进行升序排序
|
||||
// target:另一个资源对象
|
||||
// 是否是小于
|
||||
func (this *ResourceVersion) SortByIdAsc(target *ResourceVersion) bool {
|
||||
return this.Id < target.Id
|
||||
}
|
||||
|
||||
// 按照Id进行降序排序
|
||||
// target:另一个资源对象
|
||||
// 是否是大于
|
||||
func (this *ResourceVersion) SortByIdDesc(target *ResourceVersion) bool {
|
||||
return this.Id > target.Id
|
||||
}
|
||||
|
||||
//判断资源版本是否有效
|
||||
func IsResourceVersionNameValid(resourceVersionName string) (timeTick int64, hashCode string, isValid bool) {
|
||||
if len(resourceVersionName) == 0 {
|
||||
isValid = false
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if index := strings.Index(resourceVersionName, "_"); index == -1 {
|
||||
resourceVersionName = fmt.Sprintf("0_%s", resourceVersionName)
|
||||
}
|
||||
|
||||
resourceList := stringUtil.Split(resourceVersionName, []string{"_"})
|
||||
if len(resourceList) != 2 {
|
||||
isValid = false
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
//解析timeTick
|
||||
timeTick, err := strconv.ParseInt(resourceList[0], 10, 64)
|
||||
if err != nil {
|
||||
isValid = false
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
hashCode = resourceList[1]
|
||||
isValid = true
|
||||
|
||||
return
|
||||
}
|
||||
16
trunk/framework/managecenterModel/returnObject.go
Normal file
16
trunk/framework/managecenterModel/returnObject.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package managecenterModel
|
||||
|
||||
// 返回结果对象
|
||||
type ReturnObject struct {
|
||||
// 返回的状态值;0:成功;非0:失败(根据实际情况进行定义)
|
||||
Code int32
|
||||
|
||||
// 返回的失败描述信息
|
||||
Message string
|
||||
|
||||
// 返回的数据
|
||||
Data interface{}
|
||||
|
||||
// 返回的数据hash值
|
||||
HashValue string
|
||||
}
|
||||
22
trunk/framework/managecenterModel/server.go
Normal file
22
trunk/framework/managecenterModel/server.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package managecenterModel
|
||||
|
||||
// 服务器
|
||||
type Server struct {
|
||||
// 服务器Id
|
||||
Id int32 `json:"ServerID"`
|
||||
|
||||
// 服务器名称
|
||||
Name string `json:"ServerName"`
|
||||
|
||||
// 合作商Id
|
||||
PartnerId int32 `json:"PartnerID"`
|
||||
|
||||
// 服务器组Id
|
||||
GroupId int32 `json:"GroupID"`
|
||||
|
||||
// 对应的游戏版本号
|
||||
GameVersionId int32 `json:"GameVersionID"`
|
||||
|
||||
// 需要的最低游戏版本号
|
||||
MinGameVersionId int32 `json:"MinGameVersionID"`
|
||||
}
|
||||
184
trunk/framework/managecenterModel/serverGroup.go
Normal file
184
trunk/framework/managecenterModel/serverGroup.go
Normal file
@@ -0,0 +1,184 @@
|
||||
package managecenterModel
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"goutil/stringUtil"
|
||||
)
|
||||
|
||||
// 服务器组
|
||||
type ServerGroup struct {
|
||||
// 服务器组Id
|
||||
Id int32 `json:"GroupID"`
|
||||
|
||||
// 服务器组名称
|
||||
Name string `json:"GroupName"`
|
||||
|
||||
// 服务器组Url
|
||||
Url string `json:"GroupUrl"`
|
||||
|
||||
// 聊天服务器Url
|
||||
ChatServerUrl string `json:"ChatServerUrl"`
|
||||
|
||||
// 数据库连接配置
|
||||
DBConnectionConfig string `json:"DBConnectionConfig"`
|
||||
|
||||
// 服务器组状态(1:正常;2:维护)
|
||||
GroupState int32 `json:"GroupState"`
|
||||
|
||||
// 服务器组热度(1:正常;2:新服;3:推荐)
|
||||
GroupHeat int32 `json:"GroupHeat"`
|
||||
|
||||
// 服务器组负载(1:正常;2:火爆)
|
||||
GroupLoad int32 `json:"GroupLoad"`
|
||||
|
||||
// 服务器开服时间对应的Unix时间戳
|
||||
OpenTimeTick int64 `json:OpenTimeTick`
|
||||
|
||||
// 服务器组Ip(外网IP;内网IP;回调GS内网端口)
|
||||
Ip string `json:"GroupIp"`
|
||||
|
||||
// 正式服或测试服;1:正式服;2:测试服
|
||||
OfficialOrTest int32 `json:"OfficialOrTest"`
|
||||
|
||||
// 服务器组类型
|
||||
Type int32 `json:"GroupType"`
|
||||
|
||||
// 服务器组排序
|
||||
Order int32 `json:"GroupOrder"`
|
||||
|
||||
// 服务器组维护开始时间对应的时间戳
|
||||
MaintainBeginTimeTick int64 `json:MaintainBeginTimeTick`
|
||||
|
||||
// 维护持续分钟数
|
||||
MaintainMinutes int32 `json:"MaintainMinutes"`
|
||||
|
||||
// 维护信息
|
||||
MaintainMessage string `json:"MaintainMessage"`
|
||||
|
||||
// 游戏监听地址
|
||||
GameListenAddr string `json:"GameListenAddr"`
|
||||
|
||||
// 回调监听地址
|
||||
CallbackListenAddr string `json:"CallbackListenAddr"`
|
||||
|
||||
// 外网回调地址
|
||||
ExternalCallbackUrl string `json:"ExternalCallbackUrl"`
|
||||
|
||||
// 内网回调地址
|
||||
InternalCallbackUrl string `json:"InternalCallbackUrl"`
|
||||
|
||||
// 是否在主群组(机房)内
|
||||
IsInMainGroup bool `json:"IsInMainGroup"`
|
||||
|
||||
// 监控端口
|
||||
GopsPort string `json:"GopsPort"`
|
||||
}
|
||||
|
||||
// 排序方法(默认按照Id进行升序排序)
|
||||
// target:另一个服务器组对象
|
||||
// 是否是小于
|
||||
func (this *ServerGroup) SortByIdAsc(target *ServerGroup) bool {
|
||||
return this.Id < target.Id
|
||||
}
|
||||
|
||||
// 按照开服时间进行升序排序
|
||||
// target:另一个服务器组对象
|
||||
// 是否是小于
|
||||
func (this *ServerGroup) SortByOpenTimeAsc(target *ServerGroup) bool {
|
||||
return this.OpenTimeTick < target.OpenTimeTick
|
||||
}
|
||||
|
||||
// 获取数据库配置对象
|
||||
// 返回值:
|
||||
// 数据库配置对象
|
||||
// 错误对象
|
||||
func (this *ServerGroup) GetDBConfig() (*DBConnectionConfig, error) {
|
||||
var dbConfig *DBConnectionConfig
|
||||
if err := json.Unmarshal([]byte(this.DBConnectionConfig), &dbConfig); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return dbConfig, nil
|
||||
}
|
||||
|
||||
// 获取ip列表
|
||||
// 返回值:
|
||||
// ip列表
|
||||
func (this *ServerGroup) GetIPList() []string {
|
||||
return stringUtil.Split(this.Ip, nil)
|
||||
}
|
||||
|
||||
// 服务器组是否开启
|
||||
// 返回值:
|
||||
// 是否开启
|
||||
func (this *ServerGroup) IsOpen() bool {
|
||||
return this.OpenTimeTick < time.Now().Unix()
|
||||
}
|
||||
|
||||
// 获取游戏服务器的回调地址
|
||||
// suffix:地址后缀
|
||||
// 返回值
|
||||
// 游戏服务器的回调地址
|
||||
func (this *ServerGroup) GetGSCallbackUrl(suffix string) string {
|
||||
// 如果是在主群组(机房)内,则使用内网地址,否则使用外网地址
|
||||
url := ""
|
||||
if this.IsInMainGroup {
|
||||
url = this.InternalCallbackUrl
|
||||
} else {
|
||||
url = this.ExternalCallbackUrl
|
||||
}
|
||||
|
||||
if url != "" {
|
||||
if strings.HasSuffix(url, "/") {
|
||||
return fmt.Sprintf("%s%s", url, suffix)
|
||||
} else {
|
||||
return fmt.Sprintf("%s/%s", url, suffix)
|
||||
}
|
||||
}
|
||||
|
||||
// 兼容旧的ManageCenter版本
|
||||
ipList := this.GetIPList()
|
||||
|
||||
// 外网IP;内网IP;回调GS内网端口;如果数量小于3,则直接使用配置的GroupUrl;否则使用第3个值
|
||||
if len(ipList) < 3 {
|
||||
if strings.HasSuffix(this.Url, "/") {
|
||||
return fmt.Sprintf("%s%s", this.Url, suffix)
|
||||
} else {
|
||||
return fmt.Sprintf("%s/%s", this.Url, suffix)
|
||||
}
|
||||
} else {
|
||||
return fmt.Sprintf("http://%s:%s/%s", ipList[1], ipList[2], suffix)
|
||||
}
|
||||
}
|
||||
|
||||
// 判断服务器组是否相同
|
||||
// target:目标服务器组
|
||||
// 是否相同
|
||||
func (this *ServerGroup) IsEqual(target *ServerGroup) bool {
|
||||
return this.Id == target.Id &&
|
||||
this.Name == target.Name &&
|
||||
this.Url == target.Url &&
|
||||
this.ChatServerUrl == target.ChatServerUrl &&
|
||||
this.DBConnectionConfig == target.DBConnectionConfig &&
|
||||
this.GroupState == target.GroupState &&
|
||||
this.GroupHeat == target.GroupHeat &&
|
||||
this.GroupLoad == target.GroupLoad &&
|
||||
this.OpenTimeTick == target.OpenTimeTick &&
|
||||
this.Ip == target.Ip &&
|
||||
this.OfficialOrTest == target.OfficialOrTest &&
|
||||
this.Type == target.Type &&
|
||||
this.Order == target.Order &&
|
||||
this.MaintainBeginTimeTick == target.MaintainBeginTimeTick &&
|
||||
this.MaintainMinutes == target.MaintainMinutes &&
|
||||
this.MaintainMessage == target.MaintainMessage &&
|
||||
this.GameListenAddr == target.GameListenAddr &&
|
||||
this.CallbackListenAddr == target.CallbackListenAddr &&
|
||||
this.ExternalCallbackUrl == target.ExternalCallbackUrl &&
|
||||
this.InternalCallbackUrl == target.InternalCallbackUrl &&
|
||||
this.IsInMainGroup == target.IsInMainGroup &&
|
||||
this.GopsPort == target.GopsPort
|
||||
}
|
||||
18
trunk/framework/managecenterModel/serverGroupHeat.go
Normal file
18
trunk/framework/managecenterModel/serverGroupHeat.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package managecenterModel
|
||||
|
||||
// 服务器组热度
|
||||
type GroupHeat int32
|
||||
|
||||
const (
|
||||
// 正常
|
||||
Con_GroupHeat_Normal GroupHeat = 1
|
||||
|
||||
// 新服
|
||||
Con_GroupHeat_New GroupHeat = 2
|
||||
|
||||
// 推荐
|
||||
Con_GroupHeat_Recommend GroupHeat = 3
|
||||
|
||||
// 热门
|
||||
Con_GroupHeat_Heat GroupHeat = 4
|
||||
)
|
||||
12
trunk/framework/managecenterModel/serverGroupLoad.go
Normal file
12
trunk/framework/managecenterModel/serverGroupLoad.go
Normal file
@@ -0,0 +1,12 @@
|
||||
package managecenterModel
|
||||
|
||||
// 服务器状态
|
||||
type GroupLoad int32
|
||||
|
||||
const (
|
||||
// 正常
|
||||
Con_GroupLoad_Normal GroupLoad = 1
|
||||
|
||||
// 火爆
|
||||
Con_GroupLoad_Hot GroupLoad = 2
|
||||
)
|
||||
12
trunk/framework/managecenterModel/serverGroupState.go
Normal file
12
trunk/framework/managecenterModel/serverGroupState.go
Normal file
@@ -0,0 +1,12 @@
|
||||
package managecenterModel
|
||||
|
||||
// 服务器状态
|
||||
type GroupState int32
|
||||
|
||||
const (
|
||||
// 正常
|
||||
Con_GroupState_Normal GroupState = 1
|
||||
|
||||
// 维护
|
||||
Con_GroupState_Maintain GroupState = 2
|
||||
)
|
||||
22
trunk/framework/managecenterModel/serverIdRange.go
Normal file
22
trunk/framework/managecenterModel/serverIdRange.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package managecenterModel
|
||||
|
||||
// 服务器(组)Id区间类型
|
||||
type ServerIdRange struct {
|
||||
Min int32 // 最小值
|
||||
Max int32 // 最大值
|
||||
}
|
||||
|
||||
// 是否包含指定的值
|
||||
// value:指定值
|
||||
// 返回值:
|
||||
// 是否包含指定的值
|
||||
func (this *ServerIdRange) Contains(value int32) bool {
|
||||
return this.Min <= value && value <= this.Max
|
||||
}
|
||||
|
||||
func NewServerIdRange(min, max int32) *ServerIdRange {
|
||||
return &ServerIdRange{
|
||||
Min: min,
|
||||
Max: max,
|
||||
}
|
||||
}
|
||||
30
trunk/framework/managecenterModel/serverIdRule.go
Normal file
30
trunk/framework/managecenterModel/serverIdRule.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package managecenterModel
|
||||
|
||||
var (
|
||||
// 安卓正式服的服务器Id区间
|
||||
AndroidOfficial *ServerIdRange = NewServerIdRange(1, 5000)
|
||||
|
||||
// 安卓删档测试服的服务器Id区间
|
||||
AndroidPreOfficial *ServerIdRange = NewServerIdRange(5001, 9000)
|
||||
|
||||
// 安卓审核服的服务器Id区间
|
||||
AndroidAudit *ServerIdRange = NewServerIdRange(9001, 9500)
|
||||
|
||||
// 安卓测试服的服务器Id区间
|
||||
AndroidTest *ServerIdRange = NewServerIdRange(9501, 10000)
|
||||
|
||||
// IOS正式服的服务器Id区间
|
||||
IOSOfficial *ServerIdRange = NewServerIdRange(10001, 15000)
|
||||
|
||||
// IOS删档测试服的服务器Id区间
|
||||
IOSPreOfficial *ServerIdRange = NewServerIdRange(15001, 19000)
|
||||
|
||||
// IOS审核服的服务器Id区间
|
||||
IOSAudit *ServerIdRange = NewServerIdRange(19001, 19500)
|
||||
|
||||
// IOS测试服的服务器Id区间
|
||||
IOSTest *ServerIdRange = NewServerIdRange(19501, 20000)
|
||||
|
||||
// 开发服务器的服务器Id区间
|
||||
Develop *ServerIdRange = NewServerIdRange(20001, 30000)
|
||||
)
|
||||
13
trunk/framework/managecenterModel/sysConfig.go
Normal file
13
trunk/framework/managecenterModel/sysConfig.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package managecenterModel
|
||||
|
||||
// MC系统配置列表对象
|
||||
type SysConfig struct {
|
||||
// 新服有效天数
|
||||
NewServerValidDays int32 `json:"NewServerValidDays"`
|
||||
|
||||
// 用户Id
|
||||
WhiteListServerIds string `json:"WhiteListServerIds"`
|
||||
|
||||
//登录本地验证key
|
||||
DynamicLoginKey string `json:"DynamicLoginKey"`
|
||||
}
|
||||
10
trunk/framework/managecenterModel/whiteList.go
Normal file
10
trunk/framework/managecenterModel/whiteList.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package managecenterModel
|
||||
|
||||
// 白名单列表对象
|
||||
type WhiteList struct {
|
||||
// 合作商Id
|
||||
PartnerId int32 `json:"PartnerId"`
|
||||
|
||||
// 用户Id
|
||||
UserId string `json:"UserId"`
|
||||
}
|
||||
Reference in New Issue
Block a user