From 34282143935f5edd52e34304b40cc83c325818af Mon Sep 17 00:00:00 2001 From: dengbiao Date: Tue, 8 Oct 2024 17:13:00 +0800 Subject: [PATCH] update --- app/hdl/hdl_login.go | 18 ++++++++++++++++ app/md/md_login.go | 9 ++++++++ app/router/router.go | 49 ++++++++++++++++++++++---------------------- docs/docs.go | 40 ++++++++++++++++++++++++++++++++++++ docs/swagger.json | 40 ++++++++++++++++++++++++++++++++++++ docs/swagger.yaml | 26 +++++++++++++++++++++++ 6 files changed, 158 insertions(+), 24 deletions(-) diff --git a/app/hdl/hdl_login.go b/app/hdl/hdl_login.go index d87d070..00a251a 100644 --- a/app/hdl/hdl_login.go +++ b/app/hdl/hdl_login.go @@ -58,3 +58,21 @@ func Login(c *gin.Context) { }, nil) return } + +// LoginInfo +// @Summary 登录信息 +// @Tags 登录注册 +// @Description 登录信息 +// @Accept json +// @Produce json +// @Param req body md.LoginReq true "用户名密码" +// @Success 200 {object} md.LoginResponse "token" +// @Failure 400 {object} md.Response "具体错误" +// @Router /api/loginInfo [GET] +func LoginInfo(c *gin.Context) { + admin := svc.GetUser(c) + e.OutSuc(c, md.LoginResponse{ + Token: token, + }, nil) + return +} diff --git a/app/md/md_login.go b/app/md/md_login.go index 271a126..fe875a9 100644 --- a/app/md/md_login.go +++ b/app/md/md_login.go @@ -9,3 +9,12 @@ type LoginReq struct { type LoginResponse struct { Token string `json:"token"` } + +type LoginInfoResponse struct { + AdmId int `json:"adm_id" ` // 管理员id + Username string `json:"username" example:"登录账号"` + IsSuperAdministrator int `json:"is_super_administrator" example:"是否为超级管理员(0:否 1:是)"` + Memo string `json:"memo" example:"备注信息"` + CreateAt string `json:"create_at" ` + UpdateAt string `json:"update_at" ` +} diff --git a/app/router/router.go b/app/router/router.go index 35e10a8..c77d630 100644 --- a/app/router/router.go +++ b/app/router/router.go @@ -18,10 +18,10 @@ func Init() *gin.Engine { mode = "debug" } gin.SetMode(mode) - //创建一个新的启动器 + // 创建一个新的启动器 r := gin.New() r.GET("/api/swagger/*any", func(c *gin.Context) { - //r.Use(mw.SwagAuth()) + // r.Use(mw.SwagAuth()) ginSwagger.DisablingWrapHandler(swaggerFiles.Handler, "SWAGGER")(c) }) @@ -63,38 +63,39 @@ func route(r *gin.RouterGroup) { r.Use(mw.DB) // 以下接口需要用到数据库 { r.POST("/login", hdl.Login) + r.POST("/loginInfo", hdl.LoginInfo) } - r.Use(mw.CheckBody) //body参数转换 - r.Use(mw.CheckSign) //签名校验 + r.Use(mw.CheckBody) // body参数转换 + r.Use(mw.CheckSign) // 签名校验 r.Use(mw.Auth) // 以下接口需要JWT验证 - rRole(r.Group("/role")) //权限管理 - rDataCenter(r.Group("/dataCenter")) //数据中心 - rSmsCenter(r.Group("/smsCenter")) //短信中心 + rRole(r.Group("/role")) // 权限管理 + rDataCenter(r.Group("/dataCenter")) // 数据中心 + rSmsCenter(r.Group("/smsCenter")) // 短信中心 } func rRole(r *gin.RouterGroup) { - r.GET("/roleList", hdl.RoleList) //角色列表 - r.POST("/addRole", hdl.AddRole) //角色添加 - r.POST("/roleBindPermissionGroup", hdl.RoleBindPermissionGroup) //角色绑定权限组 - r.POST("/updateRoleState", hdl.UpdateRoleState) //修改角色状态 - r.POST("/updateRole", hdl.UpdateRole) //修改角色状态 - r.DELETE("/deleteRole/:id", hdl.DeleteRole) //删除角色 - r.GET("/permissionGroupList", hdl.PermissionGroupList) //权限组列表 - r.POST("/adminList", hdl.AdminList) //管理员列表 - r.POST("/updateAdminState", hdl.UpdateAdminState) //修改管理员状态 - r.POST("/updateAdmin", hdl.UpdateAdmin) //修改管理员信息 - r.POST("/addAdmin", hdl.AddAdmin) //新增管理员 - r.DELETE("/deleteAdmin/:adm_id", hdl.DeleteAdmin) //删除管理员 - r.GET("/adminInfo", hdl.AdminInfo) //获取管理员信息 - r.POST("/bindAdminRole", hdl.BindAdminRole) //绑定角色 + r.GET("/roleList", hdl.RoleList) // 角色列表 + r.POST("/addRole", hdl.AddRole) // 角色添加 + r.POST("/roleBindPermissionGroup", hdl.RoleBindPermissionGroup) // 角色绑定权限组 + r.POST("/updateRoleState", hdl.UpdateRoleState) // 修改角色状态 + r.POST("/updateRole", hdl.UpdateRole) // 修改角色状态 + r.DELETE("/deleteRole/:id", hdl.DeleteRole) // 删除角色 + r.GET("/permissionGroupList", hdl.PermissionGroupList) // 权限组列表 + r.POST("/adminList", hdl.AdminList) // 管理员列表 + r.POST("/updateAdminState", hdl.UpdateAdminState) // 修改管理员状态 + r.POST("/updateAdmin", hdl.UpdateAdmin) // 修改管理员信息 + r.POST("/addAdmin", hdl.AddAdmin) // 新增管理员 + r.DELETE("/deleteAdmin/:adm_id", hdl.DeleteAdmin) // 删除管理员 + r.GET("/adminInfo", hdl.AdminInfo) // 获取管理员信息 + r.POST("/bindAdminRole", hdl.BindAdminRole) // 绑定角色 } func rDataCenter(r *gin.RouterGroup) { - r.POST("/original/data/list", hdl.OriginalDataList) //数据中心-原始数据 + r.POST("/original/data/list", hdl.OriginalDataList) // 数据中心-原始数据 - r.POST("/generate/data/list", hdl.GenerateDataList) //数据中心-分成数据 - r.POST("/generate/data/detail", hdl.GenerateDataDetail) //数据中心-分成数据-详情 + r.POST("/generate/data/list", hdl.GenerateDataList) // 数据中心-分成数据 + r.POST("/generate/data/detail", hdl.GenerateDataDetail) // 数据中心-分成数据-详情 } func rSmsCenter(r *gin.RouterGroup) { diff --git a/docs/docs.go b/docs/docs.go index 9604979..923d3f2 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -206,6 +206,46 @@ const docTemplate = `{ } } }, + "/api/loginInfo": { + "get": { + "description": "登录信息", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "登录注册" + ], + "summary": "登录信息", + "parameters": [ + { + "description": "用户名密码", + "name": "req", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/md.LoginReq" + } + } + ], + "responses": { + "200": { + "description": "token", + "schema": { + "$ref": "#/definitions/md.LoginResponse" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, "/api/role/addAdmin": { "post": { "description": "权限管理-新增管理员", diff --git a/docs/swagger.json b/docs/swagger.json index cec05fa..5d52826 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -198,6 +198,46 @@ } } }, + "/api/loginInfo": { + "get": { + "description": "登录信息", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "登录注册" + ], + "summary": "登录信息", + "parameters": [ + { + "description": "用户名密码", + "name": "req", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/md.LoginReq" + } + } + ], + "responses": { + "200": { + "description": "token", + "schema": { + "$ref": "#/definitions/md.LoginResponse" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, "/api/role/addAdmin": { "post": { "description": "权限管理-新增管理员", diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 370f0e8..8a0b690 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -581,6 +581,32 @@ paths: summary: 登陆 tags: - 登录注册 + /api/loginInfo: + get: + consumes: + - application/json + description: 登录信息 + parameters: + - description: 用户名密码 + in: body + name: req + required: true + schema: + $ref: '#/definitions/md.LoginReq' + produces: + - application/json + responses: + "200": + description: token + schema: + $ref: '#/definitions/md.LoginResponse' + "400": + description: 具体错误 + schema: + $ref: '#/definitions/md.Response' + summary: 登录信息 + tags: + - 登录注册 /api/role/addAdmin: post: consumes: