From 295cc29141e5a48dd110a68910d00eae2124a6e0 Mon Sep 17 00:00:00 2001 From: shenjiachi Date: Tue, 26 Nov 2024 16:05:09 +0800 Subject: [PATCH] update --- app/hdl/ModuleSetting.go | 57 ++++++++++++++++++++++++++++ app/hdl/hdl_config.go | 47 ++++++++++------------- app/md/md_module_setting.go | 10 +++++ app/router/router.go | 1 + docs/docs.go | 75 +++++++++++++++++++++++++++++++++++++ docs/swagger.json | 75 +++++++++++++++++++++++++++++++++++++ docs/swagger.yaml | 53 ++++++++++++++++++++++++++ go.mod | 2 +- 8 files changed, 292 insertions(+), 28 deletions(-) create mode 100644 app/hdl/ModuleSetting.go create mode 100644 app/md/md_module_setting.go diff --git a/app/hdl/ModuleSetting.go b/app/hdl/ModuleSetting.go new file mode 100644 index 0000000..48bbe9b --- /dev/null +++ b/app/hdl/ModuleSetting.go @@ -0,0 +1,57 @@ +package hdl + +import ( + "applet/app/db" + "applet/app/e" + "applet/app/md" + "applet/app/utils" + "code.fnuoos.com/EggPlanet/egg_models.git/src/implement" + "github.com/gin-gonic/gin" +) + +// GetModuleSetting +// @Summary 页面样式 +// @Tags 页面样式 +// @Description 页面样式 +// @Accept json +// @Produce json +// @param Authorization header string true "验证参数Bearer和token空格拼接" +// @Param mod_name_value query string true "页面名称类型值(1:home_page 2:member_center 3:bottom_bar 4:invitation_download_landing_page 5:invitation_poster)" +// @Success 200 {object} md.GetModuleSettingResp "具体数据" +// @Failure 400 {object} md.Response "具体错误" +// @Router /api/v1/getModuleSetting [GET] +func GetModuleSetting(c *gin.Context) { + modName := c.Query("mod_name_value") + modNameMap := map[string]string{ + "1": "home_page", + "2": "member_center", + "3": "bottom_bar", + "4": "invitation_download_landing_page", + "5": "invitation_poster", + } + val, ok := modNameMap[modName] + if !ok { + e.OutErr(c, e.ERR_BAD_REQUEST, nil) + return + } + moduleStyleDb := implement.NewModuleStyleDb(db.Db) + moduleStyle, err := moduleStyleDb.ModuleStyleGetOneByParams(map[string]interface{}{ + "key": "mod_name", + "value": val, + }) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + var dataMap map[string]interface{} + utils.Unserialize([]byte(moduleStyle.Data), &dataMap) + resp := md.GetModuleSettingResp{ + ModName: moduleStyle.ModName, + Position: moduleStyle.Position, + SkipIdentifier: moduleStyle.SkipIdentifier, + Title: moduleStyle.Title, + Subtitle: moduleStyle.Subtitle, + Data: dataMap, + } + e.OutSuc(c, resp, nil) +} diff --git a/app/hdl/hdl_config.go b/app/hdl/hdl_config.go index 427c2fb..81f35f0 100644 --- a/app/hdl/hdl_config.go +++ b/app/hdl/hdl_config.go @@ -1,13 +1,6 @@ package hdl import ( - "applet/app/db" - "applet/app/e" - "applet/app/md" - "applet/app/svc" - "applet/app/utils" - "code.fnuoos.com/EggPlanet/egg_models.git/src/implement" - "fmt" "github.com/gin-gonic/gin" ) @@ -22,24 +15,24 @@ import ( // @Failure 400 {object} md.Response "具体错误" // @Router /api/v1/config [get] func Config(c *gin.Context) { - res := md.ConfigResp{} - eg := db.Db - NewArticleDb := implement.NewArticleDb(eg) - article, _ := NewArticleDb.ArticleCateByTypeId("1") - if article != nil { - res.Title = article.Title - res.Content = article.Content - } - userArticle, _ := NewArticleDb.ArticleCateByTypeId("2") - if userArticle != nil { - res.UserTitle = userArticle.Title - res.UserUrl = fmt.Sprintf("%s%s?article_id=%s", svc.GetSysCfgStr("wap_host"), "/api/v1/article/html", utils.AnyToString(userArticle.Id)) - } - privacyArticle, _ := NewArticleDb.ArticleCateByTypeId("3") - if privacyArticle != nil { - res.PrivacyTitle = privacyArticle.Title - res.PrivacyUrl = fmt.Sprintf("%s%s?article_id=%s", svc.GetSysCfgStr("wap_host"), "/api/v1/article/html", utils.AnyToString(userArticle.Id)) - } - e.OutSuc(c, res, nil) - return + //res := md.ConfigResp{} + //eg := db.Db + //NewArticleDb := implement.NewArticleDb(eg) + //article, _ := NewArticleDb.ArticleCateByTypeId("1") + //if article != nil { + // res.Title = article.Title + // res.Content = article.Content + //} + //userArticle, _ := NewArticleDb.ArticleCateByTypeId("2") + //if userArticle != nil { + // res.UserTitle = userArticle.Title + // res.UserUrl = fmt.Sprintf("%s%s?article_id=%s", svc.GetSysCfgStr("wap_host"), "/api/v1/article/html", utils.AnyToString(userArticle.Id)) + //} + //privacyArticle, _ := NewArticleDb.ArticleCateByTypeId("3") + //if privacyArticle != nil { + // res.PrivacyTitle = privacyArticle.Title + // res.PrivacyUrl = fmt.Sprintf("%s%s?article_id=%s", svc.GetSysCfgStr("wap_host"), "/api/v1/article/html", utils.AnyToString(userArticle.Id)) + //} + //e.OutSuc(c, res, nil) + //return } diff --git a/app/md/md_module_setting.go b/app/md/md_module_setting.go new file mode 100644 index 0000000..1b03792 --- /dev/null +++ b/app/md/md_module_setting.go @@ -0,0 +1,10 @@ +package md + +type GetModuleSettingResp struct { + ModName string `json:"mod_name"` // 模块名称 + Position string `json:"position"` // 位置 + SkipIdentifier string `json:"skip_identifier"` // 跳转标识 + Title string `json:"title"` // 标题 + Subtitle string `json:"subtitle"` // 副标题 + Data map[string]interface{} `json:"data"` // 内容 +} diff --git a/app/router/router.go b/app/router/router.go index 98c508f..7064bb3 100644 --- a/app/router/router.go +++ b/app/router/router.go @@ -65,6 +65,7 @@ func route(r *gin.RouterGroup) { r.POST("/register", hdl.Register) //注册 r.POST("/login", hdl.Login) //登录 r.POST("/findPassword", hdl.FindPassword) //找回密码 + r.GET("/getModuleSetting", hdl.GetModuleSetting) // 获取 r.Use(mw.Auth) // 以下接口需要JWT验证 rComm(r.Group("/comm")) r.GET("/userInfo", hdl.UserInfo) //用户基础信息 diff --git a/docs/docs.go b/docs/docs.go index f4f27a3..d4b5c45 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -610,6 +610,51 @@ const docTemplate = `{ } } }, + "/api/v1/getModuleSetting": { + "get": { + "description": "页面样式", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "页面样式" + ], + "summary": "页面样式", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "页面名称类型值(1:home_page 2:member_center 3:bottom_bar 4:invitation_download_landing_page 5:invitation_poster)", + "name": "mod_name_value", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "具体数据", + "schema": { + "$ref": "#/definitions/md.GetModuleSettingResp" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, "/api/v1/homePage/adRule": { "get": { "description": "视频奖励规则(获取)", @@ -2372,6 +2417,36 @@ const docTemplate = `{ } } }, + "md.GetModuleSettingResp": { + "type": "object", + "properties": { + "data": { + "description": "内容", + "type": "object", + "additionalProperties": true + }, + "mod_name": { + "description": "模块名称", + "type": "string" + }, + "position": { + "description": "位置", + "type": "string" + }, + "skip_identifier": { + "description": "跳转标识", + "type": "string" + }, + "subtitle": { + "description": "副标题", + "type": "string" + }, + "title": { + "description": "标题", + "type": "string" + } + } + }, "md.GetPriceCurveResp": { "type": "object", "properties": { diff --git a/docs/swagger.json b/docs/swagger.json index d585c26..466f73e 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -604,6 +604,51 @@ } } }, + "/api/v1/getModuleSetting": { + "get": { + "description": "页面样式", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "页面样式" + ], + "summary": "页面样式", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "页面名称类型值(1:home_page 2:member_center 3:bottom_bar 4:invitation_download_landing_page 5:invitation_poster)", + "name": "mod_name_value", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "具体数据", + "schema": { + "$ref": "#/definitions/md.GetModuleSettingResp" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, "/api/v1/homePage/adRule": { "get": { "description": "视频奖励规则(获取)", @@ -2366,6 +2411,36 @@ } } }, + "md.GetModuleSettingResp": { + "type": "object", + "properties": { + "data": { + "description": "内容", + "type": "object", + "additionalProperties": true + }, + "mod_name": { + "description": "模块名称", + "type": "string" + }, + "position": { + "description": "位置", + "type": "string" + }, + "skip_identifier": { + "description": "跳转标识", + "type": "string" + }, + "subtitle": { + "description": "副标题", + "type": "string" + }, + "title": { + "description": "标题", + "type": "string" + } + } + }, "md.GetPriceCurveResp": { "type": "object", "properties": { diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 6477e89..96b8b47 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -411,6 +411,28 @@ definitions: paginate: $ref: '#/definitions/applet_app_md.Paginate' type: object + md.GetModuleSettingResp: + properties: + data: + additionalProperties: true + description: 内容 + type: object + mod_name: + description: 模块名称 + type: string + position: + description: 位置 + type: string + skip_identifier: + description: 跳转标识 + type: string + subtitle: + description: 副标题 + type: string + title: + description: 标题 + type: string + type: object md.GetPriceCurveResp: properties: x_data: @@ -1401,6 +1423,37 @@ paths: summary: 注册 tags: - 注册 + /api/v1/getModuleSetting: + get: + consumes: + - application/json + description: 页面样式 + parameters: + - description: 验证参数Bearer和token空格拼接 + in: header + name: Authorization + required: true + type: string + - description: 页面名称类型值(1:home_page 2:member_center 3:bottom_bar 4:invitation_download_landing_page + 5:invitation_poster) + in: query + name: mod_name_value + required: true + type: string + produces: + - application/json + responses: + "200": + description: 具体数据 + schema: + $ref: '#/definitions/md.GetModuleSettingResp' + "400": + description: 具体错误 + schema: + $ref: '#/definitions/md.Response' + summary: 页面样式 + tags: + - 页面样式 /api/v1/homePage/adRule: get: consumes: diff --git a/go.mod b/go.mod index ad5e7b2..dc1fcd8 100644 --- a/go.mod +++ b/go.mod @@ -32,7 +32,7 @@ require ( ) require ( - code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241125145802-942cfd1ddd13 + code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241126074909-98c49e778178 code.fnuoos.com/EggPlanet/egg_system_rules.git v0.0.4-0.20241125081706-0915be3f4144 code.fnuoos.com/go_rely_warehouse/zyos_go_es.git v1.0.1-0.20241118083738-0f22da9ba0be code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git v0.0.5