sqlite的api,便于内部使用
liuxiaolong
2020-03-12 4b84d53ed3bf3c23e1841fc5e51835818a463b00
eventPush.go
@@ -3,15 +3,29 @@
import (
   "basic.com/pubsub/protomsg.git"
   "encoding/json"
   "fmt"
   "strconv"
)
type EventPushApi struct {
   Ip string
   Port int
}
func (api EventPushApi) getBasicUrl() string {
   if api.Ip == "" {
      return BASIC_URL
   }
   if api.Ip == "" {
      api.Ip = DEFAULT_IP
   }
   if api.Port == 0 {
      api.Port = DEFAULT_PORT
   }
   return "http://"+api.Ip+":"+strconv.Itoa(api.Port)
}
func (api EventPushApi) Save(paramBody map[string]interface{}) (bool,interface{}){
   url := BASIC_URL + DATA_URL_PREFIX + "/eventPush/save"
   url := api.getBasicUrl() + DATA_URL_PREFIX + "/eventPush/save"
   client := NewClient()
   body,err := client.DoPostRequest(url,CONTENT_TYPE_JSON, paramBody,nil,nil)
   if err != nil {
@@ -20,7 +34,7 @@
   var res Result
   if err = json.Unmarshal(body, &res); err != nil {
      fmt.Println(err)
      logPrint(err)
      return false,nil
   }
@@ -28,7 +42,7 @@
}
func (api EventPushApi) FindByEventTopic(topic string,childType string) (bool,interface{}){
   url := BASIC_URL + DATA_URL_PREFIX + "/eventPush/findByEventTopic"
   url := api.getBasicUrl() + DATA_URL_PREFIX + "/eventPush/findByEventTopic"
   client := NewClient()
   paramQuery :=make(map[string]string,0)
   paramQuery["topic"] = topic
@@ -46,7 +60,7 @@
}
func (api EventPushApi) FindAll(name string) (bool,interface{}){
   url := BASIC_URL + DATA_URL_PREFIX + "/eventPush/findAll"
   url := api.getBasicUrl() + DATA_URL_PREFIX + "/eventPush/findAll"
   client := NewClient()
   paramQuery :=make(map[string]string,0)
   paramQuery["name"] = name
@@ -63,7 +77,7 @@
}
func (api EventPushApi) FindAllDetails() (b bool,allRules []protomsg.EventPush){
   url := BASIC_URL + DATA_URL_PREFIX + "/eventPush/findAllDetails"
   url := api.getBasicUrl() + DATA_URL_PREFIX + "/eventPush/findAllDetails"
   client := NewClient()
   body, err := client.DoGetRequest(url, nil, nil)
   if err != nil {
@@ -77,14 +91,14 @@
   bytes, _ := json.Marshal(res.Data)
   err = json.Unmarshal(bytes, &allRules)
   if err !=nil{
      fmt.Println("all eventPushRules unmarshal err:",err)
      logPrint("all eventPushRules unmarshal err:",err)
      return false,nil
   }
   return true,allRules
}
func (api EventPushApi) GetById(id string) (bool,interface{}){
   url := BASIC_URL + DATA_URL_PREFIX + "/eventPush/getById"
   url := api.getBasicUrl() + DATA_URL_PREFIX + "/eventPush/getById"
   client := NewClient()
   paramQuery :=make(map[string]string,0)
   paramQuery["id"] = id
@@ -101,7 +115,7 @@
}
func (api EventPushApi) ChangeStatus(id string,enable bool) (bool,interface{}){
   url := BASIC_URL + DATA_URL_PREFIX + "/eventPush/changeStatus"
   url := api.getBasicUrl() + DATA_URL_PREFIX + "/eventPush/changeStatus"
   client := NewClient()
   paramBody :=make(map[string]interface{},0)
   paramBody["id"] = id
@@ -119,7 +133,7 @@
}
func (api EventPushApi) Delete(id string) (bool,interface{}){
   url := BASIC_URL + DATA_URL_PREFIX + "/eventPush/delete"
   url := api.getBasicUrl() + DATA_URL_PREFIX + "/eventPush/delete"
   client := NewClient()
   paramForm :=make(map[string]interface{},0)
   paramForm["id"] = id