Selaa lähdekoodia

增加Token检验接口

zhou.xiaoning 2 vuotta sitten
vanhempi
commit
4655897ae7
6 muutettua tiedostoa jossa 122 lisäystä ja 3 poistoa
  1. 15 3
      api/v1/account/login.go
  2. 39 0
      docs/docs.go
  3. 39 0
      docs/swagger.json
  4. 21 0
      docs/swagger.yaml
  5. 1 0
      initialize/router.go
  6. 7 0
      router/account.go

+ 15 - 3
api/v1/account/login.go

@@ -14,12 +14,12 @@ import (
 
 // Login 账户登录
 // @Summary 账户登录
-// @accept  application/json
-// @Produce application/json
+// @accept   application/json
+// @Produce  application/json
 // @Param   data body     request.LoginReq                                       true "登录入参"
 // @Success 200  {object} response.Response{data=accountRsp.LoginRsp,msg=string} "返回包括用户信息,token,过期时间"
 // @Router  /Account/Login [post]
-// @Tags    账户服务
+// @Tags     账户服务
 func Login(c *gin.Context) {
 	g := utils.GinUtils{C: c}
 	r := request.LoginReq{}
@@ -37,3 +37,15 @@ func Login(c *gin.Context) {
 		response.FailWithMessage(err.Error(), c)
 	}
 }
+
+// TokenCheck Token校验
+// @Summary  Token校验
+// @Security ApiKeyAuth
+// @accept  application/json
+// @Produce application/json
+// @Success  200 {object} response.Response{msg=string} "操作成功"
+// @Router   /Account/TokenCheck [get]
+// @Tags    账户服务
+func TokenCheck(c *gin.Context) {
+	response.Ok(c)
+}

+ 39 - 0
docs/docs.go

@@ -64,6 +64,45 @@ const docTemplate = `{
                 }
             }
         },
+        "/Account/TokenCheck": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "consumes": [
+                    "application/json"
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "账户服务"
+                ],
+                "summary": "Token校验",
+                "responses": {
+                    "200": {
+                        "description": "操作成功",
+                        "schema": {
+                            "allOf": [
+                                {
+                                    "$ref": "#/definitions/response.Response"
+                                },
+                                {
+                                    "type": "object",
+                                    "properties": {
+                                        "msg": {
+                                            "type": "string"
+                                        }
+                                    }
+                                }
+                            ]
+                        }
+                    }
+                }
+            }
+        },
         "/MQ/SendMsgToMQ": {
             "post": {
                 "security": [

+ 39 - 0
docs/swagger.json

@@ -55,6 +55,45 @@
                 }
             }
         },
+        "/Account/TokenCheck": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "consumes": [
+                    "application/json"
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "账户服务"
+                ],
+                "summary": "Token校验",
+                "responses": {
+                    "200": {
+                        "description": "操作成功",
+                        "schema": {
+                            "allOf": [
+                                {
+                                    "$ref": "#/definitions/response.Response"
+                                },
+                                {
+                                    "type": "object",
+                                    "properties": {
+                                        "msg": {
+                                            "type": "string"
+                                        }
+                                    }
+                                }
+                            ]
+                        }
+                    }
+                }
+            }
+        },
         "/MQ/SendMsgToMQ": {
             "post": {
                 "security": [

+ 21 - 0
docs/swagger.yaml

@@ -118,6 +118,27 @@ paths:
       summary: 账户登录
       tags:
       - 账户服务
+  /Account/TokenCheck:
+    get:
+      consumes:
+      - application/json
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: 操作成功
+          schema:
+            allOf:
+            - $ref: '#/definitions/response.Response'
+            - properties:
+                msg:
+                  type: string
+              type: object
+      security:
+      - ApiKeyAuth: []
+      summary: Token校验
+      tags:
+      - 账户服务
   /MQ/SendMsgToMQ:
     post:
       consumes:

+ 1 - 0
initialize/router.go

@@ -46,6 +46,7 @@ func Routers() *gin.Engine {
 	privateGroup.Use(middleware.JWTAuth())
 	{
 		router.InitMQPrivateRouter(privateGroup)
+		router.InitAccountPrivateRouter(privateGroup)
 	}
 
 	return Router

+ 7 - 0
router/account.go

@@ -12,3 +12,10 @@ func InitAccountPublicRouter(r *gin.RouterGroup) {
 		accountR.POST("Login", account.Login)
 	}
 }
+
+func InitAccountPrivateRouter(r *gin.RouterGroup) {
+	accountR := r.Group("Account").Use()
+	{
+		accountR.GET("TokenCheck", account.TokenCheck)
+	}
+}