mirror of
				https://github.com/TeaOSLab/EdgeAPI.git
				synced 2025-11-04 16:00:24 +08:00 
			
		
		
		
	修复IP地址不能修改在线状态的Bug
This commit is contained in:
		@@ -103,7 +103,7 @@ func (this *NodeIPAddressDAO) FindAddressName(tx *dbs.Tx, id int64) (string, err
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// CreateAddress 创建IP地址
 | 
					// CreateAddress 创建IP地址
 | 
				
			||||||
func (this *NodeIPAddressDAO) CreateAddress(tx *dbs.Tx, adminId int64, nodeId int64, role nodeconfigs.NodeRole, name string, ip string, canAccess bool) (addressId int64, err error) {
 | 
					func (this *NodeIPAddressDAO) CreateAddress(tx *dbs.Tx, adminId int64, nodeId int64, role nodeconfigs.NodeRole, name string, ip string, canAccess bool, isUp bool) (addressId int64, err error) {
 | 
				
			||||||
	if len(role) == 0 {
 | 
						if len(role) == 0 {
 | 
				
			||||||
		role = nodeconfigs.NodeRoleNode
 | 
							role = nodeconfigs.NodeRoleNode
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -114,6 +114,7 @@ func (this *NodeIPAddressDAO) CreateAddress(tx *dbs.Tx, adminId int64, nodeId in
 | 
				
			|||||||
	op.Name = name
 | 
						op.Name = name
 | 
				
			||||||
	op.Ip = ip
 | 
						op.Ip = ip
 | 
				
			||||||
	op.CanAccess = canAccess
 | 
						op.CanAccess = canAccess
 | 
				
			||||||
 | 
						op.IsUp = isUp
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	op.State = NodeIPAddressStateEnabled
 | 
						op.State = NodeIPAddressStateEnabled
 | 
				
			||||||
	addressId, err = this.SaveInt64(tx, op)
 | 
						addressId, err = this.SaveInt64(tx, op)
 | 
				
			||||||
@@ -136,7 +137,7 @@ func (this *NodeIPAddressDAO) CreateAddress(tx *dbs.Tx, adminId int64, nodeId in
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// UpdateAddress 修改IP地址
 | 
					// UpdateAddress 修改IP地址
 | 
				
			||||||
func (this *NodeIPAddressDAO) UpdateAddress(tx *dbs.Tx, adminId int64, addressId int64, name string, ip string, canAccess bool, isOn bool) (err error) {
 | 
					func (this *NodeIPAddressDAO) UpdateAddress(tx *dbs.Tx, adminId int64, addressId int64, name string, ip string, canAccess bool, isOn bool, isUp bool) (err error) {
 | 
				
			||||||
	if addressId <= 0 {
 | 
						if addressId <= 0 {
 | 
				
			||||||
		return errors.New("invalid addressId")
 | 
							return errors.New("invalid addressId")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -147,6 +148,7 @@ func (this *NodeIPAddressDAO) UpdateAddress(tx *dbs.Tx, adminId int64, addressId
 | 
				
			|||||||
	op.Ip = ip
 | 
						op.Ip = ip
 | 
				
			||||||
	op.CanAccess = canAccess
 | 
						op.CanAccess = canAccess
 | 
				
			||||||
	op.IsOn = isOn
 | 
						op.IsOn = isOn
 | 
				
			||||||
 | 
						op.IsUp = isUp
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	op.State = NodeIPAddressStateEnabled // 恢复状态
 | 
						op.State = NodeIPAddressStateEnabled // 恢复状态
 | 
				
			||||||
	err = this.Save(tx, op)
 | 
						err = this.Save(tx, op)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1365,7 +1365,7 @@ func (this *NodeService) UpdateNodeDNS(ctx context.Context, req *pb.UpdateNodeDN
 | 
				
			|||||||
				return nil, err
 | 
									return nil, err
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			_, err = models.SharedNodeIPAddressDAO.CreateAddress(tx, adminId, req.NodeId, nodeconfigs.NodeRoleNode, "DNS IP", req.IpAddr, true)
 | 
								_, err = models.SharedNodeIPAddressDAO.CreateAddress(tx, adminId, req.NodeId, nodeconfigs.NodeRoleNode, "DNS IP", req.IpAddr, true, true)
 | 
				
			||||||
			if err != nil {
 | 
								if err != nil {
 | 
				
			||||||
				return nil, err
 | 
									return nil, err
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -21,7 +21,7 @@ func (this *NodeIPAddressService) CreateNodeIPAddress(ctx context.Context, req *
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	tx := this.NullTx()
 | 
						tx := this.NullTx()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	addressId, err := models.SharedNodeIPAddressDAO.CreateAddress(tx, adminId, req.NodeId, req.Role, req.Name, req.Ip, req.CanAccess)
 | 
						addressId, err := models.SharedNodeIPAddressDAO.CreateAddress(tx, adminId, req.NodeId, req.Role, req.Name, req.Ip, req.CanAccess, req.IsUp)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -39,7 +39,7 @@ func (this *NodeIPAddressService) UpdateNodeIPAddress(ctx context.Context, req *
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	tx := this.NullTx()
 | 
						tx := this.NullTx()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	err = models.SharedNodeIPAddressDAO.UpdateAddress(tx, adminId, req.NodeIPAddressId, req.Name, req.Ip, req.CanAccess, req.IsOn)
 | 
						err = models.SharedNodeIPAddressDAO.UpdateAddress(tx, adminId, req.NodeIPAddressId, req.Name, req.Ip, req.CanAccess, req.IsOn, req.IsUp)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user