forked from all_user/stat_center
Initial commit
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
package statg
|
||||
|
||||
type Endpoint struct {
|
||||
AppId int32 `json:"appId"` // APPID
|
||||
NameFull string `json:"nameFull"` // APP全名
|
||||
NameShort string `json:"nameShort"` // APP短名
|
||||
NameEn string `json:"nameEn"` // 名字英文缩写
|
||||
ServerUrl string `json:"serverUrl"` // APP服务器地址
|
||||
H5Origin string `json:"h5Origin"` // H5原地址
|
||||
H5Target string `json:"h5Target"` // H5目标地址
|
||||
H5Config string `json:"h5Config"` // H5配置文件
|
||||
BotStat bool `json:"hourStat"` // 参与机器人统计
|
||||
BotRank bool `json:"hourReport"` // 参与机器人排名
|
||||
OwnerIndex ServerIndex `json:"ownerIndex"` // 所属服务器编号
|
||||
}
|
||||
|
||||
type Endpoints []*Endpoint
|
||||
type IndexEndpoints map[ServerIndex]Endpoints
|
||||
type AppIdEndpoints map[int32]*Endpoint
|
||||
|
||||
func (s Endpoints) GetIndexEndpoints(index ServerIndex) Endpoints {
|
||||
ret := make(Endpoints, 0)
|
||||
for _, endpoint := range s {
|
||||
if endpoint.OwnerIndex == index {
|
||||
ret = append(ret, endpoint)
|
||||
}
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
func (s Endpoints) GetBotStatEndpoints() Endpoints {
|
||||
ret := make(Endpoints, 0)
|
||||
for _, endpoint := range s {
|
||||
if endpoint.BotStat {
|
||||
ret = append(ret, endpoint)
|
||||
}
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
func (s Endpoints) GetBotRankEndpoints() Endpoints {
|
||||
ret := make(Endpoints, 0)
|
||||
for _, endpoint := range s {
|
||||
if endpoint.BotRank {
|
||||
ret = append(ret, endpoint)
|
||||
}
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
func (s Endpoints) ExistsByAppId(appId int32) bool {
|
||||
for _, endpoint := range s {
|
||||
if endpoint.AppId == appId {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (s Endpoints) GetEndpointByAppId(appId int32) *Endpoint {
|
||||
for _, endpoint := range s {
|
||||
if endpoint.AppId == appId {
|
||||
return endpoint
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s Endpoints) GetAppShortNameById(appId int32) string {
|
||||
for _, endpoint := range s {
|
||||
if endpoint.AppId == appId {
|
||||
return endpoint.NameShort
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
var (
|
||||
GlobalEndpoints = make(Endpoints, 0)
|
||||
GlobalIndexEndpoints = make(IndexEndpoints)
|
||||
GlobalAppIdEndpoints = make(AppIdEndpoints)
|
||||
)
|
||||
Reference in New Issue
Block a user