增加统计信息接口

pull/30/head
taoshihan1991 4 years ago
parent ab787526a9
commit 4dd15f016e

@ -31,3 +31,17 @@ func MainCheckAuth(c *gin.Context) {
},
})
}
func GetStatistics(c *gin.Context) {
visitors:=models.CountVisitors()
message:=models.CountMessage()
session:=len(clientList)
c.JSON(200, gin.H{
"code": 200,
"msg": "ok",
"result":gin.H{
"visitors":visitors,
"message":message,
"session":session,
},
})
}

@ -115,7 +115,7 @@ func main() {
engine.GET("/visitor",middleware.JwtApiMiddleware, controller.GetVisitor)
engine.GET("/visitors",middleware.JwtApiMiddleware, controller.GetVisitors)
engine.GET("/setting_kefu_list",tmpl.PageKefuList)
engine.GET("/statistics",middleware.JwtApiMiddleware, controller.GetStatistics)
//前台接口
engine.GET("/notice",middleware.SetLanguage, controller.GetNotice)
//前台引入js接口

@ -35,3 +35,9 @@ func FindUnreadMessageNumByVisitorId(visitor_id string)uint{
DB.Where("visitor_id=? and status=?",visitor_id,"unread").Count(&count)
return count
}
//查询条数
func CountMessage()uint{
var count uint
DB.Model(&Message{}).Count(&count)
return count
}

@ -10,19 +10,19 @@
<el-row :gutter="10">
<el-col :span="8">
<div class="smallBox bgInfo">
<h3>15000</h3>
<h3 v-html="statistics.visitors"></h3>
<p>总访客数</p>
</div>
</el-col>
<el-col :span="8">
<div class="smallBox bgSuccess">
<h3>15000</h3>
<h3 v-html="statistics.message"></h3>
<p>总消息数</p>
</div>
</el-col>
<el-col :span="8">
<div class="smallBox bgDanger">
<h3>15000</h3>
<h3 v-html="statistics.session"></h3>
<p>当前会话数</p>
</div>
</el-col>

@ -69,6 +69,7 @@
method:"",
path:"",
},
statistics:{},
},
methods: {
//提交表单
@ -166,6 +167,11 @@
_this.roleList=result;
});
}
if(ACTION=="setting"){
this.sendAjax("/statistics","get",{},function(result){
_this.statistics=result;
});
}
},
sendAjax(url,method,params,callback){
let _this=this;

@ -11,8 +11,8 @@
<span>账户设置</span>
</template>
<el-menu-item-group>
<el-menu-item index="1-1" v-on:click="openUrl('/setting')">主板</el-menu-item>
<el-menu-item index="1-2" v-on:click="openUrl('/setting_welcome')">问候</el-menu-item>
<el-menu-item index="1-1" v-on:click="openUrl('/setting')">统计信息</el-menu-item>
<el-menu-item index="1-2" v-on:click="openUrl('/setting_welcome')">欢迎</el-menu-item>
</el-menu-item-group>
</el-submenu>
<el-submenu index="3">
@ -21,7 +21,7 @@
<span>权限设置</span>
</template>
<el-menu-item-group>
<el-menu-item index="1-2" v-on:click="openUrl('/setting_kefu_list')">用户管理</el-menu-item>
<el-menu-item index="3-2" v-on:click="openUrl('/setting_kefu_list')">用户管理</el-menu-item>
<el-menu-item index="3-1" v-on:click="openUrl('/roles_list')">角色管理</el-menu-item>
</el-menu-item-group>
</el-submenu>

@ -5,7 +5,28 @@
{{template "setting_left" .}}
<el-main class="mainMain">
正在开发...
<el-button style="margin-bottom: 10px;" @click="addWelcome" type="primary" size="small">添加欢迎</el-button>
<el-table
:data="notices"
border
style="width: 100%">
<el-table-column
prop="content"
label="回复内容">
</el-table-column>
<el-table-column
prop="ctime"
label="添加时间">
</el-table-column>
<el-table-column
prop="id"
label="操作">
<template slot-scope="scope">
<el-button @click="getWelcome(scope.row.id)" type="primary" size="small" plain>编辑</el-button>
<el-button @click="deleteWelcome(scope.row.id)" type="danger" size="small" plain>删除</el-button>
</template>
</el-table-column>
</el-table>
</el-main>
</el-container>

@ -7,14 +7,14 @@ import (
//设置界面
func PageSetting(c *gin.Context) {
c.HTML(http.StatusOK, "setting.html", gin.H{
"tab_index":"2-3",
"tab_index":"1-1",
"action":"setting",
})
}
//设置欢迎
func PageSettingWelcome(c *gin.Context) {
c.HTML(http.StatusOK, "setting_welcome.html", gin.H{
"tab_index":"1-1",
"tab_index":"1-2",
"action":"setting_welcome",
})
}
@ -42,7 +42,7 @@ func PageWebCss(c *gin.Context){
}
func PageKefuList(c *gin.Context) {
c.HTML(http.StatusOK, "setting_kefu_list.html", gin.H{
"tab_index":"1-2",
"tab_index":"3-2",
"action":"setting_kefu_list",
})
}

Loading…
Cancel
Save