diff --git a/app/hdl/hdl_login.go b/app/hdl/hdl_login.go index 012073d..acb844f 100644 --- a/app/hdl/hdl_login.go +++ b/app/hdl/hdl_login.go @@ -1,6 +1,7 @@ package hdl import ( + implement2 "applet/app/db/implement" "applet/app/e" "applet/app/lib/validate" "applet/app/md" @@ -12,6 +13,15 @@ import ( "github.com/gin-gonic/gin" ) +func LoginBase(c *gin.Context) { + masterId := svc.GetMasterId(c) + engine := db.DBs[masterId] + sysCfgDb := implement2.NewSysCfgDb(engine, masterId) + res := sysCfgDb.SysCfgFindWithDb("seo_platform_logo", "seo_platform_title") + e.OutSuc(c, res, nil) + return +} + // Login 登陆 // @Summary 登陆 // @Tags 登录 diff --git a/app/hdl/hdl_set_center.go b/app/hdl/hdl_set_center.go index 54adcb0..b9e392a 100644 --- a/app/hdl/hdl_set_center.go +++ b/app/hdl/hdl_set_center.go @@ -593,3 +593,71 @@ func GetLogo(c *gin.Context) { }, nil) return } + +// SetSeo +// @Summary Seo设置 +// @Tags 设置中心-基础设置 +// @Description 基础设置-logo设置 +// @param Authorization header string true "验证参数Bearer和token空格拼接" +// @Accept json +// @Produce json +// @Param args body md.SetSeoReq true "请求参数" +// @Success 200 {string} "success" +// @Failure 400 {object} md.Response "具体错误" +// @Router /api/setCenter/basic/setSeo [POST] +func SetSeo(c *gin.Context) { + var req md.SetSeoReq + err := c.ShouldBindJSON(&req) + if err != nil { + err = validate.HandleValidateErr(err) + err1 := err.(e.E) + e.OutErr(c, err1.Code, err1.Error()) + return + } + masterId := svc.GetMasterId(c) + engine := db.DBs[masterId] + sysCfgDb := implement2.NewSysCfgDb(engine, masterId) + sysCfgDb.SysCfgUpdate("seo_medium_title", req.SeoMediumTitle) + sysCfgDb.SysCfgUpdate("seo_agent_title", req.SeoAgentTitle) + sysCfgDb.SysCfgUpdate("seo_platform_title", req.SeoPlatformTitle) + svc.ClearRedis(c, masterId, "seo_medium_title") + svc.ClearRedis(c, masterId, "seo_agent_title") + svc.ClearRedis(c, masterId, "seo_platform_title") + sysCfgDb.SysCfgUpdate("seo_medium_logo", req.SeoMediumLogo) + sysCfgDb.SysCfgUpdate("seo_agent_logo", req.SeoAgentLogo) + sysCfgDb.SysCfgUpdate("seo_platform_logo", req.SeoPlatformLogo) + svc.ClearRedis(c, masterId, "seo_medium_logo") + svc.ClearRedis(c, masterId, "seo_agent_logo") + svc.ClearRedis(c, masterId, "seo_platform_logo") + svc.ClearAllRedis(c, masterId) + e.OutSuc(c, "success", nil) + return +} + +// GetSeo +// @Summary Seo获取 +// @Tags 设置中心-基础设置 +// @Description 基础设置-logo获取 +// @param Authorization header string true "验证参数Bearer和token空格拼接" +// @Accept json +// @Produce json +// @Success 200 {object} md.SetSeoResp +// @Failure 400 {object} md.Response "具体错误" +// @Router /api/setCenter/basic/getSeo [GET] +func GetSeo(c *gin.Context) { + masterId := svc.GetMasterId(c) + engine := db.DBs[masterId] + sysCfgDb := implement2.NewSysCfgDb(engine, masterId) + res := sysCfgDb.SysCfgFindWithDb("seo_medium_logo", "seo_agent_logo", "seo_platform_logo", "seo_medium_title", "seo_agent_title", "seo_platform_title") + e.OutSuc(c, md.SetSeoResp{ + Data: md.SetSeoReq{ + SeoMediumTitle: res["seo_medium_title"], + SeoAgentTitle: res["seo_agent_title"], + SeoPlatformTitle: res["seo_platform_title"], + SeoMediumLogo: res["seo_medium_logo"], + SeoAgentLogo: res["seo_agent_logo"], + SeoPlatformLogo: res["seo_platform_logo"], + }, + }, nil) + return +} diff --git a/app/md/md_set_center.go b/app/md/md_set_center.go index 58174dc..49571d6 100644 --- a/app/md/md_set_center.go +++ b/app/md/md_set_center.go @@ -62,3 +62,14 @@ type SetLogoReq struct { type SetLogoResp struct { Data SetLogoReq `json:"data"` //数据内容 } +type SetSeoReq struct { + SeoPlatformTitle string `json:"seo_platform_title"` + SeoAgentTitle string `json:"seo_agent_title"` + SeoMediumTitle string `json:"seo_medium_title"` + SeoPlatformLogo string `json:"seo_platform_logo"` + SeoAgentLogo string `json:"seo_agent_logo"` + SeoMediumLogo string `json:"seo_medium_logo"` +} +type SetSeoResp struct { + Data SetSeoReq `json:"data"` //数据内容 +} diff --git a/app/router/router.go b/app/router/router.go index 711cfd8..e7ce0d4 100644 --- a/app/router/router.go +++ b/app/router/router.go @@ -56,6 +56,7 @@ func route(r *gin.RouterGroup) { r.Use(mw.DB) // 以下接口需要用到数据库 { r.POST("/login", hdl.Login) + r.GET("/base", hdl.LoginBase) } r.Use(mw.CheckBody) //body参数转换 r.Use(mw.CheckSign) //签名校验 @@ -130,6 +131,9 @@ func rSetCenter(r *gin.RouterGroup) { rBasicSetCenter.GET("/getMob", hdl.GetMob) rBasicSetCenter.POST("/setLogo", hdl.SetLogo) rBasicSetCenter.GET("/getLogo", hdl.GetLogo) + + rBasicSetCenter.POST("/setSeo", hdl.SetSeo) + rBasicSetCenter.GET("/getSeo", hdl.GetSeo) } rAppletSetCenter := r.Group("/applet") {