mirror of
				https://github.com/TeaOSLab/EdgeAPI.git
				synced 2025-11-04 16:00:24 +08:00 
			
		
		
		
	优化代码/实现基础的实名认证功能
This commit is contained in:
		@@ -29,7 +29,7 @@ func init() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// 创建认证信息
 | 
					// 创建认证信息
 | 
				
			||||||
func (this *ACMEAuthenticationDAO) CreateAuth(tx *dbs.Tx, taskId int64, domain string, token string, key string) error {
 | 
					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.TaskId = taskId
 | 
				
			||||||
	op.Domain = domain
 | 
						op.Domain = domain
 | 
				
			||||||
	op.Token = token
 | 
						op.Token = token
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -169,7 +169,7 @@ func (this *ACMETaskDAO) ListEnabledACMETasks(tx *dbs.Tx, adminId int64, userId
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// CreateACMETask 创建任务
 | 
					// 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) {
 | 
					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.AdminId = adminId
 | 
				
			||||||
	op.UserId = userId
 | 
						op.UserId = userId
 | 
				
			||||||
	op.AuthType = authType
 | 
						op.AuthType = authType
 | 
				
			||||||
@@ -204,7 +204,7 @@ func (this *ACMETaskDAO) UpdateACMETask(tx *dbs.Tx, acmeTaskId int64, acmeUserId
 | 
				
			|||||||
		return errors.New("invalid acmeTaskId")
 | 
							return errors.New("invalid acmeTaskId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	op := NewACMETaskOperator()
 | 
						var op = NewACMETaskOperator()
 | 
				
			||||||
	op.Id = acmeTaskId
 | 
						op.Id = acmeTaskId
 | 
				
			||||||
	op.AcmeUserId = acmeUserId
 | 
						op.AcmeUserId = acmeUserId
 | 
				
			||||||
	op.DnsProviderId = dnsProviderId
 | 
						op.DnsProviderId = dnsProviderId
 | 
				
			||||||
@@ -240,7 +240,7 @@ func (this *ACMETaskDAO) UpdateACMETaskCert(tx *dbs.Tx, taskId int64, certId int
 | 
				
			|||||||
		return errors.New("invalid taskId")
 | 
							return errors.New("invalid taskId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	op := NewACMETaskOperator()
 | 
						var op = NewACMETaskOperator()
 | 
				
			||||||
	op.Id = taskId
 | 
						op.Id = taskId
 | 
				
			||||||
	op.CertId = certId
 | 
						op.CertId = certId
 | 
				
			||||||
	err := this.Save(tx, op)
 | 
						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 {
 | 
					func (this *ACMETaskLogDAO) CreateACMETaskLog(tx *dbs.Tx, taskId int64, isOk bool, errMsg string) error {
 | 
				
			||||||
	op := NewACMETaskLogOperator()
 | 
						var op = NewACMETaskLogOperator()
 | 
				
			||||||
	op.TaskId = taskId
 | 
						op.TaskId = taskId
 | 
				
			||||||
	op.Error = errMsg
 | 
						op.Error = errMsg
 | 
				
			||||||
	op.IsOk = isOk
 | 
						op.IsOk = isOk
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -83,7 +83,7 @@ func (this *ACMEUserDAO) CreateACMEUser(tx *dbs.Tx, adminId int64, userId int64,
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	privateKeyText := base64.StdEncoding.EncodeToString(privateKeyData)
 | 
						privateKeyText := base64.StdEncoding.EncodeToString(privateKeyData)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	op := NewACMEUserOperator()
 | 
						var op = NewACMEUserOperator()
 | 
				
			||||||
	op.AdminId = adminId
 | 
						op.AdminId = adminId
 | 
				
			||||||
	op.UserId = userId
 | 
						op.UserId = userId
 | 
				
			||||||
	op.ProviderCode = providerCode
 | 
						op.ProviderCode = providerCode
 | 
				
			||||||
@@ -104,7 +104,7 @@ func (this *ACMEUserDAO) UpdateACMEUser(tx *dbs.Tx, acmeUserId int64, descriptio
 | 
				
			|||||||
	if acmeUserId <= 0 {
 | 
						if acmeUserId <= 0 {
 | 
				
			||||||
		return errors.New("invalid acmeUserId")
 | 
							return errors.New("invalid acmeUserId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewACMEUserOperator()
 | 
						var op = NewACMEUserOperator()
 | 
				
			||||||
	op.Id = acmeUserId
 | 
						op.Id = acmeUserId
 | 
				
			||||||
	op.Description = description
 | 
						op.Description = description
 | 
				
			||||||
	err := this.Save(tx, op)
 | 
						err := this.Save(tx, op)
 | 
				
			||||||
@@ -116,7 +116,7 @@ func (this *ACMEUserDAO) UpdateACMEUserRegistration(tx *dbs.Tx, acmeUserId int64
 | 
				
			|||||||
	if acmeUserId <= 0 {
 | 
						if acmeUserId <= 0 {
 | 
				
			||||||
		return errors.New("invalid acmeUserId")
 | 
							return errors.New("invalid acmeUserId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewACMEUserOperator()
 | 
						var op = NewACMEUserOperator()
 | 
				
			||||||
	op.Id = acmeUserId
 | 
						op.Id = acmeUserId
 | 
				
			||||||
	op.Registration = registrationJSON
 | 
						op.Registration = registrationJSON
 | 
				
			||||||
	err := this.Save(tx, op)
 | 
						err := this.Save(tx, op)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -115,7 +115,7 @@ func (this *AdminDAO) UpdateAdminPassword(tx *dbs.Tx, adminId int64, password st
 | 
				
			|||||||
	if adminId <= 0 {
 | 
						if adminId <= 0 {
 | 
				
			||||||
		return errors.New("invalid adminId")
 | 
							return errors.New("invalid adminId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewAdminOperator()
 | 
						var op = NewAdminOperator()
 | 
				
			||||||
	op.Id = adminId
 | 
						op.Id = adminId
 | 
				
			||||||
	op.Password = stringutil.Md5(password)
 | 
						op.Password = stringutil.Md5(password)
 | 
				
			||||||
	err := this.Save(tx, op)
 | 
						err := this.Save(tx, op)
 | 
				
			||||||
@@ -124,7 +124,7 @@ func (this *AdminDAO) UpdateAdminPassword(tx *dbs.Tx, adminId int64, password st
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// CreateAdmin 创建管理员
 | 
					// CreateAdmin 创建管理员
 | 
				
			||||||
func (this *AdminDAO) CreateAdmin(tx *dbs.Tx, username string, canLogin bool, password string, fullname string, isSuper bool, modulesJSON []byte) (int64, error) {
 | 
					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.IsOn = true
 | 
				
			||||||
	op.State = AdminStateEnabled
 | 
						op.State = AdminStateEnabled
 | 
				
			||||||
	op.Username = username
 | 
						op.Username = username
 | 
				
			||||||
@@ -149,7 +149,7 @@ func (this *AdminDAO) UpdateAdminInfo(tx *dbs.Tx, adminId int64, fullname string
 | 
				
			|||||||
	if adminId <= 0 {
 | 
						if adminId <= 0 {
 | 
				
			||||||
		return errors.New("invalid adminId")
 | 
							return errors.New("invalid adminId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewAdminOperator()
 | 
						var op = NewAdminOperator()
 | 
				
			||||||
	op.Id = adminId
 | 
						op.Id = adminId
 | 
				
			||||||
	op.Fullname = fullname
 | 
						op.Fullname = fullname
 | 
				
			||||||
	err := this.Save(tx, op)
 | 
						err := this.Save(tx, op)
 | 
				
			||||||
@@ -161,7 +161,7 @@ func (this *AdminDAO) UpdateAdmin(tx *dbs.Tx, adminId int64, username string, ca
 | 
				
			|||||||
	if adminId <= 0 {
 | 
						if adminId <= 0 {
 | 
				
			||||||
		return errors.New("invalid adminId")
 | 
							return errors.New("invalid adminId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewAdminOperator()
 | 
						var op = NewAdminOperator()
 | 
				
			||||||
	op.Id = adminId
 | 
						op.Id = adminId
 | 
				
			||||||
	op.Fullname = fullname
 | 
						op.Fullname = fullname
 | 
				
			||||||
	op.Username = username
 | 
						op.Username = username
 | 
				
			||||||
@@ -198,7 +198,7 @@ func (this *AdminDAO) UpdateAdminLogin(tx *dbs.Tx, adminId int64, username strin
 | 
				
			|||||||
	if adminId <= 0 {
 | 
						if adminId <= 0 {
 | 
				
			||||||
		return errors.New("invalid adminId")
 | 
							return errors.New("invalid adminId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewAdminOperator()
 | 
						var op = NewAdminOperator()
 | 
				
			||||||
	op.Id = adminId
 | 
						op.Id = adminId
 | 
				
			||||||
	op.Username = username
 | 
						op.Username = username
 | 
				
			||||||
	if len(password) > 0 {
 | 
						if len(password) > 0 {
 | 
				
			||||||
@@ -213,7 +213,7 @@ func (this *AdminDAO) UpdateAdminModules(tx *dbs.Tx, adminId int64, allowModules
 | 
				
			|||||||
	if adminId <= 0 {
 | 
						if adminId <= 0 {
 | 
				
			||||||
		return errors.New("invalid adminId")
 | 
							return errors.New("invalid adminId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewAdminOperator()
 | 
						var op = NewAdminOperator()
 | 
				
			||||||
	op.Id = adminId
 | 
						op.Id = adminId
 | 
				
			||||||
	op.Modules = allowModulesJSON
 | 
						op.Modules = allowModulesJSON
 | 
				
			||||||
	err := this.Save(tx, op)
 | 
						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)) 算法来代替
 | 
						token = rands.String(128) // TODO 增强安全性,将来使用 base64_encode(encrypt(salt+random)) 算法来代替
 | 
				
			||||||
	expiresAt = time.Now().Unix() + 7200
 | 
						expiresAt = time.Now().Unix() + 7200
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	op := NewAPIAccessTokenOperator()
 | 
						var op = NewAPIAccessTokenOperator()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if accessToken != nil {
 | 
						if accessToken != nil {
 | 
				
			||||||
		op.Id = accessToken.(*APIAccessToken).Id
 | 
							op.Id = accessToken.(*APIAccessToken).Id
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -134,7 +134,7 @@ func (this *APINodeDAO) CreateAPINode(tx *dbs.Tx, name string, description strin
 | 
				
			|||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	op := NewAPINodeOperator()
 | 
						var op = NewAPINodeOperator()
 | 
				
			||||||
	op.IsOn = isOn
 | 
						op.IsOn = isOn
 | 
				
			||||||
	op.UniqueId = uniqueId
 | 
						op.UniqueId = uniqueId
 | 
				
			||||||
	op.Secret = secret
 | 
						op.Secret = secret
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -112,7 +112,7 @@ func (this *ApiTokenDAO) FindEnabledTokenWithRole(tx *dbs.Tx, role string) (*Api
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// CreateAPIToken 保存API Token
 | 
					// CreateAPIToken 保存API Token
 | 
				
			||||||
func (this *ApiTokenDAO) CreateAPIToken(tx *dbs.Tx, nodeId string, secret string, role nodeconfigs.NodeRole) error {
 | 
					func (this *ApiTokenDAO) CreateAPIToken(tx *dbs.Tx, nodeId string, secret string, role nodeconfigs.NodeRole) error {
 | 
				
			||||||
	op := NewApiTokenOperator()
 | 
						var op = NewApiTokenOperator()
 | 
				
			||||||
	op.NodeId = nodeId
 | 
						op.NodeId = nodeId
 | 
				
			||||||
	op.Secret = secret
 | 
						op.Secret = secret
 | 
				
			||||||
	op.Role = role
 | 
						op.Role = role
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -42,7 +42,7 @@ func (this *AuthorityKeyDAO) UpdateKey(tx *dbs.Tx, value string, dayFrom string,
 | 
				
			|||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewAuthorityKeyOperator()
 | 
						var op = NewAuthorityKeyOperator()
 | 
				
			||||||
	if one != nil {
 | 
						if one != nil {
 | 
				
			||||||
		op.Id = one.(*AuthorityKey).Id
 | 
							op.Id = one.(*AuthorityKey).Id
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -120,7 +120,7 @@ func (this *AuthorityNodeDAO) CreateAuthorityNode(tx *dbs.Tx, name string, descr
 | 
				
			|||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	op := NewAuthorityNodeOperator()
 | 
						var op = NewAuthorityNodeOperator()
 | 
				
			||||||
	op.IsOn = isOn
 | 
						op.IsOn = isOn
 | 
				
			||||||
	op.UniqueId = uniqueId
 | 
						op.UniqueId = uniqueId
 | 
				
			||||||
	op.Secret = secret
 | 
						op.Secret = secret
 | 
				
			||||||
@@ -141,7 +141,7 @@ func (this *AuthorityNodeDAO) UpdateAuthorityNode(tx *dbs.Tx, nodeId int64, name
 | 
				
			|||||||
		return errors.New("invalid nodeId")
 | 
							return errors.New("invalid nodeId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	op := NewAuthorityNodeOperator()
 | 
						var op = NewAuthorityNodeOperator()
 | 
				
			||||||
	op.Id = nodeId
 | 
						op.Id = nodeId
 | 
				
			||||||
	op.Name = name
 | 
						op.Name = name
 | 
				
			||||||
	op.Description = description
 | 
						op.Description = description
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -125,7 +125,7 @@ func (this *ClientBrowserDAO) CreateBrowser(tx *dbs.Tx, browserName string) (int
 | 
				
			|||||||
		return browserId, nil
 | 
							return browserId, nil
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	op := NewClientBrowserOperator()
 | 
						var op = NewClientBrowserOperator()
 | 
				
			||||||
	op.Name = browserName
 | 
						op.Name = browserName
 | 
				
			||||||
	codes := []string{browserName}
 | 
						codes := []string{browserName}
 | 
				
			||||||
	codesJSON, err := json.Marshal(codes)
 | 
						codesJSON, err := json.Marshal(codes)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -125,7 +125,7 @@ func (this *ClientSystemDAO) CreateSystem(tx *dbs.Tx, systemName string) (int64,
 | 
				
			|||||||
		return systemId, nil
 | 
							return systemId, nil
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	op := NewClientSystemOperator()
 | 
						var op = NewClientSystemOperator()
 | 
				
			||||||
	op.Name = systemName
 | 
						op.Name = systemName
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	codes := []string{systemName}
 | 
						codes := []string{systemName}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -109,7 +109,7 @@ func (this *DBNodeDAO) ListEnabledNodes(tx *dbs.Tx, offset int64, size int64) (r
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// CreateDBNode 创建节点
 | 
					// 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) {
 | 
					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.State = NodeStateEnabled
 | 
				
			||||||
	op.IsOn = isOn
 | 
						op.IsOn = isOn
 | 
				
			||||||
	op.Name = name
 | 
						op.Name = name
 | 
				
			||||||
@@ -132,7 +132,7 @@ func (this *DBNodeDAO) UpdateNode(tx *dbs.Tx, nodeId int64, isOn bool, name stri
 | 
				
			|||||||
	if nodeId <= 0 {
 | 
						if nodeId <= 0 {
 | 
				
			||||||
		return errors.New("invalid nodeId")
 | 
							return errors.New("invalid nodeId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewDBNodeOperator()
 | 
						var op = NewDBNodeOperator()
 | 
				
			||||||
	op.Id = nodeId
 | 
						op.Id = nodeId
 | 
				
			||||||
	op.IsOn = isOn
 | 
						op.IsOn = isOn
 | 
				
			||||||
	op.Name = name
 | 
						op.Name = name
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -91,7 +91,7 @@ func (this *DNSDomainDAO) FindDNSDomainName(tx *dbs.Tx, id int64) (string, error
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// CreateDomain 创建域名
 | 
					// CreateDomain 创建域名
 | 
				
			||||||
func (this *DNSDomainDAO) CreateDomain(tx *dbs.Tx, adminId int64, userId int64, providerId int64, name string) (int64, error) {
 | 
					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.ProviderId = providerId
 | 
				
			||||||
	op.AdminId = adminId
 | 
						op.AdminId = adminId
 | 
				
			||||||
	op.UserId = userId
 | 
						op.UserId = userId
 | 
				
			||||||
@@ -111,7 +111,7 @@ func (this *DNSDomainDAO) UpdateDomain(tx *dbs.Tx, domainId int64, name string,
 | 
				
			|||||||
	if domainId <= 0 {
 | 
						if domainId <= 0 {
 | 
				
			||||||
		return errors.New("invalid domainId")
 | 
							return errors.New("invalid domainId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewDNSDomainOperator()
 | 
						var op = NewDNSDomainOperator()
 | 
				
			||||||
	op.Id = domainId
 | 
						op.Id = domainId
 | 
				
			||||||
	op.Name = name
 | 
						op.Name = name
 | 
				
			||||||
	op.IsOn = isOn
 | 
						op.IsOn = isOn
 | 
				
			||||||
@@ -146,7 +146,7 @@ func (this *DNSDomainDAO) UpdateDomainData(tx *dbs.Tx, domainId int64, data stri
 | 
				
			|||||||
	if domainId <= 0 {
 | 
						if domainId <= 0 {
 | 
				
			||||||
		return errors.New("invalid domainId")
 | 
							return errors.New("invalid domainId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewDNSDomainOperator()
 | 
						var op = NewDNSDomainOperator()
 | 
				
			||||||
	op.Id = domainId
 | 
						op.Id = domainId
 | 
				
			||||||
	op.Data = data
 | 
						op.Data = data
 | 
				
			||||||
	err := this.Save(tx, op)
 | 
						err := this.Save(tx, op)
 | 
				
			||||||
@@ -158,7 +158,7 @@ func (this *DNSDomainDAO) UpdateDomainRecords(tx *dbs.Tx, domainId int64, record
 | 
				
			|||||||
	if domainId <= 0 {
 | 
						if domainId <= 0 {
 | 
				
			||||||
		return errors.New("invalid domainId")
 | 
							return errors.New("invalid domainId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewDNSDomainOperator()
 | 
						var op = NewDNSDomainOperator()
 | 
				
			||||||
	op.Id = domainId
 | 
						op.Id = domainId
 | 
				
			||||||
	op.Records = recordsJSON
 | 
						op.Records = recordsJSON
 | 
				
			||||||
	op.DataUpdatedAt = time.Now().Unix()
 | 
						op.DataUpdatedAt = time.Now().Unix()
 | 
				
			||||||
@@ -171,7 +171,7 @@ func (this *DNSDomainDAO) UpdateDomainRoutes(tx *dbs.Tx, domainId int64, routesJ
 | 
				
			|||||||
	if domainId <= 0 {
 | 
						if domainId <= 0 {
 | 
				
			||||||
		return errors.New("invalid domainId")
 | 
							return errors.New("invalid domainId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewDNSDomainOperator()
 | 
						var op = NewDNSDomainOperator()
 | 
				
			||||||
	op.Id = domainId
 | 
						op.Id = domainId
 | 
				
			||||||
	op.Routes = routesJSON
 | 
						op.Routes = routesJSON
 | 
				
			||||||
	op.DataUpdatedAt = time.Now().Unix()
 | 
						op.DataUpdatedAt = time.Now().Unix()
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -68,7 +68,7 @@ func (this *DNSProviderDAO) FindEnabledDNSProvider(tx *dbs.Tx, id int64) (*DNSPr
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// CreateDNSProvider 创建服务商
 | 
					// CreateDNSProvider 创建服务商
 | 
				
			||||||
func (this *DNSProviderDAO) CreateDNSProvider(tx *dbs.Tx, adminId int64, userId int64, providerType string, name string, apiParamsJSON []byte) (int64, error) {
 | 
					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.AdminId = adminId
 | 
				
			||||||
	op.UserId = userId
 | 
						op.UserId = userId
 | 
				
			||||||
	op.Type = providerType
 | 
						op.Type = providerType
 | 
				
			||||||
@@ -90,7 +90,7 @@ func (this *DNSProviderDAO) UpdateDNSProvider(tx *dbs.Tx, dnsProviderId int64, n
 | 
				
			|||||||
		return errors.New("invalid dnsProviderId")
 | 
							return errors.New("invalid dnsProviderId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	op := NewDNSProviderOperator()
 | 
						var op = NewDNSProviderOperator()
 | 
				
			||||||
	op.Id = dnsProviderId
 | 
						op.Id = dnsProviderId
 | 
				
			||||||
	op.Name = name
 | 
						op.Name = name
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -143,7 +143,7 @@ func (this *DNSTaskDAO) UpdateDNSTaskError(tx *dbs.Tx, taskId int64, err string)
 | 
				
			|||||||
	if taskId <= 0 {
 | 
						if taskId <= 0 {
 | 
				
			||||||
		return errors.New("invalid taskId")
 | 
							return errors.New("invalid taskId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewDNSTaskOperator()
 | 
						var op = NewDNSTaskOperator()
 | 
				
			||||||
	op.Id = taskId
 | 
						op.Id = taskId
 | 
				
			||||||
	op.IsDone = true
 | 
						op.IsDone = true
 | 
				
			||||||
	op.Error = err
 | 
						op.Error = err
 | 
				
			||||||
@@ -156,7 +156,7 @@ func (this *DNSTaskDAO) UpdateDNSTaskDone(tx *dbs.Tx, taskId int64) error {
 | 
				
			|||||||
	if taskId <= 0 {
 | 
						if taskId <= 0 {
 | 
				
			||||||
		return errors.New("invalid taskId")
 | 
							return errors.New("invalid taskId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewDNSTaskOperator()
 | 
						var op = NewDNSTaskOperator()
 | 
				
			||||||
	op.Id = taskId
 | 
						op.Id = taskId
 | 
				
			||||||
	op.IsDone = true
 | 
						op.IsDone = true
 | 
				
			||||||
	op.IsOk = 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) {
 | 
					func (this *FileChunkDAO) CreateFileChunk(tx *dbs.Tx, fileId int64, data []byte) (int64, error) {
 | 
				
			||||||
	op := NewFileChunkOperator()
 | 
						var op = NewFileChunkOperator()
 | 
				
			||||||
	op.FileId = fileId
 | 
						op.FileId = fileId
 | 
				
			||||||
	op.Data = data
 | 
						op.Data = data
 | 
				
			||||||
	err := this.Save(tx, op)
 | 
						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
 | 
						return types.Int64(op.Id), nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// 列出所有的文件Chunk
 | 
					// FindAllFileChunks 列出所有的文件Chunk
 | 
				
			||||||
func (this *FileChunkDAO) FindAllFileChunks(tx *dbs.Tx, fileId int64) (result []*FileChunk, err error) {
 | 
					func (this *FileChunkDAO) FindAllFileChunks(tx *dbs.Tx, fileId int64) (result []*FileChunk, err error) {
 | 
				
			||||||
	_, err = this.Query(tx).
 | 
						_, err = this.Query(tx).
 | 
				
			||||||
		Attr("fileId", fileId).
 | 
							Attr("fileId", fileId).
 | 
				
			||||||
@@ -51,7 +51,7 @@ func (this *FileChunkDAO) FindAllFileChunks(tx *dbs.Tx, fileId int64) (result []
 | 
				
			|||||||
	return
 | 
						return
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// 读取文件的所有片段ID
 | 
					// FindAllFileChunkIds 读取文件的所有片段ID
 | 
				
			||||||
func (this *FileChunkDAO) FindAllFileChunkIds(tx *dbs.Tx, fileId int64) ([]int64, error) {
 | 
					func (this *FileChunkDAO) FindAllFileChunkIds(tx *dbs.Tx, fileId int64) ([]int64, error) {
 | 
				
			||||||
	ones, err := this.Query(tx).
 | 
						ones, err := this.Query(tx).
 | 
				
			||||||
		Attr("fileId", fileId).
 | 
							Attr("fileId", fileId).
 | 
				
			||||||
@@ -68,7 +68,7 @@ func (this *FileChunkDAO) FindAllFileChunkIds(tx *dbs.Tx, fileId int64) ([]int64
 | 
				
			|||||||
	return result, nil
 | 
						return result, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// 删除以前的文件
 | 
					// DeleteFileChunks 删除以前的文件
 | 
				
			||||||
func (this *FileChunkDAO) DeleteFileChunks(tx *dbs.Tx, fileId int64) error {
 | 
					func (this *FileChunkDAO) DeleteFileChunks(tx *dbs.Tx, fileId int64) error {
 | 
				
			||||||
	if fileId <= 0 {
 | 
						if fileId <= 0 {
 | 
				
			||||||
		return errors.New("invalid fileId")
 | 
							return errors.New("invalid fileId")
 | 
				
			||||||
@@ -79,7 +79,7 @@ func (this *FileChunkDAO) DeleteFileChunks(tx *dbs.Tx, fileId int64) error {
 | 
				
			|||||||
	return err
 | 
						return err
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// 根据ID查找片段
 | 
					// FindFileChunk 根据ID查找片段
 | 
				
			||||||
func (this *FileChunkDAO) FindFileChunk(tx *dbs.Tx, chunkId int64) (*FileChunk, error) {
 | 
					func (this *FileChunkDAO) FindFileChunk(tx *dbs.Tx, chunkId int64) (*FileChunk, error) {
 | 
				
			||||||
	one, err := this.Query(tx).
 | 
						one, err := this.Query(tx).
 | 
				
			||||||
		Pk(chunkId).
 | 
							Pk(chunkId).
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -65,7 +65,7 @@ func (this *FileDAO) FindEnabledFile(tx *dbs.Tx, id int64) (*File, error) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// CreateFile 创建文件
 | 
					// 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()
 | 
						var op = NewFileOperator()
 | 
				
			||||||
	op.AdminId = adminId
 | 
						op.AdminId = adminId
 | 
				
			||||||
	op.UserId = userId
 | 
						op.UserId = userId
 | 
				
			||||||
@@ -76,6 +76,7 @@ func (this *FileDAO) CreateFile(tx *dbs.Tx, adminId int64, userId int64, busines
 | 
				
			|||||||
	op.Filename = filename
 | 
						op.Filename = filename
 | 
				
			||||||
	op.IsPublic = isPublic
 | 
						op.IsPublic = isPublic
 | 
				
			||||||
	op.Code = utils.Sha1RandomString()
 | 
						op.Code = utils.Sha1RandomString()
 | 
				
			||||||
 | 
						op.MimeType = mimeType
 | 
				
			||||||
	err := this.Save(tx, op)
 | 
						err := this.Save(tx, op)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return 0, err
 | 
							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
 | 
						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 将文件置为已完成
 | 
					// UpdateFileIsFinished 将文件置为已完成
 | 
				
			||||||
func (this *FileDAO) UpdateFileIsFinished(tx *dbs.Tx, fileId int64) error {
 | 
					func (this *FileDAO) UpdateFileIsFinished(tx *dbs.Tx, fileId int64) error {
 | 
				
			||||||
	_, err := this.Query(tx).
 | 
						_, err := this.Query(tx).
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,6 +9,7 @@ type File struct {
 | 
				
			|||||||
	Description string `field:"description"` // 文件描述
 | 
						Description string `field:"description"` // 文件描述
 | 
				
			||||||
	Filename    string `field:"filename"`    // 文件名
 | 
						Filename    string `field:"filename"`    // 文件名
 | 
				
			||||||
	Size        uint32 `field:"size"`        // 文件尺寸
 | 
						Size        uint32 `field:"size"`        // 文件尺寸
 | 
				
			||||||
 | 
						MimeType    string `field:"mimeType"`    // Mime类型
 | 
				
			||||||
	CreatedAt   uint64 `field:"createdAt"`   // 创建时间
 | 
						CreatedAt   uint64 `field:"createdAt"`   // 创建时间
 | 
				
			||||||
	Order       uint32 `field:"order"`       // 排序
 | 
						Order       uint32 `field:"order"`       // 排序
 | 
				
			||||||
	Type        string `field:"type"`        // 类型
 | 
						Type        string `field:"type"`        // 类型
 | 
				
			||||||
@@ -25,6 +26,7 @@ type FileOperator struct {
 | 
				
			|||||||
	Description interface{} // 文件描述
 | 
						Description interface{} // 文件描述
 | 
				
			||||||
	Filename    interface{} // 文件名
 | 
						Filename    interface{} // 文件名
 | 
				
			||||||
	Size        interface{} // 文件尺寸
 | 
						Size        interface{} // 文件尺寸
 | 
				
			||||||
 | 
						MimeType    interface{} // Mime类型
 | 
				
			||||||
	CreatedAt   interface{} // 创建时间
 | 
						CreatedAt   interface{} // 创建时间
 | 
				
			||||||
	Order       interface{} // 排序
 | 
						Order       interface{} // 排序
 | 
				
			||||||
	Type        interface{} // 类型
 | 
						Type        interface{} // 类型
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -69,7 +69,7 @@ func (this *HTTPAuthPolicyDAO) FindEnabledHTTPAuthPolicy(tx *dbs.Tx, id int64) (
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// CreateHTTPAuthPolicy 创建策略
 | 
					// CreateHTTPAuthPolicy 创建策略
 | 
				
			||||||
func (this *HTTPAuthPolicyDAO) CreateHTTPAuthPolicy(tx *dbs.Tx, name string, methodType string, paramsJSON []byte) (int64, error) {
 | 
					func (this *HTTPAuthPolicyDAO) CreateHTTPAuthPolicy(tx *dbs.Tx, name string, methodType string, paramsJSON []byte) (int64, error) {
 | 
				
			||||||
	op := NewHTTPAuthPolicyOperator()
 | 
						var op = NewHTTPAuthPolicyOperator()
 | 
				
			||||||
	op.Name = name
 | 
						op.Name = name
 | 
				
			||||||
	op.Type = methodType
 | 
						op.Type = methodType
 | 
				
			||||||
	op.Params = paramsJSON
 | 
						op.Params = paramsJSON
 | 
				
			||||||
@@ -83,7 +83,7 @@ func (this *HTTPAuthPolicyDAO) UpdateHTTPAuthPolicy(tx *dbs.Tx, policyId int64,
 | 
				
			|||||||
	if policyId <= 0 {
 | 
						if policyId <= 0 {
 | 
				
			||||||
		return errors.New("invalid policyId")
 | 
							return errors.New("invalid policyId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewHTTPAuthPolicyOperator()
 | 
						var op = NewHTTPAuthPolicyOperator()
 | 
				
			||||||
	op.Id = policyId
 | 
						op.Id = policyId
 | 
				
			||||||
	op.Name = name
 | 
						op.Name = name
 | 
				
			||||||
	op.Params = paramsJSON
 | 
						op.Params = paramsJSON
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -113,7 +113,7 @@ func (this *HTTPBrotliPolicyDAO) ComposeBrotliConfig(tx *dbs.Tx, policyId int64)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// CreatePolicy 创建策略
 | 
					// CreatePolicy 创建策略
 | 
				
			||||||
func (this *HTTPBrotliPolicyDAO) CreatePolicy(tx *dbs.Tx, level int, minLengthJSON []byte, maxLengthJSON []byte, condsJSON []byte) (int64, error) {
 | 
					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.State = HTTPBrotliPolicyStateEnabled
 | 
				
			||||||
	op.IsOn = true
 | 
						op.IsOn = true
 | 
				
			||||||
	op.Level = level
 | 
						op.Level = level
 | 
				
			||||||
@@ -138,7 +138,7 @@ func (this *HTTPBrotliPolicyDAO) UpdatePolicy(tx *dbs.Tx, policyId int64, level
 | 
				
			|||||||
	if policyId <= 0 {
 | 
						if policyId <= 0 {
 | 
				
			||||||
		return errors.New("invalid policyId")
 | 
							return errors.New("invalid policyId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewHTTPBrotliPolicyOperator()
 | 
						var op = NewHTTPBrotliPolicyOperator()
 | 
				
			||||||
	op.Id = policyId
 | 
						op.Id = policyId
 | 
				
			||||||
	op.Level = level
 | 
						op.Level = level
 | 
				
			||||||
	if len(minLengthJSON) > 0 {
 | 
						if len(minLengthJSON) > 0 {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -97,7 +97,7 @@ func (this *HTTPCachePolicyDAO) FindAllEnabledCachePolicies(tx *dbs.Tx) (result
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// CreateCachePolicy 创建缓存策略
 | 
					// 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) {
 | 
					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.State = HTTPCachePolicyStateEnabled
 | 
				
			||||||
	op.IsOn = isOn
 | 
						op.IsOn = isOn
 | 
				
			||||||
	op.Name = name
 | 
						op.Name = name
 | 
				
			||||||
@@ -209,7 +209,7 @@ func (this *HTTPCachePolicyDAO) UpdateCachePolicy(tx *dbs.Tx, policyId int64, is
 | 
				
			|||||||
		return errors.New("invalid policyId")
 | 
							return errors.New("invalid policyId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	op := NewHTTPCachePolicyOperator()
 | 
						var op = NewHTTPCachePolicyOperator()
 | 
				
			||||||
	op.Id = policyId
 | 
						op.Id = policyId
 | 
				
			||||||
	op.IsOn = isOn
 | 
						op.IsOn = isOn
 | 
				
			||||||
	op.Name = name
 | 
						op.Name = name
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -113,7 +113,7 @@ func (this *HTTPDeflatePolicyDAO) ComposeDeflateConfig(tx *dbs.Tx, policyId int6
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// CreatePolicy 创建策略
 | 
					// CreatePolicy 创建策略
 | 
				
			||||||
func (this *HTTPDeflatePolicyDAO) CreatePolicy(tx *dbs.Tx, level int, minLengthJSON []byte, maxLengthJSON []byte, condsJSON []byte) (int64, error) {
 | 
					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.State = HTTPDeflatePolicyStateEnabled
 | 
				
			||||||
	op.IsOn = true
 | 
						op.IsOn = true
 | 
				
			||||||
	op.Level = level
 | 
						op.Level = level
 | 
				
			||||||
@@ -138,7 +138,7 @@ func (this *HTTPDeflatePolicyDAO) UpdatePolicy(tx *dbs.Tx, policyId int64, level
 | 
				
			|||||||
	if policyId <= 0 {
 | 
						if policyId <= 0 {
 | 
				
			||||||
		return errors.New("invalid policyId")
 | 
							return errors.New("invalid policyId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewHTTPDeflatePolicyOperator()
 | 
						var op = NewHTTPDeflatePolicyOperator()
 | 
				
			||||||
	op.Id = policyId
 | 
						op.Id = policyId
 | 
				
			||||||
	op.Level = level
 | 
						op.Level = level
 | 
				
			||||||
	if len(minLengthJSON) > 0 {
 | 
						if len(minLengthJSON) > 0 {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -121,7 +121,7 @@ func (this *HTTPFastcgiDAO) ComposeFastcgiConfig(tx *dbs.Tx, fastcgiId int64) (*
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// CreateFastcgi 创建Fastcgi
 | 
					// 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) {
 | 
					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.AdminId = adminId
 | 
				
			||||||
	op.UserId = userId
 | 
						op.UserId = userId
 | 
				
			||||||
	op.IsOn = isOn
 | 
						op.IsOn = isOn
 | 
				
			||||||
@@ -147,7 +147,7 @@ func (this *HTTPFastcgiDAO) UpdateFastcgi(tx *dbs.Tx, fastcgiId int64, isOn bool
 | 
				
			|||||||
	if fastcgiId <= 0 {
 | 
						if fastcgiId <= 0 {
 | 
				
			||||||
		return errors.New("invalid 'fastcgiId'")
 | 
							return errors.New("invalid 'fastcgiId'")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewHTTPFastcgiOperator()
 | 
						var op = NewHTTPFastcgiOperator()
 | 
				
			||||||
	op.Id = fastcgiId
 | 
						op.Id = fastcgiId
 | 
				
			||||||
	op.IsOn = isOn
 | 
						op.IsOn = isOn
 | 
				
			||||||
	op.Address = address
 | 
						op.Address = address
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -233,7 +233,7 @@ func (this *HTTPFirewallPolicyDAO) UpdateFirewallPolicyInboundAndOutbound(tx *db
 | 
				
			|||||||
	if policyId <= 0 {
 | 
						if policyId <= 0 {
 | 
				
			||||||
		return errors.New("invalid policyId")
 | 
							return errors.New("invalid policyId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewHTTPFirewallPolicyOperator()
 | 
						var op = NewHTTPFirewallPolicyOperator()
 | 
				
			||||||
	op.Id = policyId
 | 
						op.Id = policyId
 | 
				
			||||||
	if len(inboundJSON) > 0 {
 | 
						if len(inboundJSON) > 0 {
 | 
				
			||||||
		op.Inbound = inboundJSON
 | 
							op.Inbound = inboundJSON
 | 
				
			||||||
@@ -262,7 +262,7 @@ func (this *HTTPFirewallPolicyDAO) UpdateFirewallPolicyInbound(tx *dbs.Tx, polic
 | 
				
			|||||||
	if policyId <= 0 {
 | 
						if policyId <= 0 {
 | 
				
			||||||
		return errors.New("invalid policyId")
 | 
							return errors.New("invalid policyId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewHTTPFirewallPolicyOperator()
 | 
						var op = NewHTTPFirewallPolicyOperator()
 | 
				
			||||||
	op.Id = policyId
 | 
						op.Id = policyId
 | 
				
			||||||
	if len(inboundJSON) > 0 {
 | 
						if len(inboundJSON) > 0 {
 | 
				
			||||||
		op.Inbound = inboundJSON
 | 
							op.Inbound = inboundJSON
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -116,7 +116,7 @@ func (this *HTTPFirewallRuleDAO) ComposeFirewallRule(tx *dbs.Tx, ruleId int64) (
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// CreateOrUpdateRuleFromConfig 从配置中配置规则
 | 
					// CreateOrUpdateRuleFromConfig 从配置中配置规则
 | 
				
			||||||
func (this *HTTPFirewallRuleDAO) CreateOrUpdateRuleFromConfig(tx *dbs.Tx, ruleConfig *firewallconfigs.HTTPFirewallRule) (int64, error) {
 | 
					func (this *HTTPFirewallRuleDAO) CreateOrUpdateRuleFromConfig(tx *dbs.Tx, ruleConfig *firewallconfigs.HTTPFirewallRule) (int64, error) {
 | 
				
			||||||
	op := NewHTTPFirewallRuleOperator()
 | 
						var op = NewHTTPFirewallRuleOperator()
 | 
				
			||||||
	op.Id = ruleConfig.Id
 | 
						op.Id = ruleConfig.Id
 | 
				
			||||||
	op.State = HTTPFirewallRuleStateEnabled
 | 
						op.State = HTTPFirewallRuleStateEnabled
 | 
				
			||||||
	op.IsOn = ruleConfig.IsOn
 | 
						op.IsOn = ruleConfig.IsOn
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -120,7 +120,7 @@ func (this *HTTPFirewallRuleGroupDAO) ComposeFirewallRuleGroup(tx *dbs.Tx, group
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// CreateGroupFromConfig 从配置中创建分组
 | 
					// CreateGroupFromConfig 从配置中创建分组
 | 
				
			||||||
func (this *HTTPFirewallRuleGroupDAO) CreateGroupFromConfig(tx *dbs.Tx, groupConfig *firewallconfigs.HTTPFirewallRuleGroup) (int64, error) {
 | 
					func (this *HTTPFirewallRuleGroupDAO) CreateGroupFromConfig(tx *dbs.Tx, groupConfig *firewallconfigs.HTTPFirewallRuleGroup) (int64, error) {
 | 
				
			||||||
	op := NewHTTPFirewallRuleGroupOperator()
 | 
						var op = NewHTTPFirewallRuleGroupOperator()
 | 
				
			||||||
	op.IsOn = groupConfig.IsOn
 | 
						op.IsOn = groupConfig.IsOn
 | 
				
			||||||
	op.Name = groupConfig.Name
 | 
						op.Name = groupConfig.Name
 | 
				
			||||||
	op.Description = groupConfig.Description
 | 
						op.Description = groupConfig.Description
 | 
				
			||||||
@@ -166,7 +166,7 @@ func (this *HTTPFirewallRuleGroupDAO) UpdateGroupIsOn(tx *dbs.Tx, groupId int64,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// CreateGroup 创建分组
 | 
					// CreateGroup 创建分组
 | 
				
			||||||
func (this *HTTPFirewallRuleGroupDAO) CreateGroup(tx *dbs.Tx, isOn bool, name string, code string, description string) (int64, error) {
 | 
					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.State = HTTPFirewallRuleStateEnabled
 | 
				
			||||||
	op.IsOn = isOn
 | 
						op.IsOn = isOn
 | 
				
			||||||
	op.Name = name
 | 
						op.Name = name
 | 
				
			||||||
@@ -184,7 +184,7 @@ func (this *HTTPFirewallRuleGroupDAO) UpdateGroup(tx *dbs.Tx, groupId int64, isO
 | 
				
			|||||||
	if groupId <= 0 {
 | 
						if groupId <= 0 {
 | 
				
			||||||
		return errors.New("invalid groupId")
 | 
							return errors.New("invalid groupId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewHTTPFirewallRuleGroupOperator()
 | 
						var op = NewHTTPFirewallRuleGroupOperator()
 | 
				
			||||||
	op.Id = groupId
 | 
						op.Id = groupId
 | 
				
			||||||
	op.IsOn = isOn
 | 
						op.IsOn = isOn
 | 
				
			||||||
	op.Name = name
 | 
						op.Name = name
 | 
				
			||||||
@@ -202,7 +202,7 @@ func (this *HTTPFirewallRuleGroupDAO) UpdateGroupSets(tx *dbs.Tx, groupId int64,
 | 
				
			|||||||
	if groupId <= 0 {
 | 
						if groupId <= 0 {
 | 
				
			||||||
		return errors.New("invalid groupId")
 | 
							return errors.New("invalid groupId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewHTTPFirewallRuleGroupOperator()
 | 
						var op = NewHTTPFirewallRuleGroupOperator()
 | 
				
			||||||
	op.Id = groupId
 | 
						op.Id = groupId
 | 
				
			||||||
	op.Sets = setRefsJSON
 | 
						op.Sets = setRefsJSON
 | 
				
			||||||
	err := this.Save(tx, op)
 | 
						err := this.Save(tx, op)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -133,7 +133,7 @@ func (this *HTTPFirewallRuleSetDAO) ComposeFirewallRuleSet(tx *dbs.Tx, setId int
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// CreateOrUpdateSetFromConfig 从配置中创建规则集
 | 
					// CreateOrUpdateSetFromConfig 从配置中创建规则集
 | 
				
			||||||
func (this *HTTPFirewallRuleSetDAO) CreateOrUpdateSetFromConfig(tx *dbs.Tx, setConfig *firewallconfigs.HTTPFirewallRuleSet) (int64, error) {
 | 
					func (this *HTTPFirewallRuleSetDAO) CreateOrUpdateSetFromConfig(tx *dbs.Tx, setConfig *firewallconfigs.HTTPFirewallRuleSet) (int64, error) {
 | 
				
			||||||
	op := NewHTTPFirewallRuleSetOperator()
 | 
						var op = NewHTTPFirewallRuleSetOperator()
 | 
				
			||||||
	op.State = HTTPFirewallRuleSetStateEnabled
 | 
						op.State = HTTPFirewallRuleSetStateEnabled
 | 
				
			||||||
	op.Id = setConfig.Id
 | 
						op.Id = setConfig.Id
 | 
				
			||||||
	op.IsOn = setConfig.IsOn
 | 
						op.IsOn = setConfig.IsOn
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -121,7 +121,7 @@ func (this *HTTPGzipDAO) ComposeGzipConfig(tx *dbs.Tx, gzipId int64) (*servercon
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// CreateGzip 创建Gzip
 | 
					// CreateGzip 创建Gzip
 | 
				
			||||||
func (this *HTTPGzipDAO) CreateGzip(tx *dbs.Tx, level int, minLengthJSON []byte, maxLengthJSON []byte, condsJSON []byte) (int64, error) {
 | 
					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.State = HTTPGzipStateEnabled
 | 
				
			||||||
	op.IsOn = true
 | 
						op.IsOn = true
 | 
				
			||||||
	op.Level = level
 | 
						op.Level = level
 | 
				
			||||||
@@ -146,7 +146,7 @@ func (this *HTTPGzipDAO) UpdateGzip(tx *dbs.Tx, gzipId int64, level int, minLeng
 | 
				
			|||||||
	if gzipId <= 0 {
 | 
						if gzipId <= 0 {
 | 
				
			||||||
		return errors.New("invalid gzipId")
 | 
							return errors.New("invalid gzipId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewHTTPGzipOperator()
 | 
						var op = NewHTTPGzipOperator()
 | 
				
			||||||
	op.Id = gzipId
 | 
						op.Id = gzipId
 | 
				
			||||||
	op.Level = level
 | 
						op.Level = level
 | 
				
			||||||
	if len(minLengthJSON) > 0 {
 | 
						if len(minLengthJSON) > 0 {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -81,7 +81,7 @@ func (this *HTTPHeaderDAO) FindHTTPHeaderName(tx *dbs.Tx, id int64) (string, err
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// CreateHeader 创建Header
 | 
					// 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) {
 | 
					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.UserId = userId
 | 
				
			||||||
	op.State = HTTPHeaderStateEnabled
 | 
						op.State = HTTPHeaderStateEnabled
 | 
				
			||||||
	op.IsOn = true
 | 
						op.IsOn = true
 | 
				
			||||||
@@ -156,7 +156,7 @@ func (this *HTTPHeaderDAO) UpdateHeader(tx *dbs.Tx, headerId int64, name string,
 | 
				
			|||||||
		return errors.New("invalid headerId")
 | 
							return errors.New("invalid headerId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	op := NewHTTPHeaderOperator()
 | 
						var op = NewHTTPHeaderOperator()
 | 
				
			||||||
	op.Id = headerId
 | 
						op.Id = headerId
 | 
				
			||||||
	op.Name = name
 | 
						op.Name = name
 | 
				
			||||||
	op.Value = value
 | 
						op.Value = value
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -77,7 +77,7 @@ func (this *HTTPHeaderPolicyDAO) FindEnabledHTTPHeaderPolicy(tx *dbs.Tx, id int6
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// CreateHeaderPolicy 创建策略
 | 
					// CreateHeaderPolicy 创建策略
 | 
				
			||||||
func (this *HTTPHeaderPolicyDAO) CreateHeaderPolicy(tx *dbs.Tx) (int64, error) {
 | 
					func (this *HTTPHeaderPolicyDAO) CreateHeaderPolicy(tx *dbs.Tx) (int64, error) {
 | 
				
			||||||
	op := NewHTTPHeaderPolicyOperator()
 | 
						var op = NewHTTPHeaderPolicyOperator()
 | 
				
			||||||
	op.IsOn = true
 | 
						op.IsOn = true
 | 
				
			||||||
	op.State = HTTPHeaderPolicyStateEnabled
 | 
						op.State = HTTPHeaderPolicyStateEnabled
 | 
				
			||||||
	err := this.Save(tx, op)
 | 
						err := this.Save(tx, op)
 | 
				
			||||||
@@ -93,7 +93,7 @@ func (this *HTTPHeaderPolicyDAO) UpdateAddingHeaders(tx *dbs.Tx, policyId int64,
 | 
				
			|||||||
		return errors.New("invalid policyId")
 | 
							return errors.New("invalid policyId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	op := NewHTTPHeaderPolicyOperator()
 | 
						var op = NewHTTPHeaderPolicyOperator()
 | 
				
			||||||
	op.Id = policyId
 | 
						op.Id = policyId
 | 
				
			||||||
	op.AddHeaders = headersJSON
 | 
						op.AddHeaders = headersJSON
 | 
				
			||||||
	err := this.Save(tx, op)
 | 
						err := this.Save(tx, op)
 | 
				
			||||||
@@ -109,7 +109,7 @@ func (this *HTTPHeaderPolicyDAO) UpdateSettingHeaders(tx *dbs.Tx, policyId int64
 | 
				
			|||||||
		return errors.New("invalid policyId")
 | 
							return errors.New("invalid policyId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	op := NewHTTPHeaderPolicyOperator()
 | 
						var op = NewHTTPHeaderPolicyOperator()
 | 
				
			||||||
	op.Id = policyId
 | 
						op.Id = policyId
 | 
				
			||||||
	op.SetHeaders = headersJSON
 | 
						op.SetHeaders = headersJSON
 | 
				
			||||||
	err := this.Save(tx, op)
 | 
						err := this.Save(tx, op)
 | 
				
			||||||
@@ -125,7 +125,7 @@ func (this *HTTPHeaderPolicyDAO) UpdateReplacingHeaders(tx *dbs.Tx, policyId int
 | 
				
			|||||||
		return errors.New("invalid policyId")
 | 
							return errors.New("invalid policyId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	op := NewHTTPHeaderPolicyOperator()
 | 
						var op = NewHTTPHeaderPolicyOperator()
 | 
				
			||||||
	op.Id = policyId
 | 
						op.Id = policyId
 | 
				
			||||||
	op.ReplaceHeaders = headersJSON
 | 
						op.ReplaceHeaders = headersJSON
 | 
				
			||||||
	err := this.Save(tx, op)
 | 
						err := this.Save(tx, op)
 | 
				
			||||||
@@ -141,7 +141,7 @@ func (this *HTTPHeaderPolicyDAO) UpdateAddingTrailers(tx *dbs.Tx, policyId int64
 | 
				
			|||||||
		return errors.New("invalid policyId")
 | 
							return errors.New("invalid policyId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	op := NewHTTPHeaderPolicyOperator()
 | 
						var op = NewHTTPHeaderPolicyOperator()
 | 
				
			||||||
	op.Id = policyId
 | 
						op.Id = policyId
 | 
				
			||||||
	op.AddTrailers = headersJSON
 | 
						op.AddTrailers = headersJSON
 | 
				
			||||||
	err := this.Save(tx, op)
 | 
						err := this.Save(tx, op)
 | 
				
			||||||
@@ -162,7 +162,7 @@ func (this *HTTPHeaderPolicyDAO) UpdateDeletingHeaders(tx *dbs.Tx, policyId int6
 | 
				
			|||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	op := NewHTTPHeaderPolicyOperator()
 | 
						var op = NewHTTPHeaderPolicyOperator()
 | 
				
			||||||
	op.Id = policyId
 | 
						op.Id = policyId
 | 
				
			||||||
	op.DeleteHeaders = string(namesJSON)
 | 
						op.DeleteHeaders = string(namesJSON)
 | 
				
			||||||
	err = this.Save(tx, op)
 | 
						err = this.Save(tx, op)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -87,7 +87,7 @@ func (this *HTTPLocationDAO) FindHTTPLocationName(tx *dbs.Tx, id int64) (string,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// CreateLocation 创建路由规则
 | 
					// CreateLocation 创建路由规则
 | 
				
			||||||
func (this *HTTPLocationDAO) CreateLocation(tx *dbs.Tx, parentId int64, name string, pattern string, description string, isBreak bool, condsJSON []byte, domains []string) (int64, error) {
 | 
					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.IsOn = true
 | 
				
			||||||
	op.State = HTTPLocationStateEnabled
 | 
						op.State = HTTPLocationStateEnabled
 | 
				
			||||||
	op.ParentId = parentId
 | 
						op.ParentId = parentId
 | 
				
			||||||
@@ -121,7 +121,7 @@ func (this *HTTPLocationDAO) UpdateLocation(tx *dbs.Tx, locationId int64, name s
 | 
				
			|||||||
	if locationId <= 0 {
 | 
						if locationId <= 0 {
 | 
				
			||||||
		return errors.New("invalid locationId")
 | 
							return errors.New("invalid locationId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewHTTPLocationOperator()
 | 
						var op = NewHTTPLocationOperator()
 | 
				
			||||||
	op.Id = locationId
 | 
						op.Id = locationId
 | 
				
			||||||
	op.Name = name
 | 
						op.Name = name
 | 
				
			||||||
	op.Pattern = pattern
 | 
						op.Pattern = pattern
 | 
				
			||||||
@@ -257,7 +257,7 @@ func (this *HTTPLocationDAO) UpdateLocationReverseProxy(tx *dbs.Tx, locationId i
 | 
				
			|||||||
	if locationId <= 0 {
 | 
						if locationId <= 0 {
 | 
				
			||||||
		return errors.New("invalid locationId")
 | 
							return errors.New("invalid locationId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewHTTPLocationOperator()
 | 
						var op = NewHTTPLocationOperator()
 | 
				
			||||||
	op.Id = locationId
 | 
						op.Id = locationId
 | 
				
			||||||
	op.ReverseProxy = JSONBytes(reverseProxyJSON)
 | 
						op.ReverseProxy = JSONBytes(reverseProxyJSON)
 | 
				
			||||||
	err := this.Save(tx, op)
 | 
						err := this.Save(tx, op)
 | 
				
			||||||
@@ -281,7 +281,7 @@ func (this *HTTPLocationDAO) UpdateLocationWeb(tx *dbs.Tx, locationId int64, web
 | 
				
			|||||||
	if locationId <= 0 {
 | 
						if locationId <= 0 {
 | 
				
			||||||
		return errors.New("invalid locationId")
 | 
							return errors.New("invalid locationId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewHTTPLocationOperator()
 | 
						var op = NewHTTPLocationOperator()
 | 
				
			||||||
	op.Id = locationId
 | 
						op.Id = locationId
 | 
				
			||||||
	op.WebId = webId
 | 
						op.WebId = webId
 | 
				
			||||||
	err := this.Save(tx, op)
 | 
						err := this.Save(tx, op)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -78,7 +78,7 @@ func (this *HTTPPageDAO) FindEnabledHTTPPage(tx *dbs.Tx, id int64) (*HTTPPage, e
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// CreatePage 创建Page
 | 
					// 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) {
 | 
					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.UserId = userId
 | 
				
			||||||
	op.IsOn = true
 | 
						op.IsOn = true
 | 
				
			||||||
	op.State = HTTPPageStateEnabled
 | 
						op.State = HTTPPageStateEnabled
 | 
				
			||||||
@@ -108,7 +108,7 @@ func (this *HTTPPageDAO) UpdatePage(tx *dbs.Tx, pageId int64, statusList []strin
 | 
				
			|||||||
		return errors.New("invalid pageId")
 | 
							return errors.New("invalid pageId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	op := NewHTTPPageOperator()
 | 
						var op = NewHTTPPageOperator()
 | 
				
			||||||
	op.Id = pageId
 | 
						op.Id = pageId
 | 
				
			||||||
	op.IsOn = true
 | 
						op.IsOn = true
 | 
				
			||||||
	op.State = HTTPPageStateEnabled
 | 
						op.State = HTTPPageStateEnabled
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -125,7 +125,7 @@ func (this *HTTPRewriteRuleDAO) ComposeRewriteRule(tx *dbs.Tx, rewriteRuleId int
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// CreateRewriteRule 创建规则
 | 
					// 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) {
 | 
					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.State = HTTPRewriteRuleStateEnabled
 | 
				
			||||||
	op.IsOn = isOn
 | 
						op.IsOn = isOn
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -150,7 +150,7 @@ func (this *HTTPRewriteRuleDAO) UpdateRewriteRule(tx *dbs.Tx, rewriteRuleId int6
 | 
				
			|||||||
	if rewriteRuleId <= 0 {
 | 
						if rewriteRuleId <= 0 {
 | 
				
			||||||
		return errors.New("invalid rewriteRuleId")
 | 
							return errors.New("invalid rewriteRuleId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewHTTPRewriteRuleOperator()
 | 
						var op = NewHTTPRewriteRuleOperator()
 | 
				
			||||||
	op.Id = rewriteRuleId
 | 
						op.Id = rewriteRuleId
 | 
				
			||||||
	op.IsOn = isOn
 | 
						op.IsOn = isOn
 | 
				
			||||||
	op.Pattern = pattern
 | 
						op.Pattern = pattern
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -466,7 +466,7 @@ func (this *HTTPWebDAO) ComposeWebConfig(tx *dbs.Tx, webId int64, cacheMap *util
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// CreateWeb 创建Web配置
 | 
					// CreateWeb 创建Web配置
 | 
				
			||||||
func (this *HTTPWebDAO) CreateWeb(tx *dbs.Tx, adminId int64, userId int64, rootJSON []byte) (int64, error) {
 | 
					func (this *HTTPWebDAO) CreateWeb(tx *dbs.Tx, adminId int64, userId int64, rootJSON []byte) (int64, error) {
 | 
				
			||||||
	op := NewHTTPWebOperator()
 | 
						var op = NewHTTPWebOperator()
 | 
				
			||||||
	op.State = HTTPWebStateEnabled
 | 
						op.State = HTTPWebStateEnabled
 | 
				
			||||||
	op.AdminId = adminId
 | 
						op.AdminId = adminId
 | 
				
			||||||
	op.UserId = userId
 | 
						op.UserId = userId
 | 
				
			||||||
@@ -485,7 +485,7 @@ func (this *HTTPWebDAO) UpdateWeb(tx *dbs.Tx, webId int64, rootJSON []byte) erro
 | 
				
			|||||||
	if webId <= 0 {
 | 
						if webId <= 0 {
 | 
				
			||||||
		return errors.New("invalid webId")
 | 
							return errors.New("invalid webId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewHTTPWebOperator()
 | 
						var op = NewHTTPWebOperator()
 | 
				
			||||||
	op.Id = webId
 | 
						op.Id = webId
 | 
				
			||||||
	op.Root = JSONBytes(rootJSON)
 | 
						op.Root = JSONBytes(rootJSON)
 | 
				
			||||||
	err := this.Save(tx, op)
 | 
						err := this.Save(tx, op)
 | 
				
			||||||
@@ -501,7 +501,7 @@ func (this *HTTPWebDAO) UpdateWebCompression(tx *dbs.Tx, webId int64, compressio
 | 
				
			|||||||
	if webId <= 0 {
 | 
						if webId <= 0 {
 | 
				
			||||||
		return errors.New("invalid webId")
 | 
							return errors.New("invalid webId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewHTTPWebOperator()
 | 
						var op = NewHTTPWebOperator()
 | 
				
			||||||
	op.Id = webId
 | 
						op.Id = webId
 | 
				
			||||||
	op.Compression = JSONBytes(compressionConfig)
 | 
						op.Compression = JSONBytes(compressionConfig)
 | 
				
			||||||
	err := this.Save(tx, op)
 | 
						err := this.Save(tx, op)
 | 
				
			||||||
@@ -517,7 +517,7 @@ func (this *HTTPWebDAO) UpdateWebWebP(tx *dbs.Tx, webId int64, webpConfig []byte
 | 
				
			|||||||
	if webId <= 0 {
 | 
						if webId <= 0 {
 | 
				
			||||||
		return errors.New("invalid webId")
 | 
							return errors.New("invalid webId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewHTTPWebOperator()
 | 
						var op = NewHTTPWebOperator()
 | 
				
			||||||
	op.Id = webId
 | 
						op.Id = webId
 | 
				
			||||||
	op.Webp = JSONBytes(webpConfig)
 | 
						op.Webp = JSONBytes(webpConfig)
 | 
				
			||||||
	err := this.Save(tx, op)
 | 
						err := this.Save(tx, op)
 | 
				
			||||||
@@ -548,7 +548,7 @@ func (this *HTTPWebDAO) UpdateWebCharset(tx *dbs.Tx, webId int64, charsetJSON []
 | 
				
			|||||||
	if webId <= 0 {
 | 
						if webId <= 0 {
 | 
				
			||||||
		return errors.New("invalid webId")
 | 
							return errors.New("invalid webId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewHTTPWebOperator()
 | 
						var op = NewHTTPWebOperator()
 | 
				
			||||||
	op.Id = webId
 | 
						op.Id = webId
 | 
				
			||||||
	op.Charset = JSONBytes(charsetJSON)
 | 
						op.Charset = JSONBytes(charsetJSON)
 | 
				
			||||||
	err := this.Save(tx, op)
 | 
						err := this.Save(tx, op)
 | 
				
			||||||
@@ -564,7 +564,7 @@ func (this *HTTPWebDAO) UpdateWebRequestHeaderPolicy(tx *dbs.Tx, webId int64, he
 | 
				
			|||||||
	if webId <= 0 {
 | 
						if webId <= 0 {
 | 
				
			||||||
		return errors.New("invalid webId")
 | 
							return errors.New("invalid webId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewHTTPWebOperator()
 | 
						var op = NewHTTPWebOperator()
 | 
				
			||||||
	op.Id = webId
 | 
						op.Id = webId
 | 
				
			||||||
	op.RequestHeader = JSONBytes(headerPolicyJSON)
 | 
						op.RequestHeader = JSONBytes(headerPolicyJSON)
 | 
				
			||||||
	err := this.Save(tx, op)
 | 
						err := this.Save(tx, op)
 | 
				
			||||||
@@ -580,7 +580,7 @@ func (this *HTTPWebDAO) UpdateWebResponseHeaderPolicy(tx *dbs.Tx, webId int64, h
 | 
				
			|||||||
	if webId <= 0 {
 | 
						if webId <= 0 {
 | 
				
			||||||
		return errors.New("invalid webId")
 | 
							return errors.New("invalid webId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewHTTPWebOperator()
 | 
						var op = NewHTTPWebOperator()
 | 
				
			||||||
	op.Id = webId
 | 
						op.Id = webId
 | 
				
			||||||
	op.ResponseHeader = JSONBytes(headerPolicyJSON)
 | 
						op.ResponseHeader = JSONBytes(headerPolicyJSON)
 | 
				
			||||||
	err := this.Save(tx, op)
 | 
						err := this.Save(tx, op)
 | 
				
			||||||
@@ -596,7 +596,7 @@ func (this *HTTPWebDAO) UpdateWebPages(tx *dbs.Tx, webId int64, pagesJSON []byte
 | 
				
			|||||||
	if webId <= 0 {
 | 
						if webId <= 0 {
 | 
				
			||||||
		return errors.New("invalid webId")
 | 
							return errors.New("invalid webId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewHTTPWebOperator()
 | 
						var op = NewHTTPWebOperator()
 | 
				
			||||||
	op.Id = webId
 | 
						op.Id = webId
 | 
				
			||||||
	op.Pages = JSONBytes(pagesJSON)
 | 
						op.Pages = JSONBytes(pagesJSON)
 | 
				
			||||||
	err := this.Save(tx, op)
 | 
						err := this.Save(tx, op)
 | 
				
			||||||
@@ -612,7 +612,7 @@ func (this *HTTPWebDAO) UpdateWebShutdown(tx *dbs.Tx, webId int64, shutdownJSON
 | 
				
			|||||||
	if webId <= 0 {
 | 
						if webId <= 0 {
 | 
				
			||||||
		return errors.New("invalid webId")
 | 
							return errors.New("invalid webId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewHTTPWebOperator()
 | 
						var op = NewHTTPWebOperator()
 | 
				
			||||||
	op.Id = webId
 | 
						op.Id = webId
 | 
				
			||||||
	op.Shutdown = JSONBytes(shutdownJSON)
 | 
						op.Shutdown = JSONBytes(shutdownJSON)
 | 
				
			||||||
	err := this.Save(tx, op)
 | 
						err := this.Save(tx, op)
 | 
				
			||||||
@@ -628,7 +628,7 @@ func (this *HTTPWebDAO) UpdateWebAccessLogConfig(tx *dbs.Tx, webId int64, access
 | 
				
			|||||||
	if webId <= 0 {
 | 
						if webId <= 0 {
 | 
				
			||||||
		return errors.New("invalid webId")
 | 
							return errors.New("invalid webId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewHTTPWebOperator()
 | 
						var op = NewHTTPWebOperator()
 | 
				
			||||||
	op.Id = webId
 | 
						op.Id = webId
 | 
				
			||||||
	op.AccessLog = JSONBytes(accessLogJSON)
 | 
						op.AccessLog = JSONBytes(accessLogJSON)
 | 
				
			||||||
	err := this.Save(tx, op)
 | 
						err := this.Save(tx, op)
 | 
				
			||||||
@@ -644,7 +644,7 @@ func (this *HTTPWebDAO) UpdateWebStat(tx *dbs.Tx, webId int64, statJSON []byte)
 | 
				
			|||||||
	if webId <= 0 {
 | 
						if webId <= 0 {
 | 
				
			||||||
		return errors.New("invalid webId")
 | 
							return errors.New("invalid webId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewHTTPWebOperator()
 | 
						var op = NewHTTPWebOperator()
 | 
				
			||||||
	op.Id = webId
 | 
						op.Id = webId
 | 
				
			||||||
	op.Stat = JSONBytes(statJSON)
 | 
						op.Stat = JSONBytes(statJSON)
 | 
				
			||||||
	err := this.Save(tx, op)
 | 
						err := this.Save(tx, op)
 | 
				
			||||||
@@ -660,7 +660,7 @@ func (this *HTTPWebDAO) UpdateWebCache(tx *dbs.Tx, webId int64, cacheJSON []byte
 | 
				
			|||||||
	if webId <= 0 {
 | 
						if webId <= 0 {
 | 
				
			||||||
		return errors.New("invalid webId")
 | 
							return errors.New("invalid webId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewHTTPWebOperator()
 | 
						var op = NewHTTPWebOperator()
 | 
				
			||||||
	op.Id = webId
 | 
						op.Id = webId
 | 
				
			||||||
	op.Cache = JSONBytes(cacheJSON)
 | 
						op.Cache = JSONBytes(cacheJSON)
 | 
				
			||||||
	err := this.Save(tx, op)
 | 
						err := this.Save(tx, op)
 | 
				
			||||||
@@ -676,7 +676,7 @@ func (this *HTTPWebDAO) UpdateWebFirewall(tx *dbs.Tx, webId int64, firewallJSON
 | 
				
			|||||||
	if webId <= 0 {
 | 
						if webId <= 0 {
 | 
				
			||||||
		return errors.New("invalid webId")
 | 
							return errors.New("invalid webId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewHTTPWebOperator()
 | 
						var op = NewHTTPWebOperator()
 | 
				
			||||||
	op.Id = webId
 | 
						op.Id = webId
 | 
				
			||||||
	op.Firewall = JSONBytes(firewallJSON)
 | 
						op.Firewall = JSONBytes(firewallJSON)
 | 
				
			||||||
	err := this.Save(tx, op)
 | 
						err := this.Save(tx, op)
 | 
				
			||||||
@@ -692,7 +692,7 @@ func (this *HTTPWebDAO) UpdateWebLocations(tx *dbs.Tx, webId int64, locationsJSO
 | 
				
			|||||||
	if webId <= 0 {
 | 
						if webId <= 0 {
 | 
				
			||||||
		return errors.New("invalid webId")
 | 
							return errors.New("invalid webId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewHTTPWebOperator()
 | 
						var op = NewHTTPWebOperator()
 | 
				
			||||||
	op.Id = webId
 | 
						op.Id = webId
 | 
				
			||||||
	op.Locations = JSONBytes(locationsJSON)
 | 
						op.Locations = JSONBytes(locationsJSON)
 | 
				
			||||||
	err := this.Save(tx, op)
 | 
						err := this.Save(tx, op)
 | 
				
			||||||
@@ -708,7 +708,7 @@ func (this *HTTPWebDAO) UpdateWebRedirectToHTTPS(tx *dbs.Tx, webId int64, redire
 | 
				
			|||||||
	if webId <= 0 {
 | 
						if webId <= 0 {
 | 
				
			||||||
		return errors.New("invalid webId")
 | 
							return errors.New("invalid webId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewHTTPWebOperator()
 | 
						var op = NewHTTPWebOperator()
 | 
				
			||||||
	op.Id = webId
 | 
						op.Id = webId
 | 
				
			||||||
	op.RedirectToHttps = JSONBytes(redirectToHTTPSJSON)
 | 
						op.RedirectToHttps = JSONBytes(redirectToHTTPSJSON)
 | 
				
			||||||
	err := this.Save(tx, op)
 | 
						err := this.Save(tx, op)
 | 
				
			||||||
@@ -724,7 +724,7 @@ func (this *HTTPWebDAO) UpdateWebsocket(tx *dbs.Tx, webId int64, websocketJSON [
 | 
				
			|||||||
	if webId <= 0 {
 | 
						if webId <= 0 {
 | 
				
			||||||
		return errors.New("invalid webId")
 | 
							return errors.New("invalid webId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewHTTPWebOperator()
 | 
						var op = NewHTTPWebOperator()
 | 
				
			||||||
	op.Id = webId
 | 
						op.Id = webId
 | 
				
			||||||
	op.Websocket = JSONBytes(websocketJSON)
 | 
						op.Websocket = JSONBytes(websocketJSON)
 | 
				
			||||||
	err := this.Save(tx, op)
 | 
						err := this.Save(tx, op)
 | 
				
			||||||
@@ -740,7 +740,7 @@ func (this *HTTPWebDAO) UpdateWebFastcgi(tx *dbs.Tx, webId int64, fastcgiJSON []
 | 
				
			|||||||
	if webId <= 0 {
 | 
						if webId <= 0 {
 | 
				
			||||||
		return errors.New("invalid webId")
 | 
							return errors.New("invalid webId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewHTTPWebOperator()
 | 
						var op = NewHTTPWebOperator()
 | 
				
			||||||
	op.Id = webId
 | 
						op.Id = webId
 | 
				
			||||||
	op.Fastcgi = JSONBytes(fastcgiJSON)
 | 
						op.Fastcgi = JSONBytes(fastcgiJSON)
 | 
				
			||||||
	err := this.Save(tx, op)
 | 
						err := this.Save(tx, op)
 | 
				
			||||||
@@ -756,7 +756,7 @@ func (this *HTTPWebDAO) UpdateWebRewriteRules(tx *dbs.Tx, webId int64, rewriteRu
 | 
				
			|||||||
	if webId <= 0 {
 | 
						if webId <= 0 {
 | 
				
			||||||
		return errors.New("invalid webId")
 | 
							return errors.New("invalid webId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewHTTPWebOperator()
 | 
						var op = NewHTTPWebOperator()
 | 
				
			||||||
	op.Id = webId
 | 
						op.Id = webId
 | 
				
			||||||
	op.RewriteRules = JSONBytes(rewriteRulesJSON)
 | 
						op.RewriteRules = JSONBytes(rewriteRulesJSON)
 | 
				
			||||||
	err := this.Save(tx, op)
 | 
						err := this.Save(tx, op)
 | 
				
			||||||
@@ -772,7 +772,7 @@ func (this *HTTPWebDAO) UpdateWebAuth(tx *dbs.Tx, webId int64, authJSON []byte)
 | 
				
			|||||||
	if webId <= 0 {
 | 
						if webId <= 0 {
 | 
				
			||||||
		return errors.New("invalid webId")
 | 
							return errors.New("invalid webId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewHTTPWebOperator()
 | 
						var op = NewHTTPWebOperator()
 | 
				
			||||||
	op.Id = webId
 | 
						op.Id = webId
 | 
				
			||||||
	op.Auth = JSONBytes(authJSON)
 | 
						op.Auth = JSONBytes(authJSON)
 | 
				
			||||||
	err := this.Save(tx, op)
 | 
						err := this.Save(tx, op)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -110,7 +110,7 @@ func (this *HTTPWebsocketDAO) ComposeWebsocketConfig(tx *dbs.Tx, websocketId int
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// CreateWebsocket 创建Websocket配置
 | 
					// CreateWebsocket 创建Websocket配置
 | 
				
			||||||
func (this *HTTPWebsocketDAO) CreateWebsocket(tx *dbs.Tx, handshakeTimeoutJSON []byte, allowAllOrigins bool, allowedOrigins []string, requestSameOrigin bool, requestOrigin string) (websocketId int64, err error) {
 | 
					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.IsOn = true
 | 
				
			||||||
	op.State = HTTPWebsocketStateEnabled
 | 
						op.State = HTTPWebsocketStateEnabled
 | 
				
			||||||
	if len(handshakeTimeoutJSON) > 0 {
 | 
						if len(handshakeTimeoutJSON) > 0 {
 | 
				
			||||||
@@ -135,7 +135,7 @@ func (this *HTTPWebsocketDAO) UpdateWebsocket(tx *dbs.Tx, websocketId int64, han
 | 
				
			|||||||
	if websocketId <= 0 {
 | 
						if websocketId <= 0 {
 | 
				
			||||||
		return errors.New("invalid websocketId")
 | 
							return errors.New("invalid websocketId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewHTTPWebsocketOperator()
 | 
						var op = NewHTTPWebsocketOperator()
 | 
				
			||||||
	op.Id = websocketId
 | 
						op.Id = websocketId
 | 
				
			||||||
	if len(handshakeTimeoutJSON) > 0 {
 | 
						if len(handshakeTimeoutJSON) > 0 {
 | 
				
			||||||
		op.HandshakeTimeout = handshakeTimeoutJSON
 | 
							op.HandshakeTimeout = handshakeTimeoutJSON
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -330,7 +330,7 @@ func (this *IPItemDAO) UpdateIPItem(tx *dbs.Tx, itemId int64, ipFrom string, ipT
 | 
				
			|||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	op := NewIPItemOperator()
 | 
						var op = NewIPItemOperator()
 | 
				
			||||||
	op.Id = itemId
 | 
						op.Id = itemId
 | 
				
			||||||
	op.IpFrom = ipFrom
 | 
						op.IpFrom = ipFrom
 | 
				
			||||||
	op.IpTo = ipTo
 | 
						op.IpTo = ipTo
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -92,7 +92,7 @@ func (this *IPLibraryDAO) FindLatestIPLibraryWithType(tx *dbs.Tx, libraryType st
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// 创建新的IP库
 | 
					// 创建新的IP库
 | 
				
			||||||
func (this *IPLibraryDAO) CreateIPLibrary(tx *dbs.Tx, libraryType string, fileId int64) (int64, error) {
 | 
					func (this *IPLibraryDAO) CreateIPLibrary(tx *dbs.Tx, libraryType string, fileId int64) (int64, error) {
 | 
				
			||||||
	op := NewIPLibraryOperator()
 | 
						var op = NewIPLibraryOperator()
 | 
				
			||||||
	op.Type = libraryType
 | 
						op.Type = libraryType
 | 
				
			||||||
	op.FileId = fileId
 | 
						op.FileId = fileId
 | 
				
			||||||
	op.State = IPLibraryStateEnabled
 | 
						op.State = IPLibraryStateEnabled
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -165,7 +165,7 @@ func (this *IPListDAO) UpdateIPList(tx *dbs.Tx, listId int64, name string, code
 | 
				
			|||||||
	if listId <= 0 {
 | 
						if listId <= 0 {
 | 
				
			||||||
		return errors.New("invalid listId")
 | 
							return errors.New("invalid listId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewIPListOperator()
 | 
						var op = NewIPListOperator()
 | 
				
			||||||
	op.Id = listId
 | 
						op.Id = listId
 | 
				
			||||||
	op.Name = name
 | 
						op.Name = name
 | 
				
			||||||
	op.Code = code
 | 
						op.Code = code
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -36,7 +36,7 @@ func init() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// CreateLog 创建管理员日志
 | 
					// CreateLog 创建管理员日志
 | 
				
			||||||
func (this *LogDAO) CreateLog(tx *dbs.Tx, adminType string, adminId int64, level string, description string, action string, ip string) error {
 | 
					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.Level = level
 | 
				
			||||||
	op.Description = description
 | 
						op.Description = description
 | 
				
			||||||
	op.Action = action
 | 
						op.Action = action
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -78,7 +78,7 @@ func (this *LoginDAO) CreateLogin(tx *dbs.Tx, Id int64, loginType LoginType, par
 | 
				
			|||||||
	if params == nil {
 | 
						if params == nil {
 | 
				
			||||||
		params = maps.Map{}
 | 
							params = maps.Map{}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewLoginOperator()
 | 
						var op = NewLoginOperator()
 | 
				
			||||||
	op.Id = Id
 | 
						op.Id = Id
 | 
				
			||||||
	op.Type = loginType
 | 
						op.Type = loginType
 | 
				
			||||||
	op.Params = params.AsJSON()
 | 
						op.Params = params.AsJSON()
 | 
				
			||||||
@@ -99,7 +99,7 @@ func (this *LoginDAO) UpdateLogin(tx *dbs.Tx, adminId int64, loginType LoginType
 | 
				
			|||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewLoginOperator()
 | 
						var op = NewLoginOperator()
 | 
				
			||||||
	if loginId > 0 {
 | 
						if loginId > 0 {
 | 
				
			||||||
		op.Id = loginId
 | 
							op.Id = loginId
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -154,7 +154,7 @@ func (this *MessageDAO) CreateNodeMessage(tx *dbs.Tx, role string, clusterId int
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// CreateMessage 创建普通消息
 | 
					// CreateMessage 创建普通消息
 | 
				
			||||||
func (this *MessageDAO) CreateMessage(tx *dbs.Tx, adminId int64, userId int64, messageType MessageType, level string, subject string, body string, paramsJSON []byte) error {
 | 
					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.AdminId = adminId
 | 
				
			||||||
	op.UserId = userId
 | 
						op.UserId = userId
 | 
				
			||||||
	op.Type = messageType
 | 
						op.Type = messageType
 | 
				
			||||||
@@ -230,7 +230,7 @@ func (this *MessageDAO) UpdateMessageRead(tx *dbs.Tx, messageId int64, b bool) e
 | 
				
			|||||||
	if messageId <= 0 {
 | 
						if messageId <= 0 {
 | 
				
			||||||
		return errors.New("invalid messageId")
 | 
							return errors.New("invalid messageId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewMessageOperator()
 | 
						var op = NewMessageOperator()
 | 
				
			||||||
	op.Id = messageId
 | 
						op.Id = messageId
 | 
				
			||||||
	op.IsRead = b
 | 
						op.IsRead = b
 | 
				
			||||||
	err := this.Save(tx, op)
 | 
						err := this.Save(tx, op)
 | 
				
			||||||
@@ -286,7 +286,7 @@ func (this *MessageDAO) createMessage(tx *dbs.Tx, role string, clusterId int64,
 | 
				
			|||||||
	// TODO 检查同样的消息最近是否发送过
 | 
						// TODO 检查同样的消息最近是否发送过
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// 创建新消息
 | 
						// 创建新消息
 | 
				
			||||||
	op := NewMessageOperator()
 | 
						var op = NewMessageOperator()
 | 
				
			||||||
	op.AdminId = 0 // TODO
 | 
						op.AdminId = 0 // TODO
 | 
				
			||||||
	op.UserId = 0  // TODO
 | 
						op.UserId = 0  // TODO
 | 
				
			||||||
	op.Role = role
 | 
						op.Role = role
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -104,7 +104,7 @@ func (this *MessageMediaDAO) UpdateMessageMedias(tx *dbs.Tx, mediaMaps []maps.Ma
 | 
				
			|||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			return err
 | 
								return err
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		op := NewMessageMediaOperator()
 | 
							var op = NewMessageMediaOperator()
 | 
				
			||||||
		if mediaId > 0 {
 | 
							if mediaId > 0 {
 | 
				
			||||||
			op.Id = mediaId
 | 
								op.Id = mediaId
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -84,7 +84,7 @@ func (this *MessageMediaInstanceDAO) FindEnabledMessageMediaInstance(tx *dbs.Tx,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// CreateMediaInstance 创建媒介实例
 | 
					// CreateMediaInstance 创建媒介实例
 | 
				
			||||||
func (this *MessageMediaInstanceDAO) CreateMediaInstance(tx *dbs.Tx, name string, mediaType string, params maps.Map, description string, rateJSON []byte, hashLifeSeconds int32) (int64, error) {
 | 
					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.Name = name
 | 
				
			||||||
	op.MediaType = mediaType
 | 
						op.MediaType = mediaType
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -116,7 +116,7 @@ func (this *MessageMediaInstanceDAO) UpdateMediaInstance(tx *dbs.Tx, instanceId
 | 
				
			|||||||
		return errors.New("invalid instanceId")
 | 
							return errors.New("invalid instanceId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	op := NewMessageMediaInstanceOperator()
 | 
						var op = NewMessageMediaInstanceOperator()
 | 
				
			||||||
	op.Id = instanceId
 | 
						op.Id = instanceId
 | 
				
			||||||
	op.Name = name
 | 
						op.Name = name
 | 
				
			||||||
	op.MediaType = mediaType
 | 
						op.MediaType = mediaType
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -76,7 +76,7 @@ func (this *MessageReceiverDAO) DisableReceivers(tx *dbs.Tx, clusterId int64, no
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// CreateReceiver 创建接收人
 | 
					// 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) {
 | 
					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.Role = role
 | 
				
			||||||
	op.ClusterId = clusterId
 | 
						op.ClusterId = clusterId
 | 
				
			||||||
	op.NodeId = nodeId
 | 
						op.NodeId = nodeId
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -86,7 +86,7 @@ func (this *MessageRecipientDAO) FindEnabledMessageRecipient(tx *dbs.Tx, recipie
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// CreateRecipient 创建接收人
 | 
					// CreateRecipient 创建接收人
 | 
				
			||||||
func (this *MessageRecipientDAO) CreateRecipient(tx *dbs.Tx, adminId int64, instanceId int64, user string, groupIds []int64, description string, timeFrom string, timeTo string) (int64, error) {
 | 
					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.AdminId = adminId
 | 
				
			||||||
	op.InstanceId = instanceId
 | 
						op.InstanceId = instanceId
 | 
				
			||||||
	op.User = user
 | 
						op.User = user
 | 
				
			||||||
@@ -122,7 +122,7 @@ func (this *MessageRecipientDAO) UpdateRecipient(tx *dbs.Tx, recipientId int64,
 | 
				
			|||||||
		return errors.New("invalid recipientId")
 | 
							return errors.New("invalid recipientId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	op := NewMessageRecipientOperator()
 | 
						var op = NewMessageRecipientOperator()
 | 
				
			||||||
	op.Id = recipientId
 | 
						op.Id = recipientId
 | 
				
			||||||
	op.AdminId = adminId
 | 
						op.AdminId = adminId
 | 
				
			||||||
	op.InstanceId = instanceId
 | 
						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) {
 | 
					func (this *MessageRecipientGroupDAO) CreateGroup(tx *dbs.Tx, name string) (int64, error) {
 | 
				
			||||||
	op := NewMessageRecipientGroupOperator()
 | 
						var op = NewMessageRecipientGroupOperator()
 | 
				
			||||||
	op.Name = name
 | 
						op.Name = name
 | 
				
			||||||
	op.IsOn = true
 | 
						op.IsOn = true
 | 
				
			||||||
	op.State = MessageRecipientStateEnabled
 | 
						op.State = MessageRecipientStateEnabled
 | 
				
			||||||
@@ -85,7 +85,7 @@ func (this *MessageRecipientGroupDAO) UpdateGroup(tx *dbs.Tx, groupId int64, nam
 | 
				
			|||||||
	if groupId <= 0 {
 | 
						if groupId <= 0 {
 | 
				
			||||||
		return errors.New("invalid groupId")
 | 
							return errors.New("invalid groupId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewMessageRecipientGroupOperator()
 | 
						var op = NewMessageRecipientGroupOperator()
 | 
				
			||||||
	op.Id = groupId
 | 
						op.Id = groupId
 | 
				
			||||||
	op.Name = name
 | 
						op.Name = name
 | 
				
			||||||
	op.IsOn = isOn
 | 
						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.RecipientId = recipientId
 | 
				
			||||||
	op.InstanceId = instanceId
 | 
						op.InstanceId = instanceId
 | 
				
			||||||
	op.Hash = hash
 | 
						op.Hash = hash
 | 
				
			||||||
@@ -190,7 +190,7 @@ func (this *MessageTaskDAO) UpdateMessageTaskStatus(tx *dbs.Tx, taskId int64, st
 | 
				
			|||||||
	if taskId <= 0 {
 | 
						if taskId <= 0 {
 | 
				
			||||||
		return errors.New("invalid taskId")
 | 
							return errors.New("invalid taskId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewMessageTaskOperator()
 | 
						var op = NewMessageTaskOperator()
 | 
				
			||||||
	op.Id = taskId
 | 
						op.Id = taskId
 | 
				
			||||||
	op.Status = status
 | 
						op.Status = status
 | 
				
			||||||
	op.SentAt = time.Now().Unix()
 | 
						op.SentAt = time.Now().Unix()
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -49,7 +49,7 @@ func init() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// CreateLog 创建日志
 | 
					// CreateLog 创建日志
 | 
				
			||||||
func (this *MessageTaskLogDAO) CreateLog(tx *dbs.Tx, taskId int64, isOk bool, errMsg string, response string) error {
 | 
					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.TaskId = taskId
 | 
				
			||||||
	op.IsOk = isOk
 | 
						op.IsOk = isOk
 | 
				
			||||||
	op.Error = errMsg
 | 
						op.Error = errMsg
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -75,7 +75,7 @@ func (this *MetricChartDAO) FindMetricChartName(tx *dbs.Tx, chartId int64) (stri
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// CreateChart 创建图表
 | 
					// 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) {
 | 
					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.ItemId = itemId
 | 
				
			||||||
	op.Name = name
 | 
						op.Name = name
 | 
				
			||||||
	op.Type = chartType
 | 
						op.Type = chartType
 | 
				
			||||||
@@ -112,7 +112,7 @@ func (this *MetricChartDAO) UpdateChart(tx *dbs.Tx, chartId int64, name string,
 | 
				
			|||||||
	if chartId <= 0 {
 | 
						if chartId <= 0 {
 | 
				
			||||||
		return errors.New("invalid chartId")
 | 
							return errors.New("invalid chartId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewMetricChartOperator()
 | 
						var op = NewMetricChartOperator()
 | 
				
			||||||
	op.Id = chartId
 | 
						op.Id = chartId
 | 
				
			||||||
	op.Name = name
 | 
						op.Name = name
 | 
				
			||||||
	op.Type = chartType
 | 
						op.Type = chartType
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -123,7 +123,7 @@ func (this *MonitorNodeDAO) CreateMonitorNode(tx *dbs.Tx, name string, descripti
 | 
				
			|||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	op := NewMonitorNodeOperator()
 | 
						var op = NewMonitorNodeOperator()
 | 
				
			||||||
	op.IsOn = isOn
 | 
						op.IsOn = isOn
 | 
				
			||||||
	op.UniqueId = uniqueId
 | 
						op.UniqueId = uniqueId
 | 
				
			||||||
	op.Secret = secret
 | 
						op.Secret = secret
 | 
				
			||||||
@@ -144,7 +144,7 @@ func (this *MonitorNodeDAO) UpdateMonitorNode(tx *dbs.Tx, nodeId int64, name str
 | 
				
			|||||||
		return errors.New("invalid nodeId")
 | 
							return errors.New("invalid nodeId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	op := NewMonitorNodeOperator()
 | 
						var op = NewMonitorNodeOperator()
 | 
				
			||||||
	op.Id = nodeId
 | 
						op.Id = nodeId
 | 
				
			||||||
	op.Name = name
 | 
						op.Name = name
 | 
				
			||||||
	op.Description = description
 | 
						op.Description = description
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -93,7 +93,7 @@ func (this *NSDomainDAO) CreateDomain(tx *dbs.Tx, clusterId int64, userId int64,
 | 
				
			|||||||
		return 0, err
 | 
							return 0, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	op := NewNSDomainOperator()
 | 
						var op = NewNSDomainOperator()
 | 
				
			||||||
	op.ClusterId = clusterId
 | 
						op.ClusterId = clusterId
 | 
				
			||||||
	op.UserId = userId
 | 
						op.UserId = userId
 | 
				
			||||||
	op.Name = name
 | 
						op.Name = name
 | 
				
			||||||
@@ -131,7 +131,7 @@ func (this *NSDomainDAO) UpdateDomain(tx *dbs.Tx, domainId int64, clusterId int6
 | 
				
			|||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	op := NewNSDomainOperator()
 | 
						var op = NewNSDomainOperator()
 | 
				
			||||||
	op.Id = domainId
 | 
						op.Id = domainId
 | 
				
			||||||
	op.ClusterId = clusterId
 | 
						op.ClusterId = clusterId
 | 
				
			||||||
	op.UserId = userId
 | 
						op.UserId = userId
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -79,7 +79,7 @@ func (this *NSKeyDAO) FindNSKeyName(tx *dbs.Tx, id int64) (string, error) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// CreateKey 创建Key
 | 
					// CreateKey 创建Key
 | 
				
			||||||
func (this *NSKeyDAO) CreateKey(tx *dbs.Tx, domainId int64, zoneId int64, name string, algo dnsconfigs.KeyAlgorithmType, secret string, secretType string) (int64, error) {
 | 
					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.DomainId = domainId
 | 
				
			||||||
	op.ZoneId = zoneId
 | 
						op.ZoneId = zoneId
 | 
				
			||||||
	op.Name = name
 | 
						op.Name = name
 | 
				
			||||||
@@ -105,7 +105,7 @@ func (this *NSKeyDAO) UpdateKey(tx *dbs.Tx, keyId int64, name string, algo dnsco
 | 
				
			|||||||
	if keyId <= 0 {
 | 
						if keyId <= 0 {
 | 
				
			||||||
		return errors.New("invalid keyId")
 | 
							return errors.New("invalid keyId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewNSKeyOperator()
 | 
						var op = NewNSKeyOperator()
 | 
				
			||||||
	op.Id = keyId
 | 
						op.Id = keyId
 | 
				
			||||||
	op.Name = name
 | 
						op.Name = name
 | 
				
			||||||
	op.Algo = algo
 | 
						op.Algo = algo
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -95,7 +95,7 @@ func (this *NSRecordDAO) CreateRecord(tx *dbs.Tx, domainId int64, description st
 | 
				
			|||||||
		return 0, err
 | 
							return 0, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	op := NewNSRecordOperator()
 | 
						var op = NewNSRecordOperator()
 | 
				
			||||||
	op.DomainId = domainId
 | 
						op.DomainId = domainId
 | 
				
			||||||
	op.Description = description
 | 
						op.Description = description
 | 
				
			||||||
	op.Name = name
 | 
						op.Name = name
 | 
				
			||||||
@@ -139,7 +139,7 @@ func (this *NSRecordDAO) UpdateRecord(tx *dbs.Tx, recordId int64, description st
 | 
				
			|||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	op := NewNSRecordOperator()
 | 
						var op = NewNSRecordOperator()
 | 
				
			||||||
	op.Id = recordId
 | 
						op.Id = recordId
 | 
				
			||||||
	op.Description = description
 | 
						op.Description = description
 | 
				
			||||||
	op.Name = name
 | 
						op.Name = name
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -129,7 +129,7 @@ func (this *NSRouteDAO) CreateRoute(tx *dbs.Tx, clusterId int64, domainId int64,
 | 
				
			|||||||
		return 0, err
 | 
							return 0, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	op := NewNSRouteOperator()
 | 
						var op = NewNSRouteOperator()
 | 
				
			||||||
	op.ClusterId = clusterId
 | 
						op.ClusterId = clusterId
 | 
				
			||||||
	op.DomainId = domainId
 | 
						op.DomainId = domainId
 | 
				
			||||||
	op.UserId = userId
 | 
						op.UserId = userId
 | 
				
			||||||
@@ -166,7 +166,7 @@ func (this *NSRouteDAO) UpdateRoute(tx *dbs.Tx, routeId int64, name string, rang
 | 
				
			|||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	op := NewNSRouteOperator()
 | 
						var op = NewNSRouteOperator()
 | 
				
			||||||
	op.Id = routeId
 | 
						op.Id = routeId
 | 
				
			||||||
	op.Name = name
 | 
						op.Name = name
 | 
				
			||||||
	if len(rangesJSON) > 0 {
 | 
						if len(rangesJSON) > 0 {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -133,7 +133,7 @@ func (this *NodeClusterDAO) CreateCluster(tx *dbs.Tx, adminId int64, name string
 | 
				
			|||||||
		return 0, err
 | 
							return 0, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	op := NewNodeClusterOperator()
 | 
						var op = NewNodeClusterOperator()
 | 
				
			||||||
	op.AdminId = adminId
 | 
						op.AdminId = adminId
 | 
				
			||||||
	op.Name = name
 | 
						op.Name = name
 | 
				
			||||||
	op.GrantId = grantId
 | 
						op.GrantId = grantId
 | 
				
			||||||
@@ -186,7 +186,7 @@ func (this *NodeClusterDAO) UpdateCluster(tx *dbs.Tx, clusterId int64, name stri
 | 
				
			|||||||
	if clusterId <= 0 {
 | 
						if clusterId <= 0 {
 | 
				
			||||||
		return errors.New("invalid clusterId")
 | 
							return errors.New("invalid clusterId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewNodeClusterOperator()
 | 
						var op = NewNodeClusterOperator()
 | 
				
			||||||
	op.Id = clusterId
 | 
						op.Id = clusterId
 | 
				
			||||||
	op.Name = name
 | 
						op.Name = name
 | 
				
			||||||
	op.GrantId = grantId
 | 
						op.GrantId = grantId
 | 
				
			||||||
@@ -325,7 +325,7 @@ func (this *NodeClusterDAO) UpdateClusterHealthCheck(tx *dbs.Tx, clusterId int64
 | 
				
			|||||||
	if clusterId <= 0 {
 | 
						if clusterId <= 0 {
 | 
				
			||||||
		return errors.New("invalid clusterId '" + strconv.FormatInt(clusterId, 10) + "'")
 | 
							return errors.New("invalid clusterId '" + strconv.FormatInt(clusterId, 10) + "'")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewNodeClusterOperator()
 | 
						var op = NewNodeClusterOperator()
 | 
				
			||||||
	op.Id = clusterId
 | 
						op.Id = clusterId
 | 
				
			||||||
	op.HealthCheck = healthCheckJSON
 | 
						op.HealthCheck = healthCheckJSON
 | 
				
			||||||
	// 不需要通知更新
 | 
						// 不需要通知更新
 | 
				
			||||||
@@ -570,7 +570,7 @@ func (this *NodeClusterDAO) UpdateClusterTOA(tx *dbs.Tx, clusterId int64, toaJSO
 | 
				
			|||||||
	if clusterId <= 0 {
 | 
						if clusterId <= 0 {
 | 
				
			||||||
		return errors.New("invalid clusterId")
 | 
							return errors.New("invalid clusterId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewNodeClusterOperator()
 | 
						var op = NewNodeClusterOperator()
 | 
				
			||||||
	op.Id = clusterId
 | 
						op.Id = clusterId
 | 
				
			||||||
	op.Toa = toaJSON
 | 
						op.Toa = toaJSON
 | 
				
			||||||
	err := this.Save(tx, op)
 | 
						err := this.Save(tx, op)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -84,7 +84,7 @@ func (this *NodeClusterFirewallActionDAO) CreateFirewallAction(tx *dbs.Tx, admin
 | 
				
			|||||||
		params = maps.Map{}
 | 
							params = maps.Map{}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	op := NewNodeClusterFirewallActionOperator()
 | 
						var op = NewNodeClusterFirewallActionOperator()
 | 
				
			||||||
	op.AdminId = adminId
 | 
						op.AdminId = adminId
 | 
				
			||||||
	op.ClusterId = clusterId
 | 
						op.ClusterId = clusterId
 | 
				
			||||||
	op.Name = name
 | 
						op.Name = name
 | 
				
			||||||
@@ -113,7 +113,7 @@ func (this *NodeClusterFirewallActionDAO) UpdateFirewallAction(tx *dbs.Tx, actio
 | 
				
			|||||||
		params = maps.Map{}
 | 
							params = maps.Map{}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	op := NewNodeClusterFirewallActionOperator()
 | 
						var op = NewNodeClusterFirewallActionOperator()
 | 
				
			||||||
	op.Id = actionId
 | 
						op.Id = actionId
 | 
				
			||||||
	op.Name = name
 | 
						op.Name = name
 | 
				
			||||||
	op.EventLevel = eventLevel
 | 
						op.EventLevel = eventLevel
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -167,7 +167,7 @@ func (this *NodeDAO) CreateNode(tx *dbs.Tx, adminId int64, name string, clusterI
 | 
				
			|||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	op := NewNodeOperator()
 | 
						var op = NewNodeOperator()
 | 
				
			||||||
	op.AdminId = adminId
 | 
						op.AdminId = adminId
 | 
				
			||||||
	op.Name = name
 | 
						op.Name = name
 | 
				
			||||||
	op.UniqueId = uniqueId
 | 
						op.UniqueId = uniqueId
 | 
				
			||||||
@@ -1246,7 +1246,7 @@ func (this *NodeDAO) UpdateNodeConnectedAPINodes(tx *dbs.Tx, nodeId int64, apiNo
 | 
				
			|||||||
		return errors.New("invalid nodeId")
 | 
							return errors.New("invalid nodeId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	op := NewNodeOperator()
 | 
						var op = NewNodeOperator()
 | 
				
			||||||
	op.Id = nodeId
 | 
						op.Id = nodeId
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if len(apiNodeIds) > 0 {
 | 
						if len(apiNodeIds) > 0 {
 | 
				
			||||||
@@ -1476,7 +1476,7 @@ func (this *NodeDAO) UpdateNodeDNS(tx *dbs.Tx, nodeId int64, routes map[int64][]
 | 
				
			|||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewNodeOperator()
 | 
						var op = NewNodeOperator()
 | 
				
			||||||
	op.Id = nodeId
 | 
						op.Id = nodeId
 | 
				
			||||||
	op.DnsRoutes = routesJSON
 | 
						op.DnsRoutes = routesJSON
 | 
				
			||||||
	err = this.Save(tx, op)
 | 
						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)
 | 
						countUp := int(one.(*Node).CountUp)
 | 
				
			||||||
	countDown := int(one.(*Node).CountDown)
 | 
						countDown := int(one.(*Node).CountDown)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	op := NewNodeOperator()
 | 
						var op = NewNodeOperator()
 | 
				
			||||||
	op.Id = nodeId
 | 
						op.Id = nodeId
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if isUp {
 | 
						if isUp {
 | 
				
			||||||
@@ -1645,7 +1645,7 @@ func (this *NodeDAO) UpdateNodeUp(tx *dbs.Tx, nodeId int64, isUp bool) error {
 | 
				
			|||||||
		return errors.New("invalid nodeId")
 | 
							return errors.New("invalid nodeId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	op := NewNodeOperator()
 | 
						var op = NewNodeOperator()
 | 
				
			||||||
	op.Id = nodeId
 | 
						op.Id = nodeId
 | 
				
			||||||
	op.IsUp = isUp
 | 
						op.IsUp = isUp
 | 
				
			||||||
	op.CountUp = 0
 | 
						op.CountUp = 0
 | 
				
			||||||
@@ -1767,7 +1767,7 @@ func (this *NodeDAO) DeleteNodeFromCluster(tx *dbs.Tx, nodeId int64, clusterId i
 | 
				
			|||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewNodeOperator()
 | 
						var op = NewNodeOperator()
 | 
				
			||||||
	op.Id = nodeId
 | 
						op.Id = nodeId
 | 
				
			||||||
	op.ClusterId = newClusterId
 | 
						op.ClusterId = newClusterId
 | 
				
			||||||
	op.SecondaryClusterIds = secondaryClusterIdsJSON
 | 
						op.SecondaryClusterIds = secondaryClusterIdsJSON
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -75,7 +75,7 @@ func (this *NodeGrantDAO) FindNodeGrantName(tx *dbs.Tx, id uint32) (string, erro
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// CreateGrant 创建认证信息
 | 
					// 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) {
 | 
					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.AdminId = adminId
 | 
				
			||||||
	op.Name = name
 | 
						op.Name = name
 | 
				
			||||||
	op.Method = method
 | 
						op.Method = method
 | 
				
			||||||
@@ -103,7 +103,7 @@ func (this *NodeGrantDAO) UpdateGrant(tx *dbs.Tx, grantId int64, name string, me
 | 
				
			|||||||
		return errors.New("invalid grantId")
 | 
							return errors.New("invalid grantId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	op := NewNodeGrantOperator()
 | 
						var op = NewNodeGrantOperator()
 | 
				
			||||||
	op.Id = grantId
 | 
						op.Id = grantId
 | 
				
			||||||
	op.Name = name
 | 
						op.Name = name
 | 
				
			||||||
	op.Method = method
 | 
						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) {
 | 
					func (this *NodeGroupDAO) CreateNodeGroup(tx *dbs.Tx, clusterId int64, name string) (int64, error) {
 | 
				
			||||||
	op := NewNodeGroupOperator()
 | 
						var op = NewNodeGroupOperator()
 | 
				
			||||||
	op.ClusterId = clusterId
 | 
						op.ClusterId = clusterId
 | 
				
			||||||
	op.Name = name
 | 
						op.Name = name
 | 
				
			||||||
	op.State = NodeGroupStateEnabled
 | 
						op.State = NodeGroupStateEnabled
 | 
				
			||||||
@@ -89,7 +89,7 @@ func (this *NodeGroupDAO) UpdateNodeGroup(tx *dbs.Tx, groupId int64, name string
 | 
				
			|||||||
	if groupId <= 0 {
 | 
						if groupId <= 0 {
 | 
				
			||||||
		return errors.New("invalid groupId")
 | 
							return errors.New("invalid groupId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewNodeGroupOperator()
 | 
						var op = NewNodeGroupOperator()
 | 
				
			||||||
	op.Id = groupId
 | 
						op.Id = groupId
 | 
				
			||||||
	op.Name = name
 | 
						op.Name = name
 | 
				
			||||||
	err := this.Save(tx, op)
 | 
						err := this.Save(tx, op)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -161,7 +161,7 @@ func (this *NodeIPAddressDAO) UpdateAddress(tx *dbs.Tx, adminId int64, addressId
 | 
				
			|||||||
		return errors.New("invalid addressId")
 | 
							return errors.New("invalid addressId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	op := NewNodeIPAddressOperator()
 | 
						var op = NewNodeIPAddressOperator()
 | 
				
			||||||
	op.Id = addressId
 | 
						op.Id = addressId
 | 
				
			||||||
	op.Name = name
 | 
						op.Name = name
 | 
				
			||||||
	op.Ip = ip
 | 
						op.Ip = ip
 | 
				
			||||||
@@ -189,7 +189,7 @@ func (this *NodeIPAddressDAO) UpdateAddressIP(tx *dbs.Tx, addressId int64, ip st
 | 
				
			|||||||
	if addressId <= 0 {
 | 
						if addressId <= 0 {
 | 
				
			||||||
		return errors.New("invalid addressId")
 | 
							return errors.New("invalid addressId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewNodeIPAddressOperator()
 | 
						var op = NewNodeIPAddressOperator()
 | 
				
			||||||
	op.Id = addressId
 | 
						op.Id = addressId
 | 
				
			||||||
	op.Ip = ip
 | 
						op.Ip = ip
 | 
				
			||||||
	err := this.Save(tx, op)
 | 
						err := this.Save(tx, op)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -75,7 +75,7 @@ func (this *NodePriceItemDAO) FindNodePriceItemName(tx *dbs.Tx, id int64) (strin
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// CreateItem 创建价格
 | 
					// CreateItem 创建价格
 | 
				
			||||||
func (this *NodePriceItemDAO) CreateItem(tx *dbs.Tx, name string, itemType string, bitsFrom, bitsTo int64) (int64, error) {
 | 
					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.Name = name
 | 
				
			||||||
	op.Type = itemType
 | 
						op.Type = itemType
 | 
				
			||||||
	op.BitsFrom = bitsFrom
 | 
						op.BitsFrom = bitsFrom
 | 
				
			||||||
@@ -90,7 +90,7 @@ func (this *NodePriceItemDAO) UpdateItem(tx *dbs.Tx, itemId int64, name string,
 | 
				
			|||||||
	if itemId <= 0 {
 | 
						if itemId <= 0 {
 | 
				
			||||||
		return errors.New("invalid itemId")
 | 
							return errors.New("invalid itemId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewNodePriceItemOperator()
 | 
						var op = NewNodePriceItemOperator()
 | 
				
			||||||
	op.Id = itemId
 | 
						op.Id = itemId
 | 
				
			||||||
	op.Name = name
 | 
						op.Name = name
 | 
				
			||||||
	op.BitsFrom = bitsFrom
 | 
						op.BitsFrom = bitsFrom
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -75,7 +75,7 @@ func (this *NodeRegionDAO) FindNodeRegionName(tx *dbs.Tx, id int64) (string, err
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// CreateRegion 创建区域
 | 
					// CreateRegion 创建区域
 | 
				
			||||||
func (this *NodeRegionDAO) CreateRegion(tx *dbs.Tx, adminId int64, name string, description string) (int64, error) {
 | 
					func (this *NodeRegionDAO) CreateRegion(tx *dbs.Tx, adminId int64, name string, description string) (int64, error) {
 | 
				
			||||||
	op := NewNodeRegionOperator()
 | 
						var op = NewNodeRegionOperator()
 | 
				
			||||||
	op.AdminId = adminId
 | 
						op.AdminId = adminId
 | 
				
			||||||
	op.Name = name
 | 
						op.Name = name
 | 
				
			||||||
	op.Description = description
 | 
						op.Description = description
 | 
				
			||||||
@@ -89,7 +89,7 @@ func (this *NodeRegionDAO) UpdateRegion(tx *dbs.Tx, regionId int64, name string,
 | 
				
			|||||||
	if regionId <= 0 {
 | 
						if regionId <= 0 {
 | 
				
			||||||
		return errors.New("invalid regionId")
 | 
							return errors.New("invalid regionId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewNodeRegionOperator()
 | 
						var op = NewNodeRegionOperator()
 | 
				
			||||||
	op.Id = regionId
 | 
						op.Id = regionId
 | 
				
			||||||
	op.Name = name
 | 
						op.Name = name
 | 
				
			||||||
	op.Description = description
 | 
						op.Description = description
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -72,7 +72,7 @@ func (this *NodeThresholdDAO) FindEnabledNodeThreshold(tx *dbs.Tx, id int64) (*N
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// CreateThreshold 创建阈值
 | 
					// 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) {
 | 
					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.Role = role
 | 
				
			||||||
	op.ClusterId = clusterId
 | 
						op.ClusterId = clusterId
 | 
				
			||||||
	op.NodeId = nodeId
 | 
						op.NodeId = nodeId
 | 
				
			||||||
@@ -95,7 +95,7 @@ func (this *NodeThresholdDAO) UpdateThreshold(tx *dbs.Tx, thresholdId int64, ite
 | 
				
			|||||||
	if thresholdId <= 0 {
 | 
						if thresholdId <= 0 {
 | 
				
			||||||
		return errors.New("invalid thresholdId")
 | 
							return errors.New("invalid thresholdId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewNodeThresholdOperator()
 | 
						var op = NewNodeThresholdOperator()
 | 
				
			||||||
	op.Id = thresholdId
 | 
						op.Id = thresholdId
 | 
				
			||||||
	op.Item = item
 | 
						op.Item = item
 | 
				
			||||||
	op.Param = param
 | 
						op.Param = param
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -75,7 +75,7 @@ func (this *NSClusterDAO) FindEnabledNSClusterName(tx *dbs.Tx, id int64) (string
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// CreateCluster 创建集群
 | 
					// CreateCluster 创建集群
 | 
				
			||||||
func (this *NSClusterDAO) CreateCluster(tx *dbs.Tx, name string, accessLogRefJSON []byte) (int64, error) {
 | 
					func (this *NSClusterDAO) CreateCluster(tx *dbs.Tx, name string, accessLogRefJSON []byte) (int64, error) {
 | 
				
			||||||
	op := NewNSClusterOperator()
 | 
						var op = NewNSClusterOperator()
 | 
				
			||||||
	op.Name = name
 | 
						op.Name = name
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if len(accessLogRefJSON) > 0 {
 | 
						if len(accessLogRefJSON) > 0 {
 | 
				
			||||||
@@ -92,7 +92,7 @@ func (this *NSClusterDAO) UpdateCluster(tx *dbs.Tx, clusterId int64, name string
 | 
				
			|||||||
	if clusterId <= 0 {
 | 
						if clusterId <= 0 {
 | 
				
			||||||
		return errors.New("invalid clusterId")
 | 
							return errors.New("invalid clusterId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewNSClusterOperator()
 | 
						var op = NewNSClusterOperator()
 | 
				
			||||||
	op.Id = clusterId
 | 
						op.Id = clusterId
 | 
				
			||||||
	op.Name = name
 | 
						op.Name = name
 | 
				
			||||||
	op.IsOn = isOn
 | 
						op.IsOn = isOn
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -226,7 +226,7 @@ func (this *NSNodeDAO) CreateNode(tx *dbs.Tx, adminId int64, name string, cluste
 | 
				
			|||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	op := NewNSNodeOperator()
 | 
						var op = NewNSNodeOperator()
 | 
				
			||||||
	op.AdminId = adminId
 | 
						op.AdminId = adminId
 | 
				
			||||||
	op.Name = name
 | 
						op.Name = name
 | 
				
			||||||
	op.UniqueId = uniqueId
 | 
						op.UniqueId = uniqueId
 | 
				
			||||||
@@ -260,7 +260,7 @@ func (this *NSNodeDAO) UpdateNode(tx *dbs.Tx, nodeId int64, name string, cluster
 | 
				
			|||||||
	if nodeId <= 0 {
 | 
						if nodeId <= 0 {
 | 
				
			||||||
		return errors.New("invalid nodeId")
 | 
							return errors.New("invalid nodeId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewNSNodeOperator()
 | 
						var op = NewNSNodeOperator()
 | 
				
			||||||
	op.Id = nodeId
 | 
						op.Id = nodeId
 | 
				
			||||||
	op.Name = name
 | 
						op.Name = name
 | 
				
			||||||
	op.ClusterId = clusterId
 | 
						op.ClusterId = clusterId
 | 
				
			||||||
@@ -487,7 +487,7 @@ func (this *NSNodeDAO) UpdateNodeConnectedAPINodes(tx *dbs.Tx, nodeId int64, api
 | 
				
			|||||||
		return errors.New("invalid nodeId")
 | 
							return errors.New("invalid nodeId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	op := NewNSNodeOperator()
 | 
						var op = NewNSNodeOperator()
 | 
				
			||||||
	op.Id = nodeId
 | 
						op.Id = nodeId
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if len(apiNodeIds) > 0 {
 | 
						if len(apiNodeIds) > 0 {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -86,7 +86,7 @@ func (this *RegionCityDAO) FindCityWithDataId(tx *dbs.Tx, dataId string) (int64,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// CreateCity 创建城市
 | 
					// CreateCity 创建城市
 | 
				
			||||||
func (this *RegionCityDAO) CreateCity(tx *dbs.Tx, provinceId int64, name string, dataId string) (int64, error) {
 | 
					func (this *RegionCityDAO) CreateCity(tx *dbs.Tx, provinceId int64, name string, dataId string) (int64, error) {
 | 
				
			||||||
	op := NewRegionCityOperator()
 | 
						var op = NewRegionCityOperator()
 | 
				
			||||||
	op.ProvinceId = provinceId
 | 
						op.ProvinceId = provinceId
 | 
				
			||||||
	op.Name = name
 | 
						op.Name = name
 | 
				
			||||||
	op.DataId = dataId
 | 
						op.DataId = dataId
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -133,7 +133,7 @@ func (this *RegionCountryDAO) FindCountryIdWithNameCacheable(tx *dbs.Tx, country
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// CreateCountry 根据数据ID创建国家
 | 
					// CreateCountry 根据数据ID创建国家
 | 
				
			||||||
func (this *RegionCountryDAO) CreateCountry(tx *dbs.Tx, name string, dataId string) (int64, error) {
 | 
					func (this *RegionCountryDAO) CreateCountry(tx *dbs.Tx, name string, dataId string) (int64, error) {
 | 
				
			||||||
	op := NewRegionCountryOperator()
 | 
						var op = NewRegionCountryOperator()
 | 
				
			||||||
	op.Name = name
 | 
						op.Name = name
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pinyinPieces := pinyin.Pinyin(name, pinyin.NewArgs())
 | 
						pinyinPieces := pinyin.Pinyin(name, pinyin.NewArgs())
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -102,7 +102,7 @@ func (this *RegionProviderDAO) FindProviderIdWithNameCacheable(tx *dbs.Tx, provi
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// CreateProvider 创建Provider
 | 
					// CreateProvider 创建Provider
 | 
				
			||||||
func (this *RegionProviderDAO) CreateProvider(tx *dbs.Tx, name string) (int64, error) {
 | 
					func (this *RegionProviderDAO) CreateProvider(tx *dbs.Tx, name string) (int64, error) {
 | 
				
			||||||
	op := NewRegionProviderOperator()
 | 
						var op = NewRegionProviderOperator()
 | 
				
			||||||
	op.Name = name
 | 
						op.Name = name
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	codesJSON, err := json.Marshal([]string{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) {
 | 
					func (this *RegionProvinceDAO) CreateProvince(tx *dbs.Tx, countryId int64, name string, dataId string) (int64, error) {
 | 
				
			||||||
	op := NewRegionProvinceOperator()
 | 
						var op = NewRegionProvinceOperator()
 | 
				
			||||||
	op.CountryId = countryId
 | 
						op.CountryId = countryId
 | 
				
			||||||
	op.Name = name
 | 
						op.Name = name
 | 
				
			||||||
	op.DataId = dataId
 | 
						op.DataId = dataId
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -98,7 +98,7 @@ func (this *ReportNodeDAO) CreateReportNode(tx *dbs.Tx, name string, location st
 | 
				
			|||||||
		return 0, err
 | 
							return 0, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	op := NewReportNodeOperator()
 | 
						var op = NewReportNodeOperator()
 | 
				
			||||||
	op.UniqueId = uniqueId
 | 
						op.UniqueId = uniqueId
 | 
				
			||||||
	op.Secret = secret
 | 
						op.Secret = secret
 | 
				
			||||||
	op.Name = name
 | 
						op.Name = name
 | 
				
			||||||
@@ -136,7 +136,7 @@ func (this *ReportNodeDAO) UpdateReportNode(tx *dbs.Tx, nodeId int64, name strin
 | 
				
			|||||||
		return errors.New("invalid nodeId")
 | 
							return errors.New("invalid nodeId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	op := NewReportNodeOperator()
 | 
						var op = NewReportNodeOperator()
 | 
				
			||||||
	op.Id = nodeId
 | 
						op.Id = nodeId
 | 
				
			||||||
	op.Name = name
 | 
						op.Name = name
 | 
				
			||||||
	op.Location = location
 | 
						op.Location = location
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -212,7 +212,7 @@ func (this *ReverseProxyDAO) ComposeReverseProxyConfig(tx *dbs.Tx, reverseProxyI
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// CreateReverseProxy 创建反向代理
 | 
					// CreateReverseProxy 创建反向代理
 | 
				
			||||||
func (this *ReverseProxyDAO) CreateReverseProxy(tx *dbs.Tx, adminId int64, userId int64, schedulingJSON []byte, primaryOriginsJSON []byte, backupOriginsJSON []byte) (int64, error) {
 | 
					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.IsOn = true
 | 
				
			||||||
	op.State = ReverseProxyStateEnabled
 | 
						op.State = ReverseProxyStateEnabled
 | 
				
			||||||
	op.AdminId = adminId
 | 
						op.AdminId = adminId
 | 
				
			||||||
@@ -248,7 +248,7 @@ func (this *ReverseProxyDAO) UpdateReverseProxyScheduling(tx *dbs.Tx, reversePro
 | 
				
			|||||||
	if reverseProxyId <= 0 {
 | 
						if reverseProxyId <= 0 {
 | 
				
			||||||
		return errors.New("invalid reverseProxyId")
 | 
							return errors.New("invalid reverseProxyId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewReverseProxyOperator()
 | 
						var op = NewReverseProxyOperator()
 | 
				
			||||||
	op.Id = reverseProxyId
 | 
						op.Id = reverseProxyId
 | 
				
			||||||
	if len(schedulingJSON) > 0 {
 | 
						if len(schedulingJSON) > 0 {
 | 
				
			||||||
		op.Scheduling = string(schedulingJSON)
 | 
							op.Scheduling = string(schedulingJSON)
 | 
				
			||||||
@@ -267,7 +267,7 @@ func (this *ReverseProxyDAO) UpdateReverseProxyPrimaryOrigins(tx *dbs.Tx, revers
 | 
				
			|||||||
	if reverseProxyId <= 0 {
 | 
						if reverseProxyId <= 0 {
 | 
				
			||||||
		return errors.New("invalid reverseProxyId")
 | 
							return errors.New("invalid reverseProxyId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewReverseProxyOperator()
 | 
						var op = NewReverseProxyOperator()
 | 
				
			||||||
	op.Id = reverseProxyId
 | 
						op.Id = reverseProxyId
 | 
				
			||||||
	if len(origins) > 0 {
 | 
						if len(origins) > 0 {
 | 
				
			||||||
		op.PrimaryOrigins = origins
 | 
							op.PrimaryOrigins = origins
 | 
				
			||||||
@@ -286,7 +286,7 @@ func (this *ReverseProxyDAO) UpdateReverseProxyBackupOrigins(tx *dbs.Tx, reverse
 | 
				
			|||||||
	if reverseProxyId <= 0 {
 | 
						if reverseProxyId <= 0 {
 | 
				
			||||||
		return errors.New("invalid reverseProxyId")
 | 
							return errors.New("invalid reverseProxyId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewReverseProxyOperator()
 | 
						var op = NewReverseProxyOperator()
 | 
				
			||||||
	op.Id = reverseProxyId
 | 
						op.Id = reverseProxyId
 | 
				
			||||||
	if len(origins) > 0 {
 | 
						if len(origins) > 0 {
 | 
				
			||||||
		op.BackupOrigins = origins
 | 
							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")
 | 
							return errors.New("serverId should not be smaller than 0")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	op := NewServerOperator()
 | 
						var op = NewServerOperator()
 | 
				
			||||||
	op.Id = serverId
 | 
						op.Id = serverId
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if IsNull(serverNamesJSON) {
 | 
						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")
 | 
							return errors.New("serverId should not be smaller than 0")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	op := NewServerOperator()
 | 
						var op = NewServerOperator()
 | 
				
			||||||
	op.Id = serverId
 | 
						op.Id = serverId
 | 
				
			||||||
	op.IsAuditing = isAuditing
 | 
						op.IsAuditing = isAuditing
 | 
				
			||||||
	if isAuditing {
 | 
						if isAuditing {
 | 
				
			||||||
@@ -739,7 +739,7 @@ func (this *ServerDAO) UpdateServerReverseProxy(tx *dbs.Tx, serverId int64, conf
 | 
				
			|||||||
	if serverId <= 0 {
 | 
						if serverId <= 0 {
 | 
				
			||||||
		return errors.New("serverId should not be smaller than 0")
 | 
							return errors.New("serverId should not be smaller than 0")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewServerOperator()
 | 
						var op = NewServerOperator()
 | 
				
			||||||
	op.Id = serverId
 | 
						op.Id = serverId
 | 
				
			||||||
	op.ReverseProxy = JSONBytes(config)
 | 
						op.ReverseProxy = JSONBytes(config)
 | 
				
			||||||
	err := this.Save(tx, op)
 | 
						err := this.Save(tx, op)
 | 
				
			||||||
@@ -1607,7 +1607,7 @@ func (this *ServerDAO) GenerateServerDNSName(tx *dbs.Tx, serverId int64) (string
 | 
				
			|||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return "", err
 | 
							return "", err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewServerOperator()
 | 
						var op = NewServerOperator()
 | 
				
			||||||
	op.Id = serverId
 | 
						op.Id = serverId
 | 
				
			||||||
	op.DnsName = dnsName
 | 
						op.DnsName = dnsName
 | 
				
			||||||
	err = this.Save(tx, op)
 | 
						err = this.Save(tx, op)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -78,7 +78,7 @@ func (this *ServerGroupDAO) FindServerGroupName(tx *dbs.Tx, id int64) (string, e
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// CreateGroup 创建分组
 | 
					// CreateGroup 创建分组
 | 
				
			||||||
func (this *ServerGroupDAO) CreateGroup(tx *dbs.Tx, name string, userId int64) (groupId int64, err error) {
 | 
					func (this *ServerGroupDAO) CreateGroup(tx *dbs.Tx, name string, userId int64) (groupId int64, err error) {
 | 
				
			||||||
	op := NewServerGroupOperator()
 | 
						var op = NewServerGroupOperator()
 | 
				
			||||||
	op.State = ServerGroupStateEnabled
 | 
						op.State = ServerGroupStateEnabled
 | 
				
			||||||
	op.Name = name
 | 
						op.Name = name
 | 
				
			||||||
	op.UserId = userId
 | 
						op.UserId = userId
 | 
				
			||||||
@@ -95,7 +95,7 @@ func (this *ServerGroupDAO) UpdateGroup(tx *dbs.Tx, groupId int64, name string)
 | 
				
			|||||||
	if groupId <= 0 {
 | 
						if groupId <= 0 {
 | 
				
			||||||
		return errors.New("invalid groupId")
 | 
							return errors.New("invalid groupId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewServerGroupOperator()
 | 
						var op = NewServerGroupOperator()
 | 
				
			||||||
	op.Id = groupId
 | 
						op.Id = groupId
 | 
				
			||||||
	op.Name = name
 | 
						op.Name = name
 | 
				
			||||||
	err := this.Save(tx, op)
 | 
						err := this.Save(tx, op)
 | 
				
			||||||
@@ -193,7 +193,7 @@ func (this *ServerGroupDAO) UpdateHTTPReverseProxy(tx *dbs.Tx, groupId int64, co
 | 
				
			|||||||
	if groupId <= 0 {
 | 
						if groupId <= 0 {
 | 
				
			||||||
		return errors.New("groupId should not be smaller than 0")
 | 
							return errors.New("groupId should not be smaller than 0")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewServerGroupOperator()
 | 
						var op = NewServerGroupOperator()
 | 
				
			||||||
	op.Id = groupId
 | 
						op.Id = groupId
 | 
				
			||||||
	op.HttpReverseProxy = JSONBytes(config)
 | 
						op.HttpReverseProxy = JSONBytes(config)
 | 
				
			||||||
	err := this.Save(tx, op)
 | 
						err := this.Save(tx, op)
 | 
				
			||||||
@@ -209,7 +209,7 @@ func (this *ServerGroupDAO) UpdateTCPReverseProxy(tx *dbs.Tx, groupId int64, con
 | 
				
			|||||||
	if groupId <= 0 {
 | 
						if groupId <= 0 {
 | 
				
			||||||
		return errors.New("groupId should not be smaller than 0")
 | 
							return errors.New("groupId should not be smaller than 0")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewServerGroupOperator()
 | 
						var op = NewServerGroupOperator()
 | 
				
			||||||
	op.Id = groupId
 | 
						op.Id = groupId
 | 
				
			||||||
	op.TcpReverseProxy = JSONBytes(config)
 | 
						op.TcpReverseProxy = JSONBytes(config)
 | 
				
			||||||
	err := this.Save(tx, op)
 | 
						err := this.Save(tx, op)
 | 
				
			||||||
@@ -225,7 +225,7 @@ func (this *ServerGroupDAO) UpdateUDPReverseProxy(tx *dbs.Tx, groupId int64, con
 | 
				
			|||||||
	if groupId <= 0 {
 | 
						if groupId <= 0 {
 | 
				
			||||||
		return errors.New("groupId should not be smaller than 0")
 | 
							return errors.New("groupId should not be smaller than 0")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewServerGroupOperator()
 | 
						var op = NewServerGroupOperator()
 | 
				
			||||||
	op.Id = groupId
 | 
						op.Id = groupId
 | 
				
			||||||
	op.UdpReverseProxy = JSONBytes(config)
 | 
						op.UdpReverseProxy = JSONBytes(config)
 | 
				
			||||||
	err := this.Save(tx, op)
 | 
						err := this.Save(tx, op)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -64,7 +64,7 @@ func (this *ServerStatBoardChartDAO) FindEnabledServerStatBoardChart(tx *dbs.Tx,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// EnableChart 启用图表
 | 
					// EnableChart 启用图表
 | 
				
			||||||
func (this *ServerStatBoardChartDAO) EnableChart(tx *dbs.Tx, boardId int64, chartId int64) error {
 | 
					func (this *ServerStatBoardChartDAO) EnableChart(tx *dbs.Tx, boardId int64, chartId int64) error {
 | 
				
			||||||
	op := NewServerStatBoardChartOperator()
 | 
						var op = NewServerStatBoardChartOperator()
 | 
				
			||||||
	op.BoardId = boardId
 | 
						op.BoardId = boardId
 | 
				
			||||||
	op.ChartId = chartId
 | 
						op.ChartId = chartId
 | 
				
			||||||
	op.State = ServerStatBoardChartStateEnabled
 | 
						op.State = ServerStatBoardChartStateEnabled
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -89,7 +89,7 @@ func (this *SSLCertDAO) FindSSLCertName(tx *dbs.Tx, id int64) (string, error) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// CreateCert 创建证书
 | 
					// 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) {
 | 
					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.AdminId = adminId
 | 
				
			||||||
	op.UserId = userId
 | 
						op.UserId = userId
 | 
				
			||||||
	op.State = SSLCertStateEnabled
 | 
						op.State = SSLCertStateEnabled
 | 
				
			||||||
@@ -343,7 +343,7 @@ func (this *SSLCertDAO) UpdateCertACME(tx *dbs.Tx, certId int64, acmeTaskId int6
 | 
				
			|||||||
	if certId <= 0 {
 | 
						if certId <= 0 {
 | 
				
			||||||
		return errors.New("invalid certId")
 | 
							return errors.New("invalid certId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewSSLCertOperator()
 | 
						var op = NewSSLCertOperator()
 | 
				
			||||||
	op.Id = certId
 | 
						op.Id = certId
 | 
				
			||||||
	op.AcmeTaskId = acmeTaskId
 | 
						op.AcmeTaskId = acmeTaskId
 | 
				
			||||||
	op.IsACME = true
 | 
						op.IsACME = true
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -200,7 +200,7 @@ func (this *SSLPolicyDAO) FindAllEnabledPolicyIdsWithCertId(tx *dbs.Tx, certId i
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// CreatePolicy 创建Policy
 | 
					// 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) {
 | 
					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.State = SSLPolicyStateEnabled
 | 
				
			||||||
	op.IsOn = true
 | 
						op.IsOn = true
 | 
				
			||||||
	op.AdminId = adminId
 | 
						op.AdminId = adminId
 | 
				
			||||||
@@ -244,7 +244,7 @@ func (this *SSLPolicyDAO) UpdatePolicy(tx *dbs.Tx, policyId int64, http2Enabled
 | 
				
			|||||||
		return errors.New("invalid policyId")
 | 
							return errors.New("invalid policyId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	op := NewSSLPolicyOperator()
 | 
						var op = NewSSLPolicyOperator()
 | 
				
			||||||
	op.Id = policyId
 | 
						op.Id = policyId
 | 
				
			||||||
	op.Http2Enabled = http2Enabled
 | 
						op.Http2Enabled = http2Enabled
 | 
				
			||||||
	op.MinVersion = minVersion
 | 
						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")
 | 
							return errors.New("event should not be nil")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	op := NewSysEventOperator()
 | 
						var op = NewSysEventOperator()
 | 
				
			||||||
	op.Type = event.Type()
 | 
						op.Type = event.Type()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	eventJSON, err := json.Marshal(event)
 | 
						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 {
 | 
							if one == nil {
 | 
				
			||||||
			op := NewSysLockerOperator()
 | 
								var op = NewSysLockerOperator()
 | 
				
			||||||
			op.Key = key
 | 
								op.Key = key
 | 
				
			||||||
			op.TimeoutAt = time.Now().Unix() + timeout
 | 
								op.TimeoutAt = time.Now().Unix() + timeout
 | 
				
			||||||
			op.Version = 1
 | 
								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.Id = locker.Id
 | 
				
			||||||
		op.Version = locker.Version + 1
 | 
							op.Version = locker.Version + 1
 | 
				
			||||||
		op.TimeoutAt = time.Now().Unix() + timeout
 | 
							op.TimeoutAt = time.Now().Unix() + timeout
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -65,7 +65,7 @@ func (this *SysSettingDAO) UpdateSetting(tx *dbs.Tx, codeFormat string, valueJSO
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		if settingId == 0 {
 | 
							if settingId == 0 {
 | 
				
			||||||
			// 新建
 | 
								// 新建
 | 
				
			||||||
			op := NewSysSettingOperator()
 | 
								var op = NewSysSettingOperator()
 | 
				
			||||||
			op.Code = codeFormat
 | 
								op.Code = codeFormat
 | 
				
			||||||
			op.Value = valueJSON
 | 
								op.Value = valueJSON
 | 
				
			||||||
			err = this.Save(tx, op)
 | 
								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.Id = settingId
 | 
				
			||||||
		op.Value = valueJSON
 | 
							op.Value = valueJSON
 | 
				
			||||||
		err = this.Save(tx, op)
 | 
							err = this.Save(tx, op)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -70,7 +70,7 @@ func (this *UserAccessKeyDAO) CreateAccessKey(tx *dbs.Tx, adminId int64, userId
 | 
				
			|||||||
	if adminId <= 0 && userId <= 0 {
 | 
						if adminId <= 0 && userId <= 0 {
 | 
				
			||||||
		return 0, errors.New("invalid adminId or userId")
 | 
							return 0, errors.New("invalid adminId or userId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewUserAccessKeyOperator()
 | 
						var op = NewUserAccessKeyOperator()
 | 
				
			||||||
	op.AdminId = adminId
 | 
						op.AdminId = adminId
 | 
				
			||||||
	op.UserId = userId
 | 
						op.UserId = userId
 | 
				
			||||||
	op.Description = description
 | 
						op.Description = description
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -129,7 +129,7 @@ func (this *UserDAO) CreateUser(tx *dbs.Tx, username string,
 | 
				
			|||||||
	features []string,
 | 
						features []string,
 | 
				
			||||||
	registeredIP string,
 | 
						registeredIP string,
 | 
				
			||||||
	isVerified bool) (int64, error) {
 | 
						isVerified bool) (int64, error) {
 | 
				
			||||||
	op := NewUserOperator()
 | 
						var op = NewUserOperator()
 | 
				
			||||||
	op.Username = username
 | 
						op.Username = username
 | 
				
			||||||
	op.Password = stringutil.Md5(password)
 | 
						op.Password = stringutil.Md5(password)
 | 
				
			||||||
	op.Fullname = fullname
 | 
						op.Fullname = fullname
 | 
				
			||||||
@@ -191,7 +191,7 @@ func (this *UserDAO) UpdateUserInfo(tx *dbs.Tx, userId int64, fullname string, m
 | 
				
			|||||||
	if userId <= 0 {
 | 
						if userId <= 0 {
 | 
				
			||||||
		return errors.New("invalid userId")
 | 
							return errors.New("invalid userId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewUserOperator()
 | 
						var op = NewUserOperator()
 | 
				
			||||||
	op.Id = userId
 | 
						op.Id = userId
 | 
				
			||||||
	op.Fullname = fullname
 | 
						op.Fullname = fullname
 | 
				
			||||||
	op.Mobile = mobile
 | 
						op.Mobile = mobile
 | 
				
			||||||
@@ -204,7 +204,7 @@ func (this *UserDAO) UpdateUserLogin(tx *dbs.Tx, userId int64, username string,
 | 
				
			|||||||
	if userId <= 0 {
 | 
						if userId <= 0 {
 | 
				
			||||||
		return errors.New("invalid userId")
 | 
							return errors.New("invalid userId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	op := NewUserOperator()
 | 
						var op = NewUserOperator()
 | 
				
			||||||
	op.Id = userId
 | 
						op.Id = userId
 | 
				
			||||||
	op.Username = username
 | 
						op.Username = username
 | 
				
			||||||
	if len(password) > 0 {
 | 
						if len(password) > 0 {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -66,9 +66,10 @@ func (this *UserIdentityDAO) FindEnabledUserIdentity(tx *dbs.Tx, id int64) (*Use
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// CreateUserIdentity 创建
 | 
					// 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()
 | 
						var op = NewUserIdentityOperator()
 | 
				
			||||||
	op.UserId = userId
 | 
						op.UserId = userId
 | 
				
			||||||
 | 
						op.OrgType = orgType
 | 
				
			||||||
	op.Type = idType
 | 
						op.Type = idType
 | 
				
			||||||
	op.RealName = realName
 | 
						op.RealName = realName
 | 
				
			||||||
	op.Number = number
 | 
						op.Number = number
 | 
				
			||||||
@@ -96,6 +97,7 @@ func (this *UserIdentityDAO) UpdateUserIdentity(tx *dbs.Tx, identityId int64, id
 | 
				
			|||||||
	var op = NewUserIdentityOperator()
 | 
						var op = NewUserIdentityOperator()
 | 
				
			||||||
	op.Id = identityId
 | 
						op.Id = identityId
 | 
				
			||||||
	op.Type = idType
 | 
						op.Type = idType
 | 
				
			||||||
 | 
						op.RealName = realName
 | 
				
			||||||
	op.Number = number
 | 
						op.Number = number
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if fileIds == nil {
 | 
						if fileIds == nil {
 | 
				
			||||||
@@ -107,6 +109,8 @@ func (this *UserIdentityDAO) UpdateUserIdentity(tx *dbs.Tx, identityId int64, id
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	op.FileIds = fileIdsJSON
 | 
						op.FileIds = fileIdsJSON
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						op.Status = userconfigs.UserIdentityStatusNone
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return this.Save(tx, op)
 | 
						return this.Save(tx, op)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -129,10 +133,11 @@ func (this *UserIdentityDAO) CancelUserIdentity(tx *dbs.Tx, identityId int64) er
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// RejectUserIdentity 拒绝
 | 
					// 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).
 | 
						return this.Query(tx).
 | 
				
			||||||
		Pk(identityId).
 | 
							Pk(identityId).
 | 
				
			||||||
		Set("status", userconfigs.UserIdentityStatusRejected).
 | 
							Set("status", userconfigs.UserIdentityStatusRejected).
 | 
				
			||||||
 | 
							Set("rejectedReason", reason).
 | 
				
			||||||
		Set("rejectedAt", time.Now().Unix()).
 | 
							Set("rejectedAt", time.Now().Unix()).
 | 
				
			||||||
		UpdateQuickly()
 | 
							UpdateQuickly()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -170,12 +175,13 @@ func (this *UserIdentityDAO) FindUserIdentityStatus(tx *dbs.Tx, identityId int64
 | 
				
			|||||||
		FindStringCol("")
 | 
							FindStringCol("")
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// FindEnabledUserIdentityWithType 查找某个类型的认证信息
 | 
					// FindEnabledUserIdentityWithOrgType 查找某个类型的认证信息
 | 
				
			||||||
func (this *UserIdentityDAO) FindEnabledUserIdentityWithType(tx *dbs.Tx, userId int64, idType userconfigs.UserIdentityType) (*UserIdentity, error) {
 | 
					func (this *UserIdentityDAO) FindEnabledUserIdentityWithOrgType(tx *dbs.Tx, userId int64, orgType string) (*UserIdentity, error) {
 | 
				
			||||||
	one, err := this.Query(tx).
 | 
						one, err := this.Query(tx).
 | 
				
			||||||
		Attr("userId", userId).
 | 
							Attr("userId", userId).
 | 
				
			||||||
		Attr("type", idType).
 | 
							Attr("orgType", orgType).
 | 
				
			||||||
		State(UserIdentityStateEnabled).
 | 
							State(UserIdentityStateEnabled).
 | 
				
			||||||
 | 
							DescPk().
 | 
				
			||||||
		Find()
 | 
							Find()
 | 
				
			||||||
	if err != nil || one == nil {
 | 
						if err != nil || one == nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -6,7 +6,8 @@ import "github.com/iwind/TeaGo/dbs"
 | 
				
			|||||||
type UserIdentity struct {
 | 
					type UserIdentity struct {
 | 
				
			||||||
	Id             uint64   `field:"id"`             // ID
 | 
						Id             uint64   `field:"id"`             // ID
 | 
				
			||||||
	UserId         uint64   `field:"userId"`         // 用户ID
 | 
						UserId         uint64   `field:"userId"`         // 用户ID
 | 
				
			||||||
	Type        string   `field:"type"`        // 类型
 | 
						OrgType        string   `field:"orgType"`        // 组织类型
 | 
				
			||||||
 | 
						Type           string   `field:"type"`           // 证件类型
 | 
				
			||||||
	RealName       string   `field:"realName"`       // 真实姓名
 | 
						RealName       string   `field:"realName"`       // 真实姓名
 | 
				
			||||||
	Number         string   `field:"number"`         // 编号
 | 
						Number         string   `field:"number"`         // 编号
 | 
				
			||||||
	FileIds        dbs.JSON `field:"fileIds"`        // 文件ID
 | 
						FileIds        dbs.JSON `field:"fileIds"`        // 文件ID
 | 
				
			||||||
@@ -17,12 +18,14 @@ type UserIdentity struct {
 | 
				
			|||||||
	SubmittedAt    uint64   `field:"submittedAt"`    // 提交时间
 | 
						SubmittedAt    uint64   `field:"submittedAt"`    // 提交时间
 | 
				
			||||||
	RejectedAt     uint64   `field:"rejectedAt"`     // 拒绝时间
 | 
						RejectedAt     uint64   `field:"rejectedAt"`     // 拒绝时间
 | 
				
			||||||
	VerifiedAt     uint64   `field:"verifiedAt"`     // 认证时间
 | 
						VerifiedAt     uint64   `field:"verifiedAt"`     // 认证时间
 | 
				
			||||||
 | 
						RejectedReason string   `field:"rejectedReason"` // 拒绝原因
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type UserIdentityOperator struct {
 | 
					type UserIdentityOperator struct {
 | 
				
			||||||
	Id             interface{} // ID
 | 
						Id             interface{} // ID
 | 
				
			||||||
	UserId         interface{} // 用户ID
 | 
						UserId         interface{} // 用户ID
 | 
				
			||||||
	Type        interface{} // 类型
 | 
						OrgType        interface{} // 组织类型
 | 
				
			||||||
 | 
						Type           interface{} // 证件类型
 | 
				
			||||||
	RealName       interface{} // 真实姓名
 | 
						RealName       interface{} // 真实姓名
 | 
				
			||||||
	Number         interface{} // 编号
 | 
						Number         interface{} // 编号
 | 
				
			||||||
	FileIds        interface{} // 文件ID
 | 
						FileIds        interface{} // 文件ID
 | 
				
			||||||
@@ -33,6 +36,7 @@ type UserIdentityOperator struct {
 | 
				
			|||||||
	SubmittedAt    interface{} // 提交时间
 | 
						SubmittedAt    interface{} // 提交时间
 | 
				
			||||||
	RejectedAt     interface{} // 拒绝时间
 | 
						RejectedAt     interface{} // 拒绝时间
 | 
				
			||||||
	VerifiedAt     interface{} // 认证时间
 | 
						VerifiedAt     interface{} // 认证时间
 | 
				
			||||||
 | 
						RejectedReason interface{} // 拒绝原因
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func NewUserIdentityOperator() *UserIdentityOperator {
 | 
					func NewUserIdentityOperator() *UserIdentityOperator {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -162,7 +162,7 @@ func (this *UserNodeDAO) CreateUserNode(tx *dbs.Tx, name string, description str
 | 
				
			|||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	op := NewUserNodeOperator()
 | 
						var op = NewUserNodeOperator()
 | 
				
			||||||
	op.IsOn = isOn
 | 
						op.IsOn = isOn
 | 
				
			||||||
	op.UniqueId = uniqueId
 | 
						op.UniqueId = uniqueId
 | 
				
			||||||
	op.Secret = secret
 | 
						op.Secret = secret
 | 
				
			||||||
@@ -194,7 +194,7 @@ func (this *UserNodeDAO) UpdateUserNode(tx *dbs.Tx, nodeId int64, name string, d
 | 
				
			|||||||
		return errors.New("invalid nodeId")
 | 
							return errors.New("invalid nodeId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	op := NewUserNodeOperator()
 | 
						var op = NewUserNodeOperator()
 | 
				
			||||||
	op.Id = nodeId
 | 
						op.Id = nodeId
 | 
				
			||||||
	op.Name = name
 | 
						op.Name = name
 | 
				
			||||||
	op.Description = description
 | 
						op.Description = description
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -43,6 +43,8 @@ func (this *FileService) FindEnabledFile(ctx context.Context, req *pb.FindEnable
 | 
				
			|||||||
			Size:      int64(file.Size),
 | 
								Size:      int64(file.Size),
 | 
				
			||||||
			CreatedAt: int64(file.CreatedAt),
 | 
								CreatedAt: int64(file.CreatedAt),
 | 
				
			||||||
			IsPublic:  file.IsPublic,
 | 
								IsPublic:  file.IsPublic,
 | 
				
			||||||
 | 
								MimeType:  file.MimeType,
 | 
				
			||||||
 | 
								Type:      file.Type,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	}, nil
 | 
						}, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -56,7 +58,7 @@ func (this *FileService) CreateFile(ctx context.Context, req *pb.CreateFileReque
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	var tx = this.NullTx()
 | 
						var tx = this.NullTx()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	fileId, err := models.SharedFileDAO.CreateFile(tx, adminId, userId, "ipLibrary", "", req.Filename, req.Size, req.IsPublic)
 | 
						fileId, err := models.SharedFileDAO.CreateFile(tx, adminId, userId, req.Type, "", req.Filename, req.Size, req.MimeType, req.IsPublic)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -15,13 +15,21 @@ type FileChunkService struct {
 | 
				
			|||||||
// CreateFileChunk 创建文件片段
 | 
					// CreateFileChunk 创建文件片段
 | 
				
			||||||
func (this *FileChunkService) CreateFileChunk(ctx context.Context, req *pb.CreateFileChunkRequest) (*pb.CreateFileChunkResponse, error) {
 | 
					func (this *FileChunkService) CreateFileChunk(ctx context.Context, req *pb.CreateFileChunkRequest) (*pb.CreateFileChunkResponse, error) {
 | 
				
			||||||
	// 校验请求
 | 
						// 校验请求
 | 
				
			||||||
	_, err := this.ValidateAdmin(ctx)
 | 
						_, userId, err := this.ValidateAdminAndUser(ctx)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var tx = this.NullTx()
 | 
						var tx = this.NullTx()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// 检查权限
 | 
				
			||||||
 | 
						if userId > 0 {
 | 
				
			||||||
 | 
							err = models.SharedFileDAO.CheckUserFile(tx, userId, req.FileId)
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								return nil, err
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	chunkId, err := models.SharedFileChunkDAO.CreateFileChunk(tx, req.FileId, req.Data)
 | 
						chunkId, err := models.SharedFileChunkDAO.CreateFileChunk(tx, req.FileId, req.Data)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
@@ -37,10 +45,11 @@ func (this *FileChunkService) FindAllFileChunkIds(ctx context.Context, req *pb.F
 | 
				
			|||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// TODO 校验用户
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	var tx = this.NullTx()
 | 
						var tx = this.NullTx()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// 校验用户
 | 
				
			||||||
 | 
						// TODO
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	chunkIds, err := models.SharedFileChunkDAO.FindAllFileChunkIds(tx, req.FileId)
 | 
						chunkIds, err := models.SharedFileChunkDAO.FindAllFileChunkIds(tx, req.FileId)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -27,12 +27,16 @@ func (this *UserIdentityService) CreateUserIdentity(ctx context.Context, req *pb
 | 
				
			|||||||
		if len(req.FileIds) < 2 {
 | 
							if len(req.FileIds) < 2 {
 | 
				
			||||||
			return nil, errors.New("need for file(s) for id card")
 | 
								return nil, errors.New("need for file(s) for id card")
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
						case userconfigs.UserIdentityTypeEnterpriseLicense:
 | 
				
			||||||
 | 
							if len(req.FileIds) != 1 {
 | 
				
			||||||
 | 
								return nil, errors.New("need for file(s) for license")
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	default:
 | 
						default:
 | 
				
			||||||
		return nil, errors.New("unknown identity type '" + req.Type + "'")
 | 
							return nil, errors.New("unknown identity type '" + req.Type + "'")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var tx = this.NullTx()
 | 
						var tx = this.NullTx()
 | 
				
			||||||
	identityId, err := models.SharedUserIdentityDAO.CreateUserIdentity(tx, userId, req.Type, req.RealName, req.Number, req.FileIds)
 | 
						identityId, err := models.SharedUserIdentityDAO.CreateUserIdentity(tx, userId, req.OrgType, req.Type, req.RealName, req.Number, req.FileIds)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -40,29 +44,32 @@ func (this *UserIdentityService) CreateUserIdentity(ctx context.Context, req *pb
 | 
				
			|||||||
	return &pb.CreateUserIdentityResponse{UserIdentityId: identityId}, nil
 | 
						return &pb.CreateUserIdentityResponse{UserIdentityId: identityId}, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// FindUserEnabledUserIdentityWithType 查看身份认证信息
 | 
					// FindEnabledUserIdentity 查找单个身份认证信息
 | 
				
			||||||
func (this *UserIdentityService) FindUserEnabledUserIdentityWithType(ctx context.Context, req *pb.FindUserEnabledUserIdentityWithTypeRequest) (*pb.FindUserEnabledUserIdentityWithTypeResponse, error) {
 | 
					func (this *UserIdentityService) FindEnabledUserIdentity(ctx context.Context, req *pb.FindEnabledUserIdentityRequest) (*pb.FindEnabledUserIdentityResponse, error) {
 | 
				
			||||||
	_, userId, err := this.ValidateAdminAndUser(ctx)
 | 
						_, userId, err := this.ValidateAdminAndUser(ctx)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						var tx = this.NullTx()
 | 
				
			||||||
	if userId > 0 {
 | 
						if userId > 0 {
 | 
				
			||||||
		req.UserId = userId
 | 
							err = models.SharedUserIdentityDAO.CheckUserIdentity(tx, userId, req.UserIdentityId)
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								return nil, err
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var tx = this.NullTx()
 | 
						identity, err := models.SharedUserIdentityDAO.FindEnabledUserIdentity(tx, req.UserIdentityId)
 | 
				
			||||||
	identity, err := models.SharedUserIdentityDAO.FindEnabledUserIdentityWithType(tx, req.UserId, req.Type)
 | 
					 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if identity == nil {
 | 
						if identity == nil {
 | 
				
			||||||
		return &pb.FindUserEnabledUserIdentityWithTypeResponse{
 | 
							return &pb.FindEnabledUserIdentityResponse{
 | 
				
			||||||
			UserIdentity: nil,
 | 
								UserIdentity: nil,
 | 
				
			||||||
		}, nil
 | 
							}, nil
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return &pb.FindUserEnabledUserIdentityWithTypeResponse{
 | 
						return &pb.FindEnabledUserIdentityResponse{
 | 
				
			||||||
		UserIdentity: &pb.UserIdentity{
 | 
							UserIdentity: &pb.UserIdentity{
 | 
				
			||||||
			Id:             int64(identity.Id),
 | 
								Id:             int64(identity.Id),
 | 
				
			||||||
			Type:           identity.Type,
 | 
								Type:           identity.Type,
 | 
				
			||||||
@@ -75,6 +82,47 @@ func (this *UserIdentityService) FindUserEnabledUserIdentityWithType(ctx context
 | 
				
			|||||||
			SubmittedAt:    int64(identity.SubmittedAt),
 | 
								SubmittedAt:    int64(identity.SubmittedAt),
 | 
				
			||||||
			RejectedAt:     int64(identity.RejectedAt),
 | 
								RejectedAt:     int64(identity.RejectedAt),
 | 
				
			||||||
			VerifiedAt:     int64(identity.VerifiedAt),
 | 
								VerifiedAt:     int64(identity.VerifiedAt),
 | 
				
			||||||
 | 
								RejectedReason: identity.RejectedReason,
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
						}, nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// FindEnabledUserIdentityWithOrgType 查看最新的身份认证信息
 | 
				
			||||||
 | 
					func (this *UserIdentityService) FindEnabledUserIdentityWithOrgType(ctx context.Context, req *pb.FindEnabledUserIdentityWithOrgTypeRequest) (*pb.FindEnabledUserIdentityWithOrgTypeResponse, error) {
 | 
				
			||||||
 | 
						_, userId, err := this.ValidateAdminAndUser(ctx)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if userId > 0 {
 | 
				
			||||||
 | 
							req.UserId = userId
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						var tx = this.NullTx()
 | 
				
			||||||
 | 
						identity, err := models.SharedUserIdentityDAO.FindEnabledUserIdentityWithOrgType(tx, req.UserId, req.OrgType)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if identity == nil {
 | 
				
			||||||
 | 
							return &pb.FindEnabledUserIdentityWithOrgTypeResponse{
 | 
				
			||||||
 | 
								UserIdentity: nil,
 | 
				
			||||||
 | 
							}, nil
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return &pb.FindEnabledUserIdentityWithOrgTypeResponse{
 | 
				
			||||||
 | 
							UserIdentity: &pb.UserIdentity{
 | 
				
			||||||
 | 
								Id:             int64(identity.Id),
 | 
				
			||||||
 | 
								Type:           identity.Type,
 | 
				
			||||||
 | 
								RealName:       identity.RealName,
 | 
				
			||||||
 | 
								Number:         identity.Number,
 | 
				
			||||||
 | 
								FileIds:        identity.DecodeFileIds(),
 | 
				
			||||||
 | 
								Status:         identity.Status,
 | 
				
			||||||
 | 
								CreatedAt:      int64(identity.CreatedAt),
 | 
				
			||||||
 | 
								UpdatedAt:      int64(identity.UpdatedAt),
 | 
				
			||||||
 | 
								SubmittedAt:    int64(identity.SubmittedAt),
 | 
				
			||||||
 | 
								RejectedAt:     int64(identity.RejectedAt),
 | 
				
			||||||
 | 
								VerifiedAt:     int64(identity.VerifiedAt),
 | 
				
			||||||
 | 
								RejectedReason: identity.RejectedReason,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	}, nil
 | 
						}, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -88,6 +136,23 @@ func (this *UserIdentityService) UpdateUserIdentity(ctx context.Context, req *pb
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	var tx = this.NullTx()
 | 
						var tx = this.NullTx()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if len(req.RealName) > 100 {
 | 
				
			||||||
 | 
							return nil, errors.New("realName too long")
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						switch req.Type {
 | 
				
			||||||
 | 
						case userconfigs.UserIdentityTypeIDCard:
 | 
				
			||||||
 | 
							if len(req.FileIds) < 2 {
 | 
				
			||||||
 | 
								return nil, errors.New("need for file(s) for id card")
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						case userconfigs.UserIdentityTypeEnterpriseLicense:
 | 
				
			||||||
 | 
							if len(req.FileIds) != 1 {
 | 
				
			||||||
 | 
								return nil, errors.New("need for file(s) for license")
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						default:
 | 
				
			||||||
 | 
							return nil, errors.New("unknown identity type '" + req.Type + "'")
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// 检查用户
 | 
						// 检查用户
 | 
				
			||||||
	err = models.SharedUserIdentityDAO.CheckUserIdentity(tx, userId, req.UserIdentityId)
 | 
						err = models.SharedUserIdentityDAO.CheckUserIdentity(tx, userId, req.UserIdentityId)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
@@ -99,7 +164,7 @@ func (this *UserIdentityService) UpdateUserIdentity(ctx context.Context, req *pb
 | 
				
			|||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if len(status) > 0 && status != userconfigs.UserIdentityStatusNone {
 | 
						if len(status) > 0 && (status != userconfigs.UserIdentityStatusNone && status != userconfigs.UserIdentityStatusRejected) {
 | 
				
			||||||
		return nil, errors.New("identity status should be '" + userconfigs.UserIdentityStatusNone + "' instead of '" + status + "'")
 | 
							return nil, errors.New("identity status should be '" + userconfigs.UserIdentityStatusNone + "' instead of '" + status + "'")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -131,7 +196,7 @@ func (this *UserIdentityService) SubmitUserIdentity(ctx context.Context, req *pb
 | 
				
			|||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if len(status) > 0 && status != userconfigs.UserIdentityStatusNone {
 | 
						if len(status) > 0 && status != userconfigs.UserIdentityStatusNone && status != userconfigs.UserIdentityStatusRejected {
 | 
				
			||||||
		return nil, errors.New("identity status should be '" + userconfigs.UserIdentityStatusNone + "' instead of '" + status + "'")
 | 
							return nil, errors.New("identity status should be '" + userconfigs.UserIdentityStatusNone + "' instead of '" + status + "'")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -193,7 +258,7 @@ func (this *UserIdentityService) RejectUserIdentity(ctx context.Context, req *pb
 | 
				
			|||||||
		return nil, errors.New("identity status should be '" + userconfigs.UserIdentityStatusSubmitted + "' instead of '" + status + "'")
 | 
							return nil, errors.New("identity status should be '" + userconfigs.UserIdentityStatusSubmitted + "' instead of '" + status + "'")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	err = models.SharedUserIdentityDAO.RejectUserIdentity(tx, req.UserIdentityId)
 | 
						err = models.SharedUserIdentityDAO.RejectUserIdentity(tx, req.UserIdentityId, req.Reason)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -118,7 +118,7 @@ func ValidateRequest(ctx context.Context, userTypes ...UserType) (userType UserT
 | 
				
			|||||||
		return UserTypeNone, 0, 0, errors.New("invalid token")
 | 
							return UserTypeNone, 0, 0, errors.New("invalid token")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	m := maps.Map{}
 | 
						var m = maps.Map{}
 | 
				
			||||||
	err = json.Unmarshal(data, &m)
 | 
						err = json.Unmarshal(data, &m)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return UserTypeNone, 0, 0, errors.New("decode token error: " + err.Error())
 | 
							return UserTypeNone, 0, 0, errors.New("decode token error: " + err.Error())
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user