37 Star 207 Fork 104

狂奔的蜗牛. / anytunnel

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
Clone or Download
base.go 1.50 KB
Copy Edit Raw Blame History
arraykeys authored 2019-08-08 17:13 . init
package business
import (
"github.com/astaxie/beego"
"anytunnel/at-common"
"encoding/json"
"fmt"
"anytunnel/at-web/app/utils"
)
type BusinessBase struct {
}
func NewBase() *BusinessBase {
return &BusinessBase{}
}
//Get Request Api
func (this *BusinessBase) GetRequest(confKey string, urlQuerys map[string]string) (data interface{}, err error) {
uri := beego.AppConfig.String(confKey)
if(uri == "") {
return data, fmt.Errorf("%s", "uri conf error")
}
query := utils.NewUrls().HttpQueryBuild(urlQuerys)
body, code, err := at_common.HttpGet(uri + "?" + query)
if(code != 200) {
return data, fmt.Errorf("%s", "get httpcode error")
}
if(err != nil) {
return data, err
}
var results map[string]interface{}
json.Unmarshal(body, &results)
if(results["code"].(float64) != 1) {
return data, fmt.Errorf("%s", results["message"].(string))
}
return results["data"], nil
}
//Post Request Api
func (this *BusinessBase) PostRequest(confKey string, urlQuerys map[string]string, header map[string]string) (data interface{}, err error) {
uri := beego.AppConfig.String(confKey)
if(uri == "") {
return data, fmt.Errorf("%s", "uri conf error")
}
body, code, err := at_common.HttpPost(uri, urlQuerys, header)
if(code != 200) {
return data, fmt.Errorf("%s", "httpcode error")
}
if(err != nil) {
return data, err
}
var results map[string]interface{}
json.Unmarshal(body, &results)
if(results["code"].(float64) != 1) {
return data, fmt.Errorf("%s", results["message"].(string))
}
return results["data"], nil
}
JavaScript
1
https://gitee.com/snail/anytunnel.git
git@gitee.com:snail/anytunnel.git
snail
anytunnel
anytunnel
8296c84158a6

Search