修复访客分页条数

pull/30/head
taoshihan1991 5 years ago
parent ddba8d7283
commit 87063a9f5c

@ -20,7 +20,7 @@ func GetVisitors(c *gin.Context) {
page,_:=strconv.Atoi(c.Query("page")) page,_:=strconv.Atoi(c.Query("page"))
kefuId,_:=c.Get("kefu_name") kefuId,_:=c.Get("kefu_name")
vistors:=models.FindVisitorsByKefuId(uint(page),config.VisitorPageSize,kefuId.(string)) vistors:=models.FindVisitorsByKefuId(uint(page),config.VisitorPageSize,kefuId.(string))
count:=models.CountVisitors() count:=models.CountVisitorsByKefuId(kefuId.(string))
c.JSON(200, gin.H{ c.JSON(200, gin.H{
"code": 200, "code": 200,
"msg": "ok", "msg": "ok",

@ -70,4 +70,10 @@ func CountVisitors()uint{
var count uint var count uint
DB.Model(&Visitor{}).Count(&count) DB.Model(&Visitor{}).Count(&count)
return count return count
}
//查询条数
func CountVisitorsByKefuId(kefuId string)uint{
var count uint
DB.Model(&Visitor{}).Where("to_id=?",kefuId).Count(&count)
return count
} }
Loading…
Cancel
Save