From 63f173095ce3c09d9cdf8b480307d957bac9f32e Mon Sep 17 00:00:00 2001 From: "630892807@qq.com" <630892807@qq.com> Date: Tue, 6 Apr 2021 23:26:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=95=E9=A1=B5=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controller/about.go | 8 ++++++++ models/abouts.go | 7 +++++++ router/api.go | 1 + static/html/setting_bottom.html | 6 ++++++ static/html/setting_indexpages.html | 26 +++++++++++++++++++++++++- 5 files changed, 47 insertions(+), 1 deletion(-) diff --git a/controller/about.go b/controller/about.go index ba9e6ea..4345ba3 100644 --- a/controller/about.go +++ b/controller/about.go @@ -17,6 +17,14 @@ func GetAbout(c *gin.Context) { "result": about, }) } +func GetAbouts(c *gin.Context) { + about := models.FindAbouts() + c.JSON(200, gin.H{ + "code": 200, + "msg": "ok", + "result": about, + }) +} func PostAbout(c *gin.Context) { title_cn := c.PostForm("title_cn") title_en := c.PostForm("title_en") diff --git a/models/abouts.go b/models/abouts.go index 22d830d..3c09956 100644 --- a/models/abouts.go +++ b/models/abouts.go @@ -11,6 +11,13 @@ type About struct { CssJs string `json:"css_js"` HtmlCn string `json:"html_cn"` HtmlEn string `json:"html_en"` + Page string `json:"page"` +} + +func FindAbouts() []About { + var a []About + DB.Select("id,title_cn,page").Find(&a) + return a } func FindAboutByPage(page interface{}) About { diff --git a/router/api.go b/router/api.go index dc62cf5..0869ca0 100644 --- a/router/api.go +++ b/router/api.go @@ -69,6 +69,7 @@ func InitApiRouter(engine *gin.Engine) { //前台接口 engine.GET("/about", controller.GetAbout) engine.POST("/about", middleware.JwtApiMiddleware, middleware.RbacAuth, controller.PostAbout) + engine.GET("/aboutpages", middleware.JwtApiMiddleware, middleware.RbacAuth, controller.GetAbouts) engine.GET("/notice", middleware.SetLanguage, controller.GetNotice) engine.POST("/notice", middleware.JwtApiMiddleware, middleware.RbacAuth, controller.PostNotice) engine.DELETE("/notice", middleware.JwtApiMiddleware, middleware.RbacAuth, controller.DelNotice) diff --git a/static/html/setting_bottom.html b/static/html/setting_bottom.html index 5348ad5..b689bab 100644 --- a/static/html/setting_bottom.html +++ b/static/html/setting_bottom.html @@ -94,6 +94,7 @@ html_cn: "", html_en: "", }, + aboutpages:[], modifyPass:{ old_pass:"", new_pass:"", @@ -231,6 +232,11 @@ _this.pageindex=result; }); } + if(ACTION=="setting_indexpages"){ + this.sendAjax("/aboutpages","get",{},function(result){ + _this.aboutpages=result; + }); + } if(ACTION=="setting_avator"){ this.sendAjax("/kefuinfo","get",{},function(result){ _this.avatarUrl=result.avator; diff --git a/static/html/setting_indexpages.html b/static/html/setting_indexpages.html index 5d8e6f9..d72d3d0 100644 --- a/static/html/setting_indexpages.html +++ b/static/html/setting_indexpages.html @@ -1,7 +1,31 @@ {{template "header" }}