This commit is contained in:
jyuesong
2022-01-13 16:45:44 +08:00
parent d29c9e73f7
commit e8956e5ff1
11 changed files with 156 additions and 33 deletions

View File

@@ -39,6 +39,16 @@ class Api {
}
static Future<HttpResponse<TaskDetailBean>> addTask(String name, String command, String cron, {String? id}) async {
return await Http.put<TaskDetailBean>(Url.ADD_TASK, {"name": name, "command": command, "schedule": cron, "_id": id});
var data = {"name": name, "command": command, "schedule": cron};
if (id != null) {
data["_id"] = id;
return await Http.put<TaskDetailBean>(Url.ADD_TASK, data);
}
return await Http.post<TaskDetailBean>(Url.ADD_TASK, data);
}
static Future<HttpResponse<NullResponse>> delTask(String cron) async {
return await Http.delete<NullResponse>(Url.ADD_TASK, [cron]);
}
}