Browse Source

完成任务逻辑

master v0.1.0
lijianbin 3 years ago
parent
commit
8c44f6b907
1 changed files with 58 additions and 0 deletions
  1. +58
    -0
      client.dotask.go

+ 58
- 0
client.dotask.go View File

@ -1 +1,59 @@
package taskrpc package taskrpc
import (
"encoding/json"
"errors"
"log"
)
func DoTask(dbname, siteid, userId, task_type string, url ...string) (bool, error) {
if dbname == "" || userId == "" || task_type == ""{
return false, errors.New("参数错误")
}
conn, err := rpc_server_conn(url...)
if err != nil {
return false, err
}
defer conn.Close()
data := DoTaskParam{}
data.Dbname = dbname
data.SiteId = siteid
data.UserId = userId
data.Type = task_type
req, err := SetReqData(data)
if err != nil {
log.Println("DoTask crypter error:", err)
return false, err
}
res := &Response{}
err = conn.DoTask(req, res)
if err != nil {
log.Println("taskrpc DoTask 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
}

Loading…
Cancel
Save