增加客服列表

pull/30/head
taoshihan1991 4 years ago
parent 5d57dfc906
commit b71a5c5189

@ -18,3 +18,11 @@ func GetKefuInfo(c *gin.Context){
"result":info,
})
}
func GetKefuList(c *gin.Context){
users:=models.FindUsers()
c.JSON(200, gin.H{
"code": 200,
"msg": "获取成功",
"result":users,
})
}

@ -4,9 +4,15 @@ import (
"fmt"
"github.com/jinzhu/gorm"
"github.com/taoshihan1991/imaptool/config"
"time"
)
var DB *gorm.DB
type Model struct {
ID uint `gorm:"primary_key" json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt *time.Time `sql:"index" json:"deleted_at"`
}
func init(){
mysqlInfo:=config.GetMysql()
dsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8&parseTime=True&loc=Local", mysqlInfo["Username"], mysqlInfo["Password"], mysqlInfo["Server"], mysqlInfo["Port"], mysqlInfo["Database"])

@ -1,15 +1,14 @@
package models
import (
"github.com/jinzhu/gorm"
_ "github.com/jinzhu/gorm/dialects/mysql"
)
type User struct {
gorm.Model
Name string
Password string
Nickname string
Avator string
Model
Name string `json:"name"`
Password string `json:"password"`
Nickname string `json:"nickname"`
Avator string `json:"avator"`
}
func CreateUser(name string,password string){
user:=&User{
@ -27,4 +26,9 @@ func FindUserById(id interface{})User{
var user User
DB.Where("id = ?", id).First(&user)
return user
}
func FindUsers()[]User{
var users []User
DB.Order("id desc").Find(&users)
return users
}

@ -1,9 +1,7 @@
package models
import "github.com/jinzhu/gorm"
type Visitor struct {
gorm.Model
Model
Name string `json:"name"`
Avator string `json:"avator"`
SourceIp string `json:"source_ip"`

@ -43,6 +43,7 @@ func main() {
engine.GET("/chat_server", controller.NewChatServer)
//获取客服信息
engine.GET("/kefuinfo",middleware.JwtApiMiddleware, controller.GetKefuInfo)
engine.GET("/kefulist",middleware.JwtApiMiddleware, controller.GetKefuList)
//设置页
engine.GET("/setting", tmpl.PageSetting)
//设置mysql

@ -37,7 +37,7 @@
{ required: true, message: '请输入密码', trigger: 'blur' },
],
},
kefuList:[],
},
methods: {
//提交表单
@ -117,32 +117,42 @@
initInfo(){
let _this=this;
if(ACTION=="setting_mysql"){
$.ajax({
type:"get",
url:"/mysql",
headers:{
"token":localStorage.getItem("token")
},
success: function(data) {
if(data.result!=null){
_this.mysql.username=data.result.Username;
_this.mysql.password=data.result.Password;
_this.mysql.database=data.result.Database;
_this.mysql.server=data.result.Server;
_this.mysql.port=data.result.Port;
}
if(data.code!=200){
_this.$message({
message: data.msg,
type: 'error'
});
}
_this.fullscreenLoading=false;
}
this.getAjax("/mysql",{},function(result){
_this.mysql.username=result.Username;
_this.mysql.password=result.Password;
_this.mysql.database=result.Database;
_this.mysql.server=result.Server;
_this.mysql.port=result.Port;
});
}
if(ACTION=="setting_kefu_list"){
this.getAjax("/kefulist",{},function(result){
_this.kefuList=result;
});
}
},
getAjax(url,params,callback){
let _this=this;
$.ajax({
type: "get",
url: url,
headers: {
"token": localStorage.getItem("token")
},
success: function(data) {
if(data.code!=200){
_this.$message({
message: data.msg,
type: 'error'
});
}else if(data.result!=null){
callback(data.result);
}
_this.fullscreenLoading=false
}
});
}
},
created: function () {

@ -7,7 +7,33 @@
</el-aside>
<el-main class="mainMain">
ss
<el-table
:data="kefuList"
border
style="width: 100%">
<el-table-column
prop="img"
label="客服头像">
<template slot-scope="scope">
<el-avatar :size="50"><img :src="scope.row.avator"/></el-avatar>
</template>
</el-table-column>
<el-table-column
prop="name"
label="客服账号">
</el-table-column>
<el-table-column
prop="created_at"
label="添加时间">
</el-table-column>
<el-table-column
prop="id"
label="操作">
<template slot-scope="scope">
<el-button @click="deleteMonitor(scope.row.id)" type="text" size="small">删除</el-button>
</template>
</el-table-column>
</el-table>
</el-main>
</el-container>

Loading…
Cancel
Save