mirror of
				https://github.com/TeaOSLab/EdgeAPI.git
				synced 2025-11-04 16:00:24 +08:00 
			
		
		
		
	增加置顶集群功能
This commit is contained in:
		@@ -26,5 +26,5 @@ const (
 | 
			
		||||
	ReportNodeVersion    = "0.1.0"
 | 
			
		||||
 | 
			
		||||
	// SQLVersion SQL版本号
 | 
			
		||||
	SQLVersion = "2"
 | 
			
		||||
	SQLVersion = "3"
 | 
			
		||||
)
 | 
			
		||||
 
 | 
			
		||||
@@ -207,6 +207,14 @@ func (this *NodeClusterDAO) UpdateCluster(tx *dbs.Tx, clusterId int64, name stri
 | 
			
		||||
	return this.NotifyUpdate(tx, clusterId)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// UpdateClusterIsPinned 设置集群是否置顶
 | 
			
		||||
func (this *NodeClusterDAO) UpdateClusterIsPinned(tx *dbs.Tx, clusterId int64, isPinned bool) error {
 | 
			
		||||
	return this.Query(tx).
 | 
			
		||||
		Pk(clusterId).
 | 
			
		||||
		Set("isPinned", isPinned).
 | 
			
		||||
		UpdateQuickly()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CountAllEnabledClusters 计算所有集群数量
 | 
			
		||||
func (this *NodeClusterDAO) CountAllEnabledClusters(tx *dbs.Tx, keyword string) (int64, error) {
 | 
			
		||||
	query := this.Query(tx).
 | 
			
		||||
@@ -230,6 +238,7 @@ func (this *NodeClusterDAO) ListEnabledClusters(tx *dbs.Tx, keyword string, offs
 | 
			
		||||
		Offset(offset).
 | 
			
		||||
		Limit(size).
 | 
			
		||||
		Slice(&result).
 | 
			
		||||
		Desc("isPinned").
 | 
			
		||||
		DescPk().
 | 
			
		||||
		FindAll()
 | 
			
		||||
	return
 | 
			
		||||
 
 | 
			
		||||
@@ -30,6 +30,7 @@ type NodeCluster struct {
 | 
			
		||||
	NodeMaxThreads        uint32 `field:"nodeMaxThreads"`        // 节点最大线程数
 | 
			
		||||
	NodeTCPMaxConnections uint32 `field:"nodeTCPMaxConnections"` // TCP最大连接数
 | 
			
		||||
	AutoOpenPorts         uint8  `field:"autoOpenPorts"`         // 是否自动尝试开放端口
 | 
			
		||||
	IsPinned              uint8  `field:"isPinned"`              // 是否置顶
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type NodeClusterOperator struct {
 | 
			
		||||
@@ -61,6 +62,7 @@ type NodeClusterOperator struct {
 | 
			
		||||
	NodeMaxThreads        interface{} // 节点最大线程数
 | 
			
		||||
	NodeTCPMaxConnections interface{} // TCP最大连接数
 | 
			
		||||
	AutoOpenPorts         interface{} // 是否自动尝试开放端口
 | 
			
		||||
	IsPinned              interface{} // 是否置顶
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewNodeClusterOperator() *NodeClusterOperator {
 | 
			
		||||
 
 | 
			
		||||
@@ -298,6 +298,7 @@ func (this *NodeClusterService) ListEnabledNodeClusters(ctx context.Context, req
 | 
			
		||||
			DnsDomainId: int64(cluster.DnsDomainId),
 | 
			
		||||
			IsOn:        cluster.IsOn == 1,
 | 
			
		||||
			TimeZone:    cluster.TimeZone,
 | 
			
		||||
			IsPinned:    cluster.IsPinned == 1,
 | 
			
		||||
		})
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -1026,3 +1027,19 @@ func (this *NodeClusterService) FindEnabledNodeClusterConfigInfo(ctx context.Con
 | 
			
		||||
 | 
			
		||||
	return result, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// UpdateNodeClusterPinned 设置集群是否置顶
 | 
			
		||||
func (this *NodeClusterService) UpdateNodeClusterPinned(ctx context.Context, req *pb.UpdateNodeClusterPinnedRequest) (*pb.RPCSuccess, error) {
 | 
			
		||||
	_, err := this.ValidateAdmin(ctx, 0)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var tx = this.NullTx()
 | 
			
		||||
	err = models.SharedNodeClusterDAO.UpdateClusterIsPinned(tx, req.NodeClusterId, req.IsPinned)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return this.Success()
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
		Reference in New Issue
	
	Block a user