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) {