增加客服接口

pull/30/head
taoshihan1991 4 years ago
parent 8cf2a617eb
commit 4c5e4a1139

@ -27,4 +27,18 @@ CREATE TABLE `visitor` (
`client_ip` varchar(100) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `visitor_id` (`visitor_id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8
CREATE TABLE `message` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`from_id` varchar(100) NOT NULL DEFAULT '',
`to_id` varchar(100) NOT NULL DEFAULT '',
`content` varchar(2048) NOT NULL DEFAULT '',
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`deleted_at` timestamp NULL DEFAULT NULL,
`status` enum('read','unread') NOT NULL DEFAULT 'unread',
PRIMARY KEY (`id`),
KEY `from_id` (`from_id`),
KEY `to_id` (`to_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8

@ -3,6 +3,8 @@ package controller
import (
"github.com/gin-gonic/gin"
"github.com/taoshihan1991/imaptool/models"
"github.com/taoshihan1991/imaptool/tools"
"log"
)
func GetKefuInfo(c *gin.Context){
@ -19,10 +21,14 @@ func GetKefuInfo(c *gin.Context){
})
}
func PostKefuInfo(c *gin.Context){
name:=c.PostForm("name")
password:=c.PostForm("password")
avator:=c.PostForm("avator")
models.CreateUser(name,tools.Md5(password),avator)
c.JSON(200, gin.H{
"code": 200,
"msg": "ok",
"result":"aaa",
"result":"",
})
}
func GetKefuList(c *gin.Context){
@ -33,3 +39,13 @@ func GetKefuList(c *gin.Context){
"result":users,
})
}
func DeleteKefuInfo(c *gin.Context){
kefuId := c.Query("id")
log.Println(kefuId)
models.DeleteUserById(kefuId)
c.JSON(200, gin.H{
"code": 200,
"msg": "删除成功",
"result":"",
})
}

@ -10,10 +10,11 @@ type User struct {
Nickname string `json:"nickname"`
Avator string `json:"avator"`
}
func CreateUser(name string,password string){
func CreateUser(name string,password string,avator string){
user:=&User{
Name:name,
Password: password,
Avator:avator,
}
DB.Create(user)
}
@ -27,6 +28,9 @@ func FindUserById(id interface{})User{
DB.Where("id = ?", id).First(&user)
return user
}
func DeleteUserById(id string){
DB.Where("id = ?",id).Delete(User{})
}
func FindUsers()[]User{
var users []User
DB.Order("id desc").Find(&users)

@ -42,6 +42,7 @@ func main() {
//获取客服信息
engine.GET("/kefuinfo",middleware.JwtApiMiddleware, controller.GetKefuInfo)
engine.POST("/kefuinfo",middleware.JwtApiMiddleware, controller.PostKefuInfo)
engine.DELETE("/kefuinfo",middleware.JwtApiMiddleware, controller.DeleteKefuInfo)
engine.GET("/kefulist",middleware.JwtApiMiddleware, controller.GetKefuList)
//设置页
engine.GET("/setting", tmpl.PageSetting)

@ -46,7 +46,9 @@
kefuList:[],
kefuDialog:false,
kefuForm:{
name:"",
password:"",
avator:"",
},
},
methods: {
@ -147,6 +149,7 @@
$.ajax({
type: method,
url: url,
data:params,
headers: {
"token": localStorage.getItem("token")
},
@ -173,17 +176,25 @@
let _this=this;
this.$refs[formName].validate((valid) => {
if (valid) {
this.sendAjax("/kefuinfo","post",_this.kefuForm,function(result){
_this.$message({
message: data.msg,
type: 'success'
});
this.sendAjax("/kefuinfo","POST",_this.kefuForm,function(result){
_this.kefuDialog=false;
_this.sendAjax("/kefulist","get",{},function(result){
_this.kefuList=result;
});
});
} else {
return false;
}
});
},
//删除客服
deleteKefu(kefuId){
this.sendAjax("/kefuinfo","DELETE",{id:kefuId},function(result){
_this.kefuDialog=false;
_this.sendAjax("/kefulist","get",{},function(result){
_this.kefuList=result;
});
});
}
},
created: function () {

@ -31,8 +31,8 @@
prop="id"
label="操作">
<template slot-scope="scope">
<el-button @click="deleteMonitor(scope.row.id)" type="primary" size="small" plain>编辑</el-button>
<el-button @click="deleteMonitor(scope.row.id)" type="danger" size="small" plain>删除</el-button>
<el-button @click="" type="primary" size="small" plain>编辑</el-button>
<el-button @click="deleteKefu(scope.row.id)" type="danger" size="small" plain>删除</el-button>
</template>
</el-table-column>
</el-table>

Loading…
Cancel
Save