更新研发

This commit is contained in:
hoteas
2022-01-17 04:47:39 +08:00
parent a8d7b934f3
commit f31262559d
7 changed files with 605 additions and 18 deletions
+58
View File
@@ -0,0 +1,58 @@
package aliyun
import (
"fmt"
"io/ioutil"
"net/http"
//"fmt"
)
type Company struct {
ApiCode string
Url string
}
func (this *Company) Init(apiCode string) {
//"06c6a07e89dd45c88de040ee1489eef7"
this.ApiCode = apiCode
this.Url = "https://api.81api.com"
}
// GetCompanyBaseInfo 获取企业基础信息
func (this *Company) GetCompanyBaseInfo(name string) (string, error) {
url := "/getCompanyBaseInfo/"
client := &http.Client{}
reqest, err := http.NewRequest("GET", this.Url+url+name+"/?isRaiseErrorCode=1", nil)
if err != nil {
fmt.Println("Fatal error ", err.Error())
return "", err
}
reqest.Header.Add("Authorization", "APPCODE "+this.ApiCode)
response, err := client.Do(reqest)
defer response.Body.Close()
if err != nil {
fmt.Println("Fatal error ", err.Error())
return "", err
}
body, err := ioutil.ReadAll(response.Body)
if err != nil {
return "", err
}
fmt.Println(string(body))
return string(body), err
}
var DefaultCompany Company
func init() {
DefaultCompany = Company{}
}
+56
View File
@@ -0,0 +1,56 @@
package baidu
import (
"fmt"
"io/ioutil"
"net/http"
"net/url"
)
type BaiduMap struct {
Ak string
Url string
}
func (this *BaiduMap) Init(Ak string) {
//"ak=ZeT902EZvVgIoGVWEFK3osUm"
this.Ak = Ak
this.Url = "https://api.map.baidu.com/place/v2/suggestion?output=json&region=" + url.PathEscape("全国") + "&ak=" + Ak
//query
}
// GetPosition 获取定位列表
func (this *BaiduMap) GetPosition(name string) (string, error) {
client := &http.Client{}
reqest, err := http.NewRequest("GET", this.Url+"&query="+url.PathEscape(name), nil)
if err != nil {
fmt.Println("Fatal error ", err.Error())
return "", err
}
response, err := client.Do(reqest)
defer response.Body.Close()
if err != nil {
fmt.Println("Fatal error ", err.Error())
return "", err
}
body, err := ioutil.ReadAll(response.Body)
if err != nil {
return "", err
}
//fmt.Println(string(body))
return string(body), err
}
var DefaultBaiDuMap BaiduMap
func init() {
DefaultBaiDuMap = BaiduMap{}
}