美团分类操作添加对于code的支持api
This commit is contained in:
@@ -142,6 +142,39 @@ func (a *API) RetailCatUpdate(poiCode, originName, name, secondaryName string, s
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *API) RetailCatUpdate2(poiCode, originCode, originName, code, name, secondCode, secondaryName string, sequence int) (err error) {
|
||||||
|
params := map[string]interface{}{
|
||||||
|
KeyAppPoiCode: poiCode,
|
||||||
|
"category_name": name,
|
||||||
|
"sequence": sequence,
|
||||||
|
}
|
||||||
|
if code != "" {
|
||||||
|
params["category_code"] = code
|
||||||
|
}
|
||||||
|
if secondCode != "" {
|
||||||
|
params["secondary_category_code"] = secondCode
|
||||||
|
}
|
||||||
|
if secondaryName != "" {
|
||||||
|
params["secondary_category_name"] = secondaryName
|
||||||
|
}
|
||||||
|
|
||||||
|
if originCode != "" {
|
||||||
|
params["category_code_origin"] = originCode
|
||||||
|
} else {
|
||||||
|
params["category_name_origin"] = originName
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = a.AccessAPI("retailCat/update", false, params)
|
||||||
|
if err != nil {
|
||||||
|
if err2, ok := err.(*utils.ErrorWithCode); ok {
|
||||||
|
if err2.IntCode() == 833 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
func (a *API) RetailCatDelete(poiCode, name string) (err error) {
|
func (a *API) RetailCatDelete(poiCode, name string) (err error) {
|
||||||
_, err = a.AccessAPI("retailCat/delete", false, map[string]interface{}{
|
_, err = a.AccessAPI("retailCat/delete", false, map[string]interface{}{
|
||||||
KeyAppPoiCode: poiCode,
|
KeyAppPoiCode: poiCode,
|
||||||
@@ -150,6 +183,19 @@ func (a *API) RetailCatDelete(poiCode, name string) (err error) {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *API) RetailCatDelete2(poiCode, code, name string) (err error) {
|
||||||
|
params := map[string]interface{}{
|
||||||
|
KeyAppPoiCode: poiCode,
|
||||||
|
}
|
||||||
|
if code != "" {
|
||||||
|
params["category_code"] = code
|
||||||
|
} else {
|
||||||
|
params["category_name"] = name
|
||||||
|
}
|
||||||
|
_, err = a.AccessAPI("retailCat/delete", false, params)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
func (a *API) RetailCatList(poiCode string) (retailCatList []*RetailCategoryInfo, err error) {
|
func (a *API) RetailCatList(poiCode string) (retailCatList []*RetailCategoryInfo, err error) {
|
||||||
result, err := a.AccessAPI("retailCat/list", true, map[string]interface{}{
|
result, err := a.AccessAPI("retailCat/list", true, map[string]interface{}{
|
||||||
KeyAppPoiCode: poiCode,
|
KeyAppPoiCode: poiCode,
|
||||||
|
|||||||
@@ -129,17 +129,28 @@ func BenchmarkFilterMb4(b *testing.B) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestFilterMb4(t *testing.T) {
|
func TestFilterMb4(t *testing.T) {
|
||||||
str := `
|
for _, v := range [][]string{
|
||||||
{"realip":"120.52.149.107","@timestamp":"2018-07-17T21:30:19+08:00","host":"callback.jingxicaishi.com","request":"POST /djsw/pushDeliveryStatus HTTP/1.1","req_body":"timestamp=2018-07-17%2B21%253A30%253A19&sign=0027B8694AF7FF818A7E4FCFF13A8A5C&v=1.0&jd_param_json=%257B%2522createPin%2522%253A%2522JD_21028ea53427da6%2522%252C%2522deliveryCarrierName%2522%253A%2522%25E8%25BE%25BE%25E8%25BE%25BE%25E5%25B9%25B3%25E5%258F%25B0%2522%252C%2522deliveryCarrierNo%2522%253A%25229966%2522%252C%2522deliveryManName%2522%253A%2522%25E8%25AE%25B8%25E8%25BF%259E%25E8%25BE%2589%2522%252C%2522deliveryManNo%2522%253A%252213731713474%2522%252C%2522deliveryManPhone%2522%253A%252213731713474%2522%252C%2522deliveryStatus%2522%253A%252240%2522%252C%2522deliveryStatusTime%2522%253A%25222018-07-17%2B21%253A30%253A19%2522%252C%2522failType%2522%253A%2522%2522%252C%2522opTime%2522%253A%25221531834219636%2522%252C%2522orderId%2522%253A%2522817091517000222%2522%252C%2522remark%2522%253A%2522%25E5%25B7%25B2%25E5%25AE%258C%25E6%2588%2590%2522%257D&token=91633f2a-c5f5-4982-a925-a220d19095c3&app_key=1dba76d40cac446ca500c0391a0b6c9d&format=json","status":"200","size":38,"ua":"Jakarta Commons-HttpClient/3.1","cookie":"","req_time":"0.063","uri":"/djsw/pushDeliveryStatus","referer":"","xff":"","ups_status":"200","ups_addr":"172.27.0.10:8080","ups_time":"0.008"}
|
[]string{
|
||||||
`
|
`
|
||||||
if FilterMb4(str) != str {
|
{"realip":"120.52.149.107","@timestamp":"2018-07-17T21:30:19+08:00","host":"callback.jingxicaishi.com","request":"POST /djsw/pushDeliveryStatus HTTP/1.1","req_body":"timestamp=2018-07-17%2B21%253A30%253A19&sign=0027B8694AF7FF818A7E4FCFF13A8A5C&v=1.0&jd_param_json=%257B%2522createPin%2522%253A%2522JD_21028ea53427da6%2522%252C%2522deliveryCarrierName%2522%253A%2522%25E8%25BE%25BE%25E8%25BE%25BE%25E5%25B9%25B3%25E5%258F%25B0%2522%252C%2522deliveryCarrierNo%2522%253A%25229966%2522%252C%2522deliveryManName%2522%253A%2522%25E8%25AE%25B8%25E8%25BF%259E%25E8%25BE%2589%2522%252C%2522deliveryManNo%2522%253A%252213731713474%2522%252C%2522deliveryManPhone%2522%253A%252213731713474%2522%252C%2522deliveryStatus%2522%253A%252240%2522%252C%2522deliveryStatusTime%2522%253A%25222018-07-17%2B21%253A30%253A19%2522%252C%2522failType%2522%253A%2522%2522%252C%2522opTime%2522%253A%25221531834219636%2522%252C%2522orderId%2522%253A%2522817091517000222%2522%252C%2522remark%2522%253A%2522%25E5%25B7%25B2%25E5%25AE%258C%25E6%2588%2590%2522%257D&token=91633f2a-c5f5-4982-a925-a220d19095c3&app_key=1dba76d40cac446ca500c0391a0b6c9d&format=json","status":"200","size":38,"ua":"Jakarta Commons-HttpClient/3.1","cookie":"","req_time":"0.063","uri":"/djsw/pushDeliveryStatus","referer":"","xff":"","ups_status":"200","ups_addr":"172.27.0.10:8080","ups_time":"0.008"}
|
||||||
t.Fatal("FilterMb4 filtered normal characters")
|
`,
|
||||||
}
|
`
|
||||||
|
{"realip":"120.52.149.107","@timestamp":"2018-07-17T21:30:19+08:00","host":"callback.jingxicaishi.com","request":"POST /djsw/pushDeliveryStatus HTTP/1.1","req_body":"timestamp=2018-07-17%2B21%253A30%253A19&sign=0027B8694AF7FF818A7E4FCFF13A8A5C&v=1.0&jd_param_json=%257B%2522createPin%2522%253A%2522JD_21028ea53427da6%2522%252C%2522deliveryCarrierName%2522%253A%2522%25E8%25BE%25BE%25E8%25BE%25BE%25E5%25B9%25B3%25E5%258F%25B0%2522%252C%2522deliveryCarrierNo%2522%253A%25229966%2522%252C%2522deliveryManName%2522%253A%2522%25E8%25AE%25B8%25E8%25BF%259E%25E8%25BE%2589%2522%252C%2522deliveryManNo%2522%253A%252213731713474%2522%252C%2522deliveryManPhone%2522%253A%252213731713474%2522%252C%2522deliveryStatus%2522%253A%252240%2522%252C%2522deliveryStatusTime%2522%253A%25222018-07-17%2B21%253A30%253A19%2522%252C%2522failType%2522%253A%2522%2522%252C%2522opTime%2522%253A%25221531834219636%2522%252C%2522orderId%2522%253A%2522817091517000222%2522%252C%2522remark%2522%253A%2522%25E5%25B7%25B2%25E5%25AE%258C%25E6%2588%2590%2522%257D&token=91633f2a-c5f5-4982-a925-a220d19095c3&app_key=1dba76d40cac446ca500c0391a0b6c9d&format=json","status":"200","size":38,"ua":"Jakarta Commons-HttpClient/3.1","cookie":"","req_time":"0.063","uri":"/djsw/pushDeliveryStatus","referer":"","xff":"","ups_status":"200","ups_addr":"172.27.0.10:8080","ups_time":"0.008"}
|
||||||
str2 := "abcd中国人"
|
`,
|
||||||
str3 := "😋" + str2 + "😋"
|
},
|
||||||
if FilterMb4(str3) != str2 {
|
[]string{
|
||||||
t.Fatal("FilterMb4 can not filter mb4 characters")
|
"😋abcd中国人😋",
|
||||||
|
"abcd中国人",
|
||||||
|
},
|
||||||
|
[]string{
|
||||||
|
"日配冷藏❄❄",
|
||||||
|
"日配冷藏❄❄",
|
||||||
|
},
|
||||||
|
} {
|
||||||
|
str := FilterMb4(v[0])
|
||||||
|
if str != v[1] {
|
||||||
|
t.Fatalf("%s failed\nshould be:%s\nbut it's:%s", v[0], v[1], str)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user