- ugc api of ebai
This commit is contained in:
43
platformapi/ebaiapi/ugc.go
Normal file
43
platformapi/ebaiapi/ugc.go
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
package ebaiapi
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (a *API) OrderRatesGet(shopID string, baiduShopID int64, startTime, endTime time.Time, replyStatus int) (commentList []map[string]interface{}, err error) {
|
||||||
|
params := a.genShopIDParams(shopID, baiduShopID)
|
||||||
|
if !utils.IsTimeZero(startTime) {
|
||||||
|
params["startTime"] = startTime
|
||||||
|
}
|
||||||
|
if !utils.IsTimeZero(endTime) {
|
||||||
|
params["endTime"] = endTime
|
||||||
|
}
|
||||||
|
if replyStatus >= 0 {
|
||||||
|
params["replyStatus"] = replyStatus
|
||||||
|
}
|
||||||
|
pageNo := 1
|
||||||
|
for {
|
||||||
|
params["page"] = pageNo
|
||||||
|
result, err := a.AccessAPI("ugc.orderrates.get", params)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
data := result.Data.(map[string]interface{})
|
||||||
|
commentList = append(commentList, utils.Slice2MapSlice(data["comment_list"].([]interface{}))...)
|
||||||
|
total := int(utils.MustInterface2Int64(data["total"]))
|
||||||
|
if len(commentList) >= total {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return commentList, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *API) OrderRatesReply(shopID string, baiduShopID int64, commentID, content string) (err error) {
|
||||||
|
params := a.genShopIDParams(shopID, baiduShopID)
|
||||||
|
params["comment_id"] = commentID
|
||||||
|
params["content"] = content
|
||||||
|
_, err = a.AccessAPI("ugc.reply", params)
|
||||||
|
return err
|
||||||
|
}
|
||||||
16
platformapi/ebaiapi/ugc_test.go
Normal file
16
platformapi/ebaiapi/ugc_test.go
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
package ebaiapi
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"git.rosy.net.cn/baseapi"
|
||||||
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestOrderRatesGet(t *testing.T) {
|
||||||
|
commentList, err := api.OrderRatesGet("100119", 0, utils.DefaultTimeValue, utils.DefaultTimeValue, -1)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
baseapi.SugarLogger.Debug(utils.Format4Output(commentList, false))
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user