package productrpc
|
|
|
|
import (
|
|
"log"
|
|
"sort"
|
|
"strconv"
|
|
"testing"
|
|
)
|
|
|
|
func Test_GetAllActivity(t *testing.T) {
|
|
// dbname := "shop_v2"
|
|
// id := "10248"
|
|
// site_id := "10248"
|
|
// sku_id := "10248"
|
|
|
|
// ret, err := GetAllActivity(site_id, dbname, id, sku_id)
|
|
|
|
// t.Log(ret)
|
|
// t.Log(err)
|
|
|
|
res_arr := []map[string]string{
|
|
map[string]string{
|
|
"Id": "55",
|
|
"Starttime": "19852365",
|
|
},
|
|
map[string]string{
|
|
"Id": "22",
|
|
"Starttime": "17852365",
|
|
},
|
|
map[string]string{
|
|
"Id": "11",
|
|
"Starttime": "18852365",
|
|
},
|
|
}
|
|
t.Log(res_arr)
|
|
|
|
var activitys Activitys
|
|
var err error
|
|
|
|
if len(res_arr) > 0 {
|
|
var start int
|
|
|
|
for _, item := range res_arr {
|
|
start, err = strconv.Atoi(item["Starttime"])
|
|
if err != nil {
|
|
log.Println(err)
|
|
}
|
|
activitys = append(activitys, Activity{
|
|
Id: item["Id"],
|
|
Start: start,
|
|
})
|
|
}
|
|
}
|
|
|
|
sort.Sort(activitys)
|
|
|
|
t.Log(activitys)
|
|
|
|
var list []map[string]string = make([]map[string]string, 0)
|
|
|
|
if len(activitys) > 0 {
|
|
for _, v := range activitys {
|
|
for _, old := range res_arr {
|
|
if v.Id == old["Id"] {
|
|
list = append(list, old)
|
|
break
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
t.Log(list)
|
|
}
|