增加自动回复

pull/23/head
630892807@qq.com 4 years ago
parent c52d50a191
commit ecfe56ba35

@ -25,6 +25,15 @@ func GetReplys(c *gin.Context) {
"result": res,
})
}
func GetAutoReplys(c *gin.Context) {
kefu_id := c.Query("kefu_id")
res := models.FindReplyTitleByUserId(kefu_id)
c.JSON(200, gin.H{
"code": 200,
"msg": "ok",
"result": res,
})
}
func PostReply(c *gin.Context) {
var replyForm ReplyForm
kefuId, _ := c.Get("kefu_name")

@ -35,6 +35,22 @@ func FindReplyByUserId(userId interface{}) []*ReplyGroup {
}
return replyGroups
}
func FindReplyTitleByUserId(userId interface{}) []*ReplyGroup {
var replyGroups []*ReplyGroup
//DB.Raw("select a.*,b.* from reply_group a left join reply_item b on a.id=b.group_id where a.user_id=? ", userId).Scan(&replyGroups)
var replyItems []*ReplyItem
DB.Where("user_id = ?", userId).Find(&replyGroups)
DB.Select("item_name,group_id").Where("user_id = ?", userId).Find(&replyItems)
temp := make(map[string]*ReplyGroup)
for _, replyGroup := range replyGroups {
replyGroup.Items = make([]*ReplyItem, 0)
temp[replyGroup.Id] = replyGroup
}
for _, replyItem := range replyItems {
temp[replyItem.GroupId].Items = append(temp[replyItem.GroupId].Items, replyItem)
}
return replyGroups
}
func CreateReplyGroup(groupName string, userId string) {
g := &ReplyGroup{
GroupName: groupName,

@ -84,6 +84,7 @@ func InitApiRouter(engine *gin.Engine) {
engine.GET("/configs", middleware.JwtApiMiddleware, middleware.RbacAuth, controller.GetConfigs)
engine.POST("/config", middleware.JwtApiMiddleware, middleware.RbacAuth, controller.PostConfig)
engine.GET("/config", controller.GetConfig)
engine.GET("/autoreply", controller.GetAutoReplys)
engine.GET("/replys", middleware.JwtApiMiddleware, controller.GetReplys)
engine.POST("/reply", middleware.JwtApiMiddleware, middleware.RbacAuth, controller.PostReply)
engine.POST("/reply_content", middleware.JwtApiMiddleware, middleware.RbacAuth, controller.PostReplyContent)

@ -422,5 +422,16 @@
}
.kefuFuncBox .el-textarea{width: 99%;}
.kefuFolderBtn{vertical-align: middle;}
.visitorReply{
font-size: 14px;
line-height: 24px;
}
.visitorReplyTitle{
}
.visitorReplyContent{
color:#007aff;
cursor: pointer;
}
.iconBtnsBox .kefuSendBtn{margin-right: 4px;float: right;}
.clear{clear:both;}

@ -28,6 +28,21 @@
type="success">
</el-alert>
<div class="el-alert el-alert--info is-center is-light el-alert__title" v-show="msgListNum>10" v-on:click="getMesssagesByVisitorId(true)"><i class="el-icon-info" ></i>&nbsp;<{flyLang['moremessage']}></div>
<el-row :gutter="2">
<el-col :span="3"><el-avatar shape="square" :size="36" :src="noticeAvatar"></el-avatar></el-col>
<el-col :span="21">
<div class="chatUser"><{noticeName}></div>
<div class="chatContent visitorReply" >
<div v-for="reply in replys">
<div class="visitorReplyTitle"><{reply.group_name}></div>
<div v-on:click="sendReply(item.item_name)" class="visitorReplyContent" v-for="item in reply.items"><{item.item_name}></div>
</div>
</div>
</el-col>
<div class="clear"></div>
</el-row>
<el-row :gutter="2" v-for="v in msgList" v-bind:class="{'chatBoxMe': v.is_kefu==true}">
<div class="chatTime" v-bind:class="{'chatTimeHide': v.show_time==false}"><{v.time}></div>
<el-col :span="3"><el-avatar shape="square" :size="36" :src="v.avator"></el-avatar></el-col>

@ -19,6 +19,9 @@ new Vue({
sendDisabled:false,
flyLang:GOFLY_LANG[LANG],
textareaFocused:false,
replys:[],
noticeName:"",
noticeAvatar:"",
},
methods: {
//初始化websocket
@ -283,6 +286,10 @@ new Vue({
}
},
sendReply:function(title){
this.messageContent=title;
this.chatToUser();
},
//获取日期
getNowDate : function() {// 获取日期
var d = new Date(new Date());
@ -307,6 +314,8 @@ new Vue({
let _this=this;
$.get("/notice?kefu_id="+KEFU_ID,function(res) {
//debugger;
_this.noticeName=res.result.username;
_this.noticeAvatar=res.result.avatar;
if (res.result.welcome != null) {
let msg = res.result.welcome;
var len=msg.length;
@ -532,6 +541,15 @@ new Vue({
}
});
},
//自动
getAutoReply:function(){
var _this=this;
$.get("/autoreply?kefu_id="+KEFU_ID,function(res) {
if(res.code==200){
_this.replys=res.result;
}
});
},
//提示音
alertSound:function(){
var b = document.getElementById("chatMessageAudio");
@ -567,6 +585,6 @@ new Vue({
//this.scrollBottom();
//获取欢迎
this.getNotice();
this.getAutoReply();
}
})

Loading…
Cancel
Save