sqlite的api,便于内部使用
liuxiaolong
2020-06-11 8b9f4b0a54ccd281b38c41ec928e35d810a74202
taskApi.go
@@ -3,7 +3,6 @@
import (
   "basic.com/pubsub/protomsg.git"
   "encoding/json"
   "fmt"
   "strconv"
)
@@ -36,7 +35,27 @@
   }
   var res Result
   if err = json.Unmarshal(respBody, &res); err != nil {
      fmt.Println(err)
      logPrint(err)
      return taskInfos
   }
   bytes, _ := json.Marshal(res.Data)
   err = json.Unmarshal(bytes, &taskInfos)
   return taskInfos
}
func (api TaskApi) FindAllTaskDefaultArgs(scope string)(taskInfos []protomsg.TaskSdkInfo) {
   url := api.getBasicUrl() + DATA_URL_PREFIX + "/task/findAll"
   client := NewClient()
   queryParam := map[string]string {
      "scope": scope,
   }
   respBody, err := client.DoGetRequest(url, queryParam, nil)
   if err !=nil {
      return taskInfos
   }
   var res Result
   if err = json.Unmarshal(respBody, &res); err != nil {
      logPrint(err)
      return taskInfos
   }
   bytes, _ := json.Marshal(res.Data)
@@ -56,8 +75,8 @@
         }
         m := make(map[string]string,0)
         for _,s := range ti.Sdks{
            if _,ok :=m[s.IpcId];!ok{
               m[s.IpcId] = s.IpcId
            if _,ok :=m[s.SdkType];!ok{
               m[s.SdkType] = s.SdkType
               tsr.Sdks = append(tsr.Sdks,&protomsg.SdkRun{
                  IpcId:s.IpcId,
                  SdkType:s.SdkType,
@@ -80,7 +99,7 @@
   }
   var res Result
   if err = json.Unmarshal(respBody, &res); err != nil {
      fmt.Println(err)
      logPrint(err)
      return false,nil
   }
   return res.Success,res.Data
@@ -162,4 +181,18 @@
      return false,nil
   }
   return res.Success,res.Data
}
func (api TaskApi) StatisticTaskCamera() (bool,interface{}) {
   url := api.getBasicUrl() + DATA_URL_PREFIX + "/task/statisticTaskCamera"
   client := NewClient()
   respBody, err := client.DoGetRequest(url, nil, nil)
   if err != nil {
      return false,nil
   }
   var res Result
   if err = json.Unmarshal(respBody, &res); err != nil {
      return false,nil
   }
   return res.Success,res.Data
}