mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-05 01:20:25 +08:00
增加修改节点停用/启用状态API
This commit is contained in:
@@ -882,9 +882,28 @@ func (this *NodeDAO) FindNodeStatus(tx *dbs.Tx, nodeId int64) (*nodeconfigs.Node
|
|||||||
return status, nil
|
return status, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UpdateNodeIsOn 修改节点启用状态
|
||||||
|
func (this *NodeDAO) UpdateNodeIsOn(tx *dbs.Tx, nodeId int64, isOn bool) error {
|
||||||
|
if nodeId <= 0 {
|
||||||
|
return errors.New("invalid nodeId")
|
||||||
|
}
|
||||||
|
err := this.Query(tx).
|
||||||
|
Pk(nodeId).
|
||||||
|
Set("isOn", isOn).
|
||||||
|
UpdateQuickly()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.NotifyDNSUpdate(tx, nodeId)
|
||||||
|
}
|
||||||
|
|
||||||
// UpdateNodeIsActive 更改节点在线状态
|
// UpdateNodeIsActive 更改节点在线状态
|
||||||
func (this *NodeDAO) UpdateNodeIsActive(tx *dbs.Tx, nodeId int64, isActive bool) error {
|
func (this *NodeDAO) UpdateNodeIsActive(tx *dbs.Tx, nodeId int64, isActive bool) error {
|
||||||
b := "true"
|
if nodeId <= 0 {
|
||||||
|
return errors.New("invalid nodeId")
|
||||||
|
}
|
||||||
|
var b = "true"
|
||||||
if !isActive {
|
if !isActive {
|
||||||
b = "false"
|
b = "false"
|
||||||
}
|
}
|
||||||
@@ -898,6 +917,9 @@ func (this *NodeDAO) UpdateNodeIsActive(tx *dbs.Tx, nodeId int64, isActive bool)
|
|||||||
|
|
||||||
// UpdateNodeIsInstalled 设置节点安装状态
|
// UpdateNodeIsInstalled 设置节点安装状态
|
||||||
func (this *NodeDAO) UpdateNodeIsInstalled(tx *dbs.Tx, nodeId int64, isInstalled bool) error {
|
func (this *NodeDAO) UpdateNodeIsInstalled(tx *dbs.Tx, nodeId int64, isInstalled bool) error {
|
||||||
|
if nodeId <= 0 {
|
||||||
|
return errors.New("invalid nodeId")
|
||||||
|
}
|
||||||
_, err := this.Query(tx).
|
_, err := this.Query(tx).
|
||||||
Pk(nodeId).
|
Pk(nodeId).
|
||||||
Set("isInstalled", isInstalled).
|
Set("isInstalled", isInstalled).
|
||||||
|
|||||||
@@ -2293,3 +2293,19 @@ func (this *NodeService) FindNodeWebPPolicies(ctx context.Context, req *pb.FindN
|
|||||||
WebPPolicies: pbPolicies,
|
WebPPolicies: pbPolicies,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UpdateNodeIsOn 修改节点的启用状态
|
||||||
|
func (this *NodeService) UpdateNodeIsOn(ctx context.Context, req *pb.UpdateNodeIsOnRequest) (*pb.RPCSuccess, error) {
|
||||||
|
_, err := this.ValidateAdmin(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var tx = this.NullTx()
|
||||||
|
err = models.SharedNodeDAO.UpdateNodeIsOn(tx, req.NodeId, req.IsOn)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.Success()
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user