package services
import (
"github.com/astaxie/beego"
"sort"
"strconv"
"xjd_v1/models"
)
// 通话记录
type SortMonth []models.CommonlyConnectMobiles_2
func (a SortMonth) Len() int { return len(a) }
func (a SortMonth) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a SortMonth) Less(i, j int) bool {
return a[i].Connect_count > a[j].Connect_count
}
// 通讯录排序
func SortAddressBook(one_month []models.CommonlyConnectMobiles) (one_month_mn []models.CommonlyConnectMobiles_2) {
for _, v := range one_month {
var a int
var err error
if v.Connect_count == "" {
a = 0
} else {
a, err = strconv.Atoi(v.Connect_count)
if err != nil {
beego.Debug(err.Error())
return
}
}
temp := models.CommonlyConnectMobiles_2{}
temp.Connect_count = a
temp.Mobile = v.Mobile
temp.Belong_to = v.Belong_to
temp.Connect_time = v.Connect_time
temp.Originating_call_count = v.Originating_call_count
temp.Terminating_call_count = v.Terminating_call_count
temp.Mon_type = v.Mon_type
temp.Uid = v.Uid
one_month_mn = append(one_month_mn, temp)
}
sort.Sort(SortMonth(one_month_mn))
return
}
有疑问加站长微信联系(非本文作者)