- mtwm PoiInfo
This commit is contained in:
@@ -15,6 +15,38 @@ type PoiCategoryInfo struct {
|
|||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type PoiInfo struct {
|
||||||
|
Address string `json:"address,omitempty"`
|
||||||
|
AppID int `json:"app_id,omitempt"`
|
||||||
|
AppPoiCode string `json:"app_poi_code,omitempt"`
|
||||||
|
CityID int `json:"city_id,omitempt"`
|
||||||
|
Ctime int64 `json:"ctime,omitempt"`
|
||||||
|
InvoiceDescription string `json:"invoice_description,omitempt"`
|
||||||
|
InvoiceMinPrice int `json:"invoice_min_price,omitempt"`
|
||||||
|
InvoiceSupport int `json:"invoice_support,omitempt"`
|
||||||
|
IsOnline int `json:"is_online,omitempt"`
|
||||||
|
Latitude float64 `json:"latitude,omitempt"`
|
||||||
|
LocationID int `json:"location_id,omitempt"`
|
||||||
|
Longitude float64 `json:"longitude,omitempt"`
|
||||||
|
Name string `json:"name,omitempt"`
|
||||||
|
OpenLevel int `json:"open_level,omitempt"`
|
||||||
|
Phone string `json:"phone,omitempt"`
|
||||||
|
PicURL string `json:"pic_url,omitempt"`
|
||||||
|
PicURLLarge string `json:"pic_url_large,omitempt"`
|
||||||
|
PreBook int `json:"pre_book,omitempt"`
|
||||||
|
PreBookMaxDays int `json:"pre_book_max_days,omitempt"`
|
||||||
|
PreBookMinDays int `json:"pre_book_min_days,omitempt"`
|
||||||
|
PromotionInfo string `json:"promotion_info,omitempt"`
|
||||||
|
Remark string `json:"remark,omitempt"`
|
||||||
|
ShippingFee float64 `json:"shipping_fee,omitempt"`
|
||||||
|
ShippingTime string `json:"shipping_time,omitempt"`
|
||||||
|
StandbyTel string `json:"standby_tel,omitempt"`
|
||||||
|
TagName string `json:"tag_name,omitempt"`
|
||||||
|
ThirdTagName string `json:"third_tag_name,omitempt"`
|
||||||
|
TimeSelect int `json:"time_select,omitempt"`
|
||||||
|
Utime int64 `json:"utime,omitempt"`
|
||||||
|
}
|
||||||
|
|
||||||
func (a *API) PoiSave(poiCode string, poiParams map[string]interface{}) (err error) {
|
func (a *API) PoiSave(poiCode string, poiParams map[string]interface{}) (err error) {
|
||||||
_, err = a.AccessAPI("poi/save", false, utils.MergeMaps(utils.Params2Map(KeyAppPoiCode, poiCode), poiParams))
|
_, err = a.AccessAPI("poi/save", false, utils.MergeMaps(utils.Params2Map(KeyAppPoiCode, poiCode), poiParams))
|
||||||
return err
|
return err
|
||||||
@@ -33,17 +65,17 @@ func (a *API) PoiGetIDs() (ids []string, err error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *API) PoiMGet(poiCodes []string) (pois []map[string]interface{}, err error) {
|
func (a *API) PoiMGet(poiCodes []string) (pois []*PoiInfo, err error) {
|
||||||
result, err := a.AccessAPI("poi/mget", true, map[string]interface{}{
|
result, err := a.AccessAPI("poi/mget", true, map[string]interface{}{
|
||||||
KeyAppPoiCodes: strings.Join(poiCodes, ","),
|
KeyAppPoiCodes: strings.Join(poiCodes, ","),
|
||||||
})
|
})
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return utils.Slice2MapSlice(result.([]interface{})), nil
|
err = utils.Map2StructByJson(result, &pois, false)
|
||||||
}
|
}
|
||||||
return nil, err
|
return pois, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *API) PoiGet(poiCode string) (poi map[string]interface{}, err error) {
|
func (a *API) PoiGet(poiCode string) (poi *PoiInfo, err error) {
|
||||||
result, err := a.PoiMGet([]string{poiCode})
|
result, err := a.PoiMGet([]string{poiCode})
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if len(result) == 0 {
|
if len(result) == 0 {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
testPoiCode = "100077"
|
testPoiCode = "2523687"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestPoiGetIDs(t *testing.T) {
|
func TestPoiGetIDs(t *testing.T) {
|
||||||
@@ -29,7 +29,7 @@ func TestPoiMGet(t *testing.T) {
|
|||||||
if len(result) != 1 {
|
if len(result) != 1 {
|
||||||
t.Fatal("result len is not ok")
|
t.Fatal("result len is not ok")
|
||||||
}
|
}
|
||||||
if result[0][KeyAppPoiCode] != testPoiCode {
|
if result[0].AppPoiCode != testPoiCode {
|
||||||
t.Fatal("test_poi_01 is not equal")
|
t.Fatal("test_poi_01 is not equal")
|
||||||
}
|
}
|
||||||
t.Log(utils.Format4Output(result, false))
|
t.Log(utils.Format4Output(result, false))
|
||||||
@@ -40,7 +40,7 @@ func TestPoiSave(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
poiParams := utils.FilterMapNilMembers(result[0])
|
poiParams := utils.FilterMapNilMembers(utils.Struct2FlatMap(result[0]))
|
||||||
poiParams["name"] = "中国"
|
poiParams["name"] = "中国"
|
||||||
err = api.PoiSave(testPoiCode, poiParams)
|
err = api.PoiSave(testPoiCode, poiParams)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user