|
@ -58,3 +58,56 @@ func DoTask(dbname, siteid, userId, task_type string, url ...string) (bool, erro |
|
|
|
|
|
|
|
|
return task_res, nil |
|
|
return task_res, nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 完成循环类任务
|
|
|
|
|
|
func DoCycleTask(dbname, siteid, userId, task_id string, url ...string) (bool, error) { |
|
|
|
|
|
|
|
|
|
|
|
if dbname == "" || userId == "" || task_id == ""{ |
|
|
|
|
|
return false, errors.New("参数错误") |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
conn, err := rpc_server_conn(url...) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return false, err |
|
|
|
|
|
} |
|
|
|
|
|
defer conn.Close() |
|
|
|
|
|
|
|
|
|
|
|
data := DoCycleTaskParam{} |
|
|
|
|
|
data.Dbname = dbname |
|
|
|
|
|
data.SiteId = siteid |
|
|
|
|
|
data.UserId = userId |
|
|
|
|
|
data.TaskId = task_id |
|
|
|
|
|
|
|
|
|
|
|
req, err := SetReqData(data) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
log.Println("DoCycleTask crypter error:", err) |
|
|
|
|
|
return false, err |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
res := &Response{} |
|
|
|
|
|
|
|
|
|
|
|
err = conn.DoCycleTask(req, res) |
|
|
|
|
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
log.Println("taskrpc DoCycleTask error:", err) |
|
|
|
|
|
return false, err |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
res_data_de, err := GetResData(res) |
|
|
|
|
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return false, err |
|
|
|
|
|
} |
|
|
|
|
|
if res_data_de == "" { |
|
|
|
|
|
return false, nil |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var task_res bool |
|
|
|
|
|
err = json.Unmarshal([]byte(res_data_de), &task_res) |
|
|
|
|
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return false, err |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return task_res, nil |
|
|
|
|
|
} |