mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-07 02:20:24 +08:00
套餐增加Websocket连接数限制
This commit is contained in:
@@ -3,70 +3,76 @@ package models
|
|||||||
import "github.com/iwind/TeaGo/dbs"
|
import "github.com/iwind/TeaGo/dbs"
|
||||||
|
|
||||||
const (
|
const (
|
||||||
PlanField_Id dbs.FieldName = "id" // ID
|
PlanField_Id dbs.FieldName = "id" // ID
|
||||||
PlanField_IsOn dbs.FieldName = "isOn" // 是否启用
|
PlanField_IsOn dbs.FieldName = "isOn" // 是否启用
|
||||||
PlanField_Name dbs.FieldName = "name" // 套餐名
|
PlanField_Name dbs.FieldName = "name" // 套餐名
|
||||||
PlanField_ClusterId dbs.FieldName = "clusterId" // 集群ID
|
PlanField_ClusterId dbs.FieldName = "clusterId" // 集群ID
|
||||||
PlanField_TrafficLimit dbs.FieldName = "trafficLimit" // 流量限制
|
PlanField_TrafficLimit dbs.FieldName = "trafficLimit" // 流量限制
|
||||||
PlanField_Features dbs.FieldName = "features" // 允许的功能
|
PlanField_Features dbs.FieldName = "features" // 允许的功能
|
||||||
PlanField_TrafficPrice dbs.FieldName = "trafficPrice" // 流量价格设定
|
PlanField_TrafficPrice dbs.FieldName = "trafficPrice" // 流量价格设定
|
||||||
PlanField_BandwidthPrice dbs.FieldName = "bandwidthPrice" // 带宽价格
|
PlanField_BandwidthPrice dbs.FieldName = "bandwidthPrice" // 带宽价格
|
||||||
PlanField_MonthlyPrice dbs.FieldName = "monthlyPrice" // 月付
|
PlanField_MonthlyPrice dbs.FieldName = "monthlyPrice" // 月付
|
||||||
PlanField_SeasonallyPrice dbs.FieldName = "seasonallyPrice" // 季付
|
PlanField_SeasonallyPrice dbs.FieldName = "seasonallyPrice" // 季付
|
||||||
PlanField_YearlyPrice dbs.FieldName = "yearlyPrice" // 年付
|
PlanField_YearlyPrice dbs.FieldName = "yearlyPrice" // 年付
|
||||||
PlanField_PriceType dbs.FieldName = "priceType" // 价格类型
|
PlanField_PriceType dbs.FieldName = "priceType" // 价格类型
|
||||||
PlanField_Order dbs.FieldName = "order" // 排序
|
PlanField_Order dbs.FieldName = "order" // 排序
|
||||||
PlanField_State dbs.FieldName = "state" // 状态
|
PlanField_State dbs.FieldName = "state" // 状态
|
||||||
PlanField_TotalServers dbs.FieldName = "totalServers" // 可以绑定的网站数量
|
PlanField_TotalServers dbs.FieldName = "totalServers" // 可以绑定的网站数量
|
||||||
PlanField_TotalServerNamesPerServer dbs.FieldName = "totalServerNamesPerServer" // 每个网站可以绑定的域名数量
|
PlanField_TotalServerNamesPerServer dbs.FieldName = "totalServerNamesPerServer" // 每个网站可以绑定的域名数量
|
||||||
PlanField_TotalServerNames dbs.FieldName = "totalServerNames" // 总域名数量
|
PlanField_TotalServerNames dbs.FieldName = "totalServerNames" // 总域名数量
|
||||||
PlanField_MonthlyRequests dbs.FieldName = "monthlyRequests" // 每月访问量额度
|
PlanField_MonthlyRequests dbs.FieldName = "monthlyRequests" // 每月访问量额度
|
||||||
PlanField_DailyRequests dbs.FieldName = "dailyRequests" // 每日访问量额度
|
PlanField_DailyRequests dbs.FieldName = "dailyRequests" // 每日访问量额度
|
||||||
|
PlanField_DailyWebsocketConnections dbs.FieldName = "dailyWebsocketConnections" // 每日Websocket连接数
|
||||||
|
PlanField_MonthlyWebsocketConnections dbs.FieldName = "monthlyWebsocketConnections" // 每月Websocket连接数
|
||||||
)
|
)
|
||||||
|
|
||||||
// Plan 用户套餐
|
// Plan 用户套餐
|
||||||
type Plan struct {
|
type Plan struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
IsOn bool `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Name string `field:"name"` // 套餐名
|
Name string `field:"name"` // 套餐名
|
||||||
ClusterId uint32 `field:"clusterId"` // 集群ID
|
ClusterId uint32 `field:"clusterId"` // 集群ID
|
||||||
TrafficLimit dbs.JSON `field:"trafficLimit"` // 流量限制
|
TrafficLimit dbs.JSON `field:"trafficLimit"` // 流量限制
|
||||||
Features dbs.JSON `field:"features"` // 允许的功能
|
Features dbs.JSON `field:"features"` // 允许的功能
|
||||||
TrafficPrice dbs.JSON `field:"trafficPrice"` // 流量价格设定
|
TrafficPrice dbs.JSON `field:"trafficPrice"` // 流量价格设定
|
||||||
BandwidthPrice dbs.JSON `field:"bandwidthPrice"` // 带宽价格
|
BandwidthPrice dbs.JSON `field:"bandwidthPrice"` // 带宽价格
|
||||||
MonthlyPrice float64 `field:"monthlyPrice"` // 月付
|
MonthlyPrice float64 `field:"monthlyPrice"` // 月付
|
||||||
SeasonallyPrice float64 `field:"seasonallyPrice"` // 季付
|
SeasonallyPrice float64 `field:"seasonallyPrice"` // 季付
|
||||||
YearlyPrice float64 `field:"yearlyPrice"` // 年付
|
YearlyPrice float64 `field:"yearlyPrice"` // 年付
|
||||||
PriceType string `field:"priceType"` // 价格类型
|
PriceType string `field:"priceType"` // 价格类型
|
||||||
Order uint32 `field:"order"` // 排序
|
Order uint32 `field:"order"` // 排序
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
TotalServers uint32 `field:"totalServers"` // 可以绑定的网站数量
|
TotalServers uint32 `field:"totalServers"` // 可以绑定的网站数量
|
||||||
TotalServerNamesPerServer uint32 `field:"totalServerNamesPerServer"` // 每个网站可以绑定的域名数量
|
TotalServerNamesPerServer uint32 `field:"totalServerNamesPerServer"` // 每个网站可以绑定的域名数量
|
||||||
TotalServerNames uint32 `field:"totalServerNames"` // 总域名数量
|
TotalServerNames uint32 `field:"totalServerNames"` // 总域名数量
|
||||||
MonthlyRequests uint64 `field:"monthlyRequests"` // 每月访问量额度
|
MonthlyRequests uint64 `field:"monthlyRequests"` // 每月访问量额度
|
||||||
DailyRequests uint64 `field:"dailyRequests"` // 每日访问量额度
|
DailyRequests uint64 `field:"dailyRequests"` // 每日访问量额度
|
||||||
|
DailyWebsocketConnections uint64 `field:"dailyWebsocketConnections"` // 每日Websocket连接数
|
||||||
|
MonthlyWebsocketConnections uint64 `field:"monthlyWebsocketConnections"` // 每月Websocket连接数
|
||||||
}
|
}
|
||||||
|
|
||||||
type PlanOperator struct {
|
type PlanOperator struct {
|
||||||
Id any // ID
|
Id any // ID
|
||||||
IsOn any // 是否启用
|
IsOn any // 是否启用
|
||||||
Name any // 套餐名
|
Name any // 套餐名
|
||||||
ClusterId any // 集群ID
|
ClusterId any // 集群ID
|
||||||
TrafficLimit any // 流量限制
|
TrafficLimit any // 流量限制
|
||||||
Features any // 允许的功能
|
Features any // 允许的功能
|
||||||
TrafficPrice any // 流量价格设定
|
TrafficPrice any // 流量价格设定
|
||||||
BandwidthPrice any // 带宽价格
|
BandwidthPrice any // 带宽价格
|
||||||
MonthlyPrice any // 月付
|
MonthlyPrice any // 月付
|
||||||
SeasonallyPrice any // 季付
|
SeasonallyPrice any // 季付
|
||||||
YearlyPrice any // 年付
|
YearlyPrice any // 年付
|
||||||
PriceType any // 价格类型
|
PriceType any // 价格类型
|
||||||
Order any // 排序
|
Order any // 排序
|
||||||
State any // 状态
|
State any // 状态
|
||||||
TotalServers any // 可以绑定的网站数量
|
TotalServers any // 可以绑定的网站数量
|
||||||
TotalServerNamesPerServer any // 每个网站可以绑定的域名数量
|
TotalServerNamesPerServer any // 每个网站可以绑定的域名数量
|
||||||
TotalServerNames any // 总域名数量
|
TotalServerNames any // 总域名数量
|
||||||
MonthlyRequests any // 每月访问量额度
|
MonthlyRequests any // 每月访问量额度
|
||||||
DailyRequests any // 每日访问量额度
|
DailyRequests any // 每日访问量额度
|
||||||
|
DailyWebsocketConnections any // 每日Websocket连接数
|
||||||
|
MonthlyWebsocketConnections any // 每月Websocket连接数
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewPlanOperator() *PlanOperator {
|
func NewPlanOperator() *PlanOperator {
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ func init() {
|
|||||||
|
|
||||||
// UpdateUserPlanBandwidth 写入数据
|
// UpdateUserPlanBandwidth 写入数据
|
||||||
// 暂时不使用region区分
|
// 暂时不使用region区分
|
||||||
func (this *UserPlanBandwidthStatDAO) UpdateUserPlanBandwidth(tx *dbs.Tx, userId int64, userPlanId int64, regionId int64, day string, timeAt string, bandwidthBytes int64, totalBytes int64, cachedBytes int64, attackBytes int64, countRequests int64, countCachedRequests int64, countAttackRequests int64) error {
|
func (this *UserPlanBandwidthStatDAO) UpdateUserPlanBandwidth(tx *dbs.Tx, userId int64, userPlanId int64, regionId int64, day string, timeAt string, bandwidthBytes int64, totalBytes int64, cachedBytes int64, attackBytes int64, countRequests int64, countCachedRequests int64, countAttackRequests int64, countWebsocketConnections int64) error {
|
||||||
if userId <= 0 || userPlanId <= 0 {
|
if userId <= 0 || userPlanId <= 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -73,29 +73,32 @@ func (this *UserPlanBandwidthStatDAO) UpdateUserPlanBandwidth(tx *dbs.Tx, userId
|
|||||||
Param("countRequests", countRequests).
|
Param("countRequests", countRequests).
|
||||||
Param("countCachedRequests", countCachedRequests).
|
Param("countCachedRequests", countCachedRequests).
|
||||||
Param("countAttackRequests", countAttackRequests).
|
Param("countAttackRequests", countAttackRequests).
|
||||||
|
Param("countWebsocketConnections", countWebsocketConnections).
|
||||||
InsertOrUpdateQuickly(maps.Map{
|
InsertOrUpdateQuickly(maps.Map{
|
||||||
"userId": userId,
|
"userId": userId,
|
||||||
"userPlanId": userPlanId,
|
"userPlanId": userPlanId,
|
||||||
"regionId": regionId,
|
"regionId": regionId,
|
||||||
"day": day,
|
"day": day,
|
||||||
"timeAt": timeAt,
|
"timeAt": timeAt,
|
||||||
"bytes": bandwidthBytes,
|
"bytes": bandwidthBytes,
|
||||||
"totalBytes": totalBytes,
|
"totalBytes": totalBytes,
|
||||||
"avgBytes": totalBytes / 300,
|
"avgBytes": totalBytes / 300,
|
||||||
"cachedBytes": cachedBytes,
|
"cachedBytes": cachedBytes,
|
||||||
"attackBytes": attackBytes,
|
"attackBytes": attackBytes,
|
||||||
"countRequests": countRequests,
|
"countRequests": countRequests,
|
||||||
"countCachedRequests": countCachedRequests,
|
"countCachedRequests": countCachedRequests,
|
||||||
"countAttackRequests": countAttackRequests,
|
"countAttackRequests": countAttackRequests,
|
||||||
|
"countWebsocketConnections": countWebsocketConnections,
|
||||||
}, maps.Map{
|
}, maps.Map{
|
||||||
"bytes": dbs.SQL("bytes+:bytes"),
|
"bytes": dbs.SQL("bytes+:bytes"),
|
||||||
"avgBytes": dbs.SQL("(totalBytes+:totalBytes)/300"), // 因为生成SQL语句时会自动将avgBytes排在totalBytes之前,所以这里不用担心先后顺序的问题
|
"avgBytes": dbs.SQL("(totalBytes+:totalBytes)/300"), // 因为生成SQL语句时会自动将avgBytes排在totalBytes之前,所以这里不用担心先后顺序的问题
|
||||||
"totalBytes": dbs.SQL("totalBytes+:totalBytes"),
|
"totalBytes": dbs.SQL("totalBytes+:totalBytes"),
|
||||||
"cachedBytes": dbs.SQL("cachedBytes+:cachedBytes"),
|
"cachedBytes": dbs.SQL("cachedBytes+:cachedBytes"),
|
||||||
"attackBytes": dbs.SQL("attackBytes+:attackBytes"),
|
"attackBytes": dbs.SQL("attackBytes+:attackBytes"),
|
||||||
"countRequests": dbs.SQL("countRequests+:countRequests"),
|
"countRequests": dbs.SQL("countRequests+:countRequests"),
|
||||||
"countCachedRequests": dbs.SQL("countCachedRequests+:countCachedRequests"),
|
"countCachedRequests": dbs.SQL("countCachedRequests+:countCachedRequests"),
|
||||||
"countAttackRequests": dbs.SQL("countAttackRequests+:countAttackRequests"),
|
"countAttackRequests": dbs.SQL("countAttackRequests+:countAttackRequests"),
|
||||||
|
"countWebsocketConnections": dbs.SQL("countWebsocketConnections+:countWebsocketConnections"),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,55 +3,58 @@ package models
|
|||||||
import "github.com/iwind/TeaGo/dbs"
|
import "github.com/iwind/TeaGo/dbs"
|
||||||
|
|
||||||
const (
|
const (
|
||||||
UserPlanBandwidthStatField_Id dbs.FieldName = "id" // ID
|
UserPlanBandwidthStatField_Id dbs.FieldName = "id" // ID
|
||||||
UserPlanBandwidthStatField_UserId dbs.FieldName = "userId" // 用户ID
|
UserPlanBandwidthStatField_UserId dbs.FieldName = "userId" // 用户ID
|
||||||
UserPlanBandwidthStatField_UserPlanId dbs.FieldName = "userPlanId" // 用户套餐ID
|
UserPlanBandwidthStatField_UserPlanId dbs.FieldName = "userPlanId" // 用户套餐ID
|
||||||
UserPlanBandwidthStatField_Day dbs.FieldName = "day" // 日期YYYYMMDD
|
UserPlanBandwidthStatField_Day dbs.FieldName = "day" // 日期YYYYMMDD
|
||||||
UserPlanBandwidthStatField_TimeAt dbs.FieldName = "timeAt" // 时间点HHII
|
UserPlanBandwidthStatField_TimeAt dbs.FieldName = "timeAt" // 时间点HHII
|
||||||
UserPlanBandwidthStatField_Bytes dbs.FieldName = "bytes" // 带宽
|
UserPlanBandwidthStatField_Bytes dbs.FieldName = "bytes" // 带宽
|
||||||
UserPlanBandwidthStatField_RegionId dbs.FieldName = "regionId" // 区域ID
|
UserPlanBandwidthStatField_RegionId dbs.FieldName = "regionId" // 区域ID
|
||||||
UserPlanBandwidthStatField_TotalBytes dbs.FieldName = "totalBytes" // 总流量
|
UserPlanBandwidthStatField_TotalBytes dbs.FieldName = "totalBytes" // 总流量
|
||||||
UserPlanBandwidthStatField_AvgBytes dbs.FieldName = "avgBytes" // 平均流量
|
UserPlanBandwidthStatField_AvgBytes dbs.FieldName = "avgBytes" // 平均流量
|
||||||
UserPlanBandwidthStatField_CachedBytes dbs.FieldName = "cachedBytes" // 缓存的流量
|
UserPlanBandwidthStatField_CachedBytes dbs.FieldName = "cachedBytes" // 缓存的流量
|
||||||
UserPlanBandwidthStatField_AttackBytes dbs.FieldName = "attackBytes" // 攻击流量
|
UserPlanBandwidthStatField_AttackBytes dbs.FieldName = "attackBytes" // 攻击流量
|
||||||
UserPlanBandwidthStatField_CountRequests dbs.FieldName = "countRequests" // 请求数
|
UserPlanBandwidthStatField_CountRequests dbs.FieldName = "countRequests" // 请求数
|
||||||
UserPlanBandwidthStatField_CountCachedRequests dbs.FieldName = "countCachedRequests" // 缓存的请求数
|
UserPlanBandwidthStatField_CountCachedRequests dbs.FieldName = "countCachedRequests" // 缓存的请求数
|
||||||
UserPlanBandwidthStatField_CountAttackRequests dbs.FieldName = "countAttackRequests" // 攻击请求数
|
UserPlanBandwidthStatField_CountAttackRequests dbs.FieldName = "countAttackRequests" // 攻击请求数
|
||||||
|
UserPlanBandwidthStatField_CountWebsocketConnections dbs.FieldName = "countWebsocketConnections" // Websocket连接数
|
||||||
)
|
)
|
||||||
|
|
||||||
// UserPlanBandwidthStat 用户套餐带宽峰值
|
// UserPlanBandwidthStat 用户套餐带宽峰值
|
||||||
type UserPlanBandwidthStat struct {
|
type UserPlanBandwidthStat struct {
|
||||||
Id uint64 `field:"id"` // ID
|
Id uint64 `field:"id"` // ID
|
||||||
UserId uint64 `field:"userId"` // 用户ID
|
UserId uint64 `field:"userId"` // 用户ID
|
||||||
UserPlanId uint64 `field:"userPlanId"` // 用户套餐ID
|
UserPlanId uint64 `field:"userPlanId"` // 用户套餐ID
|
||||||
Day string `field:"day"` // 日期YYYYMMDD
|
Day string `field:"day"` // 日期YYYYMMDD
|
||||||
TimeAt string `field:"timeAt"` // 时间点HHII
|
TimeAt string `field:"timeAt"` // 时间点HHII
|
||||||
Bytes uint64 `field:"bytes"` // 带宽
|
Bytes uint64 `field:"bytes"` // 带宽
|
||||||
RegionId uint32 `field:"regionId"` // 区域ID
|
RegionId uint32 `field:"regionId"` // 区域ID
|
||||||
TotalBytes uint64 `field:"totalBytes"` // 总流量
|
TotalBytes uint64 `field:"totalBytes"` // 总流量
|
||||||
AvgBytes uint64 `field:"avgBytes"` // 平均流量
|
AvgBytes uint64 `field:"avgBytes"` // 平均流量
|
||||||
CachedBytes uint64 `field:"cachedBytes"` // 缓存的流量
|
CachedBytes uint64 `field:"cachedBytes"` // 缓存的流量
|
||||||
AttackBytes uint64 `field:"attackBytes"` // 攻击流量
|
AttackBytes uint64 `field:"attackBytes"` // 攻击流量
|
||||||
CountRequests uint64 `field:"countRequests"` // 请求数
|
CountRequests uint64 `field:"countRequests"` // 请求数
|
||||||
CountCachedRequests uint64 `field:"countCachedRequests"` // 缓存的请求数
|
CountCachedRequests uint64 `field:"countCachedRequests"` // 缓存的请求数
|
||||||
CountAttackRequests uint64 `field:"countAttackRequests"` // 攻击请求数
|
CountAttackRequests uint64 `field:"countAttackRequests"` // 攻击请求数
|
||||||
|
CountWebsocketConnections uint64 `field:"countWebsocketConnections"` // Websocket连接数
|
||||||
}
|
}
|
||||||
|
|
||||||
type UserPlanBandwidthStatOperator struct {
|
type UserPlanBandwidthStatOperator struct {
|
||||||
Id any // ID
|
Id any // ID
|
||||||
UserId any // 用户ID
|
UserId any // 用户ID
|
||||||
UserPlanId any // 用户套餐ID
|
UserPlanId any // 用户套餐ID
|
||||||
Day any // 日期YYYYMMDD
|
Day any // 日期YYYYMMDD
|
||||||
TimeAt any // 时间点HHII
|
TimeAt any // 时间点HHII
|
||||||
Bytes any // 带宽
|
Bytes any // 带宽
|
||||||
RegionId any // 区域ID
|
RegionId any // 区域ID
|
||||||
TotalBytes any // 总流量
|
TotalBytes any // 总流量
|
||||||
AvgBytes any // 平均流量
|
AvgBytes any // 平均流量
|
||||||
CachedBytes any // 缓存的流量
|
CachedBytes any // 缓存的流量
|
||||||
AttackBytes any // 攻击流量
|
AttackBytes any // 攻击流量
|
||||||
CountRequests any // 请求数
|
CountRequests any // 请求数
|
||||||
CountCachedRequests any // 缓存的请求数
|
CountCachedRequests any // 缓存的请求数
|
||||||
CountAttackRequests any // 攻击请求数
|
CountAttackRequests any // 攻击请求数
|
||||||
|
CountWebsocketConnections any // Websocket连接数
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewUserPlanBandwidthStatOperator() *UserPlanBandwidthStatOperator {
|
func NewUserPlanBandwidthStatOperator() *UserPlanBandwidthStatOperator {
|
||||||
|
|||||||
@@ -5,6 +5,6 @@ package models
|
|||||||
|
|
||||||
import "github.com/iwind/TeaGo/dbs"
|
import "github.com/iwind/TeaGo/dbs"
|
||||||
|
|
||||||
func (this *UserPlanStatDAO) IncreaseUserPlanStat(tx *dbs.Tx, userPlanId int64, trafficBytes int64, countRequests int64) error {
|
func (this *UserPlanStatDAO) IncreaseUserPlanStat(tx *dbs.Tx, userPlanId int64, trafficBytes int64, countRequests int64, countWebsocketConnections int64) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,34 +3,37 @@ package models
|
|||||||
import "github.com/iwind/TeaGo/dbs"
|
import "github.com/iwind/TeaGo/dbs"
|
||||||
|
|
||||||
const (
|
const (
|
||||||
UserPlanStatField_Id dbs.FieldName = "id" // ID
|
UserPlanStatField_Id dbs.FieldName = "id" // ID
|
||||||
UserPlanStatField_UserPlanId dbs.FieldName = "userPlanId" // 用户套餐ID
|
UserPlanStatField_UserPlanId dbs.FieldName = "userPlanId" // 用户套餐ID
|
||||||
UserPlanStatField_Date dbs.FieldName = "date" // 日期:YYYYMMDD或YYYYMM
|
UserPlanStatField_Date dbs.FieldName = "date" // 日期:YYYYMMDD或YYYYMM
|
||||||
UserPlanStatField_DateType dbs.FieldName = "dateType" // 日期类型:day|month
|
UserPlanStatField_DateType dbs.FieldName = "dateType" // 日期类型:day|month
|
||||||
UserPlanStatField_TrafficBytes dbs.FieldName = "trafficBytes" // 流量
|
UserPlanStatField_TrafficBytes dbs.FieldName = "trafficBytes" // 流量
|
||||||
UserPlanStatField_CountRequests dbs.FieldName = "countRequests" // 总请求数
|
UserPlanStatField_CountRequests dbs.FieldName = "countRequests" // 总请求数
|
||||||
UserPlanStatField_IsProcessed dbs.FieldName = "isProcessed" // 是否已处理
|
UserPlanStatField_CountWebsocketConnections dbs.FieldName = "countWebsocketConnections" // Websocket连接数
|
||||||
|
UserPlanStatField_IsProcessed dbs.FieldName = "isProcessed" // 是否已处理
|
||||||
)
|
)
|
||||||
|
|
||||||
// UserPlanStat 用户套餐统计
|
// UserPlanStat 用户套餐统计
|
||||||
type UserPlanStat struct {
|
type UserPlanStat struct {
|
||||||
Id uint64 `field:"id"` // ID
|
Id uint64 `field:"id"` // ID
|
||||||
UserPlanId uint64 `field:"userPlanId"` // 用户套餐ID
|
UserPlanId uint64 `field:"userPlanId"` // 用户套餐ID
|
||||||
Date string `field:"date"` // 日期:YYYYMMDD或YYYYMM
|
Date string `field:"date"` // 日期:YYYYMMDD或YYYYMM
|
||||||
DateType string `field:"dateType"` // 日期类型:day|month
|
DateType string `field:"dateType"` // 日期类型:day|month
|
||||||
TrafficBytes uint64 `field:"trafficBytes"` // 流量
|
TrafficBytes uint64 `field:"trafficBytes"` // 流量
|
||||||
CountRequests uint64 `field:"countRequests"` // 总请求数
|
CountRequests uint64 `field:"countRequests"` // 总请求数
|
||||||
IsProcessed bool `field:"isProcessed"` // 是否已处理
|
CountWebsocketConnections uint64 `field:"countWebsocketConnections"` // Websocket连接数
|
||||||
|
IsProcessed bool `field:"isProcessed"` // 是否已处理
|
||||||
}
|
}
|
||||||
|
|
||||||
type UserPlanStatOperator struct {
|
type UserPlanStatOperator struct {
|
||||||
Id any // ID
|
Id any // ID
|
||||||
UserPlanId any // 用户套餐ID
|
UserPlanId any // 用户套餐ID
|
||||||
Date any // 日期:YYYYMMDD或YYYYMM
|
Date any // 日期:YYYYMMDD或YYYYMM
|
||||||
DateType any // 日期类型:day|month
|
DateType any // 日期类型:day|month
|
||||||
TrafficBytes any // 流量
|
TrafficBytes any // 流量
|
||||||
CountRequests any // 总请求数
|
CountRequests any // 总请求数
|
||||||
IsProcessed any // 是否已处理
|
CountWebsocketConnections any // Websocket连接数
|
||||||
|
IsProcessed any // 是否已处理
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewUserPlanStatOperator() *UserPlanStatOperator {
|
func NewUserPlanStatOperator() *UserPlanStatOperator {
|
||||||
|
|||||||
@@ -80,13 +80,13 @@ func init() {
|
|||||||
// 套餐统计
|
// 套餐统计
|
||||||
if stat.UserPlanId > 0 {
|
if stat.UserPlanId > 0 {
|
||||||
// 总体统计
|
// 总体统计
|
||||||
err = models.SharedUserPlanStatDAO.IncreaseUserPlanStat(tx, stat.UserPlanId, stat.TotalBytes, stat.CountRequests)
|
err = models.SharedUserPlanStatDAO.IncreaseUserPlanStat(tx, stat.UserPlanId, stat.TotalBytes, stat.CountRequests, stat.CountWebsocketConnections)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
remotelogs.Error("ServerBandwidthStatService", "IncreaseUserPlanStat: "+err.Error())
|
remotelogs.Error("ServerBandwidthStatService", "IncreaseUserPlanStat: "+err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
// 分时统计
|
// 分时统计
|
||||||
err = models.SharedUserPlanBandwidthStatDAO.UpdateUserPlanBandwidth(tx, stat.UserId, stat.UserPlanId, stat.NodeRegionId, stat.Day, stat.TimeAt, stat.Bytes, stat.TotalBytes, stat.CachedBytes, stat.AttackBytes, stat.CountRequests, stat.CountCachedRequests, stat.CountAttackRequests)
|
err = models.SharedUserPlanBandwidthStatDAO.UpdateUserPlanBandwidth(tx, stat.UserId, stat.UserPlanId, stat.NodeRegionId, stat.Day, stat.TimeAt, stat.Bytes, stat.TotalBytes, stat.CachedBytes, stat.AttackBytes, stat.CountRequests, stat.CountCachedRequests, stat.CountAttackRequests, stat.CountWebsocketConnections)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,22 +146,24 @@ func (this *ServerBandwidthStatService) UploadServerBandwidthStats(ctx context.C
|
|||||||
oldStat.CountRequests += stat.CountRequests
|
oldStat.CountRequests += stat.CountRequests
|
||||||
oldStat.CountCachedRequests += stat.CountCachedRequests
|
oldStat.CountCachedRequests += stat.CountCachedRequests
|
||||||
oldStat.CountAttackRequests += stat.CountAttackRequests
|
oldStat.CountAttackRequests += stat.CountAttackRequests
|
||||||
|
oldStat.CountWebsocketConnections += stat.CountWebsocketConnections
|
||||||
} else {
|
} else {
|
||||||
serverBandwidthStatsMap[key] = &pb.ServerBandwidthStat{
|
serverBandwidthStatsMap[key] = &pb.ServerBandwidthStat{
|
||||||
Id: 0,
|
Id: 0,
|
||||||
NodeRegionId: stat.NodeRegionId,
|
NodeRegionId: stat.NodeRegionId,
|
||||||
UserId: stat.UserId,
|
UserId: stat.UserId,
|
||||||
ServerId: stat.ServerId,
|
ServerId: stat.ServerId,
|
||||||
Day: stat.Day,
|
Day: stat.Day,
|
||||||
TimeAt: stat.TimeAt,
|
TimeAt: stat.TimeAt,
|
||||||
Bytes: stat.Bytes,
|
Bytes: stat.Bytes,
|
||||||
TotalBytes: stat.TotalBytes,
|
TotalBytes: stat.TotalBytes,
|
||||||
CachedBytes: stat.CachedBytes,
|
CachedBytes: stat.CachedBytes,
|
||||||
AttackBytes: stat.AttackBytes,
|
AttackBytes: stat.AttackBytes,
|
||||||
CountRequests: stat.CountRequests,
|
CountRequests: stat.CountRequests,
|
||||||
CountCachedRequests: stat.CountCachedRequests,
|
CountCachedRequests: stat.CountCachedRequests,
|
||||||
CountAttackRequests: stat.CountAttackRequests,
|
CountAttackRequests: stat.CountAttackRequests,
|
||||||
UserPlanId: stat.UserPlanId,
|
CountWebsocketConnections: stat.CountWebsocketConnections,
|
||||||
|
UserPlanId: stat.UserPlanId,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
serverBandwidthStatsLocker.Unlock()
|
serverBandwidthStatsLocker.Unlock()
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user