优化代码/实现基础的实名认证功能

This commit is contained in:
GoEdgeLab
2022-07-24 09:56:27 +08:00
parent 7f64c98d88
commit d80b5a862f
89 changed files with 353 additions and 249 deletions

View File

@@ -29,7 +29,7 @@ func init() {
// 创建认证信息
func (this *ACMEAuthenticationDAO) CreateAuth(tx *dbs.Tx, taskId int64, domain string, token string, key string) error {
op := NewACMEAuthenticationOperator()
var op = NewACMEAuthenticationOperator()
op.TaskId = taskId
op.Domain = domain
op.Token = token

View File

@@ -169,7 +169,7 @@ func (this *ACMETaskDAO) ListEnabledACMETasks(tx *dbs.Tx, adminId int64, userId
// CreateACMETask 创建任务
func (this *ACMETaskDAO) CreateACMETask(tx *dbs.Tx, adminId int64, userId int64, authType acmeutils.AuthType, acmeUserId int64, dnsProviderId int64, dnsDomain string, domains []string, autoRenew bool, authURL string) (int64, error) {
op := NewACMETaskOperator()
var op = NewACMETaskOperator()
op.AdminId = adminId
op.UserId = userId
op.AuthType = authType
@@ -204,7 +204,7 @@ func (this *ACMETaskDAO) UpdateACMETask(tx *dbs.Tx, acmeTaskId int64, acmeUserId
return errors.New("invalid acmeTaskId")
}
op := NewACMETaskOperator()
var op = NewACMETaskOperator()
op.Id = acmeTaskId
op.AcmeUserId = acmeUserId
op.DnsProviderId = dnsProviderId
@@ -240,7 +240,7 @@ func (this *ACMETaskDAO) UpdateACMETaskCert(tx *dbs.Tx, taskId int64, certId int
return errors.New("invalid taskId")
}
op := NewACMETaskOperator()
var op = NewACMETaskOperator()
op.Id = taskId
op.CertId = certId
err := this.Save(tx, op)

View File

@@ -29,7 +29,7 @@ func init() {
// 生成日志
func (this *ACMETaskLogDAO) CreateACMETaskLog(tx *dbs.Tx, taskId int64, isOk bool, errMsg string) error {
op := NewACMETaskLogOperator()
var op = NewACMETaskLogOperator()
op.TaskId = taskId
op.Error = errMsg
op.IsOk = isOk

View File

@@ -83,7 +83,7 @@ func (this *ACMEUserDAO) CreateACMEUser(tx *dbs.Tx, adminId int64, userId int64,
}
privateKeyText := base64.StdEncoding.EncodeToString(privateKeyData)
op := NewACMEUserOperator()
var op = NewACMEUserOperator()
op.AdminId = adminId
op.UserId = userId
op.ProviderCode = providerCode
@@ -104,7 +104,7 @@ func (this *ACMEUserDAO) UpdateACMEUser(tx *dbs.Tx, acmeUserId int64, descriptio
if acmeUserId <= 0 {
return errors.New("invalid acmeUserId")
}
op := NewACMEUserOperator()
var op = NewACMEUserOperator()
op.Id = acmeUserId
op.Description = description
err := this.Save(tx, op)
@@ -116,7 +116,7 @@ func (this *ACMEUserDAO) UpdateACMEUserRegistration(tx *dbs.Tx, acmeUserId int64
if acmeUserId <= 0 {
return errors.New("invalid acmeUserId")
}
op := NewACMEUserOperator()
var op = NewACMEUserOperator()
op.Id = acmeUserId
op.Registration = registrationJSON
err := this.Save(tx, op)

View File

@@ -115,7 +115,7 @@ func (this *AdminDAO) UpdateAdminPassword(tx *dbs.Tx, adminId int64, password st
if adminId <= 0 {
return errors.New("invalid adminId")
}
op := NewAdminOperator()
var op = NewAdminOperator()
op.Id = adminId
op.Password = stringutil.Md5(password)
err := this.Save(tx, op)
@@ -124,7 +124,7 @@ func (this *AdminDAO) UpdateAdminPassword(tx *dbs.Tx, adminId int64, password st
// CreateAdmin 创建管理员
func (this *AdminDAO) CreateAdmin(tx *dbs.Tx, username string, canLogin bool, password string, fullname string, isSuper bool, modulesJSON []byte) (int64, error) {
op := NewAdminOperator()
var op = NewAdminOperator()
op.IsOn = true
op.State = AdminStateEnabled
op.Username = username
@@ -149,7 +149,7 @@ func (this *AdminDAO) UpdateAdminInfo(tx *dbs.Tx, adminId int64, fullname string
if adminId <= 0 {
return errors.New("invalid adminId")
}
op := NewAdminOperator()
var op = NewAdminOperator()
op.Id = adminId
op.Fullname = fullname
err := this.Save(tx, op)
@@ -161,7 +161,7 @@ func (this *AdminDAO) UpdateAdmin(tx *dbs.Tx, adminId int64, username string, ca
if adminId <= 0 {
return errors.New("invalid adminId")
}
op := NewAdminOperator()
var op = NewAdminOperator()
op.Id = adminId
op.Fullname = fullname
op.Username = username
@@ -198,7 +198,7 @@ func (this *AdminDAO) UpdateAdminLogin(tx *dbs.Tx, adminId int64, username strin
if adminId <= 0 {
return errors.New("invalid adminId")
}
op := NewAdminOperator()
var op = NewAdminOperator()
op.Id = adminId
op.Username = username
if len(password) > 0 {
@@ -213,7 +213,7 @@ func (this *AdminDAO) UpdateAdminModules(tx *dbs.Tx, adminId int64, allowModules
if adminId <= 0 {
return errors.New("invalid adminId")
}
op := NewAdminOperator()
var op = NewAdminOperator()
op.Id = adminId
op.Modules = allowModulesJSON
err := this.Save(tx, op)

View File

@@ -56,7 +56,7 @@ func (this *APIAccessTokenDAO) GenerateAccessToken(tx *dbs.Tx, adminId int64, us
token = rands.String(128) // TODO 增强安全性,将来使用 base64_encode(encrypt(salt+random)) 算法来代替
expiresAt = time.Now().Unix() + 7200
op := NewAPIAccessTokenOperator()
var op = NewAPIAccessTokenOperator()
if accessToken != nil {
op.Id = accessToken.(*APIAccessToken).Id

View File

@@ -134,7 +134,7 @@ func (this *APINodeDAO) CreateAPINode(tx *dbs.Tx, name string, description strin
return
}
op := NewAPINodeOperator()
var op = NewAPINodeOperator()
op.IsOn = isOn
op.UniqueId = uniqueId
op.Secret = secret

View File

@@ -112,7 +112,7 @@ func (this *ApiTokenDAO) FindEnabledTokenWithRole(tx *dbs.Tx, role string) (*Api
// CreateAPIToken 保存API Token
func (this *ApiTokenDAO) CreateAPIToken(tx *dbs.Tx, nodeId string, secret string, role nodeconfigs.NodeRole) error {
op := NewApiTokenOperator()
var op = NewApiTokenOperator()
op.NodeId = nodeId
op.Secret = secret
op.Role = role

View File

@@ -42,7 +42,7 @@ func (this *AuthorityKeyDAO) UpdateKey(tx *dbs.Tx, value string, dayFrom string,
if err != nil {
return err
}
op := NewAuthorityKeyOperator()
var op = NewAuthorityKeyOperator()
if one != nil {
op.Id = one.(*AuthorityKey).Id
}

View File

@@ -120,7 +120,7 @@ func (this *AuthorityNodeDAO) CreateAuthorityNode(tx *dbs.Tx, name string, descr
return
}
op := NewAuthorityNodeOperator()
var op = NewAuthorityNodeOperator()
op.IsOn = isOn
op.UniqueId = uniqueId
op.Secret = secret
@@ -141,7 +141,7 @@ func (this *AuthorityNodeDAO) UpdateAuthorityNode(tx *dbs.Tx, nodeId int64, name
return errors.New("invalid nodeId")
}
op := NewAuthorityNodeOperator()
var op = NewAuthorityNodeOperator()
op.Id = nodeId
op.Name = name
op.Description = description

View File

@@ -125,7 +125,7 @@ func (this *ClientBrowserDAO) CreateBrowser(tx *dbs.Tx, browserName string) (int
return browserId, nil
}
op := NewClientBrowserOperator()
var op = NewClientBrowserOperator()
op.Name = browserName
codes := []string{browserName}
codesJSON, err := json.Marshal(codes)

View File

@@ -125,7 +125,7 @@ func (this *ClientSystemDAO) CreateSystem(tx *dbs.Tx, systemName string) (int64,
return systemId, nil
}
op := NewClientSystemOperator()
var op = NewClientSystemOperator()
op.Name = systemName
codes := []string{systemName}

View File

@@ -109,7 +109,7 @@ func (this *DBNodeDAO) ListEnabledNodes(tx *dbs.Tx, offset int64, size int64) (r
// CreateDBNode 创建节点
func (this *DBNodeDAO) CreateDBNode(tx *dbs.Tx, isOn bool, name string, description string, host string, port int32, database string, username string, password string, charset string) (int64, error) {
op := NewDBNodeOperator()
var op = NewDBNodeOperator()
op.State = NodeStateEnabled
op.IsOn = isOn
op.Name = name
@@ -132,7 +132,7 @@ func (this *DBNodeDAO) UpdateNode(tx *dbs.Tx, nodeId int64, isOn bool, name stri
if nodeId <= 0 {
return errors.New("invalid nodeId")
}
op := NewDBNodeOperator()
var op = NewDBNodeOperator()
op.Id = nodeId
op.IsOn = isOn
op.Name = name

View File

@@ -91,7 +91,7 @@ func (this *DNSDomainDAO) FindDNSDomainName(tx *dbs.Tx, id int64) (string, error
// CreateDomain 创建域名
func (this *DNSDomainDAO) CreateDomain(tx *dbs.Tx, adminId int64, userId int64, providerId int64, name string) (int64, error) {
op := NewDNSDomainOperator()
var op = NewDNSDomainOperator()
op.ProviderId = providerId
op.AdminId = adminId
op.UserId = userId
@@ -111,7 +111,7 @@ func (this *DNSDomainDAO) UpdateDomain(tx *dbs.Tx, domainId int64, name string,
if domainId <= 0 {
return errors.New("invalid domainId")
}
op := NewDNSDomainOperator()
var op = NewDNSDomainOperator()
op.Id = domainId
op.Name = name
op.IsOn = isOn
@@ -146,7 +146,7 @@ func (this *DNSDomainDAO) UpdateDomainData(tx *dbs.Tx, domainId int64, data stri
if domainId <= 0 {
return errors.New("invalid domainId")
}
op := NewDNSDomainOperator()
var op = NewDNSDomainOperator()
op.Id = domainId
op.Data = data
err := this.Save(tx, op)
@@ -158,7 +158,7 @@ func (this *DNSDomainDAO) UpdateDomainRecords(tx *dbs.Tx, domainId int64, record
if domainId <= 0 {
return errors.New("invalid domainId")
}
op := NewDNSDomainOperator()
var op = NewDNSDomainOperator()
op.Id = domainId
op.Records = recordsJSON
op.DataUpdatedAt = time.Now().Unix()
@@ -171,7 +171,7 @@ func (this *DNSDomainDAO) UpdateDomainRoutes(tx *dbs.Tx, domainId int64, routesJ
if domainId <= 0 {
return errors.New("invalid domainId")
}
op := NewDNSDomainOperator()
var op = NewDNSDomainOperator()
op.Id = domainId
op.Routes = routesJSON
op.DataUpdatedAt = time.Now().Unix()

View File

@@ -68,7 +68,7 @@ func (this *DNSProviderDAO) FindEnabledDNSProvider(tx *dbs.Tx, id int64) (*DNSPr
// CreateDNSProvider 创建服务商
func (this *DNSProviderDAO) CreateDNSProvider(tx *dbs.Tx, adminId int64, userId int64, providerType string, name string, apiParamsJSON []byte) (int64, error) {
op := NewDNSProviderOperator()
var op = NewDNSProviderOperator()
op.AdminId = adminId
op.UserId = userId
op.Type = providerType
@@ -90,7 +90,7 @@ func (this *DNSProviderDAO) UpdateDNSProvider(tx *dbs.Tx, dnsProviderId int64, n
return errors.New("invalid dnsProviderId")
}
op := NewDNSProviderOperator()
var op = NewDNSProviderOperator()
op.Id = dnsProviderId
op.Name = name

View File

@@ -143,7 +143,7 @@ func (this *DNSTaskDAO) UpdateDNSTaskError(tx *dbs.Tx, taskId int64, err string)
if taskId <= 0 {
return errors.New("invalid taskId")
}
op := NewDNSTaskOperator()
var op = NewDNSTaskOperator()
op.Id = taskId
op.IsDone = true
op.Error = err
@@ -156,7 +156,7 @@ func (this *DNSTaskDAO) UpdateDNSTaskDone(tx *dbs.Tx, taskId int64) error {
if taskId <= 0 {
return errors.New("invalid taskId")
}
op := NewDNSTaskOperator()
var op = NewDNSTaskOperator()
op.Id = taskId
op.IsDone = true
op.IsOk = true

View File

@@ -29,9 +29,9 @@ func init() {
})
}
// 创建文件Chunk
// CreateFileChunk 创建文件Chunk
func (this *FileChunkDAO) CreateFileChunk(tx *dbs.Tx, fileId int64, data []byte) (int64, error) {
op := NewFileChunkOperator()
var op = NewFileChunkOperator()
op.FileId = fileId
op.Data = data
err := this.Save(tx, op)
@@ -41,7 +41,7 @@ func (this *FileChunkDAO) CreateFileChunk(tx *dbs.Tx, fileId int64, data []byte)
return types.Int64(op.Id), nil
}
// 列出所有的文件Chunk
// FindAllFileChunks 列出所有的文件Chunk
func (this *FileChunkDAO) FindAllFileChunks(tx *dbs.Tx, fileId int64) (result []*FileChunk, err error) {
_, err = this.Query(tx).
Attr("fileId", fileId).
@@ -51,7 +51,7 @@ func (this *FileChunkDAO) FindAllFileChunks(tx *dbs.Tx, fileId int64) (result []
return
}
// 读取文件的所有片段ID
// FindAllFileChunkIds 读取文件的所有片段ID
func (this *FileChunkDAO) FindAllFileChunkIds(tx *dbs.Tx, fileId int64) ([]int64, error) {
ones, err := this.Query(tx).
Attr("fileId", fileId).
@@ -68,7 +68,7 @@ func (this *FileChunkDAO) FindAllFileChunkIds(tx *dbs.Tx, fileId int64) ([]int64
return result, nil
}
// 删除以前的文件
// DeleteFileChunks 删除以前的文件
func (this *FileChunkDAO) DeleteFileChunks(tx *dbs.Tx, fileId int64) error {
if fileId <= 0 {
return errors.New("invalid fileId")
@@ -79,7 +79,7 @@ func (this *FileChunkDAO) DeleteFileChunks(tx *dbs.Tx, fileId int64) error {
return err
}
// 根据ID查找片段
// FindFileChunk 根据ID查找片段
func (this *FileChunkDAO) FindFileChunk(tx *dbs.Tx, chunkId int64) (*FileChunk, error) {
one, err := this.Query(tx).
Pk(chunkId).

View File

@@ -65,7 +65,7 @@ func (this *FileDAO) FindEnabledFile(tx *dbs.Tx, id int64) (*File, error) {
}
// CreateFile 创建文件
func (this *FileDAO) CreateFile(tx *dbs.Tx, adminId int64, userId int64, businessType, description string, filename string, size int64, isPublic bool) (int64, error) {
func (this *FileDAO) CreateFile(tx *dbs.Tx, adminId int64, userId int64, businessType string, description string, filename string, size int64, mimeType string, isPublic bool) (int64, error) {
var op = NewFileOperator()
op.AdminId = adminId
op.UserId = userId
@@ -76,6 +76,7 @@ func (this *FileDAO) CreateFile(tx *dbs.Tx, adminId int64, userId int64, busines
op.Filename = filename
op.IsPublic = isPublic
op.Code = utils.Sha1RandomString()
op.MimeType = mimeType
err := this.Save(tx, op)
if err != nil {
return 0, err
@@ -84,6 +85,21 @@ func (this *FileDAO) CreateFile(tx *dbs.Tx, adminId int64, userId int64, busines
return types.Int64(op.Id), nil
}
// CheckUserFile 检查用户ID
func (this *FileDAO) CheckUserFile(tx *dbs.Tx, userId int64, fileId int64) error {
b, err := this.Query(tx).
Pk(fileId).
Attr("userId", userId).
Exist()
if err != nil {
return err
}
if !b {
return ErrNotFound
}
return nil
}
// UpdateFileIsFinished 将文件置为已完成
func (this *FileDAO) UpdateFileIsFinished(tx *dbs.Tx, fileId int64) error {
_, err := this.Query(tx).

View File

@@ -9,6 +9,7 @@ type File struct {
Description string `field:"description"` // 文件描述
Filename string `field:"filename"` // 文件名
Size uint32 `field:"size"` // 文件尺寸
MimeType string `field:"mimeType"` // Mime类型
CreatedAt uint64 `field:"createdAt"` // 创建时间
Order uint32 `field:"order"` // 排序
Type string `field:"type"` // 类型
@@ -25,6 +26,7 @@ type FileOperator struct {
Description interface{} // 文件描述
Filename interface{} // 文件名
Size interface{} // 文件尺寸
MimeType interface{} // Mime类型
CreatedAt interface{} // 创建时间
Order interface{} // 排序
Type interface{} // 类型

View File

@@ -69,7 +69,7 @@ func (this *HTTPAuthPolicyDAO) FindEnabledHTTPAuthPolicy(tx *dbs.Tx, id int64) (
// CreateHTTPAuthPolicy 创建策略
func (this *HTTPAuthPolicyDAO) CreateHTTPAuthPolicy(tx *dbs.Tx, name string, methodType string, paramsJSON []byte) (int64, error) {
op := NewHTTPAuthPolicyOperator()
var op = NewHTTPAuthPolicyOperator()
op.Name = name
op.Type = methodType
op.Params = paramsJSON
@@ -83,7 +83,7 @@ func (this *HTTPAuthPolicyDAO) UpdateHTTPAuthPolicy(tx *dbs.Tx, policyId int64,
if policyId <= 0 {
return errors.New("invalid policyId")
}
op := NewHTTPAuthPolicyOperator()
var op = NewHTTPAuthPolicyOperator()
op.Id = policyId
op.Name = name
op.Params = paramsJSON

View File

@@ -113,7 +113,7 @@ func (this *HTTPBrotliPolicyDAO) ComposeBrotliConfig(tx *dbs.Tx, policyId int64)
// CreatePolicy 创建策略
func (this *HTTPBrotliPolicyDAO) CreatePolicy(tx *dbs.Tx, level int, minLengthJSON []byte, maxLengthJSON []byte, condsJSON []byte) (int64, error) {
op := NewHTTPBrotliPolicyOperator()
var op = NewHTTPBrotliPolicyOperator()
op.State = HTTPBrotliPolicyStateEnabled
op.IsOn = true
op.Level = level
@@ -138,7 +138,7 @@ func (this *HTTPBrotliPolicyDAO) UpdatePolicy(tx *dbs.Tx, policyId int64, level
if policyId <= 0 {
return errors.New("invalid policyId")
}
op := NewHTTPBrotliPolicyOperator()
var op = NewHTTPBrotliPolicyOperator()
op.Id = policyId
op.Level = level
if len(minLengthJSON) > 0 {

View File

@@ -97,7 +97,7 @@ func (this *HTTPCachePolicyDAO) FindAllEnabledCachePolicies(tx *dbs.Tx) (result
// CreateCachePolicy 创建缓存策略
func (this *HTTPCachePolicyDAO) CreateCachePolicy(tx *dbs.Tx, isOn bool, name string, description string, capacityJSON []byte, maxKeys int64, maxSizeJSON []byte, storageType string, storageOptionsJSON []byte, syncCompressionCache bool) (int64, error) {
op := NewHTTPCachePolicyOperator()
var op = NewHTTPCachePolicyOperator()
op.State = HTTPCachePolicyStateEnabled
op.IsOn = isOn
op.Name = name
@@ -209,7 +209,7 @@ func (this *HTTPCachePolicyDAO) UpdateCachePolicy(tx *dbs.Tx, policyId int64, is
return errors.New("invalid policyId")
}
op := NewHTTPCachePolicyOperator()
var op = NewHTTPCachePolicyOperator()
op.Id = policyId
op.IsOn = isOn
op.Name = name

View File

@@ -113,7 +113,7 @@ func (this *HTTPDeflatePolicyDAO) ComposeDeflateConfig(tx *dbs.Tx, policyId int6
// CreatePolicy 创建策略
func (this *HTTPDeflatePolicyDAO) CreatePolicy(tx *dbs.Tx, level int, minLengthJSON []byte, maxLengthJSON []byte, condsJSON []byte) (int64, error) {
op := NewHTTPDeflatePolicyOperator()
var op = NewHTTPDeflatePolicyOperator()
op.State = HTTPDeflatePolicyStateEnabled
op.IsOn = true
op.Level = level
@@ -138,7 +138,7 @@ func (this *HTTPDeflatePolicyDAO) UpdatePolicy(tx *dbs.Tx, policyId int64, level
if policyId <= 0 {
return errors.New("invalid policyId")
}
op := NewHTTPDeflatePolicyOperator()
var op = NewHTTPDeflatePolicyOperator()
op.Id = policyId
op.Level = level
if len(minLengthJSON) > 0 {

View File

@@ -121,7 +121,7 @@ func (this *HTTPFastcgiDAO) ComposeFastcgiConfig(tx *dbs.Tx, fastcgiId int64) (*
// CreateFastcgi 创建Fastcgi
func (this *HTTPFastcgiDAO) CreateFastcgi(tx *dbs.Tx, adminId int64, userId int64, isOn bool, address string, paramsJSON []byte, readTimeoutJSON []byte, connTimeoutJSON []byte, poolSize int32, pathInfoPattern string) (int64, error) {
op := NewHTTPFastcgiOperator()
var op = NewHTTPFastcgiOperator()
op.AdminId = adminId
op.UserId = userId
op.IsOn = isOn
@@ -147,7 +147,7 @@ func (this *HTTPFastcgiDAO) UpdateFastcgi(tx *dbs.Tx, fastcgiId int64, isOn bool
if fastcgiId <= 0 {
return errors.New("invalid 'fastcgiId'")
}
op := NewHTTPFastcgiOperator()
var op = NewHTTPFastcgiOperator()
op.Id = fastcgiId
op.IsOn = isOn
op.Address = address

View File

@@ -233,7 +233,7 @@ func (this *HTTPFirewallPolicyDAO) UpdateFirewallPolicyInboundAndOutbound(tx *db
if policyId <= 0 {
return errors.New("invalid policyId")
}
op := NewHTTPFirewallPolicyOperator()
var op = NewHTTPFirewallPolicyOperator()
op.Id = policyId
if len(inboundJSON) > 0 {
op.Inbound = inboundJSON
@@ -262,7 +262,7 @@ func (this *HTTPFirewallPolicyDAO) UpdateFirewallPolicyInbound(tx *dbs.Tx, polic
if policyId <= 0 {
return errors.New("invalid policyId")
}
op := NewHTTPFirewallPolicyOperator()
var op = NewHTTPFirewallPolicyOperator()
op.Id = policyId
if len(inboundJSON) > 0 {
op.Inbound = inboundJSON

View File

@@ -116,7 +116,7 @@ func (this *HTTPFirewallRuleDAO) ComposeFirewallRule(tx *dbs.Tx, ruleId int64) (
// CreateOrUpdateRuleFromConfig 从配置中配置规则
func (this *HTTPFirewallRuleDAO) CreateOrUpdateRuleFromConfig(tx *dbs.Tx, ruleConfig *firewallconfigs.HTTPFirewallRule) (int64, error) {
op := NewHTTPFirewallRuleOperator()
var op = NewHTTPFirewallRuleOperator()
op.Id = ruleConfig.Id
op.State = HTTPFirewallRuleStateEnabled
op.IsOn = ruleConfig.IsOn

View File

@@ -120,7 +120,7 @@ func (this *HTTPFirewallRuleGroupDAO) ComposeFirewallRuleGroup(tx *dbs.Tx, group
// CreateGroupFromConfig 从配置中创建分组
func (this *HTTPFirewallRuleGroupDAO) CreateGroupFromConfig(tx *dbs.Tx, groupConfig *firewallconfigs.HTTPFirewallRuleGroup) (int64, error) {
op := NewHTTPFirewallRuleGroupOperator()
var op = NewHTTPFirewallRuleGroupOperator()
op.IsOn = groupConfig.IsOn
op.Name = groupConfig.Name
op.Description = groupConfig.Description
@@ -166,7 +166,7 @@ func (this *HTTPFirewallRuleGroupDAO) UpdateGroupIsOn(tx *dbs.Tx, groupId int64,
// CreateGroup 创建分组
func (this *HTTPFirewallRuleGroupDAO) CreateGroup(tx *dbs.Tx, isOn bool, name string, code string, description string) (int64, error) {
op := NewHTTPFirewallRuleGroupOperator()
var op = NewHTTPFirewallRuleGroupOperator()
op.State = HTTPFirewallRuleStateEnabled
op.IsOn = isOn
op.Name = name
@@ -184,7 +184,7 @@ func (this *HTTPFirewallRuleGroupDAO) UpdateGroup(tx *dbs.Tx, groupId int64, isO
if groupId <= 0 {
return errors.New("invalid groupId")
}
op := NewHTTPFirewallRuleGroupOperator()
var op = NewHTTPFirewallRuleGroupOperator()
op.Id = groupId
op.IsOn = isOn
op.Name = name
@@ -202,7 +202,7 @@ func (this *HTTPFirewallRuleGroupDAO) UpdateGroupSets(tx *dbs.Tx, groupId int64,
if groupId <= 0 {
return errors.New("invalid groupId")
}
op := NewHTTPFirewallRuleGroupOperator()
var op = NewHTTPFirewallRuleGroupOperator()
op.Id = groupId
op.Sets = setRefsJSON
err := this.Save(tx, op)

View File

@@ -133,7 +133,7 @@ func (this *HTTPFirewallRuleSetDAO) ComposeFirewallRuleSet(tx *dbs.Tx, setId int
// CreateOrUpdateSetFromConfig 从配置中创建规则集
func (this *HTTPFirewallRuleSetDAO) CreateOrUpdateSetFromConfig(tx *dbs.Tx, setConfig *firewallconfigs.HTTPFirewallRuleSet) (int64, error) {
op := NewHTTPFirewallRuleSetOperator()
var op = NewHTTPFirewallRuleSetOperator()
op.State = HTTPFirewallRuleSetStateEnabled
op.Id = setConfig.Id
op.IsOn = setConfig.IsOn

View File

@@ -121,7 +121,7 @@ func (this *HTTPGzipDAO) ComposeGzipConfig(tx *dbs.Tx, gzipId int64) (*servercon
// CreateGzip 创建Gzip
func (this *HTTPGzipDAO) CreateGzip(tx *dbs.Tx, level int, minLengthJSON []byte, maxLengthJSON []byte, condsJSON []byte) (int64, error) {
op := NewHTTPGzipOperator()
var op = NewHTTPGzipOperator()
op.State = HTTPGzipStateEnabled
op.IsOn = true
op.Level = level
@@ -146,7 +146,7 @@ func (this *HTTPGzipDAO) UpdateGzip(tx *dbs.Tx, gzipId int64, level int, minLeng
if gzipId <= 0 {
return errors.New("invalid gzipId")
}
op := NewHTTPGzipOperator()
var op = NewHTTPGzipOperator()
op.Id = gzipId
op.Level = level
if len(minLengthJSON) > 0 {

View File

@@ -81,7 +81,7 @@ func (this *HTTPHeaderDAO) FindHTTPHeaderName(tx *dbs.Tx, id int64) (string, err
// CreateHeader 创建Header
func (this *HTTPHeaderDAO) CreateHeader(tx *dbs.Tx, userId int64, name string, value string, status []int, disableRedirect bool, shouldAppend bool, shouldReplace bool, replaceValues []*shared.HTTPHeaderReplaceValue, methods []string, domains []string) (int64, error) {
op := NewHTTPHeaderOperator()
var op = NewHTTPHeaderOperator()
op.UserId = userId
op.State = HTTPHeaderStateEnabled
op.IsOn = true
@@ -156,7 +156,7 @@ func (this *HTTPHeaderDAO) UpdateHeader(tx *dbs.Tx, headerId int64, name string,
return errors.New("invalid headerId")
}
op := NewHTTPHeaderOperator()
var op = NewHTTPHeaderOperator()
op.Id = headerId
op.Name = name
op.Value = value

View File

@@ -77,7 +77,7 @@ func (this *HTTPHeaderPolicyDAO) FindEnabledHTTPHeaderPolicy(tx *dbs.Tx, id int6
// CreateHeaderPolicy 创建策略
func (this *HTTPHeaderPolicyDAO) CreateHeaderPolicy(tx *dbs.Tx) (int64, error) {
op := NewHTTPHeaderPolicyOperator()
var op = NewHTTPHeaderPolicyOperator()
op.IsOn = true
op.State = HTTPHeaderPolicyStateEnabled
err := this.Save(tx, op)
@@ -93,7 +93,7 @@ func (this *HTTPHeaderPolicyDAO) UpdateAddingHeaders(tx *dbs.Tx, policyId int64,
return errors.New("invalid policyId")
}
op := NewHTTPHeaderPolicyOperator()
var op = NewHTTPHeaderPolicyOperator()
op.Id = policyId
op.AddHeaders = headersJSON
err := this.Save(tx, op)
@@ -109,7 +109,7 @@ func (this *HTTPHeaderPolicyDAO) UpdateSettingHeaders(tx *dbs.Tx, policyId int64
return errors.New("invalid policyId")
}
op := NewHTTPHeaderPolicyOperator()
var op = NewHTTPHeaderPolicyOperator()
op.Id = policyId
op.SetHeaders = headersJSON
err := this.Save(tx, op)
@@ -125,7 +125,7 @@ func (this *HTTPHeaderPolicyDAO) UpdateReplacingHeaders(tx *dbs.Tx, policyId int
return errors.New("invalid policyId")
}
op := NewHTTPHeaderPolicyOperator()
var op = NewHTTPHeaderPolicyOperator()
op.Id = policyId
op.ReplaceHeaders = headersJSON
err := this.Save(tx, op)
@@ -141,7 +141,7 @@ func (this *HTTPHeaderPolicyDAO) UpdateAddingTrailers(tx *dbs.Tx, policyId int64
return errors.New("invalid policyId")
}
op := NewHTTPHeaderPolicyOperator()
var op = NewHTTPHeaderPolicyOperator()
op.Id = policyId
op.AddTrailers = headersJSON
err := this.Save(tx, op)
@@ -162,7 +162,7 @@ func (this *HTTPHeaderPolicyDAO) UpdateDeletingHeaders(tx *dbs.Tx, policyId int6
return err
}
op := NewHTTPHeaderPolicyOperator()
var op = NewHTTPHeaderPolicyOperator()
op.Id = policyId
op.DeleteHeaders = string(namesJSON)
err = this.Save(tx, op)

View File

@@ -87,7 +87,7 @@ func (this *HTTPLocationDAO) FindHTTPLocationName(tx *dbs.Tx, id int64) (string,
// CreateLocation 创建路由规则
func (this *HTTPLocationDAO) CreateLocation(tx *dbs.Tx, parentId int64, name string, pattern string, description string, isBreak bool, condsJSON []byte, domains []string) (int64, error) {
op := NewHTTPLocationOperator()
var op = NewHTTPLocationOperator()
op.IsOn = true
op.State = HTTPLocationStateEnabled
op.ParentId = parentId
@@ -121,7 +121,7 @@ func (this *HTTPLocationDAO) UpdateLocation(tx *dbs.Tx, locationId int64, name s
if locationId <= 0 {
return errors.New("invalid locationId")
}
op := NewHTTPLocationOperator()
var op = NewHTTPLocationOperator()
op.Id = locationId
op.Name = name
op.Pattern = pattern
@@ -257,7 +257,7 @@ func (this *HTTPLocationDAO) UpdateLocationReverseProxy(tx *dbs.Tx, locationId i
if locationId <= 0 {
return errors.New("invalid locationId")
}
op := NewHTTPLocationOperator()
var op = NewHTTPLocationOperator()
op.Id = locationId
op.ReverseProxy = JSONBytes(reverseProxyJSON)
err := this.Save(tx, op)
@@ -281,7 +281,7 @@ func (this *HTTPLocationDAO) UpdateLocationWeb(tx *dbs.Tx, locationId int64, web
if locationId <= 0 {
return errors.New("invalid locationId")
}
op := NewHTTPLocationOperator()
var op = NewHTTPLocationOperator()
op.Id = locationId
op.WebId = webId
err := this.Save(tx, op)

View File

@@ -78,7 +78,7 @@ func (this *HTTPPageDAO) FindEnabledHTTPPage(tx *dbs.Tx, id int64) (*HTTPPage, e
// CreatePage 创建Page
func (this *HTTPPageDAO) CreatePage(tx *dbs.Tx, userId int64, statusList []string, bodyType shared.BodyType, url string, body string, newStatus int) (pageId int64, err error) {
op := NewHTTPPageOperator()
var op = NewHTTPPageOperator()
op.UserId = userId
op.IsOn = true
op.State = HTTPPageStateEnabled
@@ -108,7 +108,7 @@ func (this *HTTPPageDAO) UpdatePage(tx *dbs.Tx, pageId int64, statusList []strin
return errors.New("invalid pageId")
}
op := NewHTTPPageOperator()
var op = NewHTTPPageOperator()
op.Id = pageId
op.IsOn = true
op.State = HTTPPageStateEnabled

View File

@@ -125,7 +125,7 @@ func (this *HTTPRewriteRuleDAO) ComposeRewriteRule(tx *dbs.Tx, rewriteRuleId int
// CreateRewriteRule 创建规则
func (this *HTTPRewriteRuleDAO) CreateRewriteRule(tx *dbs.Tx, pattern string, replace string, mode string, redirectStatus int, isBreak bool, proxyHost string, withQuery bool, isOn bool, condsJSON []byte) (int64, error) {
op := NewHTTPRewriteRuleOperator()
var op = NewHTTPRewriteRuleOperator()
op.State = HTTPRewriteRuleStateEnabled
op.IsOn = isOn
@@ -150,7 +150,7 @@ func (this *HTTPRewriteRuleDAO) UpdateRewriteRule(tx *dbs.Tx, rewriteRuleId int6
if rewriteRuleId <= 0 {
return errors.New("invalid rewriteRuleId")
}
op := NewHTTPRewriteRuleOperator()
var op = NewHTTPRewriteRuleOperator()
op.Id = rewriteRuleId
op.IsOn = isOn
op.Pattern = pattern

View File

@@ -466,7 +466,7 @@ func (this *HTTPWebDAO) ComposeWebConfig(tx *dbs.Tx, webId int64, cacheMap *util
// CreateWeb 创建Web配置
func (this *HTTPWebDAO) CreateWeb(tx *dbs.Tx, adminId int64, userId int64, rootJSON []byte) (int64, error) {
op := NewHTTPWebOperator()
var op = NewHTTPWebOperator()
op.State = HTTPWebStateEnabled
op.AdminId = adminId
op.UserId = userId
@@ -485,7 +485,7 @@ func (this *HTTPWebDAO) UpdateWeb(tx *dbs.Tx, webId int64, rootJSON []byte) erro
if webId <= 0 {
return errors.New("invalid webId")
}
op := NewHTTPWebOperator()
var op = NewHTTPWebOperator()
op.Id = webId
op.Root = JSONBytes(rootJSON)
err := this.Save(tx, op)
@@ -501,7 +501,7 @@ func (this *HTTPWebDAO) UpdateWebCompression(tx *dbs.Tx, webId int64, compressio
if webId <= 0 {
return errors.New("invalid webId")
}
op := NewHTTPWebOperator()
var op = NewHTTPWebOperator()
op.Id = webId
op.Compression = JSONBytes(compressionConfig)
err := this.Save(tx, op)
@@ -517,7 +517,7 @@ func (this *HTTPWebDAO) UpdateWebWebP(tx *dbs.Tx, webId int64, webpConfig []byte
if webId <= 0 {
return errors.New("invalid webId")
}
op := NewHTTPWebOperator()
var op = NewHTTPWebOperator()
op.Id = webId
op.Webp = JSONBytes(webpConfig)
err := this.Save(tx, op)
@@ -548,7 +548,7 @@ func (this *HTTPWebDAO) UpdateWebCharset(tx *dbs.Tx, webId int64, charsetJSON []
if webId <= 0 {
return errors.New("invalid webId")
}
op := NewHTTPWebOperator()
var op = NewHTTPWebOperator()
op.Id = webId
op.Charset = JSONBytes(charsetJSON)
err := this.Save(tx, op)
@@ -564,7 +564,7 @@ func (this *HTTPWebDAO) UpdateWebRequestHeaderPolicy(tx *dbs.Tx, webId int64, he
if webId <= 0 {
return errors.New("invalid webId")
}
op := NewHTTPWebOperator()
var op = NewHTTPWebOperator()
op.Id = webId
op.RequestHeader = JSONBytes(headerPolicyJSON)
err := this.Save(tx, op)
@@ -580,7 +580,7 @@ func (this *HTTPWebDAO) UpdateWebResponseHeaderPolicy(tx *dbs.Tx, webId int64, h
if webId <= 0 {
return errors.New("invalid webId")
}
op := NewHTTPWebOperator()
var op = NewHTTPWebOperator()
op.Id = webId
op.ResponseHeader = JSONBytes(headerPolicyJSON)
err := this.Save(tx, op)
@@ -596,7 +596,7 @@ func (this *HTTPWebDAO) UpdateWebPages(tx *dbs.Tx, webId int64, pagesJSON []byte
if webId <= 0 {
return errors.New("invalid webId")
}
op := NewHTTPWebOperator()
var op = NewHTTPWebOperator()
op.Id = webId
op.Pages = JSONBytes(pagesJSON)
err := this.Save(tx, op)
@@ -612,7 +612,7 @@ func (this *HTTPWebDAO) UpdateWebShutdown(tx *dbs.Tx, webId int64, shutdownJSON
if webId <= 0 {
return errors.New("invalid webId")
}
op := NewHTTPWebOperator()
var op = NewHTTPWebOperator()
op.Id = webId
op.Shutdown = JSONBytes(shutdownJSON)
err := this.Save(tx, op)
@@ -628,7 +628,7 @@ func (this *HTTPWebDAO) UpdateWebAccessLogConfig(tx *dbs.Tx, webId int64, access
if webId <= 0 {
return errors.New("invalid webId")
}
op := NewHTTPWebOperator()
var op = NewHTTPWebOperator()
op.Id = webId
op.AccessLog = JSONBytes(accessLogJSON)
err := this.Save(tx, op)
@@ -644,7 +644,7 @@ func (this *HTTPWebDAO) UpdateWebStat(tx *dbs.Tx, webId int64, statJSON []byte)
if webId <= 0 {
return errors.New("invalid webId")
}
op := NewHTTPWebOperator()
var op = NewHTTPWebOperator()
op.Id = webId
op.Stat = JSONBytes(statJSON)
err := this.Save(tx, op)
@@ -660,7 +660,7 @@ func (this *HTTPWebDAO) UpdateWebCache(tx *dbs.Tx, webId int64, cacheJSON []byte
if webId <= 0 {
return errors.New("invalid webId")
}
op := NewHTTPWebOperator()
var op = NewHTTPWebOperator()
op.Id = webId
op.Cache = JSONBytes(cacheJSON)
err := this.Save(tx, op)
@@ -676,7 +676,7 @@ func (this *HTTPWebDAO) UpdateWebFirewall(tx *dbs.Tx, webId int64, firewallJSON
if webId <= 0 {
return errors.New("invalid webId")
}
op := NewHTTPWebOperator()
var op = NewHTTPWebOperator()
op.Id = webId
op.Firewall = JSONBytes(firewallJSON)
err := this.Save(tx, op)
@@ -692,7 +692,7 @@ func (this *HTTPWebDAO) UpdateWebLocations(tx *dbs.Tx, webId int64, locationsJSO
if webId <= 0 {
return errors.New("invalid webId")
}
op := NewHTTPWebOperator()
var op = NewHTTPWebOperator()
op.Id = webId
op.Locations = JSONBytes(locationsJSON)
err := this.Save(tx, op)
@@ -708,7 +708,7 @@ func (this *HTTPWebDAO) UpdateWebRedirectToHTTPS(tx *dbs.Tx, webId int64, redire
if webId <= 0 {
return errors.New("invalid webId")
}
op := NewHTTPWebOperator()
var op = NewHTTPWebOperator()
op.Id = webId
op.RedirectToHttps = JSONBytes(redirectToHTTPSJSON)
err := this.Save(tx, op)
@@ -724,7 +724,7 @@ func (this *HTTPWebDAO) UpdateWebsocket(tx *dbs.Tx, webId int64, websocketJSON [
if webId <= 0 {
return errors.New("invalid webId")
}
op := NewHTTPWebOperator()
var op = NewHTTPWebOperator()
op.Id = webId
op.Websocket = JSONBytes(websocketJSON)
err := this.Save(tx, op)
@@ -740,7 +740,7 @@ func (this *HTTPWebDAO) UpdateWebFastcgi(tx *dbs.Tx, webId int64, fastcgiJSON []
if webId <= 0 {
return errors.New("invalid webId")
}
op := NewHTTPWebOperator()
var op = NewHTTPWebOperator()
op.Id = webId
op.Fastcgi = JSONBytes(fastcgiJSON)
err := this.Save(tx, op)
@@ -756,7 +756,7 @@ func (this *HTTPWebDAO) UpdateWebRewriteRules(tx *dbs.Tx, webId int64, rewriteRu
if webId <= 0 {
return errors.New("invalid webId")
}
op := NewHTTPWebOperator()
var op = NewHTTPWebOperator()
op.Id = webId
op.RewriteRules = JSONBytes(rewriteRulesJSON)
err := this.Save(tx, op)
@@ -772,7 +772,7 @@ func (this *HTTPWebDAO) UpdateWebAuth(tx *dbs.Tx, webId int64, authJSON []byte)
if webId <= 0 {
return errors.New("invalid webId")
}
op := NewHTTPWebOperator()
var op = NewHTTPWebOperator()
op.Id = webId
op.Auth = JSONBytes(authJSON)
err := this.Save(tx, op)

View File

@@ -110,7 +110,7 @@ func (this *HTTPWebsocketDAO) ComposeWebsocketConfig(tx *dbs.Tx, websocketId int
// CreateWebsocket 创建Websocket配置
func (this *HTTPWebsocketDAO) CreateWebsocket(tx *dbs.Tx, handshakeTimeoutJSON []byte, allowAllOrigins bool, allowedOrigins []string, requestSameOrigin bool, requestOrigin string) (websocketId int64, err error) {
op := NewHTTPWebsocketOperator()
var op = NewHTTPWebsocketOperator()
op.IsOn = true
op.State = HTTPWebsocketStateEnabled
if len(handshakeTimeoutJSON) > 0 {
@@ -135,7 +135,7 @@ func (this *HTTPWebsocketDAO) UpdateWebsocket(tx *dbs.Tx, websocketId int64, han
if websocketId <= 0 {
return errors.New("invalid websocketId")
}
op := NewHTTPWebsocketOperator()
var op = NewHTTPWebsocketOperator()
op.Id = websocketId
if len(handshakeTimeoutJSON) > 0 {
op.HandshakeTimeout = handshakeTimeoutJSON

View File

@@ -330,7 +330,7 @@ func (this *IPItemDAO) UpdateIPItem(tx *dbs.Tx, itemId int64, ipFrom string, ipT
return err
}
op := NewIPItemOperator()
var op = NewIPItemOperator()
op.Id = itemId
op.IpFrom = ipFrom
op.IpTo = ipTo

View File

@@ -92,7 +92,7 @@ func (this *IPLibraryDAO) FindLatestIPLibraryWithType(tx *dbs.Tx, libraryType st
// 创建新的IP库
func (this *IPLibraryDAO) CreateIPLibrary(tx *dbs.Tx, libraryType string, fileId int64) (int64, error) {
op := NewIPLibraryOperator()
var op = NewIPLibraryOperator()
op.Type = libraryType
op.FileId = fileId
op.State = IPLibraryStateEnabled

View File

@@ -165,7 +165,7 @@ func (this *IPListDAO) UpdateIPList(tx *dbs.Tx, listId int64, name string, code
if listId <= 0 {
return errors.New("invalid listId")
}
op := NewIPListOperator()
var op = NewIPListOperator()
op.Id = listId
op.Name = name
op.Code = code

View File

@@ -36,7 +36,7 @@ func init() {
// CreateLog 创建管理员日志
func (this *LogDAO) CreateLog(tx *dbs.Tx, adminType string, adminId int64, level string, description string, action string, ip string) error {
op := NewLogOperator()
var op = NewLogOperator()
op.Level = level
op.Description = description
op.Action = action

View File

@@ -78,7 +78,7 @@ func (this *LoginDAO) CreateLogin(tx *dbs.Tx, Id int64, loginType LoginType, par
if params == nil {
params = maps.Map{}
}
op := NewLoginOperator()
var op = NewLoginOperator()
op.Id = Id
op.Type = loginType
op.Params = params.AsJSON()
@@ -99,7 +99,7 @@ func (this *LoginDAO) UpdateLogin(tx *dbs.Tx, adminId int64, loginType LoginType
if err != nil {
return err
}
op := NewLoginOperator()
var op = NewLoginOperator()
if loginId > 0 {
op.Id = loginId
} else {

View File

@@ -154,7 +154,7 @@ func (this *MessageDAO) CreateNodeMessage(tx *dbs.Tx, role string, clusterId int
// CreateMessage 创建普通消息
func (this *MessageDAO) CreateMessage(tx *dbs.Tx, adminId int64, userId int64, messageType MessageType, level string, subject string, body string, paramsJSON []byte) error {
op := NewMessageOperator()
var op = NewMessageOperator()
op.AdminId = adminId
op.UserId = userId
op.Type = messageType
@@ -230,7 +230,7 @@ func (this *MessageDAO) UpdateMessageRead(tx *dbs.Tx, messageId int64, b bool) e
if messageId <= 0 {
return errors.New("invalid messageId")
}
op := NewMessageOperator()
var op = NewMessageOperator()
op.Id = messageId
op.IsRead = b
err := this.Save(tx, op)
@@ -286,7 +286,7 @@ func (this *MessageDAO) createMessage(tx *dbs.Tx, role string, clusterId int64,
// TODO 检查同样的消息最近是否发送过
// 创建新消息
op := NewMessageOperator()
var op = NewMessageOperator()
op.AdminId = 0 // TODO
op.UserId = 0 // TODO
op.Role = role

View File

@@ -104,7 +104,7 @@ func (this *MessageMediaDAO) UpdateMessageMedias(tx *dbs.Tx, mediaMaps []maps.Ma
if err != nil {
return err
}
op := NewMessageMediaOperator()
var op = NewMessageMediaOperator()
if mediaId > 0 {
op.Id = mediaId
}

View File

@@ -84,7 +84,7 @@ func (this *MessageMediaInstanceDAO) FindEnabledMessageMediaInstance(tx *dbs.Tx,
// CreateMediaInstance 创建媒介实例
func (this *MessageMediaInstanceDAO) CreateMediaInstance(tx *dbs.Tx, name string, mediaType string, params maps.Map, description string, rateJSON []byte, hashLifeSeconds int32) (int64, error) {
op := NewMessageMediaInstanceOperator()
var op = NewMessageMediaInstanceOperator()
op.Name = name
op.MediaType = mediaType
@@ -116,7 +116,7 @@ func (this *MessageMediaInstanceDAO) UpdateMediaInstance(tx *dbs.Tx, instanceId
return errors.New("invalid instanceId")
}
op := NewMessageMediaInstanceOperator()
var op = NewMessageMediaInstanceOperator()
op.Id = instanceId
op.Name = name
op.MediaType = mediaType

View File

@@ -76,7 +76,7 @@ func (this *MessageReceiverDAO) DisableReceivers(tx *dbs.Tx, clusterId int64, no
// CreateReceiver 创建接收人
func (this *MessageReceiverDAO) CreateReceiver(tx *dbs.Tx, role string, clusterId int64, nodeId int64, serverId int64, messageType MessageType, params maps.Map, recipientId int64, recipientGroupId int64) (int64, error) {
op := NewMessageReceiverOperator()
var op = NewMessageReceiverOperator()
op.Role = role
op.ClusterId = clusterId
op.NodeId = nodeId

View File

@@ -86,7 +86,7 @@ func (this *MessageRecipientDAO) FindEnabledMessageRecipient(tx *dbs.Tx, recipie
// CreateRecipient 创建接收人
func (this *MessageRecipientDAO) CreateRecipient(tx *dbs.Tx, adminId int64, instanceId int64, user string, groupIds []int64, description string, timeFrom string, timeTo string) (int64, error) {
op := NewMessageRecipientOperator()
var op = NewMessageRecipientOperator()
op.AdminId = adminId
op.InstanceId = instanceId
op.User = user
@@ -122,7 +122,7 @@ func (this *MessageRecipientDAO) UpdateRecipient(tx *dbs.Tx, recipientId int64,
return errors.New("invalid recipientId")
}
op := NewMessageRecipientOperator()
var op = NewMessageRecipientOperator()
op.Id = recipientId
op.AdminId = adminId
op.InstanceId = instanceId

View File

@@ -73,7 +73,7 @@ func (this *MessageRecipientGroupDAO) FindMessageRecipientGroupName(tx *dbs.Tx,
// 创建分组
func (this *MessageRecipientGroupDAO) CreateGroup(tx *dbs.Tx, name string) (int64, error) {
op := NewMessageRecipientGroupOperator()
var op = NewMessageRecipientGroupOperator()
op.Name = name
op.IsOn = true
op.State = MessageRecipientStateEnabled
@@ -85,7 +85,7 @@ func (this *MessageRecipientGroupDAO) UpdateGroup(tx *dbs.Tx, groupId int64, nam
if groupId <= 0 {
return errors.New("invalid groupId")
}
op := NewMessageRecipientGroupOperator()
var op = NewMessageRecipientGroupOperator()
op.Id = groupId
op.Name = name
op.IsOn = isOn

View File

@@ -131,7 +131,7 @@ func (this *MessageTaskDAO) CreateMessageTask(tx *dbs.Tx, recipientId int64, ins
}
}
op := NewMessageTaskOperator()
var op = NewMessageTaskOperator()
op.RecipientId = recipientId
op.InstanceId = instanceId
op.Hash = hash
@@ -190,7 +190,7 @@ func (this *MessageTaskDAO) UpdateMessageTaskStatus(tx *dbs.Tx, taskId int64, st
if taskId <= 0 {
return errors.New("invalid taskId")
}
op := NewMessageTaskOperator()
var op = NewMessageTaskOperator()
op.Id = taskId
op.Status = status
op.SentAt = time.Now().Unix()

View File

@@ -49,7 +49,7 @@ func init() {
// CreateLog 创建日志
func (this *MessageTaskLogDAO) CreateLog(tx *dbs.Tx, taskId int64, isOk bool, errMsg string, response string) error {
op := NewMessageTaskLogOperator()
var op = NewMessageTaskLogOperator()
op.TaskId = taskId
op.IsOk = isOk
op.Error = errMsg

View File

@@ -75,7 +75,7 @@ func (this *MetricChartDAO) FindMetricChartName(tx *dbs.Tx, chartId int64) (stri
// CreateChart 创建图表
func (this *MetricChartDAO) CreateChart(tx *dbs.Tx, itemId int64, name string, chartType string, widthDiv int32, maxItems int32, params maps.Map, ignoreEmptyKeys bool, ignoredKeys []string) (int64, error) {
op := NewMetricChartOperator()
var op = NewMetricChartOperator()
op.ItemId = itemId
op.Name = name
op.Type = chartType
@@ -112,7 +112,7 @@ func (this *MetricChartDAO) UpdateChart(tx *dbs.Tx, chartId int64, name string,
if chartId <= 0 {
return errors.New("invalid chartId")
}
op := NewMetricChartOperator()
var op = NewMetricChartOperator()
op.Id = chartId
op.Name = name
op.Type = chartType

View File

@@ -123,7 +123,7 @@ func (this *MonitorNodeDAO) CreateMonitorNode(tx *dbs.Tx, name string, descripti
return
}
op := NewMonitorNodeOperator()
var op = NewMonitorNodeOperator()
op.IsOn = isOn
op.UniqueId = uniqueId
op.Secret = secret
@@ -144,7 +144,7 @@ func (this *MonitorNodeDAO) UpdateMonitorNode(tx *dbs.Tx, nodeId int64, name str
return errors.New("invalid nodeId")
}
op := NewMonitorNodeOperator()
var op = NewMonitorNodeOperator()
op.Id = nodeId
op.Name = name
op.Description = description

View File

@@ -93,7 +93,7 @@ func (this *NSDomainDAO) CreateDomain(tx *dbs.Tx, clusterId int64, userId int64,
return 0, err
}
op := NewNSDomainOperator()
var op = NewNSDomainOperator()
op.ClusterId = clusterId
op.UserId = userId
op.Name = name
@@ -131,7 +131,7 @@ func (this *NSDomainDAO) UpdateDomain(tx *dbs.Tx, domainId int64, clusterId int6
return err
}
op := NewNSDomainOperator()
var op = NewNSDomainOperator()
op.Id = domainId
op.ClusterId = clusterId
op.UserId = userId

View File

@@ -79,7 +79,7 @@ func (this *NSKeyDAO) FindNSKeyName(tx *dbs.Tx, id int64) (string, error) {
// CreateKey 创建Key
func (this *NSKeyDAO) CreateKey(tx *dbs.Tx, domainId int64, zoneId int64, name string, algo dnsconfigs.KeyAlgorithmType, secret string, secretType string) (int64, error) {
op := NewNSKeyOperator()
var op = NewNSKeyOperator()
op.DomainId = domainId
op.ZoneId = zoneId
op.Name = name
@@ -105,7 +105,7 @@ func (this *NSKeyDAO) UpdateKey(tx *dbs.Tx, keyId int64, name string, algo dnsco
if keyId <= 0 {
return errors.New("invalid keyId")
}
op := NewNSKeyOperator()
var op = NewNSKeyOperator()
op.Id = keyId
op.Name = name
op.Algo = algo

View File

@@ -95,7 +95,7 @@ func (this *NSRecordDAO) CreateRecord(tx *dbs.Tx, domainId int64, description st
return 0, err
}
op := NewNSRecordOperator()
var op = NewNSRecordOperator()
op.DomainId = domainId
op.Description = description
op.Name = name
@@ -139,7 +139,7 @@ func (this *NSRecordDAO) UpdateRecord(tx *dbs.Tx, recordId int64, description st
return err
}
op := NewNSRecordOperator()
var op = NewNSRecordOperator()
op.Id = recordId
op.Description = description
op.Name = name

View File

@@ -129,7 +129,7 @@ func (this *NSRouteDAO) CreateRoute(tx *dbs.Tx, clusterId int64, domainId int64,
return 0, err
}
op := NewNSRouteOperator()
var op = NewNSRouteOperator()
op.ClusterId = clusterId
op.DomainId = domainId
op.UserId = userId
@@ -166,7 +166,7 @@ func (this *NSRouteDAO) UpdateRoute(tx *dbs.Tx, routeId int64, name string, rang
return err
}
op := NewNSRouteOperator()
var op = NewNSRouteOperator()
op.Id = routeId
op.Name = name
if len(rangesJSON) > 0 {

View File

@@ -133,7 +133,7 @@ func (this *NodeClusterDAO) CreateCluster(tx *dbs.Tx, adminId int64, name string
return 0, err
}
op := NewNodeClusterOperator()
var op = NewNodeClusterOperator()
op.AdminId = adminId
op.Name = name
op.GrantId = grantId
@@ -186,7 +186,7 @@ func (this *NodeClusterDAO) UpdateCluster(tx *dbs.Tx, clusterId int64, name stri
if clusterId <= 0 {
return errors.New("invalid clusterId")
}
op := NewNodeClusterOperator()
var op = NewNodeClusterOperator()
op.Id = clusterId
op.Name = name
op.GrantId = grantId
@@ -325,7 +325,7 @@ func (this *NodeClusterDAO) UpdateClusterHealthCheck(tx *dbs.Tx, clusterId int64
if clusterId <= 0 {
return errors.New("invalid clusterId '" + strconv.FormatInt(clusterId, 10) + "'")
}
op := NewNodeClusterOperator()
var op = NewNodeClusterOperator()
op.Id = clusterId
op.HealthCheck = healthCheckJSON
// 不需要通知更新
@@ -570,7 +570,7 @@ func (this *NodeClusterDAO) UpdateClusterTOA(tx *dbs.Tx, clusterId int64, toaJSO
if clusterId <= 0 {
return errors.New("invalid clusterId")
}
op := NewNodeClusterOperator()
var op = NewNodeClusterOperator()
op.Id = clusterId
op.Toa = toaJSON
err := this.Save(tx, op)

View File

@@ -84,7 +84,7 @@ func (this *NodeClusterFirewallActionDAO) CreateFirewallAction(tx *dbs.Tx, admin
params = maps.Map{}
}
op := NewNodeClusterFirewallActionOperator()
var op = NewNodeClusterFirewallActionOperator()
op.AdminId = adminId
op.ClusterId = clusterId
op.Name = name
@@ -113,7 +113,7 @@ func (this *NodeClusterFirewallActionDAO) UpdateFirewallAction(tx *dbs.Tx, actio
params = maps.Map{}
}
op := NewNodeClusterFirewallActionOperator()
var op = NewNodeClusterFirewallActionOperator()
op.Id = actionId
op.Name = name
op.EventLevel = eventLevel

View File

@@ -167,7 +167,7 @@ func (this *NodeDAO) CreateNode(tx *dbs.Tx, adminId int64, name string, clusterI
return
}
op := NewNodeOperator()
var op = NewNodeOperator()
op.AdminId = adminId
op.Name = name
op.UniqueId = uniqueId
@@ -1246,7 +1246,7 @@ func (this *NodeDAO) UpdateNodeConnectedAPINodes(tx *dbs.Tx, nodeId int64, apiNo
return errors.New("invalid nodeId")
}
op := NewNodeOperator()
var op = NewNodeOperator()
op.Id = nodeId
if len(apiNodeIds) > 0 {
@@ -1476,7 +1476,7 @@ func (this *NodeDAO) UpdateNodeDNS(tx *dbs.Tx, nodeId int64, routes map[int64][]
if err != nil {
return err
}
op := NewNodeOperator()
var op = NewNodeOperator()
op.Id = nodeId
op.DnsRoutes = routesJSON
err = this.Save(tx, op)
@@ -1601,7 +1601,7 @@ func (this *NodeDAO) UpdateNodeUpCount(tx *dbs.Tx, nodeId int64, isUp bool, maxU
countUp := int(one.(*Node).CountUp)
countDown := int(one.(*Node).CountDown)
op := NewNodeOperator()
var op = NewNodeOperator()
op.Id = nodeId
if isUp {
@@ -1645,7 +1645,7 @@ func (this *NodeDAO) UpdateNodeUp(tx *dbs.Tx, nodeId int64, isUp bool) error {
return errors.New("invalid nodeId")
}
op := NewNodeOperator()
var op = NewNodeOperator()
op.Id = nodeId
op.IsUp = isUp
op.CountUp = 0
@@ -1767,7 +1767,7 @@ func (this *NodeDAO) DeleteNodeFromCluster(tx *dbs.Tx, nodeId int64, clusterId i
if err != nil {
return err
}
op := NewNodeOperator()
var op = NewNodeOperator()
op.Id = nodeId
op.ClusterId = newClusterId
op.SecondaryClusterIds = secondaryClusterIdsJSON

View File

@@ -75,7 +75,7 @@ func (this *NodeGrantDAO) FindNodeGrantName(tx *dbs.Tx, id uint32) (string, erro
// CreateGrant 创建认证信息
func (this *NodeGrantDAO) CreateGrant(tx *dbs.Tx, adminId int64, name string, method string, username string, password string, privateKey string, passphrase string, description string, nodeId int64, su bool) (grantId int64, err error) {
op := NewNodeGrantOperator()
var op = NewNodeGrantOperator()
op.AdminId = adminId
op.Name = name
op.Method = method
@@ -103,7 +103,7 @@ func (this *NodeGrantDAO) UpdateGrant(tx *dbs.Tx, grantId int64, name string, me
return errors.New("invalid grantId")
}
op := NewNodeGrantOperator()
var op = NewNodeGrantOperator()
op.Id = grantId
op.Name = name
op.Method = method

View File

@@ -73,7 +73,7 @@ func (this *NodeGroupDAO) FindNodeGroupName(tx *dbs.Tx, id int64) (string, error
// 创建分组
func (this *NodeGroupDAO) CreateNodeGroup(tx *dbs.Tx, clusterId int64, name string) (int64, error) {
op := NewNodeGroupOperator()
var op = NewNodeGroupOperator()
op.ClusterId = clusterId
op.Name = name
op.State = NodeGroupStateEnabled
@@ -89,7 +89,7 @@ func (this *NodeGroupDAO) UpdateNodeGroup(tx *dbs.Tx, groupId int64, name string
if groupId <= 0 {
return errors.New("invalid groupId")
}
op := NewNodeGroupOperator()
var op = NewNodeGroupOperator()
op.Id = groupId
op.Name = name
err := this.Save(tx, op)

View File

@@ -161,7 +161,7 @@ func (this *NodeIPAddressDAO) UpdateAddress(tx *dbs.Tx, adminId int64, addressId
return errors.New("invalid addressId")
}
op := NewNodeIPAddressOperator()
var op = NewNodeIPAddressOperator()
op.Id = addressId
op.Name = name
op.Ip = ip
@@ -189,7 +189,7 @@ func (this *NodeIPAddressDAO) UpdateAddressIP(tx *dbs.Tx, addressId int64, ip st
if addressId <= 0 {
return errors.New("invalid addressId")
}
op := NewNodeIPAddressOperator()
var op = NewNodeIPAddressOperator()
op.Id = addressId
op.Ip = ip
err := this.Save(tx, op)

View File

@@ -75,7 +75,7 @@ func (this *NodePriceItemDAO) FindNodePriceItemName(tx *dbs.Tx, id int64) (strin
// CreateItem 创建价格
func (this *NodePriceItemDAO) CreateItem(tx *dbs.Tx, name string, itemType string, bitsFrom, bitsTo int64) (int64, error) {
op := NewNodePriceItemOperator()
var op = NewNodePriceItemOperator()
op.Name = name
op.Type = itemType
op.BitsFrom = bitsFrom
@@ -90,7 +90,7 @@ func (this *NodePriceItemDAO) UpdateItem(tx *dbs.Tx, itemId int64, name string,
if itemId <= 0 {
return errors.New("invalid itemId")
}
op := NewNodePriceItemOperator()
var op = NewNodePriceItemOperator()
op.Id = itemId
op.Name = name
op.BitsFrom = bitsFrom

View File

@@ -75,7 +75,7 @@ func (this *NodeRegionDAO) FindNodeRegionName(tx *dbs.Tx, id int64) (string, err
// CreateRegion 创建区域
func (this *NodeRegionDAO) CreateRegion(tx *dbs.Tx, adminId int64, name string, description string) (int64, error) {
op := NewNodeRegionOperator()
var op = NewNodeRegionOperator()
op.AdminId = adminId
op.Name = name
op.Description = description
@@ -89,7 +89,7 @@ func (this *NodeRegionDAO) UpdateRegion(tx *dbs.Tx, regionId int64, name string,
if regionId <= 0 {
return errors.New("invalid regionId")
}
op := NewNodeRegionOperator()
var op = NewNodeRegionOperator()
op.Id = regionId
op.Name = name
op.Description = description

View File

@@ -72,7 +72,7 @@ func (this *NodeThresholdDAO) FindEnabledNodeThreshold(tx *dbs.Tx, id int64) (*N
// CreateThreshold 创建阈值
func (this *NodeThresholdDAO) CreateThreshold(tx *dbs.Tx, role string, clusterId int64, nodeId int64, item nodeconfigs.NodeValueItem, param string, operator nodeconfigs.NodeValueOperator, valueJSON []byte, message string, sumMethod nodeconfigs.NodeValueSumMethod, duration int32, durationUnit nodeconfigs.NodeValueDurationUnit, notifyDuration int32) (int64, error) {
op := NewNodeThresholdOperator()
var op = NewNodeThresholdOperator()
op.Role = role
op.ClusterId = clusterId
op.NodeId = nodeId
@@ -95,7 +95,7 @@ func (this *NodeThresholdDAO) UpdateThreshold(tx *dbs.Tx, thresholdId int64, ite
if thresholdId <= 0 {
return errors.New("invalid thresholdId")
}
op := NewNodeThresholdOperator()
var op = NewNodeThresholdOperator()
op.Id = thresholdId
op.Item = item
op.Param = param

View File

@@ -75,7 +75,7 @@ func (this *NSClusterDAO) FindEnabledNSClusterName(tx *dbs.Tx, id int64) (string
// CreateCluster 创建集群
func (this *NSClusterDAO) CreateCluster(tx *dbs.Tx, name string, accessLogRefJSON []byte) (int64, error) {
op := NewNSClusterOperator()
var op = NewNSClusterOperator()
op.Name = name
if len(accessLogRefJSON) > 0 {
@@ -92,7 +92,7 @@ func (this *NSClusterDAO) UpdateCluster(tx *dbs.Tx, clusterId int64, name string
if clusterId <= 0 {
return errors.New("invalid clusterId")
}
op := NewNSClusterOperator()
var op = NewNSClusterOperator()
op.Id = clusterId
op.Name = name
op.IsOn = isOn

View File

@@ -226,7 +226,7 @@ func (this *NSNodeDAO) CreateNode(tx *dbs.Tx, adminId int64, name string, cluste
return
}
op := NewNSNodeOperator()
var op = NewNSNodeOperator()
op.AdminId = adminId
op.Name = name
op.UniqueId = uniqueId
@@ -260,7 +260,7 @@ func (this *NSNodeDAO) UpdateNode(tx *dbs.Tx, nodeId int64, name string, cluster
if nodeId <= 0 {
return errors.New("invalid nodeId")
}
op := NewNSNodeOperator()
var op = NewNSNodeOperator()
op.Id = nodeId
op.Name = name
op.ClusterId = clusterId
@@ -487,7 +487,7 @@ func (this *NSNodeDAO) UpdateNodeConnectedAPINodes(tx *dbs.Tx, nodeId int64, api
return errors.New("invalid nodeId")
}
op := NewNSNodeOperator()
var op = NewNSNodeOperator()
op.Id = nodeId
if len(apiNodeIds) > 0 {

View File

@@ -86,7 +86,7 @@ func (this *RegionCityDAO) FindCityWithDataId(tx *dbs.Tx, dataId string) (int64,
// CreateCity 创建城市
func (this *RegionCityDAO) CreateCity(tx *dbs.Tx, provinceId int64, name string, dataId string) (int64, error) {
op := NewRegionCityOperator()
var op = NewRegionCityOperator()
op.ProvinceId = provinceId
op.Name = name
op.DataId = dataId

View File

@@ -133,7 +133,7 @@ func (this *RegionCountryDAO) FindCountryIdWithNameCacheable(tx *dbs.Tx, country
// CreateCountry 根据数据ID创建国家
func (this *RegionCountryDAO) CreateCountry(tx *dbs.Tx, name string, dataId string) (int64, error) {
op := NewRegionCountryOperator()
var op = NewRegionCountryOperator()
op.Name = name
pinyinPieces := pinyin.Pinyin(name, pinyin.NewArgs())

View File

@@ -102,7 +102,7 @@ func (this *RegionProviderDAO) FindProviderIdWithNameCacheable(tx *dbs.Tx, provi
// CreateProvider 创建Provider
func (this *RegionProviderDAO) CreateProvider(tx *dbs.Tx, name string) (int64, error) {
op := NewRegionProviderOperator()
var op = NewRegionProviderOperator()
op.Name = name
codesJSON, err := json.Marshal([]string{name})

View File

@@ -119,7 +119,7 @@ func (this *RegionProvinceDAO) FindProvinceIdWithNameCacheable(tx *dbs.Tx, count
// 创建省份
func (this *RegionProvinceDAO) CreateProvince(tx *dbs.Tx, countryId int64, name string, dataId string) (int64, error) {
op := NewRegionProvinceOperator()
var op = NewRegionProvinceOperator()
op.CountryId = countryId
op.Name = name
op.DataId = dataId

View File

@@ -98,7 +98,7 @@ func (this *ReportNodeDAO) CreateReportNode(tx *dbs.Tx, name string, location st
return 0, err
}
op := NewReportNodeOperator()
var op = NewReportNodeOperator()
op.UniqueId = uniqueId
op.Secret = secret
op.Name = name
@@ -136,7 +136,7 @@ func (this *ReportNodeDAO) UpdateReportNode(tx *dbs.Tx, nodeId int64, name strin
return errors.New("invalid nodeId")
}
op := NewReportNodeOperator()
var op = NewReportNodeOperator()
op.Id = nodeId
op.Name = name
op.Location = location

View File

@@ -212,7 +212,7 @@ func (this *ReverseProxyDAO) ComposeReverseProxyConfig(tx *dbs.Tx, reverseProxyI
// CreateReverseProxy 创建反向代理
func (this *ReverseProxyDAO) CreateReverseProxy(tx *dbs.Tx, adminId int64, userId int64, schedulingJSON []byte, primaryOriginsJSON []byte, backupOriginsJSON []byte) (int64, error) {
op := NewReverseProxyOperator()
var op = NewReverseProxyOperator()
op.IsOn = true
op.State = ReverseProxyStateEnabled
op.AdminId = adminId
@@ -248,7 +248,7 @@ func (this *ReverseProxyDAO) UpdateReverseProxyScheduling(tx *dbs.Tx, reversePro
if reverseProxyId <= 0 {
return errors.New("invalid reverseProxyId")
}
op := NewReverseProxyOperator()
var op = NewReverseProxyOperator()
op.Id = reverseProxyId
if len(schedulingJSON) > 0 {
op.Scheduling = string(schedulingJSON)
@@ -267,7 +267,7 @@ func (this *ReverseProxyDAO) UpdateReverseProxyPrimaryOrigins(tx *dbs.Tx, revers
if reverseProxyId <= 0 {
return errors.New("invalid reverseProxyId")
}
op := NewReverseProxyOperator()
var op = NewReverseProxyOperator()
op.Id = reverseProxyId
if len(origins) > 0 {
op.PrimaryOrigins = origins
@@ -286,7 +286,7 @@ func (this *ReverseProxyDAO) UpdateReverseProxyBackupOrigins(tx *dbs.Tx, reverse
if reverseProxyId <= 0 {
return errors.New("invalid reverseProxyId")
}
op := NewReverseProxyOperator()
var op = NewReverseProxyOperator()
op.Id = reverseProxyId
if len(origins) > 0 {
op.BackupOrigins = origins

View File

@@ -624,7 +624,7 @@ func (this *ServerDAO) UpdateServerNames(tx *dbs.Tx, serverId int64, serverNames
return errors.New("serverId should not be smaller than 0")
}
op := NewServerOperator()
var op = NewServerOperator()
op.Id = serverId
if IsNull(serverNamesJSON) {
@@ -657,7 +657,7 @@ func (this *ServerDAO) UpdateAuditingServerNames(tx *dbs.Tx, serverId int64, isA
return errors.New("serverId should not be smaller than 0")
}
op := NewServerOperator()
var op = NewServerOperator()
op.Id = serverId
op.IsAuditing = isAuditing
if isAuditing {
@@ -739,7 +739,7 @@ func (this *ServerDAO) UpdateServerReverseProxy(tx *dbs.Tx, serverId int64, conf
if serverId <= 0 {
return errors.New("serverId should not be smaller than 0")
}
op := NewServerOperator()
var op = NewServerOperator()
op.Id = serverId
op.ReverseProxy = JSONBytes(config)
err := this.Save(tx, op)
@@ -1607,7 +1607,7 @@ func (this *ServerDAO) GenerateServerDNSName(tx *dbs.Tx, serverId int64) (string
if err != nil {
return "", err
}
op := NewServerOperator()
var op = NewServerOperator()
op.Id = serverId
op.DnsName = dnsName
err = this.Save(tx, op)

View File

@@ -78,7 +78,7 @@ func (this *ServerGroupDAO) FindServerGroupName(tx *dbs.Tx, id int64) (string, e
// CreateGroup 创建分组
func (this *ServerGroupDAO) CreateGroup(tx *dbs.Tx, name string, userId int64) (groupId int64, err error) {
op := NewServerGroupOperator()
var op = NewServerGroupOperator()
op.State = ServerGroupStateEnabled
op.Name = name
op.UserId = userId
@@ -95,7 +95,7 @@ func (this *ServerGroupDAO) UpdateGroup(tx *dbs.Tx, groupId int64, name string)
if groupId <= 0 {
return errors.New("invalid groupId")
}
op := NewServerGroupOperator()
var op = NewServerGroupOperator()
op.Id = groupId
op.Name = name
err := this.Save(tx, op)
@@ -193,7 +193,7 @@ func (this *ServerGroupDAO) UpdateHTTPReverseProxy(tx *dbs.Tx, groupId int64, co
if groupId <= 0 {
return errors.New("groupId should not be smaller than 0")
}
op := NewServerGroupOperator()
var op = NewServerGroupOperator()
op.Id = groupId
op.HttpReverseProxy = JSONBytes(config)
err := this.Save(tx, op)
@@ -209,7 +209,7 @@ func (this *ServerGroupDAO) UpdateTCPReverseProxy(tx *dbs.Tx, groupId int64, con
if groupId <= 0 {
return errors.New("groupId should not be smaller than 0")
}
op := NewServerGroupOperator()
var op = NewServerGroupOperator()
op.Id = groupId
op.TcpReverseProxy = JSONBytes(config)
err := this.Save(tx, op)
@@ -225,7 +225,7 @@ func (this *ServerGroupDAO) UpdateUDPReverseProxy(tx *dbs.Tx, groupId int64, con
if groupId <= 0 {
return errors.New("groupId should not be smaller than 0")
}
op := NewServerGroupOperator()
var op = NewServerGroupOperator()
op.Id = groupId
op.UdpReverseProxy = JSONBytes(config)
err := this.Save(tx, op)

View File

@@ -64,7 +64,7 @@ func (this *ServerStatBoardChartDAO) FindEnabledServerStatBoardChart(tx *dbs.Tx,
// EnableChart 启用图表
func (this *ServerStatBoardChartDAO) EnableChart(tx *dbs.Tx, boardId int64, chartId int64) error {
op := NewServerStatBoardChartOperator()
var op = NewServerStatBoardChartOperator()
op.BoardId = boardId
op.ChartId = chartId
op.State = ServerStatBoardChartStateEnabled

View File

@@ -89,7 +89,7 @@ func (this *SSLCertDAO) FindSSLCertName(tx *dbs.Tx, id int64) (string, error) {
// CreateCert 创建证书
func (this *SSLCertDAO) CreateCert(tx *dbs.Tx, adminId int64, userId int64, isOn bool, name string, description string, serverName string, isCA bool, certData []byte, keyData []byte, timeBeginAt int64, timeEndAt int64, dnsNames []string, commonNames []string) (int64, error) {
op := NewSSLCertOperator()
var op = NewSSLCertOperator()
op.AdminId = adminId
op.UserId = userId
op.State = SSLCertStateEnabled
@@ -343,7 +343,7 @@ func (this *SSLCertDAO) UpdateCertACME(tx *dbs.Tx, certId int64, acmeTaskId int6
if certId <= 0 {
return errors.New("invalid certId")
}
op := NewSSLCertOperator()
var op = NewSSLCertOperator()
op.Id = certId
op.AcmeTaskId = acmeTaskId
op.IsACME = true

View File

@@ -200,7 +200,7 @@ func (this *SSLPolicyDAO) FindAllEnabledPolicyIdsWithCertId(tx *dbs.Tx, certId i
// CreatePolicy 创建Policy
func (this *SSLPolicyDAO) CreatePolicy(tx *dbs.Tx, adminId int64, userId int64, http2Enabled bool, minVersion string, certsJSON []byte, hstsJSON []byte, ocspIsOn bool, clientAuthType int32, clientCACertsJSON []byte, cipherSuitesIsOn bool, cipherSuites []string) (int64, error) {
op := NewSSLPolicyOperator()
var op = NewSSLPolicyOperator()
op.State = SSLPolicyStateEnabled
op.IsOn = true
op.AdminId = adminId
@@ -244,7 +244,7 @@ func (this *SSLPolicyDAO) UpdatePolicy(tx *dbs.Tx, policyId int64, http2Enabled
return errors.New("invalid policyId")
}
op := NewSSLPolicyOperator()
var op = NewSSLPolicyOperator()
op.Id = policyId
op.Http2Enabled = http2Enabled
op.MinVersion = minVersion

View File

@@ -35,7 +35,7 @@ func (this *SysEventDAO) CreateEvent(tx *dbs.Tx, event EventInterface) error {
return errors.New("event should not be nil")
}
op := NewSysEventOperator()
var op = NewSysEventOperator()
op.Type = event.Type()
eventJSON, err := json.Marshal(event)

View File

@@ -47,7 +47,7 @@ func (this *SysLockerDAO) Lock(tx *dbs.Tx, key string, timeout int64) (ok bool,
// 如果没有锁,则创建
if one == nil {
op := NewSysLockerOperator()
var op = NewSysLockerOperator()
op.Key = key
op.TimeoutAt = time.Now().Unix() + timeout
op.Version = 1
@@ -70,7 +70,7 @@ func (this *SysLockerDAO) Lock(tx *dbs.Tx, key string, timeout int64) (ok bool,
}
// 修改
op := NewSysLockerOperator()
var op = NewSysLockerOperator()
op.Id = locker.Id
op.Version = locker.Version + 1
op.TimeoutAt = time.Now().Unix() + timeout

View File

@@ -65,7 +65,7 @@ func (this *SysSettingDAO) UpdateSetting(tx *dbs.Tx, codeFormat string, valueJSO
if settingId == 0 {
// 新建
op := NewSysSettingOperator()
var op = NewSysSettingOperator()
op.Code = codeFormat
op.Value = valueJSON
err = this.Save(tx, op)
@@ -81,7 +81,7 @@ func (this *SysSettingDAO) UpdateSetting(tx *dbs.Tx, codeFormat string, valueJSO
}
// 修改
op := NewSysSettingOperator()
var op = NewSysSettingOperator()
op.Id = settingId
op.Value = valueJSON
err = this.Save(tx, op)

View File

@@ -70,7 +70,7 @@ func (this *UserAccessKeyDAO) CreateAccessKey(tx *dbs.Tx, adminId int64, userId
if adminId <= 0 && userId <= 0 {
return 0, errors.New("invalid adminId or userId")
}
op := NewUserAccessKeyOperator()
var op = NewUserAccessKeyOperator()
op.AdminId = adminId
op.UserId = userId
op.Description = description

View File

@@ -129,7 +129,7 @@ func (this *UserDAO) CreateUser(tx *dbs.Tx, username string,
features []string,
registeredIP string,
isVerified bool) (int64, error) {
op := NewUserOperator()
var op = NewUserOperator()
op.Username = username
op.Password = stringutil.Md5(password)
op.Fullname = fullname
@@ -191,7 +191,7 @@ func (this *UserDAO) UpdateUserInfo(tx *dbs.Tx, userId int64, fullname string, m
if userId <= 0 {
return errors.New("invalid userId")
}
op := NewUserOperator()
var op = NewUserOperator()
op.Id = userId
op.Fullname = fullname
op.Mobile = mobile
@@ -204,7 +204,7 @@ func (this *UserDAO) UpdateUserLogin(tx *dbs.Tx, userId int64, username string,
if userId <= 0 {
return errors.New("invalid userId")
}
op := NewUserOperator()
var op = NewUserOperator()
op.Id = userId
op.Username = username
if len(password) > 0 {

View File

@@ -66,9 +66,10 @@ func (this *UserIdentityDAO) FindEnabledUserIdentity(tx *dbs.Tx, id int64) (*Use
}
// CreateUserIdentity 创建
func (this *UserIdentityDAO) CreateUserIdentity(tx *dbs.Tx, userId int64, idType userconfigs.UserIdentityType, realName string, number string, fileIds []int64) (int64, error) {
func (this *UserIdentityDAO) CreateUserIdentity(tx *dbs.Tx, userId int64, orgType userconfigs.UserIdentityOrgType, idType userconfigs.UserIdentityType, realName string, number string, fileIds []int64) (int64, error) {
var op = NewUserIdentityOperator()
op.UserId = userId
op.OrgType = orgType
op.Type = idType
op.RealName = realName
op.Number = number
@@ -96,6 +97,7 @@ func (this *UserIdentityDAO) UpdateUserIdentity(tx *dbs.Tx, identityId int64, id
var op = NewUserIdentityOperator()
op.Id = identityId
op.Type = idType
op.RealName = realName
op.Number = number
if fileIds == nil {
@@ -107,6 +109,8 @@ func (this *UserIdentityDAO) UpdateUserIdentity(tx *dbs.Tx, identityId int64, id
}
op.FileIds = fileIdsJSON
op.Status = userconfigs.UserIdentityStatusNone
return this.Save(tx, op)
}
@@ -129,10 +133,11 @@ func (this *UserIdentityDAO) CancelUserIdentity(tx *dbs.Tx, identityId int64) er
}
// RejectUserIdentity 拒绝
func (this *UserIdentityDAO) RejectUserIdentity(tx *dbs.Tx, identityId int64) error {
func (this *UserIdentityDAO) RejectUserIdentity(tx *dbs.Tx, identityId int64, reason string) error {
return this.Query(tx).
Pk(identityId).
Set("status", userconfigs.UserIdentityStatusRejected).
Set("rejectedReason", reason).
Set("rejectedAt", time.Now().Unix()).
UpdateQuickly()
}
@@ -170,12 +175,13 @@ func (this *UserIdentityDAO) FindUserIdentityStatus(tx *dbs.Tx, identityId int64
FindStringCol("")
}
// FindEnabledUserIdentityWithType 查找某个类型的认证信息
func (this *UserIdentityDAO) FindEnabledUserIdentityWithType(tx *dbs.Tx, userId int64, idType userconfigs.UserIdentityType) (*UserIdentity, error) {
// FindEnabledUserIdentityWithOrgType 查找某个类型的认证信息
func (this *UserIdentityDAO) FindEnabledUserIdentityWithOrgType(tx *dbs.Tx, userId int64, orgType string) (*UserIdentity, error) {
one, err := this.Query(tx).
Attr("userId", userId).
Attr("type", idType).
Attr("orgType", orgType).
State(UserIdentityStateEnabled).
DescPk().
Find()
if err != nil || one == nil {
return nil, err

View File

@@ -6,7 +6,8 @@ import "github.com/iwind/TeaGo/dbs"
type UserIdentity struct {
Id uint64 `field:"id"` // ID
UserId uint64 `field:"userId"` // 用户ID
Type string `field:"type"` // 类型
OrgType string `field:"orgType"` // 组织类型
Type string `field:"type"` // 证件类型
RealName string `field:"realName"` // 真实姓名
Number string `field:"number"` // 编号
FileIds dbs.JSON `field:"fileIds"` // 文件ID
@@ -17,12 +18,14 @@ type UserIdentity struct {
SubmittedAt uint64 `field:"submittedAt"` // 提交时间
RejectedAt uint64 `field:"rejectedAt"` // 拒绝时间
VerifiedAt uint64 `field:"verifiedAt"` // 认证时间
RejectedReason string `field:"rejectedReason"` // 拒绝原因
}
type UserIdentityOperator struct {
Id interface{} // ID
UserId interface{} // 用户ID
Type interface{} // 类型
OrgType interface{} // 组织类型
Type interface{} // 证件类型
RealName interface{} // 真实姓名
Number interface{} // 编号
FileIds interface{} // 文件ID
@@ -33,6 +36,7 @@ type UserIdentityOperator struct {
SubmittedAt interface{} // 提交时间
RejectedAt interface{} // 拒绝时间
VerifiedAt interface{} // 认证时间
RejectedReason interface{} // 拒绝原因
}
func NewUserIdentityOperator() *UserIdentityOperator {

View File

@@ -162,7 +162,7 @@ func (this *UserNodeDAO) CreateUserNode(tx *dbs.Tx, name string, description str
return
}
op := NewUserNodeOperator()
var op = NewUserNodeOperator()
op.IsOn = isOn
op.UniqueId = uniqueId
op.Secret = secret
@@ -194,7 +194,7 @@ func (this *UserNodeDAO) UpdateUserNode(tx *dbs.Tx, nodeId int64, name string, d
return errors.New("invalid nodeId")
}
op := NewUserNodeOperator()
var op = NewUserNodeOperator()
op.Id = nodeId
op.Name = name
op.Description = description

View File

@@ -43,6 +43,8 @@ func (this *FileService) FindEnabledFile(ctx context.Context, req *pb.FindEnable
Size: int64(file.Size),
CreatedAt: int64(file.CreatedAt),
IsPublic: file.IsPublic,
MimeType: file.MimeType,
Type: file.Type,
},
}, nil
}
@@ -56,7 +58,7 @@ func (this *FileService) CreateFile(ctx context.Context, req *pb.CreateFileReque
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 {
return nil, err
}

View File

@@ -15,13 +15,21 @@ type FileChunkService struct {
// CreateFileChunk 创建文件片段
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 {
return nil, err
}
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)
if err != nil {
return nil, err
@@ -37,10 +45,11 @@ func (this *FileChunkService) FindAllFileChunkIds(ctx context.Context, req *pb.F
return nil, err
}
// TODO 校验用户
var tx = this.NullTx()
// 校验用户
// TODO
chunkIds, err := models.SharedFileChunkDAO.FindAllFileChunkIds(tx, req.FileId)
if err != nil {
return nil, err

View File

@@ -27,12 +27,16 @@ func (this *UserIdentityService) CreateUserIdentity(ctx context.Context, req *pb
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 + "'")
}
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 {
return nil, err
}
@@ -40,29 +44,32 @@ func (this *UserIdentityService) CreateUserIdentity(ctx context.Context, req *pb
return &pb.CreateUserIdentityResponse{UserIdentityId: identityId}, nil
}
// FindUserEnabledUserIdentityWithType 查看身份认证信息
func (this *UserIdentityService) FindUserEnabledUserIdentityWithType(ctx context.Context, req *pb.FindUserEnabledUserIdentityWithTypeRequest) (*pb.FindUserEnabledUserIdentityWithTypeResponse, error) {
// FindEnabledUserIdentity 查找单个身份认证信息
func (this *UserIdentityService) FindEnabledUserIdentity(ctx context.Context, req *pb.FindEnabledUserIdentityRequest) (*pb.FindEnabledUserIdentityResponse, error) {
_, userId, err := this.ValidateAdminAndUser(ctx)
if err != nil {
return nil, err
}
var tx = this.NullTx()
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.FindEnabledUserIdentityWithType(tx, req.UserId, req.Type)
identity, err := models.SharedUserIdentityDAO.FindEnabledUserIdentity(tx, req.UserIdentityId)
if err != nil {
return nil, err
}
if identity == nil {
return &pb.FindUserEnabledUserIdentityWithTypeResponse{
return &pb.FindEnabledUserIdentityResponse{
UserIdentity: nil,
}, nil
}
return &pb.FindUserEnabledUserIdentityWithTypeResponse{
return &pb.FindEnabledUserIdentityResponse{
UserIdentity: &pb.UserIdentity{
Id: int64(identity.Id),
Type: identity.Type,
@@ -75,6 +82,47 @@ func (this *UserIdentityService) FindUserEnabledUserIdentityWithType(ctx context
SubmittedAt: int64(identity.SubmittedAt),
RejectedAt: int64(identity.RejectedAt),
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
}
@@ -88,6 +136,23 @@ func (this *UserIdentityService) UpdateUserIdentity(ctx context.Context, req *pb
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)
if err != nil {
@@ -99,7 +164,7 @@ func (this *UserIdentityService) UpdateUserIdentity(ctx context.Context, req *pb
if err != nil {
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 + "'")
}
@@ -131,7 +196,7 @@ func (this *UserIdentityService) SubmitUserIdentity(ctx context.Context, req *pb
if err != nil {
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 + "'")
}
@@ -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 + "'")
}
err = models.SharedUserIdentityDAO.RejectUserIdentity(tx, req.UserIdentityId)
err = models.SharedUserIdentityDAO.RejectUserIdentity(tx, req.UserIdentityId, req.Reason)
if err != nil {
return nil, err
}

View File

@@ -118,7 +118,7 @@ func ValidateRequest(ctx context.Context, userTypes ...UserType) (userType UserT
return UserTypeNone, 0, 0, errors.New("invalid token")
}
m := maps.Map{}
var m = maps.Map{}
err = json.Unmarshal(data, &m)
if err != nil {
return UserTypeNone, 0, 0, errors.New("decode token error: " + err.Error())