Skip to content

Commit 3e3969d

Browse files
v1.0.4
1 parent a327176 commit 3e3969d

File tree

3 files changed

+303
-14
lines changed

3 files changed

+303
-14
lines changed

docs/docs.go

+113-5
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,67 @@ const docTemplate = `{
2424
"host": "{{.Host}}",
2525
"basePath": "{{.BasePath}}",
2626
"paths": {
27+
"/v1/auth/captcha": {
28+
"get": {
29+
"consumes": [
30+
"application/json"
31+
],
32+
"produces": [
33+
"application/json"
34+
],
35+
"tags": [
36+
"认证"
37+
],
38+
"summary": "登录",
39+
"parameters": [
40+
{
41+
"type": "string",
42+
"description": "capthca类型;audio,string,math,chinese,digit",
43+
"name": "type",
44+
"in": "query",
45+
"required": true
46+
}
47+
],
48+
"responses": {
49+
"200": {
50+
"description": "OK",
51+
"schema": {
52+
"allOf": [
53+
{
54+
"$ref": "#/definitions/handler.Response"
55+
},
56+
{
57+
"type": "object",
58+
"properties": {
59+
"data": {
60+
"$ref": "#/definitions/handler.GetCaptchaResponse"
61+
}
62+
}
63+
}
64+
]
65+
}
66+
},
67+
"400": {
68+
"description": "Bad Request",
69+
"schema": {
70+
"$ref": "#/definitions/handler.Response"
71+
}
72+
},
73+
"404": {
74+
"description": "Not Found",
75+
"schema": {
76+
"$ref": "#/definitions/handler.Response"
77+
}
78+
},
79+
"500": {
80+
"description": "Internal Server Error",
81+
"schema": {
82+
"$ref": "#/definitions/handler.Response"
83+
}
84+
}
85+
}
86+
}
87+
},
2788
"/v1/auth/login": {
2889
"post": {
2990
"consumes": [
@@ -35,7 +96,7 @@ const docTemplate = `{
3596
"tags": [
3697
"认证"
3798
],
38-
"summary": "登陆",
99+
"summary": "登录",
39100
"parameters": [
40101
{
41102
"description": "请求JSON数据体",
@@ -1044,6 +1105,14 @@ const docTemplate = `{
10441105
"username"
10451106
],
10461107
"properties": {
1108+
"captcha": {
1109+
"description": "Captcha 验证码;当登录错误超过次数时,必须填",
1110+
"type": "string"
1111+
},
1112+
"captcha_id": {
1113+
"description": "CaptchaID 验证码ID; 当登录错误超过次数时,必须填; 通过调用 /api/v1/auth/captcha 获得",
1114+
"type": "string"
1115+
},
10471116
"password": {
10481117
"description": "Password 密码",
10491118
"type": "string",
@@ -1059,16 +1128,20 @@ const docTemplate = `{
10591128
"handler.AuthLoginResponse": {
10601129
"description": "用户登陆返回参数",
10611130
"type": "object",
1062-
"required": [
1063-
"expires_at",
1064-
"token"
1065-
],
10661131
"properties": {
10671132
"expires_at": {
10681133
"description": "ExpiresAt 到期时间",
10691134
"type": "integer",
10701135
"example": 1725249106
10711136
},
1137+
"fail_times": {
1138+
"description": "FailTimes 累计失败次数",
1139+
"type": "integer"
1140+
},
1141+
"need_captcha": {
1142+
"description": "NeedCaptcha 是否需要验证码",
1143+
"type": "boolean"
1144+
},
10721145
"token": {
10731146
"description": "Token 认证Token",
10741147
"type": "string",
@@ -1080,6 +1153,8 @@ const docTemplate = `{
10801153
"description": "用户注册请求参数",
10811154
"type": "object",
10821155
"required": [
1156+
"captcha",
1157+
"captcha_id",
10831158
"confirm_password",
10841159
"password",
10851160
"username"
@@ -1091,6 +1166,14 @@ const docTemplate = `{
10911166
"minLength": 8,
10921167
"example": "2016-01-02"
10931168
},
1169+
"captcha": {
1170+
"description": "Captcha 验证码",
1171+
"type": "string"
1172+
},
1173+
"captcha_id": {
1174+
"description": "CaptchaID 验证码ID, 通过调用 /api/v1/auth/captcha 获得",
1175+
"type": "string"
1176+
},
10941177
"confirm_password": {
10951178
"description": "ConfirmPassword 确认密码",
10961179
"type": "string",
@@ -1312,6 +1395,31 @@ const docTemplate = `{
13121395
}
13131396
}
13141397
},
1398+
"handler.GetCaptchaResponse": {
1399+
"description": "获取验证码返回数据",
1400+
"type": "object",
1401+
"required": [
1402+
"data",
1403+
"id",
1404+
"type"
1405+
],
1406+
"properties": {
1407+
"data": {
1408+
"description": "Data 验证码数据;有图片数据,也有音频数据,前端需要根据type生成对应媒体数据",
1409+
"type": "string"
1410+
},
1411+
"id": {
1412+
"description": "ID 验证码验证ID",
1413+
"type": "string",
1414+
"example": "7uh37xVCN0oGarKZ79nx"
1415+
},
1416+
"type": {
1417+
"description": "Type 验证码类型",
1418+
"type": "string",
1419+
"example": "audio"
1420+
}
1421+
}
1422+
},
13151423
"handler.JoinGroupRequest": {
13161424
"description": "入群请求参数",
13171425
"type": "object",

docs/swagger.json

+113-5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,67 @@
1818
"host": "localhost:8080",
1919
"basePath": "/api/",
2020
"paths": {
21+
"/v1/auth/captcha": {
22+
"get": {
23+
"consumes": [
24+
"application/json"
25+
],
26+
"produces": [
27+
"application/json"
28+
],
29+
"tags": [
30+
"认证"
31+
],
32+
"summary": "登录",
33+
"parameters": [
34+
{
35+
"type": "string",
36+
"description": "capthca类型;audio,string,math,chinese,digit",
37+
"name": "type",
38+
"in": "query",
39+
"required": true
40+
}
41+
],
42+
"responses": {
43+
"200": {
44+
"description": "OK",
45+
"schema": {
46+
"allOf": [
47+
{
48+
"$ref": "#/definitions/handler.Response"
49+
},
50+
{
51+
"type": "object",
52+
"properties": {
53+
"data": {
54+
"$ref": "#/definitions/handler.GetCaptchaResponse"
55+
}
56+
}
57+
}
58+
]
59+
}
60+
},
61+
"400": {
62+
"description": "Bad Request",
63+
"schema": {
64+
"$ref": "#/definitions/handler.Response"
65+
}
66+
},
67+
"404": {
68+
"description": "Not Found",
69+
"schema": {
70+
"$ref": "#/definitions/handler.Response"
71+
}
72+
},
73+
"500": {
74+
"description": "Internal Server Error",
75+
"schema": {
76+
"$ref": "#/definitions/handler.Response"
77+
}
78+
}
79+
}
80+
}
81+
},
2182
"/v1/auth/login": {
2283
"post": {
2384
"consumes": [
@@ -29,7 +90,7 @@
2990
"tags": [
3091
"认证"
3192
],
32-
"summary": "登陆",
93+
"summary": "登录",
3394
"parameters": [
3495
{
3596
"description": "请求JSON数据体",
@@ -1038,6 +1099,14 @@
10381099
"username"
10391100
],
10401101
"properties": {
1102+
"captcha": {
1103+
"description": "Captcha 验证码;当登录错误超过次数时,必须填",
1104+
"type": "string"
1105+
},
1106+
"captcha_id": {
1107+
"description": "CaptchaID 验证码ID; 当登录错误超过次数时,必须填; 通过调用 /api/v1/auth/captcha 获得",
1108+
"type": "string"
1109+
},
10411110
"password": {
10421111
"description": "Password 密码",
10431112
"type": "string",
@@ -1053,16 +1122,20 @@
10531122
"handler.AuthLoginResponse": {
10541123
"description": "用户登陆返回参数",
10551124
"type": "object",
1056-
"required": [
1057-
"expires_at",
1058-
"token"
1059-
],
10601125
"properties": {
10611126
"expires_at": {
10621127
"description": "ExpiresAt 到期时间",
10631128
"type": "integer",
10641129
"example": 1725249106
10651130
},
1131+
"fail_times": {
1132+
"description": "FailTimes 累计失败次数",
1133+
"type": "integer"
1134+
},
1135+
"need_captcha": {
1136+
"description": "NeedCaptcha 是否需要验证码",
1137+
"type": "boolean"
1138+
},
10661139
"token": {
10671140
"description": "Token 认证Token",
10681141
"type": "string",
@@ -1074,6 +1147,8 @@
10741147
"description": "用户注册请求参数",
10751148
"type": "object",
10761149
"required": [
1150+
"captcha",
1151+
"captcha_id",
10771152
"confirm_password",
10781153
"password",
10791154
"username"
@@ -1085,6 +1160,14 @@
10851160
"minLength": 8,
10861161
"example": "2016-01-02"
10871162
},
1163+
"captcha": {
1164+
"description": "Captcha 验证码",
1165+
"type": "string"
1166+
},
1167+
"captcha_id": {
1168+
"description": "CaptchaID 验证码ID, 通过调用 /api/v1/auth/captcha 获得",
1169+
"type": "string"
1170+
},
10881171
"confirm_password": {
10891172
"description": "ConfirmPassword 确认密码",
10901173
"type": "string",
@@ -1306,6 +1389,31 @@
13061389
}
13071390
}
13081391
},
1392+
"handler.GetCaptchaResponse": {
1393+
"description": "获取验证码返回数据",
1394+
"type": "object",
1395+
"required": [
1396+
"data",
1397+
"id",
1398+
"type"
1399+
],
1400+
"properties": {
1401+
"data": {
1402+
"description": "Data 验证码数据;有图片数据,也有音频数据,前端需要根据type生成对应媒体数据",
1403+
"type": "string"
1404+
},
1405+
"id": {
1406+
"description": "ID 验证码验证ID",
1407+
"type": "string",
1408+
"example": "7uh37xVCN0oGarKZ79nx"
1409+
},
1410+
"type": {
1411+
"description": "Type 验证码类型",
1412+
"type": "string",
1413+
"example": "audio"
1414+
}
1415+
}
1416+
},
13091417
"handler.JoinGroupRequest": {
13101418
"description": "入群请求参数",
13111419
"type": "object",

0 commit comments

Comments
 (0)