mirror of
				https://github.com/TeaOSLab/EdgeAPI.git
				synced 2025-11-04 16:00:24 +08:00 
			
		
		
		
	优化代码
This commit is contained in:
		@@ -140,18 +140,9 @@ func (this *NodeDAO) FindNodeName(tx *dbs.Tx, id int64) (string, error) {
 | 
			
		||||
 | 
			
		||||
// CreateNode 创建节点
 | 
			
		||||
func (this *NodeDAO) CreateNode(tx *dbs.Tx, adminId int64, name string, clusterId int64, groupId int64, regionId int64) (nodeId int64, err error) {
 | 
			
		||||
	// 检查节点数量
 | 
			
		||||
	if teaconst.MaxNodes > 0 {
 | 
			
		||||
		count, err := this.Query(tx).
 | 
			
		||||
			State(NodeStateEnabled).
 | 
			
		||||
			Where("clusterId IN (SELECT id FROM " + SharedNodeClusterDAO.Table + " WHERE state=1)").
 | 
			
		||||
			Count()
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return 0, err
 | 
			
		||||
		}
 | 
			
		||||
		if int64(teaconst.MaxNodes) <= count {
 | 
			
		||||
			return 0, errors.New("[企业版]超出最大节点数限制:" + types.String(teaconst.MaxNodes) + ",请购买更多配额")
 | 
			
		||||
		}
 | 
			
		||||
	err = this.CheckNodesLimit(tx)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	uniqueId, err := this.GenUniqueId(tx)
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										12
									
								
								internal/db/models/node_dao_limit.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								internal/db/models/node_dao_limit.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,12 @@
 | 
			
		||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
 | 
			
		||||
//go:build !plus
 | 
			
		||||
 | 
			
		||||
package models
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"github.com/iwind/TeaGo/dbs"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func (this *NodeDAO) CheckNodesLimit(tx *dbs.Tx) error {
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user