From dff22d8265d29b7452fac7e5dba530c93e3b6ab1 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Wed, 25 Sep 2024 17:47:33 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/hdl/hdl_login.go | 10 ++++++ app/hdl/hdl_set_center.go | 68 +++++++++++++++++++++++++++++++++++++++ app/md/md_set_center.go | 11 +++++++ app/router/router.go | 4 +++ 4 files changed, 93 insertions(+) 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") { From 820a711f14f1887d9f1429c4a120d3de514e1c31 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Wed, 25 Sep 2024 17:48:33 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/hdl/hdl_login.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/hdl/hdl_login.go b/app/hdl/hdl_login.go index acb844f..acf5176 100644 --- a/app/hdl/hdl_login.go +++ b/app/hdl/hdl_login.go @@ -18,7 +18,11 @@ func LoginBase(c *gin.Context) { engine := db.DBs[masterId] sysCfgDb := implement2.NewSysCfgDb(engine, masterId) res := sysCfgDb.SysCfgFindWithDb("seo_platform_logo", "seo_platform_title") - e.OutSuc(c, res, nil) + re := map[string]string{ + "logo": res["seo_platform_logo"], + "title": res["seo_platform_title"], + } + e.OutSuc(c, re, nil) return } From ae4009315a06d902e91ef1e04daaf6fcd630fa68 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Wed, 25 Sep 2024 18:17:35 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/hdl/hdl_login.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/hdl/hdl_login.go b/app/hdl/hdl_login.go index acf5176..11d6c7b 100644 --- a/app/hdl/hdl_login.go +++ b/app/hdl/hdl_login.go @@ -19,8 +19,8 @@ func LoginBase(c *gin.Context) { sysCfgDb := implement2.NewSysCfgDb(engine, masterId) res := sysCfgDb.SysCfgFindWithDb("seo_platform_logo", "seo_platform_title") re := map[string]string{ - "logo": res["seo_platform_logo"], - "title": res["seo_platform_title"], + "seo_logo": res["seo_platform_logo"], + "seo_title": res["seo_platform_title"], } e.OutSuc(c, re, nil) return From 03fbc74dc642a14176e533c3e7f6cab1dfee6210 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Fri, 27 Sep 2024 11:22:56 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/svc/svc_medium_agent.go | 1 + 1 file changed, 1 insertion(+) diff --git a/app/svc/svc_medium_agent.go b/app/svc/svc_medium_agent.go index dee38a7..6923d8a 100644 --- a/app/svc/svc_medium_agent.go +++ b/app/svc/svc_medium_agent.go @@ -121,6 +121,7 @@ func MediumBindAgentSave(c *gin.Context) { return } agentDb := implement2.NewAgentDb(MasterDb(c)) + req.Username = strings.ReplaceAll(req.Username, " ", "") username, _ := agentDb.GetSuperAgentByUsername(req.Username) if username == nil { e.OutErr(c, 400, e.NewErr(400, "渠道代理不存在")) From 158da0d06597711b3cc091f840c0ee8cb1c60cdd Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Fri, 27 Sep 2024 11:25:42 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/hdl/hdl_set_center.go | 12 +++++++++--- app/md/md_set_center.go | 6 ++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/app/hdl/hdl_set_center.go b/app/hdl/hdl_set_center.go index b9e392a..2a3c58a 100644 --- a/app/hdl/hdl_set_center.go +++ b/app/hdl/hdl_set_center.go @@ -562,8 +562,12 @@ func SetLogo(c *gin.Context) { sysCfgDb := implement2.NewSysCfgDb(engine, masterId) sysCfgDb.SysCfgUpdate("medium_logo", req.MediumLogo) sysCfgDb.SysCfgUpdate("agent_logo", req.AgentLogo) + sysCfgDb.SysCfgUpdate("medium_login_logo", req.MediumLoginLogo) + sysCfgDb.SysCfgUpdate("agent_login_logo", req.AgentLoginLogo) svc.ClearRedis(c, masterId, "medium_logo") svc.ClearRedis(c, masterId, "agent_logo") + svc.ClearRedis(c, masterId, "medium_login_logo") + svc.ClearRedis(c, masterId, "agent_login_logo") svc.ClearAllRedis(c, masterId) e.OutSuc(c, "success", nil) return @@ -583,12 +587,14 @@ func GetLogo(c *gin.Context) { masterId := svc.GetMasterId(c) engine := db.DBs[masterId] sysCfgDb := implement2.NewSysCfgDb(engine, masterId) - res := sysCfgDb.SysCfgFindWithDb("medium_logo", "agent_logo") + res := sysCfgDb.SysCfgFindWithDb("medium_logo", "agent_logo", "medium_login_logo", "agent_login_logo") e.OutSuc(c, md.SetLogoResp{ Data: md.SetLogoReq{ - MediumLogo: res["medium_logo"], - AgentLogo: res["agent_logo"], + MediumLogo: res["medium_logo"], + AgentLogo: res["agent_logo"], + MediumLoginLogo: res["medium_login_logo"], + AgentLoginLogo: res["agent_login_logo"], }, }, nil) return diff --git a/app/md/md_set_center.go b/app/md/md_set_center.go index 49571d6..f1e4cac 100644 --- a/app/md/md_set_center.go +++ b/app/md/md_set_center.go @@ -56,8 +56,10 @@ type SetMobResp struct { Data SetMobReq `json:"data"` //数据内容 } type SetLogoReq struct { - MediumLogo string `json:"medium_logo"` - AgentLogo string `json:"agent_logo"` + MediumLogo string `json:"medium_logo"` + AgentLogo string `json:"agent_logo"` + MediumLoginLogo string `json:"medium_login_logo"` + AgentLoginLogo string `json:"agent_login_logo"` } type SetLogoResp struct { Data SetLogoReq `json:"data"` //数据内容 From c27974eb0bafeeb525815d79de8bd9ca01808def Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Fri, 27 Sep 2024 11:32:55 +0800 Subject: [PATCH 6/8] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/svc/svc_medium_agent.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/svc/svc_medium_agent.go b/app/svc/svc_medium_agent.go index 6923d8a..b02d586 100644 --- a/app/svc/svc_medium_agent.go +++ b/app/svc/svc_medium_agent.go @@ -122,7 +122,7 @@ func MediumBindAgentSave(c *gin.Context) { } agentDb := implement2.NewAgentDb(MasterDb(c)) req.Username = strings.ReplaceAll(req.Username, " ", "") - username, _ := agentDb.GetSuperAgentByUsername(req.Username) + username, _ := agentDb.GetAgent(utils.StrToInt(req.Username)) if username == nil { e.OutErr(c, 400, e.NewErr(400, "渠道代理不存在")) return From 5309808a08c3b9ea5bce05e3357645bb7c47608f Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Fri, 27 Sep 2024 11:43:35 +0800 Subject: [PATCH 7/8] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/svc/svc_medium_agent.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/svc/svc_medium_agent.go b/app/svc/svc_medium_agent.go index b02d586..9c12c95 100644 --- a/app/svc/svc_medium_agent.go +++ b/app/svc/svc_medium_agent.go @@ -24,9 +24,11 @@ func AgentBindMediumList(c *gin.Context) { //代理 查旗下 媒体 e.OutErr(c, err1.Code, err1.Error()) return } + var tmp model2.Agent + MasterDb(c).Where("id=?", req.Id).Get(&tmp) engine := db.Db agentWithMediumDb := implement.NewAgentWithMediumDb(engine) - data, total, _ := agentWithMediumDb.FindAgentWithMediumList(req.Name, req.State, utils.StrToInt(req.Id), 0, utils.StrToInt(req.Page), utils.StrToInt(req.Limit)) + data, total, _ := agentWithMediumDb.FindAgentWithMediumList(req.Name, req.State, tmp.AgentId, 0, utils.StrToInt(req.Page), utils.StrToInt(req.Limit)) list := make([]md.MediumListData, 0) NewMediumDb := implement2.NewMediumDb(MasterDb(c)) @@ -72,9 +74,11 @@ func MediumBindAgentList(c *gin.Context) { e.OutErr(c, err1.Code, err1.Error()) return } + var tmp model2.Medium + MasterDb(c).Where("id=?", req.Id).Get(&tmp) engine := db.Db agentWithMediumDb := implement.NewAgentWithMediumDb(engine) - data, total, _ := agentWithMediumDb.FindAgentWithMediumList(req.Name, req.State, 0, utils.StrToInt(req.Id), utils.StrToInt(req.Page), utils.StrToInt(req.Limit)) + data, total, _ := agentWithMediumDb.FindAgentWithMediumList(req.Name, req.State, 0, tmp.MediumId, utils.StrToInt(req.Page), utils.StrToInt(req.Limit)) list := make([]md.MediumListData, 0) NewAgentDb := implement2.NewAgentDb(MasterDb(c)) From 59073fb03bf7da156ad75f9212758472211cb497 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Fri, 27 Sep 2024 11:49:49 +0800 Subject: [PATCH 8/8] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/svc/svc_medium_agent.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/svc/svc_medium_agent.go b/app/svc/svc_medium_agent.go index 9c12c95..2fbc27d 100644 --- a/app/svc/svc_medium_agent.go +++ b/app/svc/svc_medium_agent.go @@ -24,7 +24,7 @@ func AgentBindMediumList(c *gin.Context) { //代理 查旗下 媒体 e.OutErr(c, err1.Code, err1.Error()) return } - var tmp model2.Agent + var tmp model.AgentList MasterDb(c).Where("id=?", req.Id).Get(&tmp) engine := db.Db agentWithMediumDb := implement.NewAgentWithMediumDb(engine) @@ -74,7 +74,7 @@ func MediumBindAgentList(c *gin.Context) { e.OutErr(c, err1.Code, err1.Error()) return } - var tmp model2.Medium + var tmp model.MediumList MasterDb(c).Where("id=?", req.Id).Get(&tmp) engine := db.Db agentWithMediumDb := implement.NewAgentWithMediumDb(engine)