增加客服列表

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

@ -18,3 +18,11 @@ func GetKefuInfo(c *gin.Context){
"result":info, "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" "fmt"
"github.com/jinzhu/gorm" "github.com/jinzhu/gorm"
"github.com/taoshihan1991/imaptool/config" "github.com/taoshihan1991/imaptool/config"
"time"
) )
var DB *gorm.DB 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(){ func init(){
mysqlInfo:=config.GetMysql() 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"]) 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 package models
import ( import (
"github.com/jinzhu/gorm"
_ "github.com/jinzhu/gorm/dialects/mysql" _ "github.com/jinzhu/gorm/dialects/mysql"
) )
type User struct { type User struct {
gorm.Model Model
Name string Name string `json:"name"`
Password string Password string `json:"password"`
Nickname string Nickname string `json:"nickname"`
Avator string Avator string `json:"avator"`
} }
func CreateUser(name string,password string){ func CreateUser(name string,password string){
user:=&User{ user:=&User{
@ -28,3 +27,8 @@ func FindUserById(id interface{})User{
DB.Where("id = ?", id).First(&user) DB.Where("id = ?", id).First(&user)
return user return user
} }
func FindUsers()[]User{
var users []User
DB.Order("id desc").Find(&users)
return users
}

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

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

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

@ -7,7 +7,33 @@
</el-aside> </el-aside>
<el-main class="mainMain"> <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-main>
</el-container> </el-container>

Loading…
Cancel
Save