Commit 764dd8bdffff3e0d1f068bde93b1fabf3219de1c
1 parent
6bd04fd1
Exists in
v1.2
and in
2 other branches
..
Showing
3 changed files
with
62 additions
and
0 deletions
Show diff stats
API/User.go
... | ... | @@ -137,6 +137,46 @@ func UserInfo(c *gin.Context) { |
137 | 137 | |
138 | 138 | } |
139 | 139 | |
140 | + | |
141 | + | |
142 | +// @Title 用户信息 | |
143 | +// @Description 用户管理 - 检查Token是否过期 | |
144 | +// @Accept json | |
145 | +// @Produce json | |
146 | +// @Param id aaron string true "用户id" | |
147 | +// @Param Token wgergejfwe string true "用户token" | |
148 | +// @Success 200 {object} tools.ResponseSeccess "{"errcode":0,"result":"ok"}" | |
149 | +// @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}" | |
150 | +// @Router /CheckToken? [get] | |
151 | +func CheckToken(c *gin.Context) { | |
152 | + c.Header("Access-Control-Allow-Origin", c.Request.Header.Get("Origin")) | |
153 | + c.Header("Access-Control-Allow-Credentials", "true") | |
154 | + | |
155 | + | |
156 | + if c.Query("Token") == "" || bson.IsObjectIdHex(c.Query("id")) == false{ | |
157 | + c.JSON(200, tools.ResponseError{ | |
158 | + 1, | |
159 | + "参数不正确", | |
160 | + }) | |
161 | + return | |
162 | + } | |
163 | + | |
164 | + if Token.GetToken(c.Query("id")) != c.Query("Token"){ | |
165 | + c.JSON(200, tools.ResponseError{ | |
166 | + 1, | |
167 | + "token不正确", | |
168 | + }) | |
169 | + return | |
170 | + } | |
171 | + | |
172 | + | |
173 | + c.JSON(200, tools.ResponseSeccess{ | |
174 | + 0, | |
175 | + "ok", | |
176 | + }) | |
177 | + | |
178 | +} | |
179 | + | |
140 | 180 | // @Title 修改用户信息 |
141 | 181 | // @Description 用户管理 - 修改用户信息 |
142 | 182 | // @Accept json | ... | ... |
README.md
... | ... | @@ -14,6 +14,7 @@ |
14 | 14 | 1. [设备管理 - 查询所有游玩项目](#allitems-get) |
15 | 15 | 1. [查询所有线路](#allline-get) |
16 | 16 | 1. [所有景区基础信息](#allscenic-get) |
17 | +1. [用户管理 - 检查Token是否过期](#checktoken-get) | |
17 | 18 | 1. [查询商品信息](#commodityinfo-get) |
18 | 19 | 1. [投诉 - 增加投诉](#createcomplaint-post) |
19 | 20 | 1. [查询用户的定时提醒](#dealymessage-info-get) |
... | ... | @@ -132,6 +133,26 @@ |
132 | 133 | |
133 | 134 | |
134 | 135 | |
136 | +<a name="checktoken-get"></a> | |
137 | + | |
138 | +#### /CheckToken (GET) | |
139 | + | |
140 | + | |
141 | +用户管理 - 检查Token是否过期 | |
142 | + | |
143 | +| Param Name | Example | Data Type | Description | Required? | | |
144 | +|-----|-----|-----|-----|-----| | |
145 | +| id | aaron | string | 用户id | Yes | | |
146 | +| Token | wgergejfwe | string | 用户token | Yes | | |
147 | + | |
148 | + | |
149 | +| Code | Type | Model | Message | | |
150 | +|-----|-----|-----|-----| | |
151 | +| 200 | object | [ResponseSeccess](#github.com.aarongao.tools.ResponseSeccess) | {"errcode":0,"result":"ok"} | | |
152 | +| 500 | object | [ResponseError](#github.com.aarongao.tools.ResponseError) | {"errcode":1,"errmsg":"错误原因"} | | |
153 | + | |
154 | + | |
155 | + | |
135 | 156 | <a name="commodityinfo-get"></a> |
136 | 157 | |
137 | 158 | #### /CommodityInfo (GET) | ... | ... |
main.go
... | ... | @@ -102,6 +102,7 @@ func main() { |
102 | 102 | r.POST("/Icon/Update", Api.UpdateIcon) |
103 | 103 | r.GET("/Icon/All", Api.AllIcons) |
104 | 104 | r.GET("/Icon/Info", Api.IconInfo) |
105 | + r.GET("/CheckToken", Api.CheckToken) | |
105 | 106 | //r.GET("/ws", Api.WsPage) |
106 | 107 | |
107 | 108 | r.Static("/Upload", "./Upload") | ... | ... |