| | |
| | | "basic.com/pubsub/protomsg.git" |
| | | "encoding/json" |
| | | "errors" |
| | | "strconv" |
| | | ) |
| | | |
| | | type DbTableApi struct { |
| | | |
| | | Ip string |
| | | Port int |
| | | } |
| | | |
| | | func (dbt DbTableApi) AddDbTableInfo(paramBody map[string]interface{}) (bool,interface{}) { |
| | | url := BASIC_URL + DATA_URL_PREFIX + "/dbtable/addDbTableInfo" |
| | | func (api DbTableApi) 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 DbTableApi) AddDbTableInfo(paramBody map[string]interface{}) (bool,interface{}) { |
| | | url := api.getBasicUrl() + DATA_URL_PREFIX + "/dbtable/addDbTableInfo" |
| | | client := NewClient() |
| | | body,err := client.DoPutRequest(url,CONTENT_TYPE_JSON, paramBody,nil) |
| | | if err != nil { |
| | |
| | | return res.Success,res.Data |
| | | } |
| | | |
| | | func (dbt DbTableApi) QueryDbTables(isSync string) (bool,interface{}) { |
| | | url := BASIC_URL + DATA_URL_PREFIX + "/dbtable/queryDbTables/"+isSync |
| | | func (api DbTableApi) QueryDbTables(isSync string) (bool,interface{}) { |
| | | url := api.getBasicUrl() + DATA_URL_PREFIX + "/dbtable/queryDbTables/"+isSync |
| | | client := NewClient() |
| | | body,err := client.DoPostRequest(url,CONTENT_TYPE_JSON, nil,nil,nil) |
| | | if err != nil { |
| | |
| | | return res.Success,res.Data |
| | | } |
| | | |
| | | func (dbt DbTableApi) UpdateDbTables(paramBody map[string]interface{}) (bool,interface{}) { |
| | | url := BASIC_URL + DATA_URL_PREFIX + "/dbtable/updateDbTables" |
| | | func (api DbTableApi) UpdateDbTables(paramBody map[string]interface{}) (bool,interface{}) { |
| | | url := api.getBasicUrl() + DATA_URL_PREFIX + "/dbtable/updateDbTables" |
| | | client := NewClient() |
| | | body,err := client.DoPostRequest(url,CONTENT_TYPE_JSON, paramBody,nil,nil) |
| | | if err != nil { |
| | |
| | | return res.Success,res.Data |
| | | } |
| | | |
| | | func (dbt DbTableApi) UpdateDbTableStatus(id string,enable int) (bool,interface{}) { |
| | | url := BASIC_URL + DATA_URL_PREFIX + "/dbtable/updateDbTableStatus" |
| | | func (api DbTableApi) UpdateDbTableStatus(id string,enable int) (bool,interface{}) { |
| | | url := api.getBasicUrl() + DATA_URL_PREFIX + "/dbtable/updateDbTableStatus" |
| | | client := NewClient() |
| | | paramBody := map[string]interface{}{ |
| | | "id": id, |
| | |
| | | return res.Success,res.Data |
| | | } |
| | | |
| | | func (dbt DbTableApi) DeleteById(id string) (bool,interface{}) { |
| | | url := BASIC_URL + DATA_URL_PREFIX + "/dbtable/deleteDBtablesById/"+id |
| | | func (api DbTableApi) DeleteById(id string) (bool,interface{}) { |
| | | url := api.getBasicUrl() + DATA_URL_PREFIX + "/dbtable/deleteDBtablesById/"+id |
| | | client := NewClient() |
| | | body,err := client.DoPostRequest(url,CONTENT_TYPE_JSON, nil,nil,nil) |
| | | if err != nil { |
| | |
| | | } |
| | | |
| | | //根据多个底库id查询底库信息 |
| | | func (dbt DbTableApi) DbtablesById(ids []string) (dts []protomsg.Dbtable,err error) { |
| | | url := BASIC_URL + DATA_URL_PREFIX + "/dbtable/dbtablesByIds" |
| | | func (api DbTableApi) DbtablesById(ids []string) (dts []protomsg.Dbtable,err error) { |
| | | url := api.getBasicUrl() + DATA_URL_PREFIX + "/dbtable/dbtablesByIds" |
| | | client := NewClient() |
| | | paramBody := map[string]interface{}{ |
| | | "ids": ids, |
| | |
| | | } |
| | | |
| | | // 根据tableid 查询tablename |
| | | func (dbt DbTableApi) Dbtablename(tableId string) (tableName string,err error) { |
| | | dts, e := dbt.DbtablesById([]string{tableId}) |
| | | func (api DbTableApi) Dbtablename(tableId string) (tableName string,err error) { |
| | | dts, e := api.DbtablesById([]string{tableId}) |
| | | if e !=nil { |
| | | return "",e |
| | | } |
| | |
| | | return "",errors.New("table not found") |
| | | } |
| | | |
| | | func (dbt DbTableApi) FindAllDbTables() (dts []protomsg.Dbtable,err error) { |
| | | url := BASIC_URL + DATA_URL_PREFIX + "/dbtable/findAllDbTables" |
| | | func (api DbTableApi) FindAllDbTables() (dts []protomsg.Dbtable,err error) { |
| | | url := api.getBasicUrl() + DATA_URL_PREFIX + "/dbtable/findAllDbTables" |
| | | client := NewClient() |
| | | body,err := client.DoGetRequest(url, nil,nil) |
| | | if err != nil { |
| | |
| | | return dts,nil |
| | | } |
| | | |
| | | func (dbt DbTableApi) FindAllDbTablesByCurServer(isDelete string) (dts []protomsg.Dbtable,err error){ |
| | | url := BASIC_URL + DATA_URL_PREFIX + "/dbtable/findAllDbTablesByCurServer" |
| | | func (api DbTableApi) FindAllDbTablesByCurServer(isDelete string) (dts []protomsg.Dbtable,err error){ |
| | | url := api.getBasicUrl() + DATA_URL_PREFIX + "/dbtable/findAllDbTablesByCurServer" |
| | | client := NewClient() |
| | | paramQuery := map[string]string{ |
| | | "isDelete":isDelete, |
| | | } |
| | | body,err := client.DoGetRequest(url, paramQuery,nil) |
| | | if err != nil { |
| | | return nil,err |
| | | } |
| | | |
| | | var res Result |
| | | if err = json.Unmarshal(body, &res); err != nil { |
| | | return nil,err |
| | | } |
| | | dataBytes, _ := json.Marshal(res.Data) |
| | | if err = json.Unmarshal(dataBytes, &dts);err !=nil { |
| | | return nil,err |
| | | } |
| | | return dts,nil |
| | | } |
| | | |
| | | func (api DbTableApi) FindAllLocalDbTables(isDelete string) (dts []protomsg.Dbtable,err error){ |
| | | url := api.getBasicUrl() + DATA_URL_PREFIX + "/dbtable/findAllLocalDbTables" |
| | | client := NewClient() |
| | | paramQuery := map[string]string{ |
| | | "isDelete":isDelete, |