mirror of
				https://github.com/TeaOSLab/EdgeAPI.git
				synced 2025-11-04 16:00:24 +08:00 
			
		
		
		
	优化API/修改用户集群不影响套餐服务
This commit is contained in:
		@@ -664,13 +664,23 @@ func (this *NodeDAO) FindAllNodeIdsMatch(tx *dbs.Tx, clusterId int64, includeSec
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// FindAllEnabledNodesWithClusterId 获取一个集群的所有节点
 | 
					// FindAllEnabledNodesWithClusterId 获取一个集群的所有节点
 | 
				
			||||||
func (this *NodeDAO) FindAllEnabledNodesWithClusterId(tx *dbs.Tx, clusterId int64) (result []*Node, err error) {
 | 
					func (this *NodeDAO) FindAllEnabledNodesWithClusterId(tx *dbs.Tx, clusterId int64, includeSecondary bool) (result []*Node, err error) {
 | 
				
			||||||
	_, err = this.Query(tx).
 | 
						var query = this.Query(tx)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if includeSecondary {
 | 
				
			||||||
 | 
							query.Where("(clusterId=:primaryClusterId OR JSON_CONTAINS(secondaryClusterIds, :primaryClusterIdString))").
 | 
				
			||||||
 | 
								Param("primaryClusterId", clusterId).
 | 
				
			||||||
 | 
								Param("primaryClusterIdString", types.String(clusterId))
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							query.Attr("clusterId", clusterId)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						_, err = query.
 | 
				
			||||||
		State(NodeStateEnabled).
 | 
							State(NodeStateEnabled).
 | 
				
			||||||
		Attr("clusterId", clusterId).
 | 
					 | 
				
			||||||
		DescPk().
 | 
							DescPk().
 | 
				
			||||||
		Slice(&result).
 | 
							Slice(&result).
 | 
				
			||||||
		FindAll()
 | 
							FindAll()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return
 | 
						return
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1650,6 +1650,7 @@ func (this *ServerDAO) CheckUserServer(tx *dbs.Tx, userId int64, serverId int64)
 | 
				
			|||||||
func (this *ServerDAO) UpdateUserServersClusterId(tx *dbs.Tx, userId int64, oldClusterId, newClusterId int64) error {
 | 
					func (this *ServerDAO) UpdateUserServersClusterId(tx *dbs.Tx, userId int64, oldClusterId, newClusterId int64) error {
 | 
				
			||||||
	_, err := this.Query(tx).
 | 
						_, err := this.Query(tx).
 | 
				
			||||||
		Attr("userId", userId).
 | 
							Attr("userId", userId).
 | 
				
			||||||
 | 
							Attr("userPlanId", 0).
 | 
				
			||||||
		Set("clusterId", newClusterId).
 | 
							Set("clusterId", newClusterId).
 | 
				
			||||||
		Update()
 | 
							Update()
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -169,7 +169,7 @@ func (this *UserDAO) UpdateUser(tx *dbs.Tx, userId int64, username string, passw
 | 
				
			|||||||
	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 {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -400,7 +400,7 @@ func (this *NodeService) FindAllEnabledNodesWithNodeClusterId(ctx context.Contex
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	tx := this.NullTx()
 | 
						tx := this.NullTx()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	nodes, err := models.SharedNodeDAO.FindAllEnabledNodesWithClusterId(tx, req.NodeClusterId)
 | 
						nodes, err := models.SharedNodeDAO.FindAllEnabledNodesWithClusterId(tx, req.NodeClusterId, req.IncludeSecondary)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -52,7 +52,7 @@ func (this *HealthCheckExecutor) Run() ([]*HealthCheckResult, error) {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var results = []*HealthCheckResult{}
 | 
						var results = []*HealthCheckResult{}
 | 
				
			||||||
	nodes, err := models.NewNodeDAO().FindAllEnabledNodesWithClusterId(nil, this.clusterId)
 | 
						nodes, err := models.NewNodeDAO().FindAllEnabledNodesWithClusterId(nil, this.clusterId, false)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user