fn
This commit is contained in:
@@ -77,7 +77,7 @@ func (a *API) signParam2(params map[string]interface{}) (sig string) {
|
|||||||
sb.WriteString("&access_token=")
|
sb.WriteString("&access_token=")
|
||||||
sb.WriteString(a.accessToken)
|
sb.WriteString(a.accessToken)
|
||||||
sb.WriteString("&data=")
|
sb.WriteString("&data=")
|
||||||
sb.WriteString(url.QueryEscape(params["data"].(string)))
|
sb.WriteString(params["data"].(string))
|
||||||
sb.WriteString("&salt=")
|
sb.WriteString("&salt=")
|
||||||
sb.WriteString(utils.Int64ToStr(utils.MustInterface2Int64(params["salt"])))
|
sb.WriteString(utils.Int64ToStr(utils.MustInterface2Int64(params["salt"])))
|
||||||
sig = sb.String()
|
sig = sb.String()
|
||||||
@@ -91,7 +91,6 @@ func (a *API) AccessAPI(action string, url string, bizParams map[string]interfac
|
|||||||
params["salt"] = GetSalt()
|
params["salt"] = GetSalt()
|
||||||
params["app_id"] = a.appID
|
params["app_id"] = a.appID
|
||||||
if action != tokenAction {
|
if action != tokenAction {
|
||||||
// params["access_token"] = a.accessToken
|
|
||||||
data, _ := json.Marshal(bizParams)
|
data, _ := json.Marshal(bizParams)
|
||||||
params["data"] = string(data)
|
params["data"] = string(data)
|
||||||
signStr := a.signParam2(params)
|
signStr := a.signParam2(params)
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ func init() {
|
|||||||
sugarLogger = logger.Sugar()
|
sugarLogger = logger.Sugar()
|
||||||
baseapi.Init(sugarLogger)
|
baseapi.Init(sugarLogger)
|
||||||
api = New("6a3e2073-1850-413b-9eb7-6c342ec36e1c", "a8248088-a742-4c33-a0db-03aeae00ca7d")
|
api = New("6a3e2073-1850-413b-9eb7-6c342ec36e1c", "a8248088-a742-4c33-a0db-03aeae00ca7d")
|
||||||
api.SetToken("n-3a7f291f-9614-407b-91c6-8534e8fd09c3-w")
|
api.SetToken("n-6446dfbe-322d-434c-a4eb-9dae44436c08-w")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetAccessToken(t *testing.T) {
|
func TestGetAccessToken(t *testing.T) {
|
||||||
|
|||||||
@@ -32,18 +32,16 @@ type GetStoreResult struct {
|
|||||||
PositionSource int `json:"position_source"`
|
PositionSource int `json:"position_source"`
|
||||||
City string `json:"city"`
|
City string `json:"city"`
|
||||||
ContactPhone string `json:"contact_phone"`
|
ContactPhone string `json:"contact_phone"`
|
||||||
ServiceCode int `json:"service_code"`
|
ServiceCode string `json:"service_code"`
|
||||||
Status int `json:"status"` //1关店,2开店
|
Status int `json:"status"` //1关店,2开店
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *API) GetStore(storeID int) (getStoreResult *GetStoreResult, err error) {
|
func (a *API) GetStore(storeID string) (getStoreResult *GetStoreResult, err error) {
|
||||||
result, err := a.AccessAPI("v2/chain_store/query", URL, map[string]interface{}{
|
result, err := a.AccessAPI("v2/chain_store/query", URL, map[string]interface{}{
|
||||||
"chain_store_code": []string{utils.Int2Str(storeID)},
|
"chain_store_code": []string{storeID},
|
||||||
}, true)
|
}, true)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
var results []*GetStoreResult
|
utils.Map2StructByJson(result["data"].([]interface{})[0], &getStoreResult, false)
|
||||||
utils.Map2StructByJson(result["data"], results, false)
|
|
||||||
getStoreResult = results[0]
|
|
||||||
}
|
}
|
||||||
return getStoreResult, err
|
return getStoreResult, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package fnpsapi
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCreateStore(t *testing.T) {
|
func TestCreateStore(t *testing.T) {
|
||||||
@@ -14,10 +16,18 @@ func TestCreateStore(t *testing.T) {
|
|||||||
PositionSource: 3,
|
PositionSource: 3,
|
||||||
Longitude: "104.045409",
|
Longitude: "104.045409",
|
||||||
Latitude: "30.693387",
|
Latitude: "30.693387",
|
||||||
// ServiceCode: "1",
|
ServiceCode: "1",
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
// t.Log(utils.Format4Output(result, false))
|
// t.Log(utils.Format4Output(result, false))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestGetStore(t *testing.T) {
|
||||||
|
result, err := api.GetStore("2")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
t.Log(utils.Format4Output(result, false))
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user