diff --git a/API/User.go b/API/User.go index b338896..589ed63 100644 --- a/API/User.go +++ b/API/User.go @@ -137,6 +137,46 @@ func UserInfo(c *gin.Context) { } + + +// @Title 用户信息 +// @Description 用户管理 - 检查Token是否过期 +// @Accept json +// @Produce json +// @Param id aaron string true "用户id" +// @Param Token wgergejfwe string true "用户token" +// @Success 200 {object} tools.ResponseSeccess "{"errcode":0,"result":"ok"}" +// @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}" +// @Router /CheckToken? [get] +func CheckToken(c *gin.Context) { + c.Header("Access-Control-Allow-Origin", c.Request.Header.Get("Origin")) + c.Header("Access-Control-Allow-Credentials", "true") + + + if c.Query("Token") == "" || bson.IsObjectIdHex(c.Query("id")) == false{ + c.JSON(200, tools.ResponseError{ + 1, + "参数不正确", + }) + return + } + + if Token.GetToken(c.Query("id")) != c.Query("Token"){ + c.JSON(200, tools.ResponseError{ + 1, + "token不正确", + }) + return + } + + + c.JSON(200, tools.ResponseSeccess{ + 0, + "ok", + }) + +} + // @Title 修改用户信息 // @Description 用户管理 - 修改用户信息 // @Accept json diff --git a/README.md b/README.md index 4127658..8a05662 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ 1. [设备管理 - 查询所有游玩项目](#allitems-get) 1. [查询所有线路](#allline-get) 1. [所有景区基础信息](#allscenic-get) +1. [用户管理 - 检查Token是否过期](#checktoken-get) 1. [查询商品信息](#commodityinfo-get) 1. [投诉 - 增加投诉](#createcomplaint-post) 1. [查询用户的定时提醒](#dealymessage-info-get) @@ -132,6 +133,26 @@ + + +#### /CheckToken (GET) + + +用户管理 - 检查Token是否过期 + +| Param Name | Example | Data Type | Description | Required? | +|-----|-----|-----|-----|-----| +| id | aaron | string | 用户id | Yes | +| Token | wgergejfwe | string | 用户token | Yes | + + +| Code | Type | Model | Message | +|-----|-----|-----|-----| +| 200 | object | [ResponseSeccess](#github.com.aarongao.tools.ResponseSeccess) | {"errcode":0,"result":"ok"} | +| 500 | object | [ResponseError](#github.com.aarongao.tools.ResponseError) | {"errcode":1,"errmsg":"错误原因"} | + + + #### /CommodityInfo (GET) diff --git a/main.go b/main.go index 61efc67..eab8bb9 100644 --- a/main.go +++ b/main.go @@ -102,6 +102,7 @@ func main() { r.POST("/Icon/Update", Api.UpdateIcon) r.GET("/Icon/All", Api.AllIcons) r.GET("/Icon/Info", Api.IconInfo) + r.GET("/CheckToken", Api.CheckToken) //r.GET("/ws", Api.WsPage) r.Static("/Upload", "./Upload") -- libgit2 0.21.0