diff --git a/controller/notice.go b/controller/notice.go
index 9d00046..22ad845 100644
--- a/controller/notice.go
+++ b/controller/notice.go
@@ -52,6 +52,17 @@ func PostNotice(c *gin.Context) {
"result": "",
})
}
+func PostNoticeSave(c *gin.Context) {
+ kefuId, _ := c.Get("kefu_name")
+ content := c.PostForm("content")
+ id := c.PostForm("id")
+ models.UpdateWelcome(fmt.Sprintf("%s", kefuId),id, content)
+ c.JSON(200, gin.H{
+ "code": 200,
+ "msg": "ok",
+ "result": "",
+ })
+}
func DelNotice(c *gin.Context) {
kefuId, _ := c.Get("kefu_name")
id := c.Query("id")
diff --git a/models/welcomes.go b/models/welcomes.go
index f1c7eb6..698651b 100644
--- a/models/welcomes.go
+++ b/models/welcomes.go
@@ -22,6 +22,16 @@ func CreateWelcome(userId string, content string) uint {
DB.Create(w)
return w.ID
}
+func UpdateWelcome(userId string,id string, content string) uint {
+ if userId == "" || content == "" {
+ return 0
+ }
+ w := &Welcome{
+ Content: content,
+ }
+ DB.Model(w).Where("user_id = ? and id = ?", userId,id).Update(w)
+ return w.ID
+}
func FindWelcomeByUserId(userId interface{}) Welcome {
var w Welcome
DB.Where("user_id = ? and is_default=?", userId, 1).First(&w)
diff --git a/router/api.go b/router/api.go
index f96168b..6f34777 100644
--- a/router/api.go
+++ b/router/api.go
@@ -50,6 +50,7 @@ func InitApiRouter(engine *gin.Engine) {
engine.GET("/notice", middleware.SetLanguage, controller.GetNotice)
engine.POST("/notice", middleware.JwtApiMiddleware, controller.PostNotice)
engine.DELETE("/notice", middleware.JwtApiMiddleware, controller.DelNotice)
+ engine.POST("/notice_save", middleware.JwtApiMiddleware, controller.PostNoticeSave)
engine.GET("/notices", middleware.JwtApiMiddleware, controller.GetNotices)
engine.POST("/ipblack", middleware.JwtApiMiddleware, controller.PostIpblack)
engine.DELETE("/ipblack", middleware.JwtApiMiddleware, controller.DelIpblack)
diff --git a/static/html/setting_bottom.html b/static/html/setting_bottom.html
index ee5a860..08d8878 100644
--- a/static/html/setting_bottom.html
+++ b/static/html/setting_bottom.html
@@ -342,6 +342,15 @@
});
});
},
+ //设置配置项
+ setWelcomeItem(id,content){
+ let _this=this;
+ this.sendAjax("/notice_save","POST",{id:id,content:content},function(result){
+ _this.sendAjax("/notices","get",{},function(result){
+ _this.noticeList=result;
+ });
+ });
+ },
//提交角色表单
submitRoleForm(formName){
let _this=this;
diff --git a/static/html/setting_welcome.html b/static/html/setting_welcome.html
index 0187b02..56714ef 100644
--- a/static/html/setting_welcome.html
+++ b/static/html/setting_welcome.html
@@ -13,6 +13,9 @@
+
+
+