Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
07b377c2fb | ||
|
|
33a3795773 | ||
|
|
bddb3cae96 | ||
|
|
6a525c2b82 | ||
|
|
3a137c1c3f | ||
|
|
19867568a9 | ||
|
|
c2600b911b | ||
|
|
fe511ae7e5 | ||
|
|
876c631c85 | ||
|
|
a4cc138ef3 | ||
|
|
3f9a7a8a49 | ||
|
|
09d8ef00c2 | ||
|
|
b4f77ddc63 |
@@ -161,6 +161,20 @@ func main() {
|
||||
}
|
||||
}
|
||||
})
|
||||
app.On("instance", func() {
|
||||
var sock = gosock.NewTmpSock(teaconst.ProcessName)
|
||||
reply, err := sock.Send(&gosock.Command{Code: "instance"})
|
||||
if err != nil {
|
||||
fmt.Println("[ERROR]" + err.Error())
|
||||
} else {
|
||||
replyJSON, err := json.MarshalIndent(reply.Params, "", " ")
|
||||
if err != nil {
|
||||
fmt.Println("[ERROR]marshal result failed: " + err.Error())
|
||||
} else {
|
||||
fmt.Println(string(replyJSON))
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
app.Run(func() {
|
||||
nodes.NewAPINode().Start()
|
||||
|
||||
2
go.mod
2
go.mod
@@ -13,7 +13,7 @@ require (
|
||||
github.com/go-sql-driver/mysql v1.5.0
|
||||
github.com/golang/protobuf v1.5.2
|
||||
github.com/iwind/TeaGo v0.0.0-20220408111647-f36b9bba3570
|
||||
github.com/iwind/gosock v0.0.0-20210722083328-12b2d66abec3
|
||||
github.com/iwind/gosock v0.0.0-20220505115348-f88412125a62
|
||||
github.com/mozillazg/go-pinyin v0.18.0
|
||||
github.com/pkg/sftp v1.12.0
|
||||
github.com/shirou/gopsutil/v3 v3.22.2
|
||||
|
||||
2
go.sum
2
go.sum
@@ -241,6 +241,8 @@ github.com/iwind/TeaGo v0.0.0-20220408111647-f36b9bba3570 h1:zqz2FiMMkSHXWO1EsTR
|
||||
github.com/iwind/TeaGo v0.0.0-20220408111647-f36b9bba3570/go.mod h1:HRHK0zoC/og3c9/hKosD9yYVMTnnzm3PgXUdhRYHaLc=
|
||||
github.com/iwind/gosock v0.0.0-20210722083328-12b2d66abec3 h1:aBSonas7vFcgTj9u96/bWGILGv1ZbUSTLiOzcI1ZT6c=
|
||||
github.com/iwind/gosock v0.0.0-20210722083328-12b2d66abec3/go.mod h1:H5Q7SXwbx3a97ecJkaS2sD77gspzE7HFUafBO0peEyA=
|
||||
github.com/iwind/gosock v0.0.0-20220505115348-f88412125a62 h1:HJH6RDheAY156DnIfJSD/bEvqyXzsZuE2gzs8PuUjoo=
|
||||
github.com/iwind/gosock v0.0.0-20220505115348-f88412125a62/go.mod h1:H5Q7SXwbx3a97ecJkaS2sD77gspzE7HFUafBO0peEyA=
|
||||
github.com/jarcoal/httpmock v1.0.5/go.mod h1:ATjnClrvW/3tijVmpL/va5Z3aAyGvqU3gCT8nX0Txik=
|
||||
github.com/jarcoal/httpmock v1.0.6/go.mod h1:ATjnClrvW/3tijVmpL/va5Z3aAyGvqU3gCT8nX0Txik=
|
||||
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package teaconst
|
||||
|
||||
const (
|
||||
Version = "0.4.9"
|
||||
Version = "0.4.10"
|
||||
|
||||
ProductName = "Edge API"
|
||||
ProcessName = "edge-api"
|
||||
@@ -18,8 +18,8 @@ const (
|
||||
|
||||
// 其他节点版本号,用来检测是否有需要升级的节点
|
||||
|
||||
NodeVersion = "0.4.9"
|
||||
UserNodeVersion = "0.3.5"
|
||||
NodeVersion = "0.4.10"
|
||||
UserNodeVersion = "0.3.6"
|
||||
AuthorityNodeVersion = "0.0.2"
|
||||
MonitorNodeVersion = "0.0.4"
|
||||
DNSNodeVersion = "0.2.4"
|
||||
|
||||
@@ -2,9 +2,18 @@
|
||||
|
||||
package teaconst
|
||||
|
||||
var (
|
||||
IsPlus = false
|
||||
MaxNodes int32 = 0
|
||||
NodeId int64 = 0
|
||||
Debug = false
|
||||
import (
|
||||
"crypto/sha1"
|
||||
"fmt"
|
||||
"github.com/iwind/TeaGo/rands"
|
||||
"github.com/iwind/TeaGo/types"
|
||||
"time"
|
||||
)
|
||||
|
||||
var (
|
||||
IsPlus = false
|
||||
MaxNodes int32 = 0
|
||||
NodeId int64 = 0
|
||||
Debug = false
|
||||
InstanceCode = fmt.Sprintf("%x", sha1.Sum([]byte("INSTANCE"+types.String(time.Now().UnixNano())+"@"+types.String(rands.Int64()))))
|
||||
)
|
||||
|
||||
@@ -29,7 +29,7 @@ func init() {
|
||||
|
||||
// 创建认证信息
|
||||
func (this *ACMEAuthenticationDAO) CreateAuth(tx *dbs.Tx, taskId int64, domain string, token string, key string) error {
|
||||
op := NewACMEAuthenticationOperator()
|
||||
var op = NewACMEAuthenticationOperator()
|
||||
op.TaskId = taskId
|
||||
op.Domain = domain
|
||||
op.Token = token
|
||||
|
||||
@@ -169,7 +169,7 @@ func (this *ACMETaskDAO) ListEnabledACMETasks(tx *dbs.Tx, adminId int64, userId
|
||||
|
||||
// CreateACMETask 创建任务
|
||||
func (this *ACMETaskDAO) CreateACMETask(tx *dbs.Tx, adminId int64, userId int64, authType acmeutils.AuthType, acmeUserId int64, dnsProviderId int64, dnsDomain string, domains []string, autoRenew bool, authURL string) (int64, error) {
|
||||
op := NewACMETaskOperator()
|
||||
var op = NewACMETaskOperator()
|
||||
op.AdminId = adminId
|
||||
op.UserId = userId
|
||||
op.AuthType = authType
|
||||
@@ -204,7 +204,7 @@ func (this *ACMETaskDAO) UpdateACMETask(tx *dbs.Tx, acmeTaskId int64, acmeUserId
|
||||
return errors.New("invalid acmeTaskId")
|
||||
}
|
||||
|
||||
op := NewACMETaskOperator()
|
||||
var op = NewACMETaskOperator()
|
||||
op.Id = acmeTaskId
|
||||
op.AcmeUserId = acmeUserId
|
||||
op.DnsProviderId = dnsProviderId
|
||||
@@ -240,7 +240,7 @@ func (this *ACMETaskDAO) UpdateACMETaskCert(tx *dbs.Tx, taskId int64, certId int
|
||||
return errors.New("invalid taskId")
|
||||
}
|
||||
|
||||
op := NewACMETaskOperator()
|
||||
var op = NewACMETaskOperator()
|
||||
op.Id = taskId
|
||||
op.CertId = certId
|
||||
err := this.Save(tx, op)
|
||||
|
||||
@@ -29,7 +29,7 @@ func init() {
|
||||
|
||||
// 生成日志
|
||||
func (this *ACMETaskLogDAO) CreateACMETaskLog(tx *dbs.Tx, taskId int64, isOk bool, errMsg string) error {
|
||||
op := NewACMETaskLogOperator()
|
||||
var op = NewACMETaskLogOperator()
|
||||
op.TaskId = taskId
|
||||
op.Error = errMsg
|
||||
op.IsOk = isOk
|
||||
|
||||
@@ -83,7 +83,7 @@ func (this *ACMEUserDAO) CreateACMEUser(tx *dbs.Tx, adminId int64, userId int64,
|
||||
}
|
||||
privateKeyText := base64.StdEncoding.EncodeToString(privateKeyData)
|
||||
|
||||
op := NewACMEUserOperator()
|
||||
var op = NewACMEUserOperator()
|
||||
op.AdminId = adminId
|
||||
op.UserId = userId
|
||||
op.ProviderCode = providerCode
|
||||
@@ -104,7 +104,7 @@ func (this *ACMEUserDAO) UpdateACMEUser(tx *dbs.Tx, acmeUserId int64, descriptio
|
||||
if acmeUserId <= 0 {
|
||||
return errors.New("invalid acmeUserId")
|
||||
}
|
||||
op := NewACMEUserOperator()
|
||||
var op = NewACMEUserOperator()
|
||||
op.Id = acmeUserId
|
||||
op.Description = description
|
||||
err := this.Save(tx, op)
|
||||
@@ -116,7 +116,7 @@ func (this *ACMEUserDAO) UpdateACMEUserRegistration(tx *dbs.Tx, acmeUserId int64
|
||||
if acmeUserId <= 0 {
|
||||
return errors.New("invalid acmeUserId")
|
||||
}
|
||||
op := NewACMEUserOperator()
|
||||
var op = NewACMEUserOperator()
|
||||
op.Id = acmeUserId
|
||||
op.Registration = registrationJSON
|
||||
err := this.Save(tx, op)
|
||||
|
||||
@@ -115,7 +115,7 @@ func (this *AdminDAO) UpdateAdminPassword(tx *dbs.Tx, adminId int64, password st
|
||||
if adminId <= 0 {
|
||||
return errors.New("invalid adminId")
|
||||
}
|
||||
op := NewAdminOperator()
|
||||
var op = NewAdminOperator()
|
||||
op.Id = adminId
|
||||
op.Password = stringutil.Md5(password)
|
||||
err := this.Save(tx, op)
|
||||
@@ -124,7 +124,7 @@ func (this *AdminDAO) UpdateAdminPassword(tx *dbs.Tx, adminId int64, password st
|
||||
|
||||
// CreateAdmin 创建管理员
|
||||
func (this *AdminDAO) CreateAdmin(tx *dbs.Tx, username string, canLogin bool, password string, fullname string, isSuper bool, modulesJSON []byte) (int64, error) {
|
||||
op := NewAdminOperator()
|
||||
var op = NewAdminOperator()
|
||||
op.IsOn = true
|
||||
op.State = AdminStateEnabled
|
||||
op.Username = username
|
||||
@@ -149,7 +149,7 @@ func (this *AdminDAO) UpdateAdminInfo(tx *dbs.Tx, adminId int64, fullname string
|
||||
if adminId <= 0 {
|
||||
return errors.New("invalid adminId")
|
||||
}
|
||||
op := NewAdminOperator()
|
||||
var op = NewAdminOperator()
|
||||
op.Id = adminId
|
||||
op.Fullname = fullname
|
||||
err := this.Save(tx, op)
|
||||
@@ -161,7 +161,7 @@ func (this *AdminDAO) UpdateAdmin(tx *dbs.Tx, adminId int64, username string, ca
|
||||
if adminId <= 0 {
|
||||
return errors.New("invalid adminId")
|
||||
}
|
||||
op := NewAdminOperator()
|
||||
var op = NewAdminOperator()
|
||||
op.Id = adminId
|
||||
op.Fullname = fullname
|
||||
op.Username = username
|
||||
@@ -198,7 +198,7 @@ func (this *AdminDAO) UpdateAdminLogin(tx *dbs.Tx, adminId int64, username strin
|
||||
if adminId <= 0 {
|
||||
return errors.New("invalid adminId")
|
||||
}
|
||||
op := NewAdminOperator()
|
||||
var op = NewAdminOperator()
|
||||
op.Id = adminId
|
||||
op.Username = username
|
||||
if len(password) > 0 {
|
||||
@@ -213,7 +213,7 @@ func (this *AdminDAO) UpdateAdminModules(tx *dbs.Tx, adminId int64, allowModules
|
||||
if adminId <= 0 {
|
||||
return errors.New("invalid adminId")
|
||||
}
|
||||
op := NewAdminOperator()
|
||||
var op = NewAdminOperator()
|
||||
op.Id = adminId
|
||||
op.Modules = allowModulesJSON
|
||||
err := this.Save(tx, op)
|
||||
|
||||
@@ -56,7 +56,7 @@ func (this *APIAccessTokenDAO) GenerateAccessToken(tx *dbs.Tx, adminId int64, us
|
||||
token = rands.String(128) // TODO 增强安全性,将来使用 base64_encode(encrypt(salt+random)) 算法来代替
|
||||
expiresAt = time.Now().Unix() + 7200
|
||||
|
||||
op := NewAPIAccessTokenOperator()
|
||||
var op = NewAPIAccessTokenOperator()
|
||||
|
||||
if accessToken != nil {
|
||||
op.Id = accessToken.(*APIAccessToken).Id
|
||||
|
||||
@@ -134,7 +134,7 @@ func (this *APINodeDAO) CreateAPINode(tx *dbs.Tx, name string, description strin
|
||||
return
|
||||
}
|
||||
|
||||
op := NewAPINodeOperator()
|
||||
var op = NewAPINodeOperator()
|
||||
op.IsOn = isOn
|
||||
op.UniqueId = uniqueId
|
||||
op.Secret = secret
|
||||
|
||||
@@ -112,7 +112,7 @@ func (this *ApiTokenDAO) FindEnabledTokenWithRole(tx *dbs.Tx, role string) (*Api
|
||||
|
||||
// CreateAPIToken 保存API Token
|
||||
func (this *ApiTokenDAO) CreateAPIToken(tx *dbs.Tx, nodeId string, secret string, role nodeconfigs.NodeRole) error {
|
||||
op := NewApiTokenOperator()
|
||||
var op = NewApiTokenOperator()
|
||||
op.NodeId = nodeId
|
||||
op.Secret = secret
|
||||
op.Role = role
|
||||
|
||||
@@ -42,7 +42,7 @@ func (this *AuthorityKeyDAO) UpdateKey(tx *dbs.Tx, value string, dayFrom string,
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
op := NewAuthorityKeyOperator()
|
||||
var op = NewAuthorityKeyOperator()
|
||||
if one != nil {
|
||||
op.Id = one.(*AuthorityKey).Id
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ func (this *AuthorityNodeDAO) CreateAuthorityNode(tx *dbs.Tx, name string, descr
|
||||
return
|
||||
}
|
||||
|
||||
op := NewAuthorityNodeOperator()
|
||||
var op = NewAuthorityNodeOperator()
|
||||
op.IsOn = isOn
|
||||
op.UniqueId = uniqueId
|
||||
op.Secret = secret
|
||||
@@ -141,7 +141,7 @@ func (this *AuthorityNodeDAO) UpdateAuthorityNode(tx *dbs.Tx, nodeId int64, name
|
||||
return errors.New("invalid nodeId")
|
||||
}
|
||||
|
||||
op := NewAuthorityNodeOperator()
|
||||
var op = NewAuthorityNodeOperator()
|
||||
op.Id = nodeId
|
||||
op.Name = name
|
||||
op.Description = description
|
||||
|
||||
@@ -125,7 +125,7 @@ func (this *ClientBrowserDAO) CreateBrowser(tx *dbs.Tx, browserName string) (int
|
||||
return browserId, nil
|
||||
}
|
||||
|
||||
op := NewClientBrowserOperator()
|
||||
var op = NewClientBrowserOperator()
|
||||
op.Name = browserName
|
||||
codes := []string{browserName}
|
||||
codesJSON, err := json.Marshal(codes)
|
||||
|
||||
@@ -125,7 +125,7 @@ func (this *ClientSystemDAO) CreateSystem(tx *dbs.Tx, systemName string) (int64,
|
||||
return systemId, nil
|
||||
}
|
||||
|
||||
op := NewClientSystemOperator()
|
||||
var op = NewClientSystemOperator()
|
||||
op.Name = systemName
|
||||
|
||||
codes := []string{systemName}
|
||||
|
||||
@@ -109,7 +109,7 @@ func (this *DBNodeDAO) ListEnabledNodes(tx *dbs.Tx, offset int64, size int64) (r
|
||||
|
||||
// CreateDBNode 创建节点
|
||||
func (this *DBNodeDAO) CreateDBNode(tx *dbs.Tx, isOn bool, name string, description string, host string, port int32, database string, username string, password string, charset string) (int64, error) {
|
||||
op := NewDBNodeOperator()
|
||||
var op = NewDBNodeOperator()
|
||||
op.State = NodeStateEnabled
|
||||
op.IsOn = isOn
|
||||
op.Name = name
|
||||
@@ -132,7 +132,7 @@ func (this *DBNodeDAO) UpdateNode(tx *dbs.Tx, nodeId int64, isOn bool, name stri
|
||||
if nodeId <= 0 {
|
||||
return errors.New("invalid nodeId")
|
||||
}
|
||||
op := NewDBNodeOperator()
|
||||
var op = NewDBNodeOperator()
|
||||
op.Id = nodeId
|
||||
op.IsOn = isOn
|
||||
op.Name = name
|
||||
|
||||
@@ -91,7 +91,7 @@ func (this *DNSDomainDAO) FindDNSDomainName(tx *dbs.Tx, id int64) (string, error
|
||||
|
||||
// CreateDomain 创建域名
|
||||
func (this *DNSDomainDAO) CreateDomain(tx *dbs.Tx, adminId int64, userId int64, providerId int64, name string) (int64, error) {
|
||||
op := NewDNSDomainOperator()
|
||||
var op = NewDNSDomainOperator()
|
||||
op.ProviderId = providerId
|
||||
op.AdminId = adminId
|
||||
op.UserId = userId
|
||||
@@ -111,7 +111,7 @@ func (this *DNSDomainDAO) UpdateDomain(tx *dbs.Tx, domainId int64, name string,
|
||||
if domainId <= 0 {
|
||||
return errors.New("invalid domainId")
|
||||
}
|
||||
op := NewDNSDomainOperator()
|
||||
var op = NewDNSDomainOperator()
|
||||
op.Id = domainId
|
||||
op.Name = name
|
||||
op.IsOn = isOn
|
||||
@@ -146,7 +146,7 @@ func (this *DNSDomainDAO) UpdateDomainData(tx *dbs.Tx, domainId int64, data stri
|
||||
if domainId <= 0 {
|
||||
return errors.New("invalid domainId")
|
||||
}
|
||||
op := NewDNSDomainOperator()
|
||||
var op = NewDNSDomainOperator()
|
||||
op.Id = domainId
|
||||
op.Data = data
|
||||
err := this.Save(tx, op)
|
||||
@@ -158,7 +158,7 @@ func (this *DNSDomainDAO) UpdateDomainRecords(tx *dbs.Tx, domainId int64, record
|
||||
if domainId <= 0 {
|
||||
return errors.New("invalid domainId")
|
||||
}
|
||||
op := NewDNSDomainOperator()
|
||||
var op = NewDNSDomainOperator()
|
||||
op.Id = domainId
|
||||
op.Records = recordsJSON
|
||||
op.DataUpdatedAt = time.Now().Unix()
|
||||
@@ -171,7 +171,7 @@ func (this *DNSDomainDAO) UpdateDomainRoutes(tx *dbs.Tx, domainId int64, routesJ
|
||||
if domainId <= 0 {
|
||||
return errors.New("invalid domainId")
|
||||
}
|
||||
op := NewDNSDomainOperator()
|
||||
var op = NewDNSDomainOperator()
|
||||
op.Id = domainId
|
||||
op.Routes = routesJSON
|
||||
op.DataUpdatedAt = time.Now().Unix()
|
||||
|
||||
@@ -68,7 +68,7 @@ func (this *DNSProviderDAO) FindEnabledDNSProvider(tx *dbs.Tx, id int64) (*DNSPr
|
||||
|
||||
// CreateDNSProvider 创建服务商
|
||||
func (this *DNSProviderDAO) CreateDNSProvider(tx *dbs.Tx, adminId int64, userId int64, providerType string, name string, apiParamsJSON []byte) (int64, error) {
|
||||
op := NewDNSProviderOperator()
|
||||
var op = NewDNSProviderOperator()
|
||||
op.AdminId = adminId
|
||||
op.UserId = userId
|
||||
op.Type = providerType
|
||||
@@ -90,7 +90,7 @@ func (this *DNSProviderDAO) UpdateDNSProvider(tx *dbs.Tx, dnsProviderId int64, n
|
||||
return errors.New("invalid dnsProviderId")
|
||||
}
|
||||
|
||||
op := NewDNSProviderOperator()
|
||||
var op = NewDNSProviderOperator()
|
||||
op.Id = dnsProviderId
|
||||
op.Name = name
|
||||
|
||||
|
||||
@@ -143,7 +143,7 @@ func (this *DNSTaskDAO) UpdateDNSTaskError(tx *dbs.Tx, taskId int64, err string)
|
||||
if taskId <= 0 {
|
||||
return errors.New("invalid taskId")
|
||||
}
|
||||
op := NewDNSTaskOperator()
|
||||
var op = NewDNSTaskOperator()
|
||||
op.Id = taskId
|
||||
op.IsDone = true
|
||||
op.Error = err
|
||||
@@ -156,7 +156,7 @@ func (this *DNSTaskDAO) UpdateDNSTaskDone(tx *dbs.Tx, taskId int64) error {
|
||||
if taskId <= 0 {
|
||||
return errors.New("invalid taskId")
|
||||
}
|
||||
op := NewDNSTaskOperator()
|
||||
var op = NewDNSTaskOperator()
|
||||
op.Id = taskId
|
||||
op.IsDone = true
|
||||
op.IsOk = true
|
||||
|
||||
@@ -29,9 +29,9 @@ func init() {
|
||||
})
|
||||
}
|
||||
|
||||
// 创建文件Chunk
|
||||
// CreateFileChunk 创建文件Chunk
|
||||
func (this *FileChunkDAO) CreateFileChunk(tx *dbs.Tx, fileId int64, data []byte) (int64, error) {
|
||||
op := NewFileChunkOperator()
|
||||
var op = NewFileChunkOperator()
|
||||
op.FileId = fileId
|
||||
op.Data = data
|
||||
err := this.Save(tx, op)
|
||||
@@ -41,7 +41,7 @@ func (this *FileChunkDAO) CreateFileChunk(tx *dbs.Tx, fileId int64, data []byte)
|
||||
return types.Int64(op.Id), nil
|
||||
}
|
||||
|
||||
// 列出所有的文件Chunk
|
||||
// FindAllFileChunks 列出所有的文件Chunk
|
||||
func (this *FileChunkDAO) FindAllFileChunks(tx *dbs.Tx, fileId int64) (result []*FileChunk, err error) {
|
||||
_, err = this.Query(tx).
|
||||
Attr("fileId", fileId).
|
||||
@@ -51,7 +51,7 @@ func (this *FileChunkDAO) FindAllFileChunks(tx *dbs.Tx, fileId int64) (result []
|
||||
return
|
||||
}
|
||||
|
||||
// 读取文件的所有片段ID
|
||||
// FindAllFileChunkIds 读取文件的所有片段ID
|
||||
func (this *FileChunkDAO) FindAllFileChunkIds(tx *dbs.Tx, fileId int64) ([]int64, error) {
|
||||
ones, err := this.Query(tx).
|
||||
Attr("fileId", fileId).
|
||||
@@ -68,7 +68,7 @@ func (this *FileChunkDAO) FindAllFileChunkIds(tx *dbs.Tx, fileId int64) ([]int64
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// 删除以前的文件
|
||||
// DeleteFileChunks 删除以前的文件
|
||||
func (this *FileChunkDAO) DeleteFileChunks(tx *dbs.Tx, fileId int64) error {
|
||||
if fileId <= 0 {
|
||||
return errors.New("invalid fileId")
|
||||
@@ -79,7 +79,7 @@ func (this *FileChunkDAO) DeleteFileChunks(tx *dbs.Tx, fileId int64) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// 根据ID查找片段
|
||||
// FindFileChunk 根据ID查找片段
|
||||
func (this *FileChunkDAO) FindFileChunk(tx *dbs.Tx, chunkId int64) (*FileChunk, error) {
|
||||
one, err := this.Query(tx).
|
||||
Pk(chunkId).
|
||||
|
||||
@@ -65,7 +65,7 @@ func (this *FileDAO) FindEnabledFile(tx *dbs.Tx, id int64) (*File, error) {
|
||||
}
|
||||
|
||||
// CreateFile 创建文件
|
||||
func (this *FileDAO) CreateFile(tx *dbs.Tx, adminId int64, userId int64, businessType, description string, filename string, size int64, isPublic bool) (int64, error) {
|
||||
func (this *FileDAO) CreateFile(tx *dbs.Tx, adminId int64, userId int64, businessType string, description string, filename string, size int64, mimeType string, isPublic bool) (int64, error) {
|
||||
var op = NewFileOperator()
|
||||
op.AdminId = adminId
|
||||
op.UserId = userId
|
||||
@@ -76,6 +76,7 @@ func (this *FileDAO) CreateFile(tx *dbs.Tx, adminId int64, userId int64, busines
|
||||
op.Filename = filename
|
||||
op.IsPublic = isPublic
|
||||
op.Code = utils.Sha1RandomString()
|
||||
op.MimeType = mimeType
|
||||
err := this.Save(tx, op)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
@@ -84,6 +85,21 @@ func (this *FileDAO) CreateFile(tx *dbs.Tx, adminId int64, userId int64, busines
|
||||
return types.Int64(op.Id), nil
|
||||
}
|
||||
|
||||
// CheckUserFile 检查用户ID
|
||||
func (this *FileDAO) CheckUserFile(tx *dbs.Tx, userId int64, fileId int64) error {
|
||||
b, err := this.Query(tx).
|
||||
Pk(fileId).
|
||||
Attr("userId", userId).
|
||||
Exist()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !b {
|
||||
return ErrNotFound
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// UpdateFileIsFinished 将文件置为已完成
|
||||
func (this *FileDAO) UpdateFileIsFinished(tx *dbs.Tx, fileId int64) error {
|
||||
_, err := this.Query(tx).
|
||||
|
||||
@@ -9,6 +9,7 @@ type File struct {
|
||||
Description string `field:"description"` // 文件描述
|
||||
Filename string `field:"filename"` // 文件名
|
||||
Size uint32 `field:"size"` // 文件尺寸
|
||||
MimeType string `field:"mimeType"` // Mime类型
|
||||
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
||||
Order uint32 `field:"order"` // 排序
|
||||
Type string `field:"type"` // 类型
|
||||
@@ -25,6 +26,7 @@ type FileOperator struct {
|
||||
Description interface{} // 文件描述
|
||||
Filename interface{} // 文件名
|
||||
Size interface{} // 文件尺寸
|
||||
MimeType interface{} // Mime类型
|
||||
CreatedAt interface{} // 创建时间
|
||||
Order interface{} // 排序
|
||||
Type interface{} // 类型
|
||||
|
||||
@@ -69,7 +69,7 @@ func (this *HTTPAuthPolicyDAO) FindEnabledHTTPAuthPolicy(tx *dbs.Tx, id int64) (
|
||||
|
||||
// CreateHTTPAuthPolicy 创建策略
|
||||
func (this *HTTPAuthPolicyDAO) CreateHTTPAuthPolicy(tx *dbs.Tx, name string, methodType string, paramsJSON []byte) (int64, error) {
|
||||
op := NewHTTPAuthPolicyOperator()
|
||||
var op = NewHTTPAuthPolicyOperator()
|
||||
op.Name = name
|
||||
op.Type = methodType
|
||||
op.Params = paramsJSON
|
||||
@@ -83,7 +83,7 @@ func (this *HTTPAuthPolicyDAO) UpdateHTTPAuthPolicy(tx *dbs.Tx, policyId int64,
|
||||
if policyId <= 0 {
|
||||
return errors.New("invalid policyId")
|
||||
}
|
||||
op := NewHTTPAuthPolicyOperator()
|
||||
var op = NewHTTPAuthPolicyOperator()
|
||||
op.Id = policyId
|
||||
op.Name = name
|
||||
op.Params = paramsJSON
|
||||
|
||||
@@ -113,7 +113,7 @@ func (this *HTTPBrotliPolicyDAO) ComposeBrotliConfig(tx *dbs.Tx, policyId int64)
|
||||
|
||||
// CreatePolicy 创建策略
|
||||
func (this *HTTPBrotliPolicyDAO) CreatePolicy(tx *dbs.Tx, level int, minLengthJSON []byte, maxLengthJSON []byte, condsJSON []byte) (int64, error) {
|
||||
op := NewHTTPBrotliPolicyOperator()
|
||||
var op = NewHTTPBrotliPolicyOperator()
|
||||
op.State = HTTPBrotliPolicyStateEnabled
|
||||
op.IsOn = true
|
||||
op.Level = level
|
||||
@@ -138,7 +138,7 @@ func (this *HTTPBrotliPolicyDAO) UpdatePolicy(tx *dbs.Tx, policyId int64, level
|
||||
if policyId <= 0 {
|
||||
return errors.New("invalid policyId")
|
||||
}
|
||||
op := NewHTTPBrotliPolicyOperator()
|
||||
var op = NewHTTPBrotliPolicyOperator()
|
||||
op.Id = policyId
|
||||
op.Level = level
|
||||
if len(minLengthJSON) > 0 {
|
||||
|
||||
@@ -97,7 +97,7 @@ func (this *HTTPCachePolicyDAO) FindAllEnabledCachePolicies(tx *dbs.Tx) (result
|
||||
|
||||
// CreateCachePolicy 创建缓存策略
|
||||
func (this *HTTPCachePolicyDAO) CreateCachePolicy(tx *dbs.Tx, isOn bool, name string, description string, capacityJSON []byte, maxKeys int64, maxSizeJSON []byte, storageType string, storageOptionsJSON []byte, syncCompressionCache bool) (int64, error) {
|
||||
op := NewHTTPCachePolicyOperator()
|
||||
var op = NewHTTPCachePolicyOperator()
|
||||
op.State = HTTPCachePolicyStateEnabled
|
||||
op.IsOn = isOn
|
||||
op.Name = name
|
||||
@@ -209,7 +209,7 @@ func (this *HTTPCachePolicyDAO) UpdateCachePolicy(tx *dbs.Tx, policyId int64, is
|
||||
return errors.New("invalid policyId")
|
||||
}
|
||||
|
||||
op := NewHTTPCachePolicyOperator()
|
||||
var op = NewHTTPCachePolicyOperator()
|
||||
op.Id = policyId
|
||||
op.IsOn = isOn
|
||||
op.Name = name
|
||||
|
||||
@@ -113,7 +113,7 @@ func (this *HTTPDeflatePolicyDAO) ComposeDeflateConfig(tx *dbs.Tx, policyId int6
|
||||
|
||||
// CreatePolicy 创建策略
|
||||
func (this *HTTPDeflatePolicyDAO) CreatePolicy(tx *dbs.Tx, level int, minLengthJSON []byte, maxLengthJSON []byte, condsJSON []byte) (int64, error) {
|
||||
op := NewHTTPDeflatePolicyOperator()
|
||||
var op = NewHTTPDeflatePolicyOperator()
|
||||
op.State = HTTPDeflatePolicyStateEnabled
|
||||
op.IsOn = true
|
||||
op.Level = level
|
||||
@@ -138,7 +138,7 @@ func (this *HTTPDeflatePolicyDAO) UpdatePolicy(tx *dbs.Tx, policyId int64, level
|
||||
if policyId <= 0 {
|
||||
return errors.New("invalid policyId")
|
||||
}
|
||||
op := NewHTTPDeflatePolicyOperator()
|
||||
var op = NewHTTPDeflatePolicyOperator()
|
||||
op.Id = policyId
|
||||
op.Level = level
|
||||
if len(minLengthJSON) > 0 {
|
||||
|
||||
@@ -121,7 +121,7 @@ func (this *HTTPFastcgiDAO) ComposeFastcgiConfig(tx *dbs.Tx, fastcgiId int64) (*
|
||||
|
||||
// CreateFastcgi 创建Fastcgi
|
||||
func (this *HTTPFastcgiDAO) CreateFastcgi(tx *dbs.Tx, adminId int64, userId int64, isOn bool, address string, paramsJSON []byte, readTimeoutJSON []byte, connTimeoutJSON []byte, poolSize int32, pathInfoPattern string) (int64, error) {
|
||||
op := NewHTTPFastcgiOperator()
|
||||
var op = NewHTTPFastcgiOperator()
|
||||
op.AdminId = adminId
|
||||
op.UserId = userId
|
||||
op.IsOn = isOn
|
||||
@@ -147,7 +147,7 @@ func (this *HTTPFastcgiDAO) UpdateFastcgi(tx *dbs.Tx, fastcgiId int64, isOn bool
|
||||
if fastcgiId <= 0 {
|
||||
return errors.New("invalid 'fastcgiId'")
|
||||
}
|
||||
op := NewHTTPFastcgiOperator()
|
||||
var op = NewHTTPFastcgiOperator()
|
||||
op.Id = fastcgiId
|
||||
op.IsOn = isOn
|
||||
op.Address = address
|
||||
|
||||
@@ -233,7 +233,7 @@ func (this *HTTPFirewallPolicyDAO) UpdateFirewallPolicyInboundAndOutbound(tx *db
|
||||
if policyId <= 0 {
|
||||
return errors.New("invalid policyId")
|
||||
}
|
||||
op := NewHTTPFirewallPolicyOperator()
|
||||
var op = NewHTTPFirewallPolicyOperator()
|
||||
op.Id = policyId
|
||||
if len(inboundJSON) > 0 {
|
||||
op.Inbound = inboundJSON
|
||||
@@ -262,7 +262,7 @@ func (this *HTTPFirewallPolicyDAO) UpdateFirewallPolicyInbound(tx *dbs.Tx, polic
|
||||
if policyId <= 0 {
|
||||
return errors.New("invalid policyId")
|
||||
}
|
||||
op := NewHTTPFirewallPolicyOperator()
|
||||
var op = NewHTTPFirewallPolicyOperator()
|
||||
op.Id = policyId
|
||||
if len(inboundJSON) > 0 {
|
||||
op.Inbound = inboundJSON
|
||||
|
||||
@@ -116,7 +116,7 @@ func (this *HTTPFirewallRuleDAO) ComposeFirewallRule(tx *dbs.Tx, ruleId int64) (
|
||||
|
||||
// CreateOrUpdateRuleFromConfig 从配置中配置规则
|
||||
func (this *HTTPFirewallRuleDAO) CreateOrUpdateRuleFromConfig(tx *dbs.Tx, ruleConfig *firewallconfigs.HTTPFirewallRule) (int64, error) {
|
||||
op := NewHTTPFirewallRuleOperator()
|
||||
var op = NewHTTPFirewallRuleOperator()
|
||||
op.Id = ruleConfig.Id
|
||||
op.State = HTTPFirewallRuleStateEnabled
|
||||
op.IsOn = ruleConfig.IsOn
|
||||
|
||||
@@ -120,7 +120,7 @@ func (this *HTTPFirewallRuleGroupDAO) ComposeFirewallRuleGroup(tx *dbs.Tx, group
|
||||
|
||||
// CreateGroupFromConfig 从配置中创建分组
|
||||
func (this *HTTPFirewallRuleGroupDAO) CreateGroupFromConfig(tx *dbs.Tx, groupConfig *firewallconfigs.HTTPFirewallRuleGroup) (int64, error) {
|
||||
op := NewHTTPFirewallRuleGroupOperator()
|
||||
var op = NewHTTPFirewallRuleGroupOperator()
|
||||
op.IsOn = groupConfig.IsOn
|
||||
op.Name = groupConfig.Name
|
||||
op.Description = groupConfig.Description
|
||||
@@ -166,7 +166,7 @@ func (this *HTTPFirewallRuleGroupDAO) UpdateGroupIsOn(tx *dbs.Tx, groupId int64,
|
||||
|
||||
// CreateGroup 创建分组
|
||||
func (this *HTTPFirewallRuleGroupDAO) CreateGroup(tx *dbs.Tx, isOn bool, name string, code string, description string) (int64, error) {
|
||||
op := NewHTTPFirewallRuleGroupOperator()
|
||||
var op = NewHTTPFirewallRuleGroupOperator()
|
||||
op.State = HTTPFirewallRuleStateEnabled
|
||||
op.IsOn = isOn
|
||||
op.Name = name
|
||||
@@ -184,7 +184,7 @@ func (this *HTTPFirewallRuleGroupDAO) UpdateGroup(tx *dbs.Tx, groupId int64, isO
|
||||
if groupId <= 0 {
|
||||
return errors.New("invalid groupId")
|
||||
}
|
||||
op := NewHTTPFirewallRuleGroupOperator()
|
||||
var op = NewHTTPFirewallRuleGroupOperator()
|
||||
op.Id = groupId
|
||||
op.IsOn = isOn
|
||||
op.Name = name
|
||||
@@ -202,7 +202,7 @@ func (this *HTTPFirewallRuleGroupDAO) UpdateGroupSets(tx *dbs.Tx, groupId int64,
|
||||
if groupId <= 0 {
|
||||
return errors.New("invalid groupId")
|
||||
}
|
||||
op := NewHTTPFirewallRuleGroupOperator()
|
||||
var op = NewHTTPFirewallRuleGroupOperator()
|
||||
op.Id = groupId
|
||||
op.Sets = setRefsJSON
|
||||
err := this.Save(tx, op)
|
||||
|
||||
@@ -133,7 +133,7 @@ func (this *HTTPFirewallRuleSetDAO) ComposeFirewallRuleSet(tx *dbs.Tx, setId int
|
||||
|
||||
// CreateOrUpdateSetFromConfig 从配置中创建规则集
|
||||
func (this *HTTPFirewallRuleSetDAO) CreateOrUpdateSetFromConfig(tx *dbs.Tx, setConfig *firewallconfigs.HTTPFirewallRuleSet) (int64, error) {
|
||||
op := NewHTTPFirewallRuleSetOperator()
|
||||
var op = NewHTTPFirewallRuleSetOperator()
|
||||
op.State = HTTPFirewallRuleSetStateEnabled
|
||||
op.Id = setConfig.Id
|
||||
op.IsOn = setConfig.IsOn
|
||||
|
||||
@@ -121,7 +121,7 @@ func (this *HTTPGzipDAO) ComposeGzipConfig(tx *dbs.Tx, gzipId int64) (*servercon
|
||||
|
||||
// CreateGzip 创建Gzip
|
||||
func (this *HTTPGzipDAO) CreateGzip(tx *dbs.Tx, level int, minLengthJSON []byte, maxLengthJSON []byte, condsJSON []byte) (int64, error) {
|
||||
op := NewHTTPGzipOperator()
|
||||
var op = NewHTTPGzipOperator()
|
||||
op.State = HTTPGzipStateEnabled
|
||||
op.IsOn = true
|
||||
op.Level = level
|
||||
@@ -146,7 +146,7 @@ func (this *HTTPGzipDAO) UpdateGzip(tx *dbs.Tx, gzipId int64, level int, minLeng
|
||||
if gzipId <= 0 {
|
||||
return errors.New("invalid gzipId")
|
||||
}
|
||||
op := NewHTTPGzipOperator()
|
||||
var op = NewHTTPGzipOperator()
|
||||
op.Id = gzipId
|
||||
op.Level = level
|
||||
if len(minLengthJSON) > 0 {
|
||||
|
||||
@@ -81,7 +81,7 @@ func (this *HTTPHeaderDAO) FindHTTPHeaderName(tx *dbs.Tx, id int64) (string, err
|
||||
|
||||
// CreateHeader 创建Header
|
||||
func (this *HTTPHeaderDAO) CreateHeader(tx *dbs.Tx, userId int64, name string, value string, status []int, disableRedirect bool, shouldAppend bool, shouldReplace bool, replaceValues []*shared.HTTPHeaderReplaceValue, methods []string, domains []string) (int64, error) {
|
||||
op := NewHTTPHeaderOperator()
|
||||
var op = NewHTTPHeaderOperator()
|
||||
op.UserId = userId
|
||||
op.State = HTTPHeaderStateEnabled
|
||||
op.IsOn = true
|
||||
@@ -156,7 +156,7 @@ func (this *HTTPHeaderDAO) UpdateHeader(tx *dbs.Tx, headerId int64, name string,
|
||||
return errors.New("invalid headerId")
|
||||
}
|
||||
|
||||
op := NewHTTPHeaderOperator()
|
||||
var op = NewHTTPHeaderOperator()
|
||||
op.Id = headerId
|
||||
op.Name = name
|
||||
op.Value = value
|
||||
|
||||
@@ -77,7 +77,7 @@ func (this *HTTPHeaderPolicyDAO) FindEnabledHTTPHeaderPolicy(tx *dbs.Tx, id int6
|
||||
|
||||
// CreateHeaderPolicy 创建策略
|
||||
func (this *HTTPHeaderPolicyDAO) CreateHeaderPolicy(tx *dbs.Tx) (int64, error) {
|
||||
op := NewHTTPHeaderPolicyOperator()
|
||||
var op = NewHTTPHeaderPolicyOperator()
|
||||
op.IsOn = true
|
||||
op.State = HTTPHeaderPolicyStateEnabled
|
||||
err := this.Save(tx, op)
|
||||
@@ -93,7 +93,7 @@ func (this *HTTPHeaderPolicyDAO) UpdateAddingHeaders(tx *dbs.Tx, policyId int64,
|
||||
return errors.New("invalid policyId")
|
||||
}
|
||||
|
||||
op := NewHTTPHeaderPolicyOperator()
|
||||
var op = NewHTTPHeaderPolicyOperator()
|
||||
op.Id = policyId
|
||||
op.AddHeaders = headersJSON
|
||||
err := this.Save(tx, op)
|
||||
@@ -109,7 +109,7 @@ func (this *HTTPHeaderPolicyDAO) UpdateSettingHeaders(tx *dbs.Tx, policyId int64
|
||||
return errors.New("invalid policyId")
|
||||
}
|
||||
|
||||
op := NewHTTPHeaderPolicyOperator()
|
||||
var op = NewHTTPHeaderPolicyOperator()
|
||||
op.Id = policyId
|
||||
op.SetHeaders = headersJSON
|
||||
err := this.Save(tx, op)
|
||||
@@ -125,7 +125,7 @@ func (this *HTTPHeaderPolicyDAO) UpdateReplacingHeaders(tx *dbs.Tx, policyId int
|
||||
return errors.New("invalid policyId")
|
||||
}
|
||||
|
||||
op := NewHTTPHeaderPolicyOperator()
|
||||
var op = NewHTTPHeaderPolicyOperator()
|
||||
op.Id = policyId
|
||||
op.ReplaceHeaders = headersJSON
|
||||
err := this.Save(tx, op)
|
||||
@@ -141,7 +141,7 @@ func (this *HTTPHeaderPolicyDAO) UpdateAddingTrailers(tx *dbs.Tx, policyId int64
|
||||
return errors.New("invalid policyId")
|
||||
}
|
||||
|
||||
op := NewHTTPHeaderPolicyOperator()
|
||||
var op = NewHTTPHeaderPolicyOperator()
|
||||
op.Id = policyId
|
||||
op.AddTrailers = headersJSON
|
||||
err := this.Save(tx, op)
|
||||
@@ -162,7 +162,7 @@ func (this *HTTPHeaderPolicyDAO) UpdateDeletingHeaders(tx *dbs.Tx, policyId int6
|
||||
return err
|
||||
}
|
||||
|
||||
op := NewHTTPHeaderPolicyOperator()
|
||||
var op = NewHTTPHeaderPolicyOperator()
|
||||
op.Id = policyId
|
||||
op.DeleteHeaders = string(namesJSON)
|
||||
err = this.Save(tx, op)
|
||||
|
||||
@@ -87,7 +87,7 @@ func (this *HTTPLocationDAO) FindHTTPLocationName(tx *dbs.Tx, id int64) (string,
|
||||
|
||||
// CreateLocation 创建路由规则
|
||||
func (this *HTTPLocationDAO) CreateLocation(tx *dbs.Tx, parentId int64, name string, pattern string, description string, isBreak bool, condsJSON []byte, domains []string) (int64, error) {
|
||||
op := NewHTTPLocationOperator()
|
||||
var op = NewHTTPLocationOperator()
|
||||
op.IsOn = true
|
||||
op.State = HTTPLocationStateEnabled
|
||||
op.ParentId = parentId
|
||||
@@ -121,7 +121,7 @@ func (this *HTTPLocationDAO) UpdateLocation(tx *dbs.Tx, locationId int64, name s
|
||||
if locationId <= 0 {
|
||||
return errors.New("invalid locationId")
|
||||
}
|
||||
op := NewHTTPLocationOperator()
|
||||
var op = NewHTTPLocationOperator()
|
||||
op.Id = locationId
|
||||
op.Name = name
|
||||
op.Pattern = pattern
|
||||
@@ -257,7 +257,7 @@ func (this *HTTPLocationDAO) UpdateLocationReverseProxy(tx *dbs.Tx, locationId i
|
||||
if locationId <= 0 {
|
||||
return errors.New("invalid locationId")
|
||||
}
|
||||
op := NewHTTPLocationOperator()
|
||||
var op = NewHTTPLocationOperator()
|
||||
op.Id = locationId
|
||||
op.ReverseProxy = JSONBytes(reverseProxyJSON)
|
||||
err := this.Save(tx, op)
|
||||
@@ -281,7 +281,7 @@ func (this *HTTPLocationDAO) UpdateLocationWeb(tx *dbs.Tx, locationId int64, web
|
||||
if locationId <= 0 {
|
||||
return errors.New("invalid locationId")
|
||||
}
|
||||
op := NewHTTPLocationOperator()
|
||||
var op = NewHTTPLocationOperator()
|
||||
op.Id = locationId
|
||||
op.WebId = webId
|
||||
err := this.Save(tx, op)
|
||||
|
||||
@@ -78,7 +78,7 @@ func (this *HTTPPageDAO) FindEnabledHTTPPage(tx *dbs.Tx, id int64) (*HTTPPage, e
|
||||
|
||||
// CreatePage 创建Page
|
||||
func (this *HTTPPageDAO) CreatePage(tx *dbs.Tx, userId int64, statusList []string, bodyType shared.BodyType, url string, body string, newStatus int) (pageId int64, err error) {
|
||||
op := NewHTTPPageOperator()
|
||||
var op = NewHTTPPageOperator()
|
||||
op.UserId = userId
|
||||
op.IsOn = true
|
||||
op.State = HTTPPageStateEnabled
|
||||
@@ -108,7 +108,7 @@ func (this *HTTPPageDAO) UpdatePage(tx *dbs.Tx, pageId int64, statusList []strin
|
||||
return errors.New("invalid pageId")
|
||||
}
|
||||
|
||||
op := NewHTTPPageOperator()
|
||||
var op = NewHTTPPageOperator()
|
||||
op.Id = pageId
|
||||
op.IsOn = true
|
||||
op.State = HTTPPageStateEnabled
|
||||
|
||||
@@ -125,7 +125,7 @@ func (this *HTTPRewriteRuleDAO) ComposeRewriteRule(tx *dbs.Tx, rewriteRuleId int
|
||||
|
||||
// CreateRewriteRule 创建规则
|
||||
func (this *HTTPRewriteRuleDAO) CreateRewriteRule(tx *dbs.Tx, pattern string, replace string, mode string, redirectStatus int, isBreak bool, proxyHost string, withQuery bool, isOn bool, condsJSON []byte) (int64, error) {
|
||||
op := NewHTTPRewriteRuleOperator()
|
||||
var op = NewHTTPRewriteRuleOperator()
|
||||
op.State = HTTPRewriteRuleStateEnabled
|
||||
op.IsOn = isOn
|
||||
|
||||
@@ -150,7 +150,7 @@ func (this *HTTPRewriteRuleDAO) UpdateRewriteRule(tx *dbs.Tx, rewriteRuleId int6
|
||||
if rewriteRuleId <= 0 {
|
||||
return errors.New("invalid rewriteRuleId")
|
||||
}
|
||||
op := NewHTTPRewriteRuleOperator()
|
||||
var op = NewHTTPRewriteRuleOperator()
|
||||
op.Id = rewriteRuleId
|
||||
op.IsOn = isOn
|
||||
op.Pattern = pattern
|
||||
|
||||
@@ -466,7 +466,7 @@ func (this *HTTPWebDAO) ComposeWebConfig(tx *dbs.Tx, webId int64, cacheMap *util
|
||||
|
||||
// CreateWeb 创建Web配置
|
||||
func (this *HTTPWebDAO) CreateWeb(tx *dbs.Tx, adminId int64, userId int64, rootJSON []byte) (int64, error) {
|
||||
op := NewHTTPWebOperator()
|
||||
var op = NewHTTPWebOperator()
|
||||
op.State = HTTPWebStateEnabled
|
||||
op.AdminId = adminId
|
||||
op.UserId = userId
|
||||
@@ -485,7 +485,7 @@ func (this *HTTPWebDAO) UpdateWeb(tx *dbs.Tx, webId int64, rootJSON []byte) erro
|
||||
if webId <= 0 {
|
||||
return errors.New("invalid webId")
|
||||
}
|
||||
op := NewHTTPWebOperator()
|
||||
var op = NewHTTPWebOperator()
|
||||
op.Id = webId
|
||||
op.Root = JSONBytes(rootJSON)
|
||||
err := this.Save(tx, op)
|
||||
@@ -501,7 +501,7 @@ func (this *HTTPWebDAO) UpdateWebCompression(tx *dbs.Tx, webId int64, compressio
|
||||
if webId <= 0 {
|
||||
return errors.New("invalid webId")
|
||||
}
|
||||
op := NewHTTPWebOperator()
|
||||
var op = NewHTTPWebOperator()
|
||||
op.Id = webId
|
||||
op.Compression = JSONBytes(compressionConfig)
|
||||
err := this.Save(tx, op)
|
||||
@@ -517,7 +517,7 @@ func (this *HTTPWebDAO) UpdateWebWebP(tx *dbs.Tx, webId int64, webpConfig []byte
|
||||
if webId <= 0 {
|
||||
return errors.New("invalid webId")
|
||||
}
|
||||
op := NewHTTPWebOperator()
|
||||
var op = NewHTTPWebOperator()
|
||||
op.Id = webId
|
||||
op.Webp = JSONBytes(webpConfig)
|
||||
err := this.Save(tx, op)
|
||||
@@ -548,7 +548,7 @@ func (this *HTTPWebDAO) UpdateWebCharset(tx *dbs.Tx, webId int64, charsetJSON []
|
||||
if webId <= 0 {
|
||||
return errors.New("invalid webId")
|
||||
}
|
||||
op := NewHTTPWebOperator()
|
||||
var op = NewHTTPWebOperator()
|
||||
op.Id = webId
|
||||
op.Charset = JSONBytes(charsetJSON)
|
||||
err := this.Save(tx, op)
|
||||
@@ -564,7 +564,7 @@ func (this *HTTPWebDAO) UpdateWebRequestHeaderPolicy(tx *dbs.Tx, webId int64, he
|
||||
if webId <= 0 {
|
||||
return errors.New("invalid webId")
|
||||
}
|
||||
op := NewHTTPWebOperator()
|
||||
var op = NewHTTPWebOperator()
|
||||
op.Id = webId
|
||||
op.RequestHeader = JSONBytes(headerPolicyJSON)
|
||||
err := this.Save(tx, op)
|
||||
@@ -580,7 +580,7 @@ func (this *HTTPWebDAO) UpdateWebResponseHeaderPolicy(tx *dbs.Tx, webId int64, h
|
||||
if webId <= 0 {
|
||||
return errors.New("invalid webId")
|
||||
}
|
||||
op := NewHTTPWebOperator()
|
||||
var op = NewHTTPWebOperator()
|
||||
op.Id = webId
|
||||
op.ResponseHeader = JSONBytes(headerPolicyJSON)
|
||||
err := this.Save(tx, op)
|
||||
@@ -596,7 +596,7 @@ func (this *HTTPWebDAO) UpdateWebPages(tx *dbs.Tx, webId int64, pagesJSON []byte
|
||||
if webId <= 0 {
|
||||
return errors.New("invalid webId")
|
||||
}
|
||||
op := NewHTTPWebOperator()
|
||||
var op = NewHTTPWebOperator()
|
||||
op.Id = webId
|
||||
op.Pages = JSONBytes(pagesJSON)
|
||||
err := this.Save(tx, op)
|
||||
@@ -612,7 +612,7 @@ func (this *HTTPWebDAO) UpdateWebShutdown(tx *dbs.Tx, webId int64, shutdownJSON
|
||||
if webId <= 0 {
|
||||
return errors.New("invalid webId")
|
||||
}
|
||||
op := NewHTTPWebOperator()
|
||||
var op = NewHTTPWebOperator()
|
||||
op.Id = webId
|
||||
op.Shutdown = JSONBytes(shutdownJSON)
|
||||
err := this.Save(tx, op)
|
||||
@@ -628,7 +628,7 @@ func (this *HTTPWebDAO) UpdateWebAccessLogConfig(tx *dbs.Tx, webId int64, access
|
||||
if webId <= 0 {
|
||||
return errors.New("invalid webId")
|
||||
}
|
||||
op := NewHTTPWebOperator()
|
||||
var op = NewHTTPWebOperator()
|
||||
op.Id = webId
|
||||
op.AccessLog = JSONBytes(accessLogJSON)
|
||||
err := this.Save(tx, op)
|
||||
@@ -644,7 +644,7 @@ func (this *HTTPWebDAO) UpdateWebStat(tx *dbs.Tx, webId int64, statJSON []byte)
|
||||
if webId <= 0 {
|
||||
return errors.New("invalid webId")
|
||||
}
|
||||
op := NewHTTPWebOperator()
|
||||
var op = NewHTTPWebOperator()
|
||||
op.Id = webId
|
||||
op.Stat = JSONBytes(statJSON)
|
||||
err := this.Save(tx, op)
|
||||
@@ -660,7 +660,7 @@ func (this *HTTPWebDAO) UpdateWebCache(tx *dbs.Tx, webId int64, cacheJSON []byte
|
||||
if webId <= 0 {
|
||||
return errors.New("invalid webId")
|
||||
}
|
||||
op := NewHTTPWebOperator()
|
||||
var op = NewHTTPWebOperator()
|
||||
op.Id = webId
|
||||
op.Cache = JSONBytes(cacheJSON)
|
||||
err := this.Save(tx, op)
|
||||
@@ -676,7 +676,7 @@ func (this *HTTPWebDAO) UpdateWebFirewall(tx *dbs.Tx, webId int64, firewallJSON
|
||||
if webId <= 0 {
|
||||
return errors.New("invalid webId")
|
||||
}
|
||||
op := NewHTTPWebOperator()
|
||||
var op = NewHTTPWebOperator()
|
||||
op.Id = webId
|
||||
op.Firewall = JSONBytes(firewallJSON)
|
||||
err := this.Save(tx, op)
|
||||
@@ -692,7 +692,7 @@ func (this *HTTPWebDAO) UpdateWebLocations(tx *dbs.Tx, webId int64, locationsJSO
|
||||
if webId <= 0 {
|
||||
return errors.New("invalid webId")
|
||||
}
|
||||
op := NewHTTPWebOperator()
|
||||
var op = NewHTTPWebOperator()
|
||||
op.Id = webId
|
||||
op.Locations = JSONBytes(locationsJSON)
|
||||
err := this.Save(tx, op)
|
||||
@@ -708,7 +708,7 @@ func (this *HTTPWebDAO) UpdateWebRedirectToHTTPS(tx *dbs.Tx, webId int64, redire
|
||||
if webId <= 0 {
|
||||
return errors.New("invalid webId")
|
||||
}
|
||||
op := NewHTTPWebOperator()
|
||||
var op = NewHTTPWebOperator()
|
||||
op.Id = webId
|
||||
op.RedirectToHttps = JSONBytes(redirectToHTTPSJSON)
|
||||
err := this.Save(tx, op)
|
||||
@@ -724,7 +724,7 @@ func (this *HTTPWebDAO) UpdateWebsocket(tx *dbs.Tx, webId int64, websocketJSON [
|
||||
if webId <= 0 {
|
||||
return errors.New("invalid webId")
|
||||
}
|
||||
op := NewHTTPWebOperator()
|
||||
var op = NewHTTPWebOperator()
|
||||
op.Id = webId
|
||||
op.Websocket = JSONBytes(websocketJSON)
|
||||
err := this.Save(tx, op)
|
||||
@@ -740,7 +740,7 @@ func (this *HTTPWebDAO) UpdateWebFastcgi(tx *dbs.Tx, webId int64, fastcgiJSON []
|
||||
if webId <= 0 {
|
||||
return errors.New("invalid webId")
|
||||
}
|
||||
op := NewHTTPWebOperator()
|
||||
var op = NewHTTPWebOperator()
|
||||
op.Id = webId
|
||||
op.Fastcgi = JSONBytes(fastcgiJSON)
|
||||
err := this.Save(tx, op)
|
||||
@@ -756,7 +756,7 @@ func (this *HTTPWebDAO) UpdateWebRewriteRules(tx *dbs.Tx, webId int64, rewriteRu
|
||||
if webId <= 0 {
|
||||
return errors.New("invalid webId")
|
||||
}
|
||||
op := NewHTTPWebOperator()
|
||||
var op = NewHTTPWebOperator()
|
||||
op.Id = webId
|
||||
op.RewriteRules = JSONBytes(rewriteRulesJSON)
|
||||
err := this.Save(tx, op)
|
||||
@@ -772,7 +772,7 @@ func (this *HTTPWebDAO) UpdateWebAuth(tx *dbs.Tx, webId int64, authJSON []byte)
|
||||
if webId <= 0 {
|
||||
return errors.New("invalid webId")
|
||||
}
|
||||
op := NewHTTPWebOperator()
|
||||
var op = NewHTTPWebOperator()
|
||||
op.Id = webId
|
||||
op.Auth = JSONBytes(authJSON)
|
||||
err := this.Save(tx, op)
|
||||
|
||||
@@ -110,7 +110,7 @@ func (this *HTTPWebsocketDAO) ComposeWebsocketConfig(tx *dbs.Tx, websocketId int
|
||||
|
||||
// CreateWebsocket 创建Websocket配置
|
||||
func (this *HTTPWebsocketDAO) CreateWebsocket(tx *dbs.Tx, handshakeTimeoutJSON []byte, allowAllOrigins bool, allowedOrigins []string, requestSameOrigin bool, requestOrigin string) (websocketId int64, err error) {
|
||||
op := NewHTTPWebsocketOperator()
|
||||
var op = NewHTTPWebsocketOperator()
|
||||
op.IsOn = true
|
||||
op.State = HTTPWebsocketStateEnabled
|
||||
if len(handshakeTimeoutJSON) > 0 {
|
||||
@@ -135,7 +135,7 @@ func (this *HTTPWebsocketDAO) UpdateWebsocket(tx *dbs.Tx, websocketId int64, han
|
||||
if websocketId <= 0 {
|
||||
return errors.New("invalid websocketId")
|
||||
}
|
||||
op := NewHTTPWebsocketOperator()
|
||||
var op = NewHTTPWebsocketOperator()
|
||||
op.Id = websocketId
|
||||
if len(handshakeTimeoutJSON) > 0 {
|
||||
op.HandshakeTimeout = handshakeTimeoutJSON
|
||||
|
||||
@@ -330,7 +330,7 @@ func (this *IPItemDAO) UpdateIPItem(tx *dbs.Tx, itemId int64, ipFrom string, ipT
|
||||
return err
|
||||
}
|
||||
|
||||
op := NewIPItemOperator()
|
||||
var op = NewIPItemOperator()
|
||||
op.Id = itemId
|
||||
op.IpFrom = ipFrom
|
||||
op.IpTo = ipTo
|
||||
|
||||
@@ -92,7 +92,7 @@ func (this *IPLibraryDAO) FindLatestIPLibraryWithType(tx *dbs.Tx, libraryType st
|
||||
|
||||
// 创建新的IP库
|
||||
func (this *IPLibraryDAO) CreateIPLibrary(tx *dbs.Tx, libraryType string, fileId int64) (int64, error) {
|
||||
op := NewIPLibraryOperator()
|
||||
var op = NewIPLibraryOperator()
|
||||
op.Type = libraryType
|
||||
op.FileId = fileId
|
||||
op.State = IPLibraryStateEnabled
|
||||
|
||||
@@ -165,7 +165,7 @@ func (this *IPListDAO) UpdateIPList(tx *dbs.Tx, listId int64, name string, code
|
||||
if listId <= 0 {
|
||||
return errors.New("invalid listId")
|
||||
}
|
||||
op := NewIPListOperator()
|
||||
var op = NewIPListOperator()
|
||||
op.Id = listId
|
||||
op.Name = name
|
||||
op.Code = code
|
||||
|
||||
@@ -36,7 +36,7 @@ func init() {
|
||||
|
||||
// CreateLog 创建管理员日志
|
||||
func (this *LogDAO) CreateLog(tx *dbs.Tx, adminType string, adminId int64, level string, description string, action string, ip string) error {
|
||||
op := NewLogOperator()
|
||||
var op = NewLogOperator()
|
||||
op.Level = level
|
||||
op.Description = description
|
||||
op.Action = action
|
||||
|
||||
@@ -40,7 +40,7 @@ func init() {
|
||||
})
|
||||
}
|
||||
|
||||
// 启用条目
|
||||
// EnableLogin 启用条目
|
||||
func (this *LoginDAO) EnableLogin(tx *dbs.Tx, id int64) error {
|
||||
_, err := this.Query(tx).
|
||||
Pk(id).
|
||||
@@ -49,7 +49,7 @@ func (this *LoginDAO) EnableLogin(tx *dbs.Tx, id int64) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// 禁用条目
|
||||
// DisableLogin 禁用条目
|
||||
func (this *LoginDAO) DisableLogin(tx *dbs.Tx, id int64) error {
|
||||
_, err := this.Query(tx).
|
||||
Pk(id).
|
||||
@@ -58,7 +58,7 @@ func (this *LoginDAO) DisableLogin(tx *dbs.Tx, id int64) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// 查找启用中的条目
|
||||
// FindEnabledLogin 查找启用中的条目
|
||||
func (this *LoginDAO) FindEnabledLogin(tx *dbs.Tx, id int64) (*Login, error) {
|
||||
result, err := this.Query(tx).
|
||||
Pk(id).
|
||||
@@ -70,7 +70,7 @@ func (this *LoginDAO) FindEnabledLogin(tx *dbs.Tx, id int64) (*Login, error) {
|
||||
return result.(*Login), err
|
||||
}
|
||||
|
||||
// 创建认证
|
||||
// CreateLogin 创建认证
|
||||
func (this *LoginDAO) CreateLogin(tx *dbs.Tx, Id int64, loginType LoginType, params maps.Map) (int64, error) {
|
||||
if Id <= 0 {
|
||||
return 0, errors.New("invalid Id")
|
||||
@@ -78,7 +78,7 @@ func (this *LoginDAO) CreateLogin(tx *dbs.Tx, Id int64, loginType LoginType, par
|
||||
if params == nil {
|
||||
params = maps.Map{}
|
||||
}
|
||||
op := NewLoginOperator()
|
||||
var op = NewLoginOperator()
|
||||
op.Id = Id
|
||||
op.Type = loginType
|
||||
op.Params = params.AsJSON()
|
||||
@@ -87,23 +87,34 @@ func (this *LoginDAO) CreateLogin(tx *dbs.Tx, Id int64, loginType LoginType, par
|
||||
return this.SaveInt64(tx, op)
|
||||
}
|
||||
|
||||
// 修改认证
|
||||
func (this *LoginDAO) UpdateLogin(tx *dbs.Tx, adminId int64, loginType LoginType, params maps.Map, isOn bool) error {
|
||||
// UpdateLogin 修改认证
|
||||
func (this *LoginDAO) UpdateLogin(tx *dbs.Tx, adminId int64, userId int64, loginType LoginType, params maps.Map, isOn bool) error {
|
||||
if adminId <= 0 && userId <= 0 {
|
||||
return errors.New("invalid adminId and userId")
|
||||
}
|
||||
|
||||
// 是否已经存在
|
||||
loginId, err := this.Query(tx).
|
||||
Attr("adminId", adminId).
|
||||
var query = this.Query(tx).
|
||||
Attr("type", loginType).
|
||||
State(LoginStateEnabled).
|
||||
ResultPk().
|
||||
FindInt64Col(0)
|
||||
ResultPk()
|
||||
|
||||
if adminId > 0 {
|
||||
query.Attr("adminId", adminId)
|
||||
} else if userId > 0 {
|
||||
query.Attr("userId", userId)
|
||||
}
|
||||
|
||||
loginId, err := query.FindInt64Col(0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
op := NewLoginOperator()
|
||||
var op = NewLoginOperator()
|
||||
if loginId > 0 {
|
||||
op.Id = loginId
|
||||
} else {
|
||||
op.AdminId = adminId
|
||||
op.UserId = userId
|
||||
op.Type = loginType
|
||||
op.State = LoginStateEnabled
|
||||
}
|
||||
@@ -117,35 +128,54 @@ func (this *LoginDAO) UpdateLogin(tx *dbs.Tx, adminId int64, loginType LoginType
|
||||
return this.Save(tx, op)
|
||||
}
|
||||
|
||||
// 禁用相关认证
|
||||
func (this *LoginDAO) DisableLoginWithAdminId(tx *dbs.Tx, adminId int64, loginType LoginType) error {
|
||||
_, err := this.Query(tx).
|
||||
Attr("adminId", adminId).
|
||||
// DisableLoginWithType 禁用相关认证
|
||||
func (this *LoginDAO) DisableLoginWithType(tx *dbs.Tx, adminId int64, userId int64, loginType LoginType) error {
|
||||
var query = this.Query(tx).
|
||||
Attr("type", loginType).
|
||||
Set("isOn", false).
|
||||
Set("isOn", false)
|
||||
|
||||
if adminId > 0 {
|
||||
query.Attr("adminId", adminId)
|
||||
} else if userId > 0 {
|
||||
query.Attr("userId", userId)
|
||||
}
|
||||
|
||||
_, err := query.
|
||||
Update()
|
||||
return err
|
||||
}
|
||||
|
||||
// 查找管理员相关的认证
|
||||
func (this *LoginDAO) FindEnabledLoginWithAdminId(tx *dbs.Tx, adminId int64, loginType LoginType) (*Login, error) {
|
||||
one, err := this.Query(tx).
|
||||
Attr("adminId", adminId).
|
||||
// FindEnabledLoginWithType 查找管理员和用户相关的认证
|
||||
func (this *LoginDAO) FindEnabledLoginWithType(tx *dbs.Tx, adminId int64, userId int64, loginType LoginType) (*Login, error) {
|
||||
var query = this.Query(tx).
|
||||
Attr("type", loginType).
|
||||
State(LoginStateEnabled).
|
||||
Find()
|
||||
State(LoginStateEnabled)
|
||||
|
||||
if adminId > 0 {
|
||||
query.Attr("adminId", adminId)
|
||||
} else if userId > 0 {
|
||||
query.Attr("userId", userId)
|
||||
}
|
||||
|
||||
one, err := query.Find()
|
||||
if err != nil || one == nil {
|
||||
return nil, err
|
||||
}
|
||||
return one.(*Login), nil
|
||||
}
|
||||
|
||||
// 检查某个认证是否启用
|
||||
func (this *LoginDAO) CheckLoginIsOn(tx *dbs.Tx, adminId int64, loginType LoginType) (bool, error) {
|
||||
return this.Query(tx).
|
||||
Attr("adminId", adminId).
|
||||
// CheckLoginIsOn 检查某个认证是否启用
|
||||
func (this *LoginDAO) CheckLoginIsOn(tx *dbs.Tx, adminId int64, userId int64, loginType LoginType) (bool, error) {
|
||||
var query = this.Query(tx).
|
||||
Attr("type", loginType).
|
||||
State(LoginStateEnabled).
|
||||
Attr("isOn", true).
|
||||
Exist()
|
||||
Attr("isOn", true)
|
||||
|
||||
if adminId > 0 {
|
||||
query.Attr("adminId", adminId)
|
||||
} else if userId > 0 {
|
||||
query.Attr("userId", userId)
|
||||
}
|
||||
|
||||
return query.Exist()
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ func (this *MessageDAO) CreateNodeMessage(tx *dbs.Tx, role string, clusterId int
|
||||
|
||||
// CreateMessage 创建普通消息
|
||||
func (this *MessageDAO) CreateMessage(tx *dbs.Tx, adminId int64, userId int64, messageType MessageType, level string, subject string, body string, paramsJSON []byte) error {
|
||||
op := NewMessageOperator()
|
||||
var op = NewMessageOperator()
|
||||
op.AdminId = adminId
|
||||
op.UserId = userId
|
||||
op.Type = messageType
|
||||
@@ -230,7 +230,7 @@ func (this *MessageDAO) UpdateMessageRead(tx *dbs.Tx, messageId int64, b bool) e
|
||||
if messageId <= 0 {
|
||||
return errors.New("invalid messageId")
|
||||
}
|
||||
op := NewMessageOperator()
|
||||
var op = NewMessageOperator()
|
||||
op.Id = messageId
|
||||
op.IsRead = b
|
||||
err := this.Save(tx, op)
|
||||
@@ -286,7 +286,7 @@ func (this *MessageDAO) createMessage(tx *dbs.Tx, role string, clusterId int64,
|
||||
// TODO 检查同样的消息最近是否发送过
|
||||
|
||||
// 创建新消息
|
||||
op := NewMessageOperator()
|
||||
var op = NewMessageOperator()
|
||||
op.AdminId = 0 // TODO
|
||||
op.UserId = 0 // TODO
|
||||
op.Role = role
|
||||
|
||||
@@ -104,7 +104,7 @@ func (this *MessageMediaDAO) UpdateMessageMedias(tx *dbs.Tx, mediaMaps []maps.Ma
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
op := NewMessageMediaOperator()
|
||||
var op = NewMessageMediaOperator()
|
||||
if mediaId > 0 {
|
||||
op.Id = mediaId
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ func (this *MessageMediaInstanceDAO) FindEnabledMessageMediaInstance(tx *dbs.Tx,
|
||||
|
||||
// CreateMediaInstance 创建媒介实例
|
||||
func (this *MessageMediaInstanceDAO) CreateMediaInstance(tx *dbs.Tx, name string, mediaType string, params maps.Map, description string, rateJSON []byte, hashLifeSeconds int32) (int64, error) {
|
||||
op := NewMessageMediaInstanceOperator()
|
||||
var op = NewMessageMediaInstanceOperator()
|
||||
op.Name = name
|
||||
op.MediaType = mediaType
|
||||
|
||||
@@ -116,7 +116,7 @@ func (this *MessageMediaInstanceDAO) UpdateMediaInstance(tx *dbs.Tx, instanceId
|
||||
return errors.New("invalid instanceId")
|
||||
}
|
||||
|
||||
op := NewMessageMediaInstanceOperator()
|
||||
var op = NewMessageMediaInstanceOperator()
|
||||
op.Id = instanceId
|
||||
op.Name = name
|
||||
op.MediaType = mediaType
|
||||
|
||||
@@ -76,7 +76,7 @@ func (this *MessageReceiverDAO) DisableReceivers(tx *dbs.Tx, clusterId int64, no
|
||||
|
||||
// CreateReceiver 创建接收人
|
||||
func (this *MessageReceiverDAO) CreateReceiver(tx *dbs.Tx, role string, clusterId int64, nodeId int64, serverId int64, messageType MessageType, params maps.Map, recipientId int64, recipientGroupId int64) (int64, error) {
|
||||
op := NewMessageReceiverOperator()
|
||||
var op = NewMessageReceiverOperator()
|
||||
op.Role = role
|
||||
op.ClusterId = clusterId
|
||||
op.NodeId = nodeId
|
||||
|
||||
@@ -86,7 +86,7 @@ func (this *MessageRecipientDAO) FindEnabledMessageRecipient(tx *dbs.Tx, recipie
|
||||
|
||||
// CreateRecipient 创建接收人
|
||||
func (this *MessageRecipientDAO) CreateRecipient(tx *dbs.Tx, adminId int64, instanceId int64, user string, groupIds []int64, description string, timeFrom string, timeTo string) (int64, error) {
|
||||
op := NewMessageRecipientOperator()
|
||||
var op = NewMessageRecipientOperator()
|
||||
op.AdminId = adminId
|
||||
op.InstanceId = instanceId
|
||||
op.User = user
|
||||
@@ -122,7 +122,7 @@ func (this *MessageRecipientDAO) UpdateRecipient(tx *dbs.Tx, recipientId int64,
|
||||
return errors.New("invalid recipientId")
|
||||
}
|
||||
|
||||
op := NewMessageRecipientOperator()
|
||||
var op = NewMessageRecipientOperator()
|
||||
op.Id = recipientId
|
||||
op.AdminId = adminId
|
||||
op.InstanceId = instanceId
|
||||
|
||||
@@ -73,7 +73,7 @@ func (this *MessageRecipientGroupDAO) FindMessageRecipientGroupName(tx *dbs.Tx,
|
||||
|
||||
// 创建分组
|
||||
func (this *MessageRecipientGroupDAO) CreateGroup(tx *dbs.Tx, name string) (int64, error) {
|
||||
op := NewMessageRecipientGroupOperator()
|
||||
var op = NewMessageRecipientGroupOperator()
|
||||
op.Name = name
|
||||
op.IsOn = true
|
||||
op.State = MessageRecipientStateEnabled
|
||||
@@ -85,7 +85,7 @@ func (this *MessageRecipientGroupDAO) UpdateGroup(tx *dbs.Tx, groupId int64, nam
|
||||
if groupId <= 0 {
|
||||
return errors.New("invalid groupId")
|
||||
}
|
||||
op := NewMessageRecipientGroupOperator()
|
||||
var op = NewMessageRecipientGroupOperator()
|
||||
op.Id = groupId
|
||||
op.Name = name
|
||||
op.IsOn = isOn
|
||||
|
||||
@@ -131,7 +131,7 @@ func (this *MessageTaskDAO) CreateMessageTask(tx *dbs.Tx, recipientId int64, ins
|
||||
}
|
||||
}
|
||||
|
||||
op := NewMessageTaskOperator()
|
||||
var op = NewMessageTaskOperator()
|
||||
op.RecipientId = recipientId
|
||||
op.InstanceId = instanceId
|
||||
op.Hash = hash
|
||||
@@ -190,7 +190,7 @@ func (this *MessageTaskDAO) UpdateMessageTaskStatus(tx *dbs.Tx, taskId int64, st
|
||||
if taskId <= 0 {
|
||||
return errors.New("invalid taskId")
|
||||
}
|
||||
op := NewMessageTaskOperator()
|
||||
var op = NewMessageTaskOperator()
|
||||
op.Id = taskId
|
||||
op.Status = status
|
||||
op.SentAt = time.Now().Unix()
|
||||
|
||||
@@ -49,7 +49,7 @@ func init() {
|
||||
|
||||
// CreateLog 创建日志
|
||||
func (this *MessageTaskLogDAO) CreateLog(tx *dbs.Tx, taskId int64, isOk bool, errMsg string, response string) error {
|
||||
op := NewMessageTaskLogOperator()
|
||||
var op = NewMessageTaskLogOperator()
|
||||
op.TaskId = taskId
|
||||
op.IsOk = isOk
|
||||
op.Error = errMsg
|
||||
|
||||
@@ -75,7 +75,7 @@ func (this *MetricChartDAO) FindMetricChartName(tx *dbs.Tx, chartId int64) (stri
|
||||
|
||||
// CreateChart 创建图表
|
||||
func (this *MetricChartDAO) CreateChart(tx *dbs.Tx, itemId int64, name string, chartType string, widthDiv int32, maxItems int32, params maps.Map, ignoreEmptyKeys bool, ignoredKeys []string) (int64, error) {
|
||||
op := NewMetricChartOperator()
|
||||
var op = NewMetricChartOperator()
|
||||
op.ItemId = itemId
|
||||
op.Name = name
|
||||
op.Type = chartType
|
||||
@@ -112,7 +112,7 @@ func (this *MetricChartDAO) UpdateChart(tx *dbs.Tx, chartId int64, name string,
|
||||
if chartId <= 0 {
|
||||
return errors.New("invalid chartId")
|
||||
}
|
||||
op := NewMetricChartOperator()
|
||||
var op = NewMetricChartOperator()
|
||||
op.Id = chartId
|
||||
op.Name = name
|
||||
op.Type = chartType
|
||||
|
||||
@@ -123,7 +123,7 @@ func (this *MonitorNodeDAO) CreateMonitorNode(tx *dbs.Tx, name string, descripti
|
||||
return
|
||||
}
|
||||
|
||||
op := NewMonitorNodeOperator()
|
||||
var op = NewMonitorNodeOperator()
|
||||
op.IsOn = isOn
|
||||
op.UniqueId = uniqueId
|
||||
op.Secret = secret
|
||||
@@ -144,7 +144,7 @@ func (this *MonitorNodeDAO) UpdateMonitorNode(tx *dbs.Tx, nodeId int64, name str
|
||||
return errors.New("invalid nodeId")
|
||||
}
|
||||
|
||||
op := NewMonitorNodeOperator()
|
||||
var op = NewMonitorNodeOperator()
|
||||
op.Id = nodeId
|
||||
op.Name = name
|
||||
op.Description = description
|
||||
|
||||
@@ -93,7 +93,7 @@ func (this *NSDomainDAO) CreateDomain(tx *dbs.Tx, clusterId int64, userId int64,
|
||||
return 0, err
|
||||
}
|
||||
|
||||
op := NewNSDomainOperator()
|
||||
var op = NewNSDomainOperator()
|
||||
op.ClusterId = clusterId
|
||||
op.UserId = userId
|
||||
op.Name = name
|
||||
@@ -131,7 +131,7 @@ func (this *NSDomainDAO) UpdateDomain(tx *dbs.Tx, domainId int64, clusterId int6
|
||||
return err
|
||||
}
|
||||
|
||||
op := NewNSDomainOperator()
|
||||
var op = NewNSDomainOperator()
|
||||
op.Id = domainId
|
||||
op.ClusterId = clusterId
|
||||
op.UserId = userId
|
||||
|
||||
@@ -79,7 +79,7 @@ func (this *NSKeyDAO) FindNSKeyName(tx *dbs.Tx, id int64) (string, error) {
|
||||
|
||||
// CreateKey 创建Key
|
||||
func (this *NSKeyDAO) CreateKey(tx *dbs.Tx, domainId int64, zoneId int64, name string, algo dnsconfigs.KeyAlgorithmType, secret string, secretType string) (int64, error) {
|
||||
op := NewNSKeyOperator()
|
||||
var op = NewNSKeyOperator()
|
||||
op.DomainId = domainId
|
||||
op.ZoneId = zoneId
|
||||
op.Name = name
|
||||
@@ -105,7 +105,7 @@ func (this *NSKeyDAO) UpdateKey(tx *dbs.Tx, keyId int64, name string, algo dnsco
|
||||
if keyId <= 0 {
|
||||
return errors.New("invalid keyId")
|
||||
}
|
||||
op := NewNSKeyOperator()
|
||||
var op = NewNSKeyOperator()
|
||||
op.Id = keyId
|
||||
op.Name = name
|
||||
op.Algo = algo
|
||||
|
||||
@@ -95,7 +95,7 @@ func (this *NSRecordDAO) CreateRecord(tx *dbs.Tx, domainId int64, description st
|
||||
return 0, err
|
||||
}
|
||||
|
||||
op := NewNSRecordOperator()
|
||||
var op = NewNSRecordOperator()
|
||||
op.DomainId = domainId
|
||||
op.Description = description
|
||||
op.Name = name
|
||||
@@ -139,7 +139,7 @@ func (this *NSRecordDAO) UpdateRecord(tx *dbs.Tx, recordId int64, description st
|
||||
return err
|
||||
}
|
||||
|
||||
op := NewNSRecordOperator()
|
||||
var op = NewNSRecordOperator()
|
||||
op.Id = recordId
|
||||
op.Description = description
|
||||
op.Name = name
|
||||
|
||||
@@ -129,7 +129,7 @@ func (this *NSRouteDAO) CreateRoute(tx *dbs.Tx, clusterId int64, domainId int64,
|
||||
return 0, err
|
||||
}
|
||||
|
||||
op := NewNSRouteOperator()
|
||||
var op = NewNSRouteOperator()
|
||||
op.ClusterId = clusterId
|
||||
op.DomainId = domainId
|
||||
op.UserId = userId
|
||||
@@ -166,7 +166,7 @@ func (this *NSRouteDAO) UpdateRoute(tx *dbs.Tx, routeId int64, name string, rang
|
||||
return err
|
||||
}
|
||||
|
||||
op := NewNSRouteOperator()
|
||||
var op = NewNSRouteOperator()
|
||||
op.Id = routeId
|
||||
op.Name = name
|
||||
if len(rangesJSON) > 0 {
|
||||
|
||||
@@ -133,7 +133,7 @@ func (this *NodeClusterDAO) CreateCluster(tx *dbs.Tx, adminId int64, name string
|
||||
return 0, err
|
||||
}
|
||||
|
||||
op := NewNodeClusterOperator()
|
||||
var op = NewNodeClusterOperator()
|
||||
op.AdminId = adminId
|
||||
op.Name = name
|
||||
op.GrantId = grantId
|
||||
@@ -186,7 +186,7 @@ func (this *NodeClusterDAO) UpdateCluster(tx *dbs.Tx, clusterId int64, name stri
|
||||
if clusterId <= 0 {
|
||||
return errors.New("invalid clusterId")
|
||||
}
|
||||
op := NewNodeClusterOperator()
|
||||
var op = NewNodeClusterOperator()
|
||||
op.Id = clusterId
|
||||
op.Name = name
|
||||
op.GrantId = grantId
|
||||
@@ -325,7 +325,7 @@ func (this *NodeClusterDAO) UpdateClusterHealthCheck(tx *dbs.Tx, clusterId int64
|
||||
if clusterId <= 0 {
|
||||
return errors.New("invalid clusterId '" + strconv.FormatInt(clusterId, 10) + "'")
|
||||
}
|
||||
op := NewNodeClusterOperator()
|
||||
var op = NewNodeClusterOperator()
|
||||
op.Id = clusterId
|
||||
op.HealthCheck = healthCheckJSON
|
||||
// 不需要通知更新
|
||||
@@ -570,7 +570,7 @@ func (this *NodeClusterDAO) UpdateClusterTOA(tx *dbs.Tx, clusterId int64, toaJSO
|
||||
if clusterId <= 0 {
|
||||
return errors.New("invalid clusterId")
|
||||
}
|
||||
op := NewNodeClusterOperator()
|
||||
var op = NewNodeClusterOperator()
|
||||
op.Id = clusterId
|
||||
op.Toa = toaJSON
|
||||
err := this.Save(tx, op)
|
||||
|
||||
@@ -84,7 +84,7 @@ func (this *NodeClusterFirewallActionDAO) CreateFirewallAction(tx *dbs.Tx, admin
|
||||
params = maps.Map{}
|
||||
}
|
||||
|
||||
op := NewNodeClusterFirewallActionOperator()
|
||||
var op = NewNodeClusterFirewallActionOperator()
|
||||
op.AdminId = adminId
|
||||
op.ClusterId = clusterId
|
||||
op.Name = name
|
||||
@@ -113,7 +113,7 @@ func (this *NodeClusterFirewallActionDAO) UpdateFirewallAction(tx *dbs.Tx, actio
|
||||
params = maps.Map{}
|
||||
}
|
||||
|
||||
op := NewNodeClusterFirewallActionOperator()
|
||||
var op = NewNodeClusterFirewallActionOperator()
|
||||
op.Id = actionId
|
||||
op.Name = name
|
||||
op.EventLevel = eventLevel
|
||||
|
||||
@@ -167,7 +167,7 @@ func (this *NodeDAO) CreateNode(tx *dbs.Tx, adminId int64, name string, clusterI
|
||||
return
|
||||
}
|
||||
|
||||
op := NewNodeOperator()
|
||||
var op = NewNodeOperator()
|
||||
op.AdminId = adminId
|
||||
op.Name = name
|
||||
op.UniqueId = uniqueId
|
||||
@@ -1246,7 +1246,7 @@ func (this *NodeDAO) UpdateNodeConnectedAPINodes(tx *dbs.Tx, nodeId int64, apiNo
|
||||
return errors.New("invalid nodeId")
|
||||
}
|
||||
|
||||
op := NewNodeOperator()
|
||||
var op = NewNodeOperator()
|
||||
op.Id = nodeId
|
||||
|
||||
if len(apiNodeIds) > 0 {
|
||||
@@ -1476,7 +1476,7 @@ func (this *NodeDAO) UpdateNodeDNS(tx *dbs.Tx, nodeId int64, routes map[int64][]
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
op := NewNodeOperator()
|
||||
var op = NewNodeOperator()
|
||||
op.Id = nodeId
|
||||
op.DnsRoutes = routesJSON
|
||||
err = this.Save(tx, op)
|
||||
@@ -1601,7 +1601,7 @@ func (this *NodeDAO) UpdateNodeUpCount(tx *dbs.Tx, nodeId int64, isUp bool, maxU
|
||||
countUp := int(one.(*Node).CountUp)
|
||||
countDown := int(one.(*Node).CountDown)
|
||||
|
||||
op := NewNodeOperator()
|
||||
var op = NewNodeOperator()
|
||||
op.Id = nodeId
|
||||
|
||||
if isUp {
|
||||
@@ -1645,7 +1645,7 @@ func (this *NodeDAO) UpdateNodeUp(tx *dbs.Tx, nodeId int64, isUp bool) error {
|
||||
return errors.New("invalid nodeId")
|
||||
}
|
||||
|
||||
op := NewNodeOperator()
|
||||
var op = NewNodeOperator()
|
||||
op.Id = nodeId
|
||||
op.IsUp = isUp
|
||||
op.CountUp = 0
|
||||
@@ -1767,7 +1767,7 @@ func (this *NodeDAO) DeleteNodeFromCluster(tx *dbs.Tx, nodeId int64, clusterId i
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
op := NewNodeOperator()
|
||||
var op = NewNodeOperator()
|
||||
op.Id = nodeId
|
||||
op.ClusterId = newClusterId
|
||||
op.SecondaryClusterIds = secondaryClusterIdsJSON
|
||||
|
||||
@@ -75,7 +75,7 @@ func (this *NodeGrantDAO) FindNodeGrantName(tx *dbs.Tx, id uint32) (string, erro
|
||||
|
||||
// CreateGrant 创建认证信息
|
||||
func (this *NodeGrantDAO) CreateGrant(tx *dbs.Tx, adminId int64, name string, method string, username string, password string, privateKey string, passphrase string, description string, nodeId int64, su bool) (grantId int64, err error) {
|
||||
op := NewNodeGrantOperator()
|
||||
var op = NewNodeGrantOperator()
|
||||
op.AdminId = adminId
|
||||
op.Name = name
|
||||
op.Method = method
|
||||
@@ -103,7 +103,7 @@ func (this *NodeGrantDAO) UpdateGrant(tx *dbs.Tx, grantId int64, name string, me
|
||||
return errors.New("invalid grantId")
|
||||
}
|
||||
|
||||
op := NewNodeGrantOperator()
|
||||
var op = NewNodeGrantOperator()
|
||||
op.Id = grantId
|
||||
op.Name = name
|
||||
op.Method = method
|
||||
|
||||
@@ -73,7 +73,7 @@ func (this *NodeGroupDAO) FindNodeGroupName(tx *dbs.Tx, id int64) (string, error
|
||||
|
||||
// 创建分组
|
||||
func (this *NodeGroupDAO) CreateNodeGroup(tx *dbs.Tx, clusterId int64, name string) (int64, error) {
|
||||
op := NewNodeGroupOperator()
|
||||
var op = NewNodeGroupOperator()
|
||||
op.ClusterId = clusterId
|
||||
op.Name = name
|
||||
op.State = NodeGroupStateEnabled
|
||||
@@ -89,7 +89,7 @@ func (this *NodeGroupDAO) UpdateNodeGroup(tx *dbs.Tx, groupId int64, name string
|
||||
if groupId <= 0 {
|
||||
return errors.New("invalid groupId")
|
||||
}
|
||||
op := NewNodeGroupOperator()
|
||||
var op = NewNodeGroupOperator()
|
||||
op.Id = groupId
|
||||
op.Name = name
|
||||
err := this.Save(tx, op)
|
||||
|
||||
@@ -161,7 +161,7 @@ func (this *NodeIPAddressDAO) UpdateAddress(tx *dbs.Tx, adminId int64, addressId
|
||||
return errors.New("invalid addressId")
|
||||
}
|
||||
|
||||
op := NewNodeIPAddressOperator()
|
||||
var op = NewNodeIPAddressOperator()
|
||||
op.Id = addressId
|
||||
op.Name = name
|
||||
op.Ip = ip
|
||||
@@ -189,7 +189,7 @@ func (this *NodeIPAddressDAO) UpdateAddressIP(tx *dbs.Tx, addressId int64, ip st
|
||||
if addressId <= 0 {
|
||||
return errors.New("invalid addressId")
|
||||
}
|
||||
op := NewNodeIPAddressOperator()
|
||||
var op = NewNodeIPAddressOperator()
|
||||
op.Id = addressId
|
||||
op.Ip = ip
|
||||
err := this.Save(tx, op)
|
||||
|
||||
@@ -75,7 +75,7 @@ func (this *NodePriceItemDAO) FindNodePriceItemName(tx *dbs.Tx, id int64) (strin
|
||||
|
||||
// CreateItem 创建价格
|
||||
func (this *NodePriceItemDAO) CreateItem(tx *dbs.Tx, name string, itemType string, bitsFrom, bitsTo int64) (int64, error) {
|
||||
op := NewNodePriceItemOperator()
|
||||
var op = NewNodePriceItemOperator()
|
||||
op.Name = name
|
||||
op.Type = itemType
|
||||
op.BitsFrom = bitsFrom
|
||||
@@ -90,7 +90,7 @@ func (this *NodePriceItemDAO) UpdateItem(tx *dbs.Tx, itemId int64, name string,
|
||||
if itemId <= 0 {
|
||||
return errors.New("invalid itemId")
|
||||
}
|
||||
op := NewNodePriceItemOperator()
|
||||
var op = NewNodePriceItemOperator()
|
||||
op.Id = itemId
|
||||
op.Name = name
|
||||
op.BitsFrom = bitsFrom
|
||||
|
||||
@@ -75,7 +75,7 @@ func (this *NodeRegionDAO) FindNodeRegionName(tx *dbs.Tx, id int64) (string, err
|
||||
|
||||
// CreateRegion 创建区域
|
||||
func (this *NodeRegionDAO) CreateRegion(tx *dbs.Tx, adminId int64, name string, description string) (int64, error) {
|
||||
op := NewNodeRegionOperator()
|
||||
var op = NewNodeRegionOperator()
|
||||
op.AdminId = adminId
|
||||
op.Name = name
|
||||
op.Description = description
|
||||
@@ -89,7 +89,7 @@ func (this *NodeRegionDAO) UpdateRegion(tx *dbs.Tx, regionId int64, name string,
|
||||
if regionId <= 0 {
|
||||
return errors.New("invalid regionId")
|
||||
}
|
||||
op := NewNodeRegionOperator()
|
||||
var op = NewNodeRegionOperator()
|
||||
op.Id = regionId
|
||||
op.Name = name
|
||||
op.Description = description
|
||||
|
||||
@@ -72,7 +72,7 @@ func (this *NodeThresholdDAO) FindEnabledNodeThreshold(tx *dbs.Tx, id int64) (*N
|
||||
|
||||
// CreateThreshold 创建阈值
|
||||
func (this *NodeThresholdDAO) CreateThreshold(tx *dbs.Tx, role string, clusterId int64, nodeId int64, item nodeconfigs.NodeValueItem, param string, operator nodeconfigs.NodeValueOperator, valueJSON []byte, message string, sumMethod nodeconfigs.NodeValueSumMethod, duration int32, durationUnit nodeconfigs.NodeValueDurationUnit, notifyDuration int32) (int64, error) {
|
||||
op := NewNodeThresholdOperator()
|
||||
var op = NewNodeThresholdOperator()
|
||||
op.Role = role
|
||||
op.ClusterId = clusterId
|
||||
op.NodeId = nodeId
|
||||
@@ -95,7 +95,7 @@ func (this *NodeThresholdDAO) UpdateThreshold(tx *dbs.Tx, thresholdId int64, ite
|
||||
if thresholdId <= 0 {
|
||||
return errors.New("invalid thresholdId")
|
||||
}
|
||||
op := NewNodeThresholdOperator()
|
||||
var op = NewNodeThresholdOperator()
|
||||
op.Id = thresholdId
|
||||
op.Item = item
|
||||
op.Param = param
|
||||
|
||||
@@ -75,7 +75,7 @@ func (this *NSClusterDAO) FindEnabledNSClusterName(tx *dbs.Tx, id int64) (string
|
||||
|
||||
// CreateCluster 创建集群
|
||||
func (this *NSClusterDAO) CreateCluster(tx *dbs.Tx, name string, accessLogRefJSON []byte) (int64, error) {
|
||||
op := NewNSClusterOperator()
|
||||
var op = NewNSClusterOperator()
|
||||
op.Name = name
|
||||
|
||||
if len(accessLogRefJSON) > 0 {
|
||||
@@ -92,7 +92,7 @@ func (this *NSClusterDAO) UpdateCluster(tx *dbs.Tx, clusterId int64, name string
|
||||
if clusterId <= 0 {
|
||||
return errors.New("invalid clusterId")
|
||||
}
|
||||
op := NewNSClusterOperator()
|
||||
var op = NewNSClusterOperator()
|
||||
op.Id = clusterId
|
||||
op.Name = name
|
||||
op.IsOn = isOn
|
||||
|
||||
@@ -226,7 +226,7 @@ func (this *NSNodeDAO) CreateNode(tx *dbs.Tx, adminId int64, name string, cluste
|
||||
return
|
||||
}
|
||||
|
||||
op := NewNSNodeOperator()
|
||||
var op = NewNSNodeOperator()
|
||||
op.AdminId = adminId
|
||||
op.Name = name
|
||||
op.UniqueId = uniqueId
|
||||
@@ -260,7 +260,7 @@ func (this *NSNodeDAO) UpdateNode(tx *dbs.Tx, nodeId int64, name string, cluster
|
||||
if nodeId <= 0 {
|
||||
return errors.New("invalid nodeId")
|
||||
}
|
||||
op := NewNSNodeOperator()
|
||||
var op = NewNSNodeOperator()
|
||||
op.Id = nodeId
|
||||
op.Name = name
|
||||
op.ClusterId = clusterId
|
||||
@@ -487,7 +487,7 @@ func (this *NSNodeDAO) UpdateNodeConnectedAPINodes(tx *dbs.Tx, nodeId int64, api
|
||||
return errors.New("invalid nodeId")
|
||||
}
|
||||
|
||||
op := NewNSNodeOperator()
|
||||
var op = NewNSNodeOperator()
|
||||
op.Id = nodeId
|
||||
|
||||
if len(apiNodeIds) > 0 {
|
||||
|
||||
@@ -86,7 +86,7 @@ func (this *RegionCityDAO) FindCityWithDataId(tx *dbs.Tx, dataId string) (int64,
|
||||
|
||||
// CreateCity 创建城市
|
||||
func (this *RegionCityDAO) CreateCity(tx *dbs.Tx, provinceId int64, name string, dataId string) (int64, error) {
|
||||
op := NewRegionCityOperator()
|
||||
var op = NewRegionCityOperator()
|
||||
op.ProvinceId = provinceId
|
||||
op.Name = name
|
||||
op.DataId = dataId
|
||||
|
||||
@@ -133,7 +133,7 @@ func (this *RegionCountryDAO) FindCountryIdWithNameCacheable(tx *dbs.Tx, country
|
||||
|
||||
// CreateCountry 根据数据ID创建国家
|
||||
func (this *RegionCountryDAO) CreateCountry(tx *dbs.Tx, name string, dataId string) (int64, error) {
|
||||
op := NewRegionCountryOperator()
|
||||
var op = NewRegionCountryOperator()
|
||||
op.Name = name
|
||||
|
||||
pinyinPieces := pinyin.Pinyin(name, pinyin.NewArgs())
|
||||
|
||||
@@ -102,7 +102,7 @@ func (this *RegionProviderDAO) FindProviderIdWithNameCacheable(tx *dbs.Tx, provi
|
||||
|
||||
// CreateProvider 创建Provider
|
||||
func (this *RegionProviderDAO) CreateProvider(tx *dbs.Tx, name string) (int64, error) {
|
||||
op := NewRegionProviderOperator()
|
||||
var op = NewRegionProviderOperator()
|
||||
op.Name = name
|
||||
|
||||
codesJSON, err := json.Marshal([]string{name})
|
||||
|
||||
@@ -119,7 +119,7 @@ func (this *RegionProvinceDAO) FindProvinceIdWithNameCacheable(tx *dbs.Tx, count
|
||||
|
||||
// 创建省份
|
||||
func (this *RegionProvinceDAO) CreateProvince(tx *dbs.Tx, countryId int64, name string, dataId string) (int64, error) {
|
||||
op := NewRegionProvinceOperator()
|
||||
var op = NewRegionProvinceOperator()
|
||||
op.CountryId = countryId
|
||||
op.Name = name
|
||||
op.DataId = dataId
|
||||
|
||||
@@ -98,7 +98,7 @@ func (this *ReportNodeDAO) CreateReportNode(tx *dbs.Tx, name string, location st
|
||||
return 0, err
|
||||
}
|
||||
|
||||
op := NewReportNodeOperator()
|
||||
var op = NewReportNodeOperator()
|
||||
op.UniqueId = uniqueId
|
||||
op.Secret = secret
|
||||
op.Name = name
|
||||
@@ -136,7 +136,7 @@ func (this *ReportNodeDAO) UpdateReportNode(tx *dbs.Tx, nodeId int64, name strin
|
||||
return errors.New("invalid nodeId")
|
||||
}
|
||||
|
||||
op := NewReportNodeOperator()
|
||||
var op = NewReportNodeOperator()
|
||||
op.Id = nodeId
|
||||
op.Name = name
|
||||
op.Location = location
|
||||
|
||||
@@ -212,7 +212,7 @@ func (this *ReverseProxyDAO) ComposeReverseProxyConfig(tx *dbs.Tx, reverseProxyI
|
||||
|
||||
// CreateReverseProxy 创建反向代理
|
||||
func (this *ReverseProxyDAO) CreateReverseProxy(tx *dbs.Tx, adminId int64, userId int64, schedulingJSON []byte, primaryOriginsJSON []byte, backupOriginsJSON []byte) (int64, error) {
|
||||
op := NewReverseProxyOperator()
|
||||
var op = NewReverseProxyOperator()
|
||||
op.IsOn = true
|
||||
op.State = ReverseProxyStateEnabled
|
||||
op.AdminId = adminId
|
||||
@@ -248,7 +248,7 @@ func (this *ReverseProxyDAO) UpdateReverseProxyScheduling(tx *dbs.Tx, reversePro
|
||||
if reverseProxyId <= 0 {
|
||||
return errors.New("invalid reverseProxyId")
|
||||
}
|
||||
op := NewReverseProxyOperator()
|
||||
var op = NewReverseProxyOperator()
|
||||
op.Id = reverseProxyId
|
||||
if len(schedulingJSON) > 0 {
|
||||
op.Scheduling = string(schedulingJSON)
|
||||
@@ -267,7 +267,7 @@ func (this *ReverseProxyDAO) UpdateReverseProxyPrimaryOrigins(tx *dbs.Tx, revers
|
||||
if reverseProxyId <= 0 {
|
||||
return errors.New("invalid reverseProxyId")
|
||||
}
|
||||
op := NewReverseProxyOperator()
|
||||
var op = NewReverseProxyOperator()
|
||||
op.Id = reverseProxyId
|
||||
if len(origins) > 0 {
|
||||
op.PrimaryOrigins = origins
|
||||
@@ -286,7 +286,7 @@ func (this *ReverseProxyDAO) UpdateReverseProxyBackupOrigins(tx *dbs.Tx, reverse
|
||||
if reverseProxyId <= 0 {
|
||||
return errors.New("invalid reverseProxyId")
|
||||
}
|
||||
op := NewReverseProxyOperator()
|
||||
var op = NewReverseProxyOperator()
|
||||
op.Id = reverseProxyId
|
||||
if len(origins) > 0 {
|
||||
op.BackupOrigins = origins
|
||||
|
||||
@@ -624,7 +624,7 @@ func (this *ServerDAO) UpdateServerNames(tx *dbs.Tx, serverId int64, serverNames
|
||||
return errors.New("serverId should not be smaller than 0")
|
||||
}
|
||||
|
||||
op := NewServerOperator()
|
||||
var op = NewServerOperator()
|
||||
op.Id = serverId
|
||||
|
||||
if IsNull(serverNamesJSON) {
|
||||
@@ -657,7 +657,7 @@ func (this *ServerDAO) UpdateAuditingServerNames(tx *dbs.Tx, serverId int64, isA
|
||||
return errors.New("serverId should not be smaller than 0")
|
||||
}
|
||||
|
||||
op := NewServerOperator()
|
||||
var op = NewServerOperator()
|
||||
op.Id = serverId
|
||||
op.IsAuditing = isAuditing
|
||||
if isAuditing {
|
||||
@@ -739,7 +739,7 @@ func (this *ServerDAO) UpdateServerReverseProxy(tx *dbs.Tx, serverId int64, conf
|
||||
if serverId <= 0 {
|
||||
return errors.New("serverId should not be smaller than 0")
|
||||
}
|
||||
op := NewServerOperator()
|
||||
var op = NewServerOperator()
|
||||
op.Id = serverId
|
||||
op.ReverseProxy = JSONBytes(config)
|
||||
err := this.Save(tx, op)
|
||||
@@ -918,6 +918,7 @@ func (this *ServerDAO) FindAllEnabledServersWithNode(tx *dbs.Tx, nodeId int64) (
|
||||
for _, clusterId := range clusterIds {
|
||||
ones, err := this.Query(tx).
|
||||
Attr("clusterId", clusterId).
|
||||
Where("(userId=0 OR userId IN (SELECT id FROM " + SharedUserDAO.Table + " WHERE isOn AND state=1))").
|
||||
State(ServerStateEnabled).
|
||||
AscPk().
|
||||
FindAll()
|
||||
@@ -1607,7 +1608,7 @@ func (this *ServerDAO) GenerateServerDNSName(tx *dbs.Tx, serverId int64) (string
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
op := NewServerOperator()
|
||||
var op = NewServerOperator()
|
||||
op.Id = serverId
|
||||
op.DnsName = dnsName
|
||||
err = this.Save(tx, op)
|
||||
@@ -2526,6 +2527,28 @@ func (this *ServerDAO) FindServerUAM(tx *dbs.Tx, serverId int64) ([]byte, error)
|
||||
FindJSONCol()
|
||||
}
|
||||
|
||||
// FindUserServerClusterIds 获取用户相关服务的集群ID组合
|
||||
func (this *ServerDAO) FindUserServerClusterIds(tx *dbs.Tx, userId int64) ([]int64, error) {
|
||||
if userId <= 0 {
|
||||
return nil, nil
|
||||
}
|
||||
ones, err := this.Query(tx).
|
||||
State(ServerStateEnabled).
|
||||
Attr("userId", userId).
|
||||
Gt("clusterId", 0).
|
||||
Result("DISTINCT(clusterId) AS clusterId").
|
||||
FindAll()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var clusterIds = []int64{}
|
||||
for _, one := range ones {
|
||||
clusterIds = append(clusterIds, int64(one.(*Server).ClusterId))
|
||||
}
|
||||
return clusterIds, nil
|
||||
}
|
||||
|
||||
// NotifyUpdate 同步服务所在的集群
|
||||
func (this *ServerDAO) NotifyUpdate(tx *dbs.Tx, serverId int64) error {
|
||||
// 创建任务
|
||||
@@ -2608,3 +2631,23 @@ func (this *ServerDAO) NotifyDisable(tx *dbs.Tx, serverId int64) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NotifyUserClustersChange 通知用户相关集群更新
|
||||
func (this *ServerDAO) NotifyUserClustersChange(tx *dbs.Tx, userId int64) error {
|
||||
if userId <= 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
clusterIds, err := this.FindUserServerClusterIds(tx, userId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, clusterId := range clusterIds {
|
||||
err = SharedNodeClusterDAO.NotifyUpdate(tx, clusterId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ func (this *ServerGroupDAO) FindServerGroupName(tx *dbs.Tx, id int64) (string, e
|
||||
|
||||
// CreateGroup 创建分组
|
||||
func (this *ServerGroupDAO) CreateGroup(tx *dbs.Tx, name string, userId int64) (groupId int64, err error) {
|
||||
op := NewServerGroupOperator()
|
||||
var op = NewServerGroupOperator()
|
||||
op.State = ServerGroupStateEnabled
|
||||
op.Name = name
|
||||
op.UserId = userId
|
||||
@@ -95,7 +95,7 @@ func (this *ServerGroupDAO) UpdateGroup(tx *dbs.Tx, groupId int64, name string)
|
||||
if groupId <= 0 {
|
||||
return errors.New("invalid groupId")
|
||||
}
|
||||
op := NewServerGroupOperator()
|
||||
var op = NewServerGroupOperator()
|
||||
op.Id = groupId
|
||||
op.Name = name
|
||||
err := this.Save(tx, op)
|
||||
@@ -193,7 +193,7 @@ func (this *ServerGroupDAO) UpdateHTTPReverseProxy(tx *dbs.Tx, groupId int64, co
|
||||
if groupId <= 0 {
|
||||
return errors.New("groupId should not be smaller than 0")
|
||||
}
|
||||
op := NewServerGroupOperator()
|
||||
var op = NewServerGroupOperator()
|
||||
op.Id = groupId
|
||||
op.HttpReverseProxy = JSONBytes(config)
|
||||
err := this.Save(tx, op)
|
||||
@@ -209,7 +209,7 @@ func (this *ServerGroupDAO) UpdateTCPReverseProxy(tx *dbs.Tx, groupId int64, con
|
||||
if groupId <= 0 {
|
||||
return errors.New("groupId should not be smaller than 0")
|
||||
}
|
||||
op := NewServerGroupOperator()
|
||||
var op = NewServerGroupOperator()
|
||||
op.Id = groupId
|
||||
op.TcpReverseProxy = JSONBytes(config)
|
||||
err := this.Save(tx, op)
|
||||
@@ -225,7 +225,7 @@ func (this *ServerGroupDAO) UpdateUDPReverseProxy(tx *dbs.Tx, groupId int64, con
|
||||
if groupId <= 0 {
|
||||
return errors.New("groupId should not be smaller than 0")
|
||||
}
|
||||
op := NewServerGroupOperator()
|
||||
var op = NewServerGroupOperator()
|
||||
op.Id = groupId
|
||||
op.UdpReverseProxy = JSONBytes(config)
|
||||
err := this.Save(tx, op)
|
||||
|
||||
@@ -64,7 +64,7 @@ func (this *ServerStatBoardChartDAO) FindEnabledServerStatBoardChart(tx *dbs.Tx,
|
||||
|
||||
// EnableChart 启用图表
|
||||
func (this *ServerStatBoardChartDAO) EnableChart(tx *dbs.Tx, boardId int64, chartId int64) error {
|
||||
op := NewServerStatBoardChartOperator()
|
||||
var op = NewServerStatBoardChartOperator()
|
||||
op.BoardId = boardId
|
||||
op.ChartId = chartId
|
||||
op.State = ServerStatBoardChartStateEnabled
|
||||
|
||||
@@ -89,7 +89,7 @@ func (this *SSLCertDAO) FindSSLCertName(tx *dbs.Tx, id int64) (string, error) {
|
||||
|
||||
// CreateCert 创建证书
|
||||
func (this *SSLCertDAO) CreateCert(tx *dbs.Tx, adminId int64, userId int64, isOn bool, name string, description string, serverName string, isCA bool, certData []byte, keyData []byte, timeBeginAt int64, timeEndAt int64, dnsNames []string, commonNames []string) (int64, error) {
|
||||
op := NewSSLCertOperator()
|
||||
var op = NewSSLCertOperator()
|
||||
op.AdminId = adminId
|
||||
op.UserId = userId
|
||||
op.State = SSLCertStateEnabled
|
||||
@@ -343,7 +343,7 @@ func (this *SSLCertDAO) UpdateCertACME(tx *dbs.Tx, certId int64, acmeTaskId int6
|
||||
if certId <= 0 {
|
||||
return errors.New("invalid certId")
|
||||
}
|
||||
op := NewSSLCertOperator()
|
||||
var op = NewSSLCertOperator()
|
||||
op.Id = certId
|
||||
op.AcmeTaskId = acmeTaskId
|
||||
op.IsACME = true
|
||||
|
||||
@@ -200,7 +200,7 @@ func (this *SSLPolicyDAO) FindAllEnabledPolicyIdsWithCertId(tx *dbs.Tx, certId i
|
||||
|
||||
// CreatePolicy 创建Policy
|
||||
func (this *SSLPolicyDAO) CreatePolicy(tx *dbs.Tx, adminId int64, userId int64, http2Enabled bool, minVersion string, certsJSON []byte, hstsJSON []byte, ocspIsOn bool, clientAuthType int32, clientCACertsJSON []byte, cipherSuitesIsOn bool, cipherSuites []string) (int64, error) {
|
||||
op := NewSSLPolicyOperator()
|
||||
var op = NewSSLPolicyOperator()
|
||||
op.State = SSLPolicyStateEnabled
|
||||
op.IsOn = true
|
||||
op.AdminId = adminId
|
||||
@@ -244,7 +244,7 @@ func (this *SSLPolicyDAO) UpdatePolicy(tx *dbs.Tx, policyId int64, http2Enabled
|
||||
return errors.New("invalid policyId")
|
||||
}
|
||||
|
||||
op := NewSSLPolicyOperator()
|
||||
var op = NewSSLPolicyOperator()
|
||||
op.Id = policyId
|
||||
op.Http2Enabled = http2Enabled
|
||||
op.MinVersion = minVersion
|
||||
|
||||
@@ -35,7 +35,7 @@ func (this *SysEventDAO) CreateEvent(tx *dbs.Tx, event EventInterface) error {
|
||||
return errors.New("event should not be nil")
|
||||
}
|
||||
|
||||
op := NewSysEventOperator()
|
||||
var op = NewSysEventOperator()
|
||||
op.Type = event.Type()
|
||||
|
||||
eventJSON, err := json.Marshal(event)
|
||||
|
||||
@@ -47,7 +47,7 @@ func (this *SysLockerDAO) Lock(tx *dbs.Tx, key string, timeout int64) (ok bool,
|
||||
|
||||
// 如果没有锁,则创建
|
||||
if one == nil {
|
||||
op := NewSysLockerOperator()
|
||||
var op = NewSysLockerOperator()
|
||||
op.Key = key
|
||||
op.TimeoutAt = time.Now().Unix() + timeout
|
||||
op.Version = 1
|
||||
@@ -70,7 +70,7 @@ func (this *SysLockerDAO) Lock(tx *dbs.Tx, key string, timeout int64) (ok bool,
|
||||
}
|
||||
|
||||
// 修改
|
||||
op := NewSysLockerOperator()
|
||||
var op = NewSysLockerOperator()
|
||||
op.Id = locker.Id
|
||||
op.Version = locker.Version + 1
|
||||
op.TimeoutAt = time.Now().Unix() + timeout
|
||||
|
||||
@@ -65,7 +65,7 @@ func (this *SysSettingDAO) UpdateSetting(tx *dbs.Tx, codeFormat string, valueJSO
|
||||
|
||||
if settingId == 0 {
|
||||
// 新建
|
||||
op := NewSysSettingOperator()
|
||||
var op = NewSysSettingOperator()
|
||||
op.Code = codeFormat
|
||||
op.Value = valueJSON
|
||||
err = this.Save(tx, op)
|
||||
@@ -81,7 +81,7 @@ func (this *SysSettingDAO) UpdateSetting(tx *dbs.Tx, codeFormat string, valueJSO
|
||||
}
|
||||
|
||||
// 修改
|
||||
op := NewSysSettingOperator()
|
||||
var op = NewSysSettingOperator()
|
||||
op.Id = settingId
|
||||
op.Value = valueJSON
|
||||
err = this.Save(tx, op)
|
||||
|
||||
@@ -70,7 +70,7 @@ func (this *UserAccessKeyDAO) CreateAccessKey(tx *dbs.Tx, adminId int64, userId
|
||||
if adminId <= 0 && userId <= 0 {
|
||||
return 0, errors.New("invalid adminId or userId")
|
||||
}
|
||||
op := NewUserAccessKeyOperator()
|
||||
var op = NewUserAccessKeyOperator()
|
||||
op.AdminId = adminId
|
||||
op.UserId = userId
|
||||
op.Description = description
|
||||
|
||||
@@ -42,19 +42,29 @@ func init() {
|
||||
}
|
||||
|
||||
// EnableUser 启用条目
|
||||
func (this *UserDAO) EnableUser(tx *dbs.Tx, id int64) (rowsAffected int64, err error) {
|
||||
return this.Query(tx).
|
||||
Pk(id).
|
||||
func (this *UserDAO) EnableUser(tx *dbs.Tx, userId int64) error {
|
||||
if userId <= 0 {
|
||||
return errors.New("invalid 'userId'")
|
||||
}
|
||||
|
||||
_, err := this.Query(tx).
|
||||
Pk(userId).
|
||||
Set("state", UserStateEnabled).
|
||||
Update()
|
||||
return err
|
||||
}
|
||||
|
||||
// DisableUser 禁用条目
|
||||
func (this *UserDAO) DisableUser(tx *dbs.Tx, id int64) (rowsAffected int64, err error) {
|
||||
return this.Query(tx).
|
||||
Pk(id).
|
||||
func (this *UserDAO) DisableUser(tx *dbs.Tx, userId int64) error {
|
||||
if userId <= 0 {
|
||||
return errors.New("invalid 'userId'")
|
||||
}
|
||||
|
||||
_, err := this.Query(tx).
|
||||
Pk(userId).
|
||||
Set("state", UserStateDisabled).
|
||||
Update()
|
||||
return err
|
||||
}
|
||||
|
||||
// FindEnabledUser 查找启用的用户
|
||||
@@ -108,6 +118,15 @@ func (this *UserDAO) FindBasicUserWithoutState(tx *dbs.Tx, id int64) (*User, err
|
||||
return result.(*User), err
|
||||
}
|
||||
|
||||
// FindEnabledUserIdWithUsername 根据用户名查找用户ID
|
||||
func (this *UserDAO) FindEnabledUserIdWithUsername(tx *dbs.Tx, username string) (int64, error) {
|
||||
return this.Query(tx).
|
||||
ResultPk().
|
||||
State(UserStateEnabled).
|
||||
Attr("username", username).
|
||||
FindInt64Col(0)
|
||||
}
|
||||
|
||||
// FindUserFullname 获取管理员名称
|
||||
func (this *UserDAO) FindUserFullname(tx *dbs.Tx, userId int64) (string, error) {
|
||||
return this.Query(tx).
|
||||
@@ -129,7 +148,7 @@ func (this *UserDAO) CreateUser(tx *dbs.Tx, username string,
|
||||
features []string,
|
||||
registeredIP string,
|
||||
isVerified bool) (int64, error) {
|
||||
op := NewUserOperator()
|
||||
var op = NewUserOperator()
|
||||
op.Username = username
|
||||
op.Password = stringutil.Md5(password)
|
||||
op.Fullname = fullname
|
||||
@@ -169,6 +188,16 @@ func (this *UserDAO) UpdateUser(tx *dbs.Tx, userId int64, username string, passw
|
||||
if userId <= 0 {
|
||||
return errors.New("invalid userId")
|
||||
}
|
||||
|
||||
// 是否启用变化
|
||||
oldIsOn, err := this.Query(tx).
|
||||
Pk(userId).
|
||||
Result("isOn").
|
||||
FindBoolCol()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var op = NewUserOperator()
|
||||
op.Id = userId
|
||||
op.Username = username
|
||||
@@ -182,8 +211,16 @@ func (this *UserDAO) UpdateUser(tx *dbs.Tx, userId int64, username string, passw
|
||||
op.Remark = remark
|
||||
op.ClusterId = nodeClusterId
|
||||
op.IsOn = isOn
|
||||
err := this.Save(tx, op)
|
||||
return err
|
||||
err = this.Save(tx, op)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if oldIsOn != isOn {
|
||||
return SharedServerDAO.NotifyUserClustersChange(tx, userId)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// UpdateUserInfo 修改用户基本信息
|
||||
@@ -191,7 +228,7 @@ func (this *UserDAO) UpdateUserInfo(tx *dbs.Tx, userId int64, fullname string, m
|
||||
if userId <= 0 {
|
||||
return errors.New("invalid userId")
|
||||
}
|
||||
op := NewUserOperator()
|
||||
var op = NewUserOperator()
|
||||
op.Id = userId
|
||||
op.Fullname = fullname
|
||||
op.Mobile = mobile
|
||||
@@ -204,7 +241,7 @@ func (this *UserDAO) UpdateUserLogin(tx *dbs.Tx, userId int64, username string,
|
||||
if userId <= 0 {
|
||||
return errors.New("invalid userId")
|
||||
}
|
||||
op := NewUserOperator()
|
||||
var op = NewUserOperator()
|
||||
op.Id = userId
|
||||
op.Username = username
|
||||
if len(password) > 0 {
|
||||
@@ -226,7 +263,8 @@ func (this *UserDAO) CountAllEnabledUsers(tx *dbs.Tx, clusterId int64, keyword s
|
||||
Param("keyword", dbutils.QuoteLike(keyword))
|
||||
}
|
||||
if isVerifying {
|
||||
query.Attr("isVerified", 0)
|
||||
query.Where("(isVerified=0 OR (id IN (SELECT userId FROM " + SharedUserIdentityDAO.Table + " WHERE status=:identityStatus AND state=1)))")
|
||||
query.Param("identityStatus", userconfigs.UserIdentityStatusSubmitted)
|
||||
}
|
||||
return query.Count()
|
||||
}
|
||||
@@ -235,7 +273,8 @@ func (this *UserDAO) CountAllEnabledUsers(tx *dbs.Tx, clusterId int64, keyword s
|
||||
func (this *UserDAO) CountAllVerifyingUsers(tx *dbs.Tx) (int64, error) {
|
||||
query := this.Query(tx)
|
||||
query.State(UserStateEnabled)
|
||||
query.Attr("isVerified", 0)
|
||||
query.Where("(isVerified=0 OR (id IN (SELECT userId FROM " + SharedUserIdentityDAO.Table + " WHERE status=:identityStatus AND state=1)))")
|
||||
query.Param("identityStatus", userconfigs.UserIdentityStatusSubmitted)
|
||||
return query.Count()
|
||||
}
|
||||
|
||||
@@ -251,7 +290,8 @@ func (this *UserDAO) ListEnabledUsers(tx *dbs.Tx, clusterId int64, keyword strin
|
||||
Param("keyword", dbutils.QuoteLike(keyword))
|
||||
}
|
||||
if isVerifying {
|
||||
query.Attr("isVerified", 0)
|
||||
query.Where("(isVerified=0 OR (id IN (SELECT userId FROM " + SharedUserIdentityDAO.Table + " WHERE status=:identityStatus AND state=1)))")
|
||||
query.Param("identityStatus", userconfigs.UserIdentityStatusSubmitted)
|
||||
}
|
||||
_, err = query.
|
||||
DescPk().
|
||||
|
||||
@@ -66,9 +66,10 @@ func (this *UserIdentityDAO) FindEnabledUserIdentity(tx *dbs.Tx, id int64) (*Use
|
||||
}
|
||||
|
||||
// CreateUserIdentity 创建
|
||||
func (this *UserIdentityDAO) CreateUserIdentity(tx *dbs.Tx, userId int64, idType userconfigs.UserIdentityType, realName string, number string, fileIds []int64) (int64, error) {
|
||||
func (this *UserIdentityDAO) CreateUserIdentity(tx *dbs.Tx, userId int64, orgType userconfigs.UserIdentityOrgType, idType userconfigs.UserIdentityType, realName string, number string, fileIds []int64) (int64, error) {
|
||||
var op = NewUserIdentityOperator()
|
||||
op.UserId = userId
|
||||
op.OrgType = orgType
|
||||
op.Type = idType
|
||||
op.RealName = realName
|
||||
op.Number = number
|
||||
@@ -96,6 +97,7 @@ func (this *UserIdentityDAO) UpdateUserIdentity(tx *dbs.Tx, identityId int64, id
|
||||
var op = NewUserIdentityOperator()
|
||||
op.Id = identityId
|
||||
op.Type = idType
|
||||
op.RealName = realName
|
||||
op.Number = number
|
||||
|
||||
if fileIds == nil {
|
||||
@@ -107,6 +109,8 @@ func (this *UserIdentityDAO) UpdateUserIdentity(tx *dbs.Tx, identityId int64, id
|
||||
}
|
||||
op.FileIds = fileIdsJSON
|
||||
|
||||
op.Status = userconfigs.UserIdentityStatusNone
|
||||
|
||||
return this.Save(tx, op)
|
||||
}
|
||||
|
||||
@@ -128,11 +132,21 @@ func (this *UserIdentityDAO) CancelUserIdentity(tx *dbs.Tx, identityId int64) er
|
||||
UpdateQuickly()
|
||||
}
|
||||
|
||||
// ResetUserIdentity 重置实名认证状态
|
||||
func (this *UserIdentityDAO) ResetUserIdentity(tx *dbs.Tx, identityId int64) error {
|
||||
return this.Query(tx).
|
||||
Pk(identityId).
|
||||
Set("status", userconfigs.UserIdentityStatusSubmitted).
|
||||
Set("updatedAt", time.Now().Unix()).
|
||||
UpdateQuickly()
|
||||
}
|
||||
|
||||
// RejectUserIdentity 拒绝
|
||||
func (this *UserIdentityDAO) RejectUserIdentity(tx *dbs.Tx, identityId int64) error {
|
||||
func (this *UserIdentityDAO) RejectUserIdentity(tx *dbs.Tx, identityId int64, reason string) error {
|
||||
return this.Query(tx).
|
||||
Pk(identityId).
|
||||
Set("status", userconfigs.UserIdentityStatusRejected).
|
||||
Set("rejectReason", reason).
|
||||
Set("rejectedAt", time.Now().Unix()).
|
||||
UpdateQuickly()
|
||||
}
|
||||
@@ -170,15 +184,35 @@ func (this *UserIdentityDAO) FindUserIdentityStatus(tx *dbs.Tx, identityId int64
|
||||
FindStringCol("")
|
||||
}
|
||||
|
||||
// FindEnabledUserIdentityWithType 查找某个类型的认证信息
|
||||
func (this *UserIdentityDAO) FindEnabledUserIdentityWithType(tx *dbs.Tx, userId int64, idType userconfigs.UserIdentityType) (*UserIdentity, error) {
|
||||
// FindEnabledUserIdentityWithOrgType 查找某个类型的认证信息
|
||||
func (this *UserIdentityDAO) FindEnabledUserIdentityWithOrgType(tx *dbs.Tx, userId int64, orgType userconfigs.UserIdentityOrgType) (*UserIdentity, error) {
|
||||
one, err := this.Query(tx).
|
||||
Attr("userId", userId).
|
||||
Attr("type", idType).
|
||||
Attr("orgType", orgType).
|
||||
State(UserIdentityStateEnabled).
|
||||
DescPk().
|
||||
Find()
|
||||
if err != nil || one == nil {
|
||||
return nil, err
|
||||
}
|
||||
return one.(*UserIdentity), nil
|
||||
}
|
||||
|
||||
// CheckUserIdentityIsVerified 检查实名认证
|
||||
func (this *UserIdentityDAO) CheckUserIdentityIsVerified(tx *dbs.Tx, userId int64, orgType userconfigs.UserIdentityOrgType) (bool, error) {
|
||||
return this.Query(tx).
|
||||
Attr("userId", userId).
|
||||
Attr("orgType", orgType).
|
||||
Attr("status", userconfigs.UserIdentityStatusVerified).
|
||||
State(UserIdentityStateEnabled).
|
||||
Exist()
|
||||
}
|
||||
|
||||
// CheckUserIdentityStatus 检查状态
|
||||
func (this *UserIdentityDAO) CheckUserIdentityStatus(tx *dbs.Tx, userId int64, status userconfigs.UserIdentityStatus) (bool, error) {
|
||||
return this.Query(tx).
|
||||
Attr("userId", userId).
|
||||
Attr("status", status).
|
||||
State(UserIdentityStateEnabled).
|
||||
Exist()
|
||||
}
|
||||
|
||||
@@ -4,35 +4,39 @@ import "github.com/iwind/TeaGo/dbs"
|
||||
|
||||
// UserIdentity 用户实名认证信息
|
||||
type UserIdentity struct {
|
||||
Id uint64 `field:"id"` // ID
|
||||
UserId uint64 `field:"userId"` // 用户ID
|
||||
Type string `field:"type"` // 类型
|
||||
RealName string `field:"realName"` // 真实姓名
|
||||
Number string `field:"number"` // 编号
|
||||
FileIds dbs.JSON `field:"fileIds"` // 文件ID
|
||||
Status string `field:"status"` // 状态:none,submitted,verified,rejected
|
||||
State uint8 `field:"state"` // 状态
|
||||
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
||||
UpdatedAt uint64 `field:"updatedAt"` // 修改时间
|
||||
SubmittedAt uint64 `field:"submittedAt"` // 提交时间
|
||||
RejectedAt uint64 `field:"rejectedAt"` // 拒绝时间
|
||||
VerifiedAt uint64 `field:"verifiedAt"` // 认证时间
|
||||
Id uint64 `field:"id"` // ID
|
||||
UserId uint64 `field:"userId"` // 用户ID
|
||||
OrgType string `field:"orgType"` // 组织类型
|
||||
Type string `field:"type"` // 证件类型
|
||||
RealName string `field:"realName"` // 真实姓名
|
||||
Number string `field:"number"` // 编号
|
||||
FileIds dbs.JSON `field:"fileIds"` // 文件ID
|
||||
Status string `field:"status"` // 状态:none,submitted,verified,rejected
|
||||
State uint8 `field:"state"` // 状态
|
||||
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
||||
UpdatedAt uint64 `field:"updatedAt"` // 修改时间
|
||||
SubmittedAt uint64 `field:"submittedAt"` // 提交时间
|
||||
RejectedAt uint64 `field:"rejectedAt"` // 拒绝时间
|
||||
VerifiedAt uint64 `field:"verifiedAt"` // 认证时间
|
||||
RejectReason string `field:"rejectReason"` // 拒绝原因
|
||||
}
|
||||
|
||||
type UserIdentityOperator struct {
|
||||
Id interface{} // ID
|
||||
UserId interface{} // 用户ID
|
||||
Type interface{} // 类型
|
||||
RealName interface{} // 真实姓名
|
||||
Number interface{} // 编号
|
||||
FileIds interface{} // 文件ID
|
||||
Status interface{} // 状态:none,submitted,verified,rejected
|
||||
State interface{} // 状态
|
||||
CreatedAt interface{} // 创建时间
|
||||
UpdatedAt interface{} // 修改时间
|
||||
SubmittedAt interface{} // 提交时间
|
||||
RejectedAt interface{} // 拒绝时间
|
||||
VerifiedAt interface{} // 认证时间
|
||||
Id interface{} // ID
|
||||
UserId interface{} // 用户ID
|
||||
OrgType interface{} // 组织类型
|
||||
Type interface{} // 证件类型
|
||||
RealName interface{} // 真实姓名
|
||||
Number interface{} // 编号
|
||||
FileIds interface{} // 文件ID
|
||||
Status interface{} // 状态:none,submitted,verified,rejected
|
||||
State interface{} // 状态
|
||||
CreatedAt interface{} // 创建时间
|
||||
UpdatedAt interface{} // 修改时间
|
||||
SubmittedAt interface{} // 提交时间
|
||||
RejectedAt interface{} // 拒绝时间
|
||||
VerifiedAt interface{} // 认证时间
|
||||
RejectReason interface{} // 拒绝原因
|
||||
}
|
||||
|
||||
func NewUserIdentityOperator() *UserIdentityOperator {
|
||||
|
||||
@@ -162,7 +162,7 @@ func (this *UserNodeDAO) CreateUserNode(tx *dbs.Tx, name string, description str
|
||||
return
|
||||
}
|
||||
|
||||
op := NewUserNodeOperator()
|
||||
var op = NewUserNodeOperator()
|
||||
op.IsOn = isOn
|
||||
op.UniqueId = uniqueId
|
||||
op.Secret = secret
|
||||
@@ -194,7 +194,7 @@ func (this *UserNodeDAO) UpdateUserNode(tx *dbs.Tx, nodeId int64, name string, d
|
||||
return errors.New("invalid nodeId")
|
||||
}
|
||||
|
||||
op := NewUserNodeOperator()
|
||||
var op = NewUserNodeOperator()
|
||||
op.Id = nodeId
|
||||
op.Name = name
|
||||
op.Description = description
|
||||
|
||||
@@ -677,6 +677,12 @@ func (this *APINode) listenSock() error {
|
||||
Params: map[string]interface{}{"count": 0},
|
||||
})
|
||||
}
|
||||
case "instance":
|
||||
_ = cmd.Reply(&gosock.Command{
|
||||
Params: map[string]interface{}{
|
||||
"code": teaconst.InstanceCode,
|
||||
},
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -58,6 +58,8 @@ func (this *NodeStatusExecutor) update() {
|
||||
status.BuildVersionCode = utils.VersionToLong(teaconst.Version)
|
||||
status.OS = runtime.GOOS
|
||||
status.Arch = runtime.GOARCH
|
||||
exe, _ := os.Executable()
|
||||
status.ExePath = exe
|
||||
status.ConfigVersion = 0
|
||||
status.IsActive = true
|
||||
status.ConnectionCount = 0 // TODO 实现连接数计算
|
||||
|
||||
@@ -20,7 +20,7 @@ type NSService struct {
|
||||
|
||||
// ComposeNSBoard 组合看板数据
|
||||
func (this *NSService) ComposeNSBoard(ctx context.Context, req *pb.ComposeNSBoardRequest) (*pb.ComposeNSBoardResponse, error) {
|
||||
_, err := this.ValidateAdmin(ctx, 0)
|
||||
_, err := this.ValidateAdmin(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ func (this *NSAccessLogService) CreateNSAccessLogs(ctx context.Context, req *pb.
|
||||
return &pb.CreateNSAccessLogsResponse{}, nil
|
||||
}
|
||||
|
||||
tx := this.NullTx()
|
||||
var tx = this.NullTx()
|
||||
|
||||
err = models.SharedNSAccessLogDAO.CreateNSAccessLogs(tx, req.NsAccessLogs)
|
||||
if err != nil {
|
||||
@@ -40,12 +40,12 @@ func (this *NSAccessLogService) CreateNSAccessLogs(ctx context.Context, req *pb.
|
||||
// ListNSAccessLogs 列出单页访问日志
|
||||
func (this *NSAccessLogService) ListNSAccessLogs(ctx context.Context, req *pb.ListNSAccessLogsRequest) (*pb.ListNSAccessLogsResponse, error) {
|
||||
// 校验请求
|
||||
_, userId, err := this.ValidateAdminAndUser(ctx, 0, 0)
|
||||
_, userId, err := this.ValidateAdminAndUser(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
tx := this.NullTx()
|
||||
var tx = this.NullTx()
|
||||
|
||||
// 检查服务ID
|
||||
if userId > 0 {
|
||||
@@ -97,12 +97,12 @@ func (this *NSAccessLogService) ListNSAccessLogs(ctx context.Context, req *pb.Li
|
||||
// FindNSAccessLog 查找单个日志
|
||||
func (this *NSAccessLogService) FindNSAccessLog(ctx context.Context, req *pb.FindNSAccessLogRequest) (*pb.FindNSAccessLogResponse, error) {
|
||||
// 校验请求
|
||||
_, userId, err := this.ValidateAdminAndUser(ctx, 0, 0)
|
||||
_, userId, err := this.ValidateAdminAndUser(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
tx := this.NullTx()
|
||||
var tx = this.NullTx()
|
||||
|
||||
accessLog, err := models.SharedNSAccessLogDAO.FindAccessLogWithRequestId(tx, req.RequestId)
|
||||
if err != nil {
|
||||
|
||||
@@ -19,7 +19,7 @@ type NSClusterService struct {
|
||||
|
||||
// CreateNSCluster 创建集群
|
||||
func (this *NSClusterService) CreateNSCluster(ctx context.Context, req *pb.CreateNSClusterRequest) (*pb.CreateNSClusterResponse, error) {
|
||||
_, err := this.ValidateAdmin(ctx, 0)
|
||||
_, err := this.ValidateAdmin(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -33,7 +33,7 @@ func (this *NSClusterService) CreateNSCluster(ctx context.Context, req *pb.Creat
|
||||
|
||||
// UpdateNSCluster 修改集群
|
||||
func (this *NSClusterService) UpdateNSCluster(ctx context.Context, req *pb.UpdateNSClusterRequest) (*pb.RPCSuccess, error) {
|
||||
_, err := this.ValidateAdmin(ctx, 0)
|
||||
_, err := this.ValidateAdmin(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -47,7 +47,7 @@ func (this *NSClusterService) UpdateNSCluster(ctx context.Context, req *pb.Updat
|
||||
|
||||
// FindNSClusterAccessLog 查找集群访问日志配置
|
||||
func (this *NSClusterService) FindNSClusterAccessLog(ctx context.Context, req *pb.FindNSClusterAccessLogRequest) (*pb.FindNSClusterAccessLogResponse, error) {
|
||||
_, err := this.ValidateAdmin(ctx, 0)
|
||||
_, err := this.ValidateAdmin(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -62,7 +62,7 @@ func (this *NSClusterService) FindNSClusterAccessLog(ctx context.Context, req *p
|
||||
|
||||
// UpdateNSClusterAccessLog 修改集群访问日志配置
|
||||
func (this *NSClusterService) UpdateNSClusterAccessLog(ctx context.Context, req *pb.UpdateNSClusterAccessLogRequest) (*pb.RPCSuccess, error) {
|
||||
_, err := this.ValidateAdmin(ctx, 0)
|
||||
_, err := this.ValidateAdmin(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -77,7 +77,7 @@ func (this *NSClusterService) UpdateNSClusterAccessLog(ctx context.Context, req
|
||||
|
||||
// DeleteNSCluster 删除集群
|
||||
func (this *NSClusterService) DeleteNSCluster(ctx context.Context, req *pb.DeleteNSCluster) (*pb.RPCSuccess, error) {
|
||||
_, err := this.ValidateAdmin(ctx, 0)
|
||||
_, err := this.ValidateAdmin(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -98,7 +98,7 @@ func (this *NSClusterService) DeleteNSCluster(ctx context.Context, req *pb.Delet
|
||||
|
||||
// FindEnabledNSCluster 查找单个可用集群信息
|
||||
func (this *NSClusterService) FindEnabledNSCluster(ctx context.Context, req *pb.FindEnabledNSClusterRequest) (*pb.FindEnabledNSClusterResponse, error) {
|
||||
_, err := this.ValidateAdmin(ctx, 0)
|
||||
_, err := this.ValidateAdmin(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -120,7 +120,7 @@ func (this *NSClusterService) FindEnabledNSCluster(ctx context.Context, req *pb.
|
||||
|
||||
// CountAllEnabledNSClusters 计算所有可用集群的数量
|
||||
func (this *NSClusterService) CountAllEnabledNSClusters(ctx context.Context, req *pb.CountAllEnabledNSClustersRequest) (*pb.RPCCountResponse, error) {
|
||||
_, err := this.ValidateAdmin(ctx, 0)
|
||||
_, err := this.ValidateAdmin(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -134,7 +134,7 @@ func (this *NSClusterService) CountAllEnabledNSClusters(ctx context.Context, req
|
||||
|
||||
// ListEnabledNSClusters 列出单页可用集群
|
||||
func (this *NSClusterService) ListEnabledNSClusters(ctx context.Context, req *pb.ListEnabledNSClustersRequest) (*pb.ListEnabledNSClustersResponse, error) {
|
||||
_, err := this.ValidateAdmin(ctx, 0)
|
||||
_, err := this.ValidateAdmin(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -157,7 +157,7 @@ func (this *NSClusterService) ListEnabledNSClusters(ctx context.Context, req *pb
|
||||
|
||||
// FindAllEnabledNSClusters 查找所有可用集群
|
||||
func (this *NSClusterService) FindAllEnabledNSClusters(ctx context.Context, req *pb.FindAllEnabledNSClustersRequest) (*pb.FindAllEnabledNSClustersResponse, error) {
|
||||
_, err := this.ValidateAdmin(ctx, 0)
|
||||
_, err := this.ValidateAdmin(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -180,7 +180,7 @@ func (this *NSClusterService) FindAllEnabledNSClusters(ctx context.Context, req
|
||||
|
||||
// UpdateNSClusterRecursionConfig 设置递归DNS配置
|
||||
func (this *NSClusterService) UpdateNSClusterRecursionConfig(ctx context.Context, req *pb.UpdateNSClusterRecursionConfigRequest) (*pb.RPCSuccess, error) {
|
||||
_, err := this.ValidateAdmin(ctx, 0)
|
||||
_, err := this.ValidateAdmin(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -202,7 +202,7 @@ func (this *NSClusterService) UpdateNSClusterRecursionConfig(ctx context.Context
|
||||
|
||||
// FindNSClusterRecursionConfig 读取递归DNS配置
|
||||
func (this *NSClusterService) FindNSClusterRecursionConfig(ctx context.Context, req *pb.FindNSClusterRecursionConfigRequest) (*pb.FindNSClusterRecursionConfigResponse, error) {
|
||||
_, err := this.ValidateAdmin(ctx, 0)
|
||||
_, err := this.ValidateAdmin(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ type NSDomainService struct {
|
||||
|
||||
// CreateNSDomain 创建域名
|
||||
func (this *NSDomainService) CreateNSDomain(ctx context.Context, req *pb.CreateNSDomainRequest) (*pb.CreateNSDomainResponse, error) {
|
||||
_, err := this.ValidateAdmin(ctx, 0)
|
||||
_, err := this.ValidateAdmin(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -34,7 +34,7 @@ func (this *NSDomainService) CreateNSDomain(ctx context.Context, req *pb.CreateN
|
||||
|
||||
// UpdateNSDomain 修改域名
|
||||
func (this *NSDomainService) UpdateNSDomain(ctx context.Context, req *pb.UpdateNSDomainRequest) (*pb.RPCSuccess, error) {
|
||||
_, err := this.ValidateAdmin(ctx, 0)
|
||||
_, err := this.ValidateAdmin(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -49,7 +49,7 @@ func (this *NSDomainService) UpdateNSDomain(ctx context.Context, req *pb.UpdateN
|
||||
|
||||
// DeleteNSDomain 删除域名
|
||||
func (this *NSDomainService) DeleteNSDomain(ctx context.Context, req *pb.DeleteNSDomainRequest) (*pb.RPCSuccess, error) {
|
||||
_, err := this.ValidateAdmin(ctx, 0)
|
||||
_, err := this.ValidateAdmin(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -64,7 +64,7 @@ func (this *NSDomainService) DeleteNSDomain(ctx context.Context, req *pb.DeleteN
|
||||
|
||||
// FindEnabledNSDomain 查找单个域名
|
||||
func (this *NSDomainService) FindEnabledNSDomain(ctx context.Context, req *pb.FindEnabledNSDomainRequest) (*pb.FindEnabledNSDomainResponse, error) {
|
||||
_, err := this.ValidateAdmin(ctx, 0)
|
||||
_, err := this.ValidateAdmin(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -123,7 +123,7 @@ func (this *NSDomainService) FindEnabledNSDomain(ctx context.Context, req *pb.Fi
|
||||
|
||||
// CountAllEnabledNSDomains 计算域名数量
|
||||
func (this *NSDomainService) CountAllEnabledNSDomains(ctx context.Context, req *pb.CountAllEnabledNSDomainsRequest) (*pb.RPCCountResponse, error) {
|
||||
_, err := this.ValidateAdmin(ctx, 0)
|
||||
_, err := this.ValidateAdmin(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -138,7 +138,7 @@ func (this *NSDomainService) CountAllEnabledNSDomains(ctx context.Context, req *
|
||||
|
||||
// ListEnabledNSDomains 列出单页域名
|
||||
func (this *NSDomainService) ListEnabledNSDomains(ctx context.Context, req *pb.ListEnabledNSDomainsRequest) (*pb.ListEnabledNSDomainsResponse, error) {
|
||||
_, err := this.ValidateAdmin(ctx, 0)
|
||||
_, err := this.ValidateAdmin(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -230,7 +230,7 @@ func (this *NSDomainService) ListNSDomainsAfterVersion(ctx context.Context, req
|
||||
|
||||
// FindEnabledNSDomainTSIG 查找TSIG配置
|
||||
func (this *NSDomainService) FindEnabledNSDomainTSIG(ctx context.Context, req *pb.FindEnabledNSDomainTSIGRequest) (*pb.FindEnabledNSDomainTSIGResponse, error) {
|
||||
_, err := this.ValidateAdmin(ctx, 0)
|
||||
_, err := this.ValidateAdmin(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -245,7 +245,7 @@ func (this *NSDomainService) FindEnabledNSDomainTSIG(ctx context.Context, req *p
|
||||
|
||||
// UpdateNSDomainTSIG 修改TSIG配置
|
||||
func (this *NSDomainService) UpdateNSDomainTSIG(ctx context.Context, req *pb.UpdateNSDomainTSIGRequest) (*pb.RPCSuccess, error) {
|
||||
_, err := this.ValidateAdmin(ctx, 0)
|
||||
_, err := this.ValidateAdmin(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ type NSKeyService struct {
|
||||
|
||||
// CreateNSKey 创建密钥
|
||||
func (this *NSKeyService) CreateNSKey(ctx context.Context, req *pb.CreateNSKeyRequest) (*pb.CreateNSKeyResponse, error) {
|
||||
_, err := this.ValidateAdmin(ctx, 0)
|
||||
_, err := this.ValidateAdmin(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -31,7 +31,7 @@ func (this *NSKeyService) CreateNSKey(ctx context.Context, req *pb.CreateNSKeyRe
|
||||
|
||||
// UpdateNSKey 修改密钥
|
||||
func (this *NSKeyService) UpdateNSKey(ctx context.Context, req *pb.UpdateNSKeyRequest) (*pb.RPCSuccess, error) {
|
||||
_, err := this.ValidateAdmin(ctx, 0)
|
||||
_, err := this.ValidateAdmin(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -45,7 +45,7 @@ func (this *NSKeyService) UpdateNSKey(ctx context.Context, req *pb.UpdateNSKeyRe
|
||||
|
||||
// DeleteNSKey 删除密钥
|
||||
func (this *NSKeyService) DeleteNSKey(ctx context.Context, req *pb.DeleteNSKeyRequest) (*pb.RPCSuccess, error) {
|
||||
_, err := this.ValidateAdmin(ctx, 0)
|
||||
_, err := this.ValidateAdmin(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -60,7 +60,7 @@ func (this *NSKeyService) DeleteNSKey(ctx context.Context, req *pb.DeleteNSKeyRe
|
||||
|
||||
// FindEnabledNSKey 查找单个密钥
|
||||
func (this *NSKeyService) FindEnabledNSKey(ctx context.Context, req *pb.FindEnabledNSKeyRequest) (*pb.FindEnabledNSKeyResponse, error) {
|
||||
_, err := this.ValidateAdmin(ctx, 0)
|
||||
_, err := this.ValidateAdmin(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -87,7 +87,7 @@ func (this *NSKeyService) FindEnabledNSKey(ctx context.Context, req *pb.FindEnab
|
||||
|
||||
// CountAllEnabledNSKeys 计算密钥数量
|
||||
func (this *NSKeyService) CountAllEnabledNSKeys(ctx context.Context, req *pb.CountAllEnabledNSKeysRequest) (*pb.RPCCountResponse, error) {
|
||||
_, err := this.ValidateAdmin(ctx, 0)
|
||||
_, err := this.ValidateAdmin(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -102,7 +102,7 @@ func (this *NSKeyService) CountAllEnabledNSKeys(ctx context.Context, req *pb.Cou
|
||||
|
||||
// ListEnabledNSKeys 列出单页密钥
|
||||
func (this *NSKeyService) ListEnabledNSKeys(ctx context.Context, req *pb.ListEnabledNSKeysRequest) (*pb.ListEnabledNSKeysResponse, error) {
|
||||
_, err := this.ValidateAdmin(ctx, 0)
|
||||
_, err := this.ValidateAdmin(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ type NSNodeService struct {
|
||||
|
||||
// FindAllEnabledNSNodesWithNSClusterId 根据集群查找所有节点
|
||||
func (this *NSNodeService) FindAllEnabledNSNodesWithNSClusterId(ctx context.Context, req *pb.FindAllEnabledNSNodesWithNSClusterIdRequest) (*pb.FindAllEnabledNSNodesWithNSClusterIdResponse, error) {
|
||||
_, err := this.ValidateAdmin(ctx, 0)
|
||||
_, err := this.ValidateAdmin(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -59,7 +59,7 @@ func (this *NSNodeService) FindAllEnabledNSNodesWithNSClusterId(ctx context.Cont
|
||||
|
||||
// CountAllEnabledNSNodes 所有可用的节点数量
|
||||
func (this *NSNodeService) CountAllEnabledNSNodes(ctx context.Context, req *pb.CountAllEnabledNSNodesRequest) (*pb.RPCCountResponse, error) {
|
||||
_, err := this.ValidateAdmin(ctx, 0)
|
||||
_, err := this.ValidateAdmin(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -74,7 +74,7 @@ func (this *NSNodeService) CountAllEnabledNSNodes(ctx context.Context, req *pb.C
|
||||
|
||||
// CountAllEnabledNSNodesMatch 计算匹配的节点数量
|
||||
func (this *NSNodeService) CountAllEnabledNSNodesMatch(ctx context.Context, req *pb.CountAllEnabledNSNodesMatchRequest) (*pb.RPCCountResponse, error) {
|
||||
_, err := this.ValidateAdmin(ctx, 0)
|
||||
_, err := this.ValidateAdmin(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -89,7 +89,7 @@ func (this *NSNodeService) CountAllEnabledNSNodesMatch(ctx context.Context, req
|
||||
|
||||
// ListEnabledNSNodesMatch 列出单页节点
|
||||
func (this *NSNodeService) ListEnabledNSNodesMatch(ctx context.Context, req *pb.ListEnabledNSNodesMatchRequest) (*pb.ListEnabledNSNodesMatchResponse, error) {
|
||||
_, err := this.ValidateAdmin(ctx, 0)
|
||||
_, err := this.ValidateAdmin(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -139,12 +139,12 @@ func (this *NSNodeService) ListEnabledNSNodesMatch(ctx context.Context, req *pb.
|
||||
// CountAllUpgradeNSNodesWithNSClusterId 计算需要升级的节点数量
|
||||
func (this *NSNodeService) CountAllUpgradeNSNodesWithNSClusterId(ctx context.Context, req *pb.CountAllUpgradeNSNodesWithNSClusterIdRequest) (*pb.RPCCountResponse, error) {
|
||||
// 校验请求
|
||||
_, err := this.ValidateAdmin(ctx, 0)
|
||||
_, err := this.ValidateAdmin(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
tx := this.NullTx()
|
||||
var tx = this.NullTx()
|
||||
|
||||
deployFiles := installers.SharedDeployManager.LoadNSNodeFiles()
|
||||
total := int64(0)
|
||||
@@ -161,12 +161,12 @@ func (this *NSNodeService) CountAllUpgradeNSNodesWithNSClusterId(ctx context.Con
|
||||
|
||||
// CreateNSNode 创建节点
|
||||
func (this *NSNodeService) CreateNSNode(ctx context.Context, req *pb.CreateNSNodeRequest) (*pb.CreateNSNodeResponse, error) {
|
||||
adminId, err := this.ValidateAdmin(ctx, 0)
|
||||
adminId, err := this.ValidateAdmin(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
tx := this.NullTx()
|
||||
var tx = this.NullTx()
|
||||
|
||||
nodeId, err := models.SharedNSNodeDAO.CreateNode(tx, adminId, req.Name, req.NodeClusterId)
|
||||
if err != nil {
|
||||
@@ -188,12 +188,12 @@ func (this *NSNodeService) CreateNSNode(ctx context.Context, req *pb.CreateNSNod
|
||||
|
||||
// DeleteNSNode 删除节点
|
||||
func (this *NSNodeService) DeleteNSNode(ctx context.Context, req *pb.DeleteNSNodeRequest) (*pb.RPCSuccess, error) {
|
||||
_, err := this.ValidateAdmin(ctx, 0)
|
||||
_, err := this.ValidateAdmin(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
tx := this.NullTx()
|
||||
var tx = this.NullTx()
|
||||
|
||||
err = models.SharedNSNodeDAO.DisableNSNode(tx, req.NsNodeId)
|
||||
if err != nil {
|
||||
@@ -211,12 +211,12 @@ func (this *NSNodeService) DeleteNSNode(ctx context.Context, req *pb.DeleteNSNod
|
||||
|
||||
// FindEnabledNSNode 查询单个节点信息
|
||||
func (this *NSNodeService) FindEnabledNSNode(ctx context.Context, req *pb.FindEnabledNSNodeRequest) (*pb.FindEnabledNSNodeResponse, error) {
|
||||
_, err := this.ValidateAdmin(ctx, 0)
|
||||
_, err := this.ValidateAdmin(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
tx := this.NullTx()
|
||||
var tx = this.NullTx()
|
||||
|
||||
node, err := models.SharedNSNodeDAO.FindEnabledNSNode(tx, req.NsNodeId)
|
||||
if err != nil {
|
||||
@@ -285,12 +285,12 @@ func (this *NSNodeService) FindEnabledNSNode(ctx context.Context, req *pb.FindEn
|
||||
|
||||
// UpdateNSNode 修改节点
|
||||
func (this *NSNodeService) UpdateNSNode(ctx context.Context, req *pb.UpdateNSNodeRequest) (*pb.RPCSuccess, error) {
|
||||
_, err := this.ValidateAdmin(ctx, 0)
|
||||
_, err := this.ValidateAdmin(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
tx := this.NullTx()
|
||||
var tx = this.NullTx()
|
||||
|
||||
err = models.SharedNSNodeDAO.UpdateNode(tx, req.NsNodeId, req.Name, req.NsClusterId, req.IsOn)
|
||||
if err != nil {
|
||||
@@ -322,7 +322,7 @@ func (this *NSNodeService) UpdateNSNode(ctx context.Context, req *pb.UpdateNSNod
|
||||
|
||||
// InstallNSNode 安装节点
|
||||
func (this *NSNodeService) InstallNSNode(ctx context.Context, req *pb.InstallNSNodeRequest) (*pb.InstallNSNodeResponse, error) {
|
||||
_, err := this.ValidateAdmin(ctx, 0)
|
||||
_, err := this.ValidateAdmin(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -340,12 +340,12 @@ func (this *NSNodeService) InstallNSNode(ctx context.Context, req *pb.InstallNSN
|
||||
// FindNSNodeInstallStatus 读取节点安装状态
|
||||
func (this *NSNodeService) FindNSNodeInstallStatus(ctx context.Context, req *pb.FindNSNodeInstallStatusRequest) (*pb.FindNSNodeInstallStatusResponse, error) {
|
||||
// 校验请求
|
||||
_, err := this.ValidateAdmin(ctx, 0)
|
||||
_, err := this.ValidateAdmin(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
tx := this.NullTx()
|
||||
var tx = this.NullTx()
|
||||
|
||||
installStatus, err := models.SharedNSNodeDAO.FindNodeInstallStatus(tx, req.NsNodeId)
|
||||
if err != nil {
|
||||
@@ -368,12 +368,12 @@ func (this *NSNodeService) FindNSNodeInstallStatus(ctx context.Context, req *pb.
|
||||
|
||||
// UpdateNSNodeIsInstalled 修改节点安装状态
|
||||
func (this *NSNodeService) UpdateNSNodeIsInstalled(ctx context.Context, req *pb.UpdateNSNodeIsInstalledRequest) (*pb.RPCSuccess, error) {
|
||||
_, err := this.ValidateAdmin(ctx, 0)
|
||||
_, err := this.ValidateAdmin(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
tx := this.NullTx()
|
||||
var tx = this.NullTx()
|
||||
|
||||
err = models.SharedNSNodeDAO.UpdateNodeIsInstalled(tx, req.NsNodeId, req.IsInstalled)
|
||||
if err != nil {
|
||||
@@ -502,7 +502,7 @@ func (this *NSNodeService) UpdateNSNodeConnectedAPINodes(ctx context.Context, re
|
||||
return nil, err
|
||||
}
|
||||
|
||||
tx := this.NullTx()
|
||||
var tx = this.NullTx()
|
||||
|
||||
err = models.SharedNSNodeDAO.UpdateNodeConnectedAPINodes(tx, nodeId, req.ApiNodeIds)
|
||||
if err != nil {
|
||||
@@ -515,12 +515,12 @@ func (this *NSNodeService) UpdateNSNodeConnectedAPINodes(ctx context.Context, re
|
||||
// UpdateNSNodeLogin 修改节点登录信息
|
||||
func (this *NSNodeService) UpdateNSNodeLogin(ctx context.Context, req *pb.UpdateNSNodeLoginRequest) (*pb.RPCSuccess, error) {
|
||||
// 校验请求
|
||||
_, err := this.ValidateAdmin(ctx, 0)
|
||||
_, err := this.ValidateAdmin(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
tx := this.NullTx()
|
||||
var tx = this.NullTx()
|
||||
|
||||
if req.NodeLogin.Id <= 0 {
|
||||
_, err := models.SharedNodeLoginDAO.CreateNodeLogin(tx, nodeconfigs.NodeRoleDNS, req.NsNodeId, req.NodeLogin.Name, req.NodeLogin.Type, req.NodeLogin.Params)
|
||||
@@ -537,7 +537,7 @@ func (this *NSNodeService) UpdateNSNodeLogin(ctx context.Context, req *pb.Update
|
||||
// StartNSNode 启动节点
|
||||
func (this *NSNodeService) StartNSNode(ctx context.Context, req *pb.StartNSNodeRequest) (*pb.StartNSNodeResponse, error) {
|
||||
// 校验节点
|
||||
_, err := this.ValidateAdmin(ctx, 0)
|
||||
_, err := this.ValidateAdmin(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -563,7 +563,7 @@ func (this *NSNodeService) StartNSNode(ctx context.Context, req *pb.StartNSNodeR
|
||||
// StopNSNode 停止节点
|
||||
func (this *NSNodeService) StopNSNode(ctx context.Context, req *pb.StopNSNodeRequest) (*pb.StopNSNodeResponse, error) {
|
||||
// 校验节点
|
||||
_, err := this.ValidateAdmin(ctx, 0)
|
||||
_, err := this.ValidateAdmin(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ func (this *NSNodeService) NsNodeStream(server pb.NSNodeService_NsNodeStreamServ
|
||||
|
||||
//logs.Println("[RPC]accepted ns node '" + types.String(nodeId) + "' connection")
|
||||
|
||||
tx := this.NullTx()
|
||||
var tx = this.NullTx()
|
||||
|
||||
// 标记为活跃状态
|
||||
oldIsActive, err := models.SharedNSNodeDAO.FindNodeActive(tx, nodeId)
|
||||
@@ -227,7 +227,7 @@ func (this *NSNodeService) NsNodeStream(server pb.NSNodeService_NsNodeStreamServ
|
||||
// SendCommandToNSNode 向节点发送命令
|
||||
func (this *NSNodeService) SendCommandToNSNode(ctx context.Context, req *pb.NSNodeStreamMessage) (*pb.NSNodeStreamMessage, error) {
|
||||
// 校验请求
|
||||
_, _, err := this.ValidateAdminAndUser(ctx, 0, 0)
|
||||
_, _, err := this.ValidateAdminAndUser(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ type NSQuestionOptionService struct {
|
||||
|
||||
// CreateNSQuestionOption 创建选项
|
||||
func (this *NSQuestionOptionService) CreateNSQuestionOption(ctx context.Context, req *pb.CreateNSQuestionOptionRequest) (*pb.CreateNSQuestionOptionResponse, error) {
|
||||
_, err := this.ValidateAdmin(ctx, 0)
|
||||
_, err := this.ValidateAdmin(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -63,7 +63,7 @@ func (this *NSQuestionOptionService) FindNSQuestionOption(ctx context.Context, r
|
||||
|
||||
// DeleteNSQuestionOption 删除选项
|
||||
func (this *NSQuestionOptionService) DeleteNSQuestionOption(ctx context.Context, req *pb.DeleteNSQuestionOptionRequest) (*pb.RPCSuccess, error) {
|
||||
_, err := this.ValidateAdmin(ctx, 0)
|
||||
_, err := this.ValidateAdmin(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user