增加回复分组接口

pull/23/head
陶士涵 4 years ago
parent 0fa0f0d88a
commit 28780f6e8c

@ -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(),
})
}
}

@ -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)
}

@ -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)
}

@ -261,7 +261,9 @@
width="30%"
top="0"
>
<el-input v-model="groupName"></el-input>
<span slot="footer" class="dialog-footer">
<el-button @click="addReplyGroup">保 存</el-button>
<el-button @click="replyGroupDialog = false">取 消</el-button>
</span>
</el-dialog>

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

Loading…
Cancel
Save