mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2026-01-01 11:26:36 +08:00
商业版增加UAM功能
This commit is contained in:
@@ -3,6 +3,7 @@ package models
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
teaconst "github.com/TeaOSLab/EdgeAPI/internal/const"
|
||||
"github.com/TeaOSLab/EdgeAPI/internal/db/models/dns"
|
||||
dbutils "github.com/TeaOSLab/EdgeAPI/internal/db/utils"
|
||||
"github.com/TeaOSLab/EdgeAPI/internal/utils"
|
||||
@@ -1130,6 +1131,18 @@ func (this *ServerDAO) ComposeServerConfig(tx *dbs.Tx, server *Server, cacheMap
|
||||
}
|
||||
}
|
||||
|
||||
// UAM
|
||||
if teaconst.IsPlus && IsNotNull(server.Uam) {
|
||||
var uamConfig = &serverconfigs.UAMConfig{}
|
||||
err = json.Unmarshal(server.Uam, uamConfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if uamConfig.IsOn {
|
||||
config.UAM = uamConfig
|
||||
}
|
||||
}
|
||||
|
||||
if cacheMap != nil {
|
||||
cacheMap.Put(cacheKey, config)
|
||||
}
|
||||
@@ -2276,6 +2289,35 @@ func (this *ServerDAO) FindServerLastUserPlanIdAndUserId(tx *dbs.Tx, serverId in
|
||||
return int64(one.(*Server).LastUserPlanId), int64(one.(*Server).UserId), nil
|
||||
}
|
||||
|
||||
// UpdateServerUAM 开启UAM
|
||||
func (this *ServerDAO) UpdateServerUAM(tx *dbs.Tx, serverId int64, uamConfig *serverconfigs.UAMConfig) error {
|
||||
if uamConfig == nil {
|
||||
return nil
|
||||
}
|
||||
configJSON, err := json.Marshal(uamConfig)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = this.Query(tx).
|
||||
Pk(serverId).
|
||||
Set("uam", configJSON).
|
||||
UpdateQuickly()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return this.NotifyUpdate(tx, serverId)
|
||||
}
|
||||
|
||||
// FindServerUAM 查找服务的UAM配置
|
||||
func (this *ServerDAO) FindServerUAM(tx *dbs.Tx, serverId int64) ([]byte, error) {
|
||||
return this.Query(tx).
|
||||
Pk(serverId).
|
||||
Result("uam").
|
||||
FindJSONCol()
|
||||
}
|
||||
|
||||
// NotifyUpdate 同步集群
|
||||
func (this *ServerDAO) NotifyUpdate(tx *dbs.Tx, serverId int64) error {
|
||||
// 创建任务
|
||||
|
||||
@@ -46,6 +46,7 @@ type Server struct {
|
||||
TotalTraffic float64 `field:"totalTraffic"` // 总流量
|
||||
UserPlanId uint32 `field:"userPlanId"` // 所属套餐ID
|
||||
LastUserPlanId uint32 `field:"lastUserPlanId"` // 上一次使用的套餐
|
||||
Uam dbs.JSON `field:"uam"` // UAM设置
|
||||
}
|
||||
|
||||
type ServerOperator struct {
|
||||
@@ -91,6 +92,7 @@ type ServerOperator struct {
|
||||
TotalTraffic interface{} // 总流量
|
||||
UserPlanId interface{} // 所属套餐ID
|
||||
LastUserPlanId interface{} // 上一次使用的套餐
|
||||
Uam interface{} // UAM设置
|
||||
}
|
||||
|
||||
func NewServerOperator() *ServerOperator {
|
||||
|
||||
Reference in New Issue
Block a user