换成单集群模式
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
_ "github.com/go-sql-driver/mysql"
|
||||
"github.com/iwind/TeaGo/Tea"
|
||||
"github.com/iwind/TeaGo/dbs"
|
||||
@@ -35,12 +37,17 @@ func init() {
|
||||
})
|
||||
}
|
||||
|
||||
func (this *HTTPDNSAppDAO) CreateApp(tx *dbs.Tx, name string, appId string, primaryClusterId int64, backupClusterId int64, isOn bool, userId int64) (int64, error) {
|
||||
func (this *HTTPDNSAppDAO) CreateApp(tx *dbs.Tx, name string, appId string, clusterIdsJSON []byte, isOn bool, userId int64) (int64, error) {
|
||||
var op = NewHTTPDNSAppOperator()
|
||||
op.Name = name
|
||||
op.AppId = appId
|
||||
op.PrimaryClusterId = primaryClusterId
|
||||
op.BackupClusterId = backupClusterId
|
||||
|
||||
if len(clusterIdsJSON) > 0 {
|
||||
op.ClusterIdsJSON = string(clusterIdsJSON)
|
||||
} else {
|
||||
op.ClusterIdsJSON = "[]"
|
||||
}
|
||||
|
||||
op.IsOn = isOn
|
||||
op.UserId = userId
|
||||
op.SNIMode = HTTPDNSSNIModeFixedHide
|
||||
@@ -54,18 +61,37 @@ func (this *HTTPDNSAppDAO) CreateApp(tx *dbs.Tx, name string, appId string, prim
|
||||
return types.Int64(op.Id), nil
|
||||
}
|
||||
|
||||
func (this *HTTPDNSAppDAO) UpdateApp(tx *dbs.Tx, appDbId int64, name string, primaryClusterId int64, backupClusterId int64, isOn bool, userId int64) error {
|
||||
func (this *HTTPDNSAppDAO) UpdateApp(tx *dbs.Tx, appDbId int64, name string, clusterIdsJSON []byte, isOn bool, userId int64) error {
|
||||
var op = NewHTTPDNSAppOperator()
|
||||
op.Id = appDbId
|
||||
op.Name = name
|
||||
op.PrimaryClusterId = primaryClusterId
|
||||
op.BackupClusterId = backupClusterId
|
||||
|
||||
if len(clusterIdsJSON) > 0 {
|
||||
op.ClusterIdsJSON = string(clusterIdsJSON)
|
||||
} else {
|
||||
op.ClusterIdsJSON = "[]"
|
||||
}
|
||||
|
||||
op.IsOn = isOn
|
||||
op.UserId = userId
|
||||
op.UpdatedAt = time.Now().Unix()
|
||||
return this.Save(tx, op)
|
||||
}
|
||||
|
||||
// ReadAppClusterIds reads cluster IDs from ClusterIdsJSON.
|
||||
func (this *HTTPDNSAppDAO) ReadAppClusterIds(app *HTTPDNSApp) []int64 {
|
||||
if app == nil {
|
||||
return nil
|
||||
}
|
||||
if len(app.ClusterIdsJSON) > 0 {
|
||||
var ids []int64
|
||||
if err := json.Unmarshal([]byte(app.ClusterIdsJSON), &ids); err == nil && len(ids) > 0 {
|
||||
return ids
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (this *HTTPDNSAppDAO) DisableApp(tx *dbs.Tx, appDbId int64) error {
|
||||
_, err := this.Query(tx).
|
||||
Pk(appDbId).
|
||||
|
||||
Reference in New Issue
Block a user