diff --git a/controller/reply.go b/controller/reply.go index 69b7c9b..2c2c070 100644 --- a/controller/reply.go +++ b/controller/reply.go @@ -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") diff --git a/models/replys.go b/models/replys.go index 8170c7a..8cb5381 100644 --- a/models/replys.go +++ b/models/replys.go @@ -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, diff --git a/router/api.go b/router/api.go index 2674b04..fd1e10c 100644 --- a/router/api.go +++ b/router/api.go @@ -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) diff --git a/static/css/common.css b/static/css/common.css index 225f7f0..f2faf5c 100644 --- a/static/css/common.css +++ b/static/css/common.css @@ -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;} \ No newline at end of file diff --git a/static/html/chat_page.html b/static/html/chat_page.html index 85cf22d..d0efae3 100644 --- a/static/html/chat_page.html +++ b/static/html/chat_page.html @@ -28,6 +28,21 @@ type="success">