From 37968c35ed09987a10e6b71762156eaa270ae2f6 Mon Sep 17 00:00:00 2001 From: dengbiao Date: Wed, 9 Oct 2024 15:33:53 +0800 Subject: [PATCH] 1 --- app/enum/enum_sys_cfg.go | 19 +++++++ app/hdl/hdl_set_center.go | 64 ++++++++++++++++++++++++ app/md/md_set_center.go | 11 ++++ app/router/router.go | 6 +++ docs/docs.go | 102 ++++++++++++++++++++++++++++++++++++++ docs/swagger.json | 102 ++++++++++++++++++++++++++++++++++++++ docs/swagger.yaml | 68 +++++++++++++++++++++++++ 7 files changed, 372 insertions(+) create mode 100644 app/enum/enum_sys_cfg.go create mode 100644 app/hdl/hdl_set_center.go create mode 100644 app/md/md_set_center.go diff --git a/app/enum/enum_sys_cfg.go b/app/enum/enum_sys_cfg.go new file mode 100644 index 0000000..1d8fc0a --- /dev/null +++ b/app/enum/enum_sys_cfg.go @@ -0,0 +1,19 @@ +package enum + +type SysCfg string + +const ( + AppName = "app_name" + AppLogo = "app_logo" +) + +func (gt SysCfg) String() string { + switch gt { + case AppName: + return "项目名称" + case AppLogo: + return "项目logo" + default: + return "未知" + } +} diff --git a/app/hdl/hdl_set_center.go b/app/hdl/hdl_set_center.go new file mode 100644 index 0000000..31a9e82 --- /dev/null +++ b/app/hdl/hdl_set_center.go @@ -0,0 +1,64 @@ +package hdl + +import ( + implement2 "applet/app/db/implement" + "applet/app/e" + "applet/app/enum" + "applet/app/lib/validate" + "applet/app/md" + "applet/app/svc" + db "code.fnuoos.com/zhimeng/model.git/src" + "github.com/gin-gonic/gin" +) + +// BasicSet +// @Summary 基础设置 +// @Tags 设置中心-基础设置 +// @Description 基础设置-设置 +// @param Authorization header string true "验证参数Bearer和token空格拼接" +// @Accept json +// @Produce json +// @Param args body md.BasicSetReq true "请求参数" +// @Success 200 {string} "success" +// @Failure 400 {object} md.Response "具体错误" +// @Router /api/setCenter/basicSet [POST] +func BasicSet(c *gin.Context) { + var req md.BasicSetReq + 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(enum.AppName, req.AppName) + sysCfgDb.SysCfgUpdate(enum.AppLogo, req.AppLogo) + e.OutSuc(c, "success", nil) + return +} + +// BasicGet +// @Summary 基础设置 +// @Tags 设置中心-基础设置 +// @Description 基础设置-获取 +// @param Authorization header string true "验证参数Bearer和token空格拼接" +// @Accept json +// @Produce json +// @Success 200 {string} "success" +// @Failure 400 {object} md.Response "具体错误" +// @Router /api/setCenter/basicGet [GET] +func BasicGet(c *gin.Context) { + masterId := svc.GetMasterId(c) + engine := db.DBs[masterId] + sysCfgDb := implement2.NewSysCfgDb(engine, masterId) + res := sysCfgDb.SysCfgFindWithDb(enum.AppLogo, enum.AppName) + + e.OutSuc(c, md.BasicSetResp{ + AppName: res[enum.AppName], + AppLogo: res[enum.AppLogo], + }, nil) + return +} diff --git a/app/md/md_set_center.go b/app/md/md_set_center.go new file mode 100644 index 0000000..d38ebd1 --- /dev/null +++ b/app/md/md_set_center.go @@ -0,0 +1,11 @@ +package md + +type BasicSetReq struct { + AppName string `json:"app_name" binding:"required" example:"项目名称"` + AppLogo string `json:"app_logo" binding:"required" example:"项目logo"` +} + +type BasicSetResp struct { + AppName string `json:"app_name" example:"项目名称"` + AppLogo string `json:"app_logo" example:"项目logo"` +} diff --git a/app/router/router.go b/app/router/router.go index 1d26dc8..65ec3e7 100644 --- a/app/router/router.go +++ b/app/router/router.go @@ -76,12 +76,18 @@ func route(r *gin.RouterGroup) { rRole(r.Group("/role")) // 权限管理 rDataCenter(r.Group("/dataCenter")) // 数据中心 rSmsCenter(r.Group("/smsCenter")) // 短信中心 + rSetCenter(r.Group("/setCenter")) // 设置中心 } func rComm(r *gin.RouterGroup) { r.POST("/getMenuList", hdl.MenuList) // 获取菜单栏列表 } +func rSetCenter(r *gin.RouterGroup) { + r.POST("/basicSet", hdl.BasicSet) + r.GET("/basicGet", hdl.BasicGet) +} + func rRole(r *gin.RouterGroup) { r.GET("/roleList", hdl.RoleList) // 角色列表 r.POST("/addRole", hdl.AddRole) // 角色添加 diff --git a/docs/docs.go b/docs/docs.go index f693f4d..c4d2ffb 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -835,6 +835,91 @@ const docTemplate = `{ } } }, + "/api/setCenter/basicGet": { + "get": { + "description": "基础设置-获取", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "设置中心-基础设置" + ], + "summary": "基础设置", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "success", + "schema": { + "type": "string" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, + "/api/setCenter/basicSet": { + "post": { + "description": "基础设置-设置", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "设置中心-基础设置" + ], + "summary": "基础设置", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "请求参数", + "name": "args", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/md.BasicSetReq" + } + } + ], + "responses": { + "200": { + "description": "success", + "schema": { + "type": "string" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, "/api/smsCenter/detail": { "post": { "description": "短信中心-详情", @@ -1028,6 +1113,23 @@ const docTemplate = `{ } } }, + "md.BasicSetReq": { + "type": "object", + "required": [ + "app_logo", + "app_name" + ], + "properties": { + "app_logo": { + "type": "string", + "example": "项目logo" + }, + "app_name": { + "type": "string", + "example": "项目名称" + } + } + }, "md.BindAdminRoleReq": { "type": "object", "required": [ diff --git a/docs/swagger.json b/docs/swagger.json index b928ba7..b57506d 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -827,6 +827,91 @@ } } }, + "/api/setCenter/basicGet": { + "get": { + "description": "基础设置-获取", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "设置中心-基础设置" + ], + "summary": "基础设置", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "success", + "schema": { + "type": "string" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, + "/api/setCenter/basicSet": { + "post": { + "description": "基础设置-设置", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "设置中心-基础设置" + ], + "summary": "基础设置", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "请求参数", + "name": "args", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/md.BasicSetReq" + } + } + ], + "responses": { + "200": { + "description": "success", + "schema": { + "type": "string" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, "/api/smsCenter/detail": { "post": { "description": "短信中心-详情", @@ -1020,6 +1105,23 @@ } } }, + "md.BasicSetReq": { + "type": "object", + "required": [ + "app_logo", + "app_name" + ], + "properties": { + "app_logo": { + "type": "string", + "example": "项目logo" + }, + "app_name": { + "type": "string", + "example": "项目名称" + } + } + }, "md.BindAdminRoleReq": { "type": "object", "required": [ diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 01615ff..62daa06 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -32,6 +32,18 @@ definitions: username: type: string type: object + md.BasicSetReq: + properties: + app_logo: + example: 项目logo + type: string + app_name: + example: 项目名称 + type: string + required: + - app_logo + - app_name + type: object md.BindAdminRoleReq: properties: adm_id: @@ -1015,6 +1027,62 @@ paths: summary: 修改角色状态 tags: - 权限管理 + /api/setCenter/basicGet: + get: + consumes: + - application/json + description: 基础设置-获取 + parameters: + - description: 验证参数Bearer和token空格拼接 + in: header + name: Authorization + required: true + type: string + produces: + - application/json + responses: + "200": + description: success + schema: + type: string + "400": + description: 具体错误 + schema: + $ref: '#/definitions/md.Response' + summary: 基础设置 + tags: + - 设置中心-基础设置 + /api/setCenter/basicSet: + post: + consumes: + - application/json + description: 基础设置-设置 + parameters: + - description: 验证参数Bearer和token空格拼接 + in: header + name: Authorization + required: true + type: string + - description: 请求参数 + in: body + name: args + required: true + schema: + $ref: '#/definitions/md.BasicSetReq' + produces: + - application/json + responses: + "200": + description: success + schema: + type: string + "400": + description: 具体错误 + schema: + $ref: '#/definitions/md.Response' + summary: 基础设置 + tags: + - 设置中心-基础设置 /api/smsCenter/detail: post: consumes: