package controller import ( "github.com/gin-gonic/gin" "kefu/models" "kefu/tools" "kefu/types" ) func GetUpdownLine(c *gin.Context) { kefuName, _ := c.Get("kefu_name") entIdStr, _ := c.Get("ent_id") onlineStatus := c.Query("online_status") online := &models.UpDownLine{ EntId: entIdStr.(string), KefuName: kefuName.(string), OnlineStatus: uint(tools.Str2Int(onlineStatus)), ClientIp: c.ClientIP(), CreatedAt: types.Time{}, } online.AddUpDownLine() c.JSON(200, gin.H{ "code": 200, "msg": "ok", }) } /** 上下线列表 */ func GetUpDownLineList(c *gin.Context) { entId, _ := c.Get("ent_id") kefuName, _ := c.Get("kefu_name") roleId, _ := c.Get("role_id") query := "1=1" var arg = []interface{}{} if roleId.(float64) != 1 { query += " and ent_id = ? " arg = append(arg, entId) } if roleId.(float64) == 3 { query += " and kefu_name = ? " arg = append(arg, kefuName) } page, pagesize := HandlePagePageSize(c) count := models.CountUpDownLineWhere(query, arg...) exts := models.FindUpDownLineByWhere(page, pagesize, query, arg...) c.JSON(200, gin.H{ "code": 200, "msg": "ok", "result": gin.H{ "list": exts, "count": count, "pagesize": pagesize, "page": page, }, }) }