mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-03 06:40:26 +08:00
增加清空节点同步任务、清空DNS同步任务API
This commit is contained in:
@@ -155,6 +155,12 @@ func (this *DNSTaskDAO) DeleteDNSTask(tx *dbs.Tx, taskId int64) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// DeleteAllDNSTasks 删除所有任务
|
||||
func (this *DNSTaskDAO) DeleteAllDNSTasks(tx *dbs.Tx) error {
|
||||
return this.Query(tx).
|
||||
DeleteQuickly()
|
||||
}
|
||||
|
||||
// UpdateDNSTaskError 设置任务错误
|
||||
func (this *DNSTaskDAO) UpdateDNSTaskError(tx *dbs.Tx, taskId int64, err string) error {
|
||||
if taskId <= 0 {
|
||||
|
||||
@@ -233,6 +233,12 @@ func (this *NodeTaskDAO) DeleteNodeTasks(tx *dbs.Tx, role string, nodeId int64)
|
||||
return err
|
||||
}
|
||||
|
||||
// DeleteAllNodeTasks 删除所有节点相关任务
|
||||
func (this *NodeTaskDAO)DeleteAllNodeTasks(tx *dbs.Tx) error {
|
||||
return this.Query(tx).
|
||||
DeleteQuickly()
|
||||
}
|
||||
|
||||
// FindDoingNodeTasks 查询一个节点的所有任务
|
||||
func (this *NodeTaskDAO) FindDoingNodeTasks(tx *dbs.Tx, role string, nodeId int64, version int64) (result []*NodeTask, err error) {
|
||||
if nodeId <= 0 {
|
||||
|
||||
@@ -117,3 +117,19 @@ func (this *DNSTaskService) DeleteDNSTask(ctx context.Context, req *pb.DeleteDNS
|
||||
}
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// DeleteAllDNSTasks 删除所有同步任务
|
||||
func (this *DNSTaskService) DeleteAllDNSTasks(ctx context.Context, req *pb.DeleteAllDNSTasksRequest) (*pb.RPCSuccess, error) {
|
||||
_, err := this.ValidateAdmin(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var tx = this.NullTx()
|
||||
err = dns.SharedDNSTaskDAO.DeleteAllDNSTasks(tx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return this.Success()
|
||||
}
|
||||
@@ -216,6 +216,22 @@ func (this *NodeTaskService) DeleteNodeTasks(ctx context.Context, req *pb.Delete
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// DeleteAllNodeTasks 删除所有任务
|
||||
func (this *NodeTaskService) DeleteAllNodeTasks(ctx context.Context, req *pb.DeleteAllNodeTasksRequest) (*pb.RPCSuccess, error) {
|
||||
_, err := this.ValidateAdmin(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var tx = this.NullTx()
|
||||
err = models.SharedNodeTaskDAO.DeleteAllNodeTasks(tx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return this.Success()
|
||||
}
|
||||
|
||||
// CountDoingNodeTasks 计算正在执行的任务数量
|
||||
func (this *NodeTaskService) CountDoingNodeTasks(ctx context.Context, req *pb.CountDoingNodeTasksRequest) (*pb.RPCCountResponse, error) {
|
||||
_, err := this.ValidateAdmin(ctx)
|
||||
|
||||
Reference in New Issue
Block a user