From 28780f6e8c98e1ede6239ebb9785c6de3835a2b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=B6=E5=A3=AB=E6=B6=B5?= <630892807@qq.com> Date: Mon, 14 Dec 2020 23:46:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=9B=9E=E5=A4=8D=E5=88=86?= =?UTF-8?q?=E7=BB=84=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controller/reply.go | 14 ++++++++++++++ models/replys.go | 8 ++++++++ router/api.go | 1 + static/html/chat_main.html | 2 ++ static/js/chat-main.js | 10 ++++++++++ 5 files changed, 35 insertions(+) diff --git a/controller/reply.go b/controller/reply.go index 126e2ca..ce7a55d 100644 --- a/controller/reply.go +++ b/controller/reply.go @@ -6,6 +6,10 @@ import ( "log" ) +type ReplyForm struct { + GroupName string `form:"group_name" binding:"required"` +} + func GetReplys(c *gin.Context) { kefuId, _ := c.Get("kefu_name") log.Println(kefuId) @@ -16,3 +20,13 @@ func GetReplys(c *gin.Context) { "result": res, }) } +func PostReply(c *gin.Context) { + var replyForm ReplyForm + err := c.Bind(&replyForm) + if err != nil { + c.JSON(200, gin.H{ + "code": 200, + "msg": "error:" + err.Error(), + }) + } +} diff --git a/models/replys.go b/models/replys.go index 7bff642..d7e2585 100644 --- a/models/replys.go +++ b/models/replys.go @@ -9,6 +9,7 @@ type ReplyItem struct { type ReplyGroup struct { Id string `json:"group_id"` GroupName string `json:"group_name"` + UserId string `json:"user_id"` Items []ReplyItem `json:"items"` } @@ -17,3 +18,10 @@ func FindReplyByUserId(userId interface{}) 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(&replyGroup) return replyGroup } +func CreateReplyGroup(groupName string, userId string) { + g := &ReplyGroup{ + GroupName: groupName, + UserId: userId, + } + DB.Create(g) +} diff --git a/router/api.go b/router/api.go index aa6a3ab..32cddbf 100644 --- a/router/api.go +++ b/router/api.go @@ -82,6 +82,7 @@ func InitApiRouter(engine *gin.Engine) { engine.POST("/config", middleware.JwtApiMiddleware, middleware.RbacAuth, controller.PostConfig) engine.GET("/config", controller.GetConfig) engine.GET("/replys", middleware.JwtApiMiddleware, controller.GetReplys) + engine.POST("/reply", middleware.JwtApiMiddleware, controller.PostReply) //微信接口 engine.GET("/micro_program", middleware.JwtApiMiddleware, controller.GetCheckWeixinSign) } diff --git a/static/html/chat_main.html b/static/html/chat_main.html index 79a2896..4d8b07a 100644 --- a/static/html/chat_main.html +++ b/static/html/chat_main.html @@ -261,7 +261,9 @@ width="30%" top="0" > + + 保 存 取 消 diff --git a/static/js/chat-main.js b/static/js/chat-main.js index 11019dd..3b3f7ba 100644 --- a/static/js/chat-main.js +++ b/static/js/chat-main.js @@ -38,6 +38,7 @@ var app=new Vue({ transKefuDialog:false, otherKefus:[], replyGroupDialog:false, + groupName:"", }, methods: { //跳转 @@ -612,6 +613,14 @@ var app=new Vue({ _this.transKefuDialog = false }); }, + //保存回复分组 + addReplyGroup(){ + var _this=this; + this.sendAjax("/reply","post",{group_name:this.group_name},function(result){ + //_this.otherKefus=result; + _this.replyGroupDialog = false + }); + }, sendAjax(url,method,params,callback){ let _this=this; $.ajax({ @@ -619,6 +628,7 @@ var app=new Vue({ url: url, data:params, headers: { + "Content-Type":"", "token": localStorage.getItem("token") }, success: function(data) {