mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-03 23:20:26 +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
|
||||
}
|
||||
|
||||
// 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 更改节点在线状态
|
||||
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 {
|
||||
b = "false"
|
||||
}
|
||||
@@ -898,6 +917,9 @@ func (this *NodeDAO) UpdateNodeIsActive(tx *dbs.Tx, nodeId int64, isActive bool)
|
||||
|
||||
// UpdateNodeIsInstalled 设置节点安装状态
|
||||
func (this *NodeDAO) UpdateNodeIsInstalled(tx *dbs.Tx, nodeId int64, isInstalled bool) error {
|
||||
if nodeId <= 0 {
|
||||
return errors.New("invalid nodeId")
|
||||
}
|
||||
_, err := this.Query(tx).
|
||||
Pk(nodeId).
|
||||
Set("isInstalled", isInstalled).
|
||||
|
||||
@@ -2293,3 +2293,19 @@ func (this *NodeService) FindNodeWebPPolicies(ctx context.Context, req *pb.FindN
|
||||
WebPPolicies: pbPolicies,
|
||||
}, 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