first
continuous-integration/drone/push Build is passing Details

master
NY 4 weeks ago
parent 6d4250f004
commit 41cb0c5832

@ -14,6 +14,15 @@ type SsoSendSmsCodeParams struct {
Mobile string `json:"mobile"` Mobile string `json:"mobile"`
} }
// SsoSendSmsCode 发送短信验证码接口
// @Summary 发送短信验证码
// @Description 该接口用于发送短信验证码,限制验证码的发送频率和每天发送的次数。
// @Tags sms
// @Accept json
// @Produce json
// @Param body body SsoSendSmsCodeParams true "发送短信验证码的请求参数"
// @Success 200 {object} dapi.ResponseCommon "短信验证码发送成功"
// @Router /api/v1/login/captcha [post]
func SsoSendSmsCode(a *dapi.ApiBase, params *SsoSendSmsCodeParams) error { func SsoSendSmsCode(a *dapi.ApiBase, params *SsoSendSmsCodeParams) error {
redisCodeKey := fmt.Sprintf("smscode:%s", params.Mobile) redisCodeKey := fmt.Sprintf("smscode:%s", params.Mobile)
redisDailyKey := fmt.Sprintf("smscode_daily:%s", params.Mobile) redisDailyKey := fmt.Sprintf("smscode_daily:%s", params.Mobile)

@ -28,7 +28,15 @@ type SsoRegisterResponse struct {
} `json:"data"` } `json:"data"`
} }
// SsoRegister 注册接口 // SsoRegister 用户注册接口
// @Summary 用户注册
// @Description 该接口用于用户通过手机号、密码、验证码等信息进行注册。如果注册成功返回用户的Token。
// @Tags register
// @Accept json
// @Produce json
// @Param body body SsoRegisterParams true "用户注册信息"
// @Success 200 {object} SsoRegisterResponse "注册成功返回Token"
// @Router /api/v1/login/register [post]
func SsoRegister(a *dapi.ApiBase, data *SsoRegisterParams) error { func SsoRegister(a *dapi.ApiBase, data *SsoRegisterParams) error {
if len(data.Mobile) == 0 { if len(data.Mobile) == 0 {
return a.ReturnPublicErrorResponse(a.Translate("mobile_required")) return a.ReturnPublicErrorResponse(a.Translate("mobile_required"))

@ -27,10 +27,9 @@ type SsoLoginResponse struct {
// @Tags login // @Tags login
// @Accept json // @Accept json
// @Produce json // @Produce json
// @Param mobile query string true "用户手机号" // @Param body body SsoLoginParams true "用户登录信息"
// @Param password query string true "用户密码"
// @Success 200 {object} SsoLoginResponse "登录成功返回Token" // @Success 200 {object} SsoLoginResponse "登录成功返回Token"
// @Router /api/v1/login/register [post] // @Router /api/v1/login/login [post]
func SsoLogin(a *dapi.ApiBase, data *SsoLoginParams) error { func SsoLogin(a *dapi.ApiBase, data *SsoLoginParams) error {
Response := SsoLoginResponse{} Response := SsoLoginResponse{}

@ -15,7 +15,41 @@ const docTemplate = `{
"host": "{{.Host}}", "host": "{{.Host}}",
"basePath": "{{.BasePath}}", "basePath": "{{.BasePath}}",
"paths": { "paths": {
"/api/v1/login/register": { "/api/v1/login/captcha": {
"post": {
"description": "该接口用于发送短信验证码,限制验证码的发送频率和每天发送的次数。",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"sms"
],
"summary": "发送短信验证码",
"parameters": [
{
"description": "发送短信验证码的请求参数",
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/login.SsoSendSmsCodeParams"
}
}
],
"responses": {
"200": {
"description": "短信验证码发送成功",
"schema": {
"$ref": "#/definitions/dapi.ResponseCommon"
}
}
}
}
},
"/api/v1/login/login": {
"post": { "post": {
"description": "该接口用于用户通过手机号和密码进行登录。如果登录失败,系统会记录错误信息并限制登录次数。", "description": "该接口用于用户通过手机号和密码进行登录。如果登录失败,系统会记录错误信息并限制登录次数。",
"consumes": [ "consumes": [
@ -30,18 +64,13 @@ const docTemplate = `{
"summary": "用户登录", "summary": "用户登录",
"parameters": [ "parameters": [
{ {
"type": "string", "description": "用户登录信息",
"description": "用户手机号", "name": "body",
"name": "mobile", "in": "body",
"in": "query", "required": true,
"required": true "schema": {
}, "$ref": "#/definitions/login.SsoLoginParams"
{ }
"type": "string",
"description": "用户密码",
"name": "password",
"in": "query",
"required": true
} }
], ],
"responses": { "responses": {
@ -53,9 +82,72 @@ const docTemplate = `{
} }
} }
} }
},
"/api/v1/login/register": {
"post": {
"description": "该接口用于用户通过手机号、密码、验证码等信息进行注册。如果注册成功返回用户的Token。",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"register"
],
"summary": "用户注册",
"parameters": [
{
"description": "用户注册信息",
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/login.SsoRegisterParams"
}
}
],
"responses": {
"200": {
"description": "注册成功返回Token",
"schema": {
"$ref": "#/definitions/login.SsoRegisterResponse"
}
}
}
}
} }
}, },
"definitions": { "definitions": {
"dapi.ResponseCommon": {
"type": "object",
"properties": {
"code": {
"description": "返回Code 200 成功 其他是失败",
"type": "integer"
},
"count": {
"description": "条数",
"type": "integer"
},
"message": {
"description": "返回信息"
}
}
},
"login.SsoLoginParams": {
"type": "object",
"properties": {
"mobile": {
"description": "登陆手机号",
"type": "string"
},
"passWord": {
"description": "密码",
"type": "string"
}
}
},
"login.SsoLoginResponse": { "login.SsoLoginResponse": {
"type": "object", "type": "object",
"properties": { "properties": {
@ -81,6 +173,63 @@ const docTemplate = `{
"description": "返回信息" "description": "返回信息"
} }
} }
},
"login.SsoRegisterParams": {
"type": "object",
"properties": {
"captcha": {
"description": "验证码",
"type": "string"
},
"email": {
"description": "邮箱(可选)",
"type": "string"
},
"invite": {
"description": "邀请码(可选)",
"type": "string"
},
"mobile": {
"description": "手机号",
"type": "string"
},
"password": {
"description": "密码",
"type": "string"
}
}
},
"login.SsoRegisterResponse": {
"type": "object",
"properties": {
"code": {
"description": "返回Code 200 成功 其他是失败",
"type": "integer"
},
"count": {
"description": "条数",
"type": "integer"
},
"data": {
"type": "object",
"properties": {
"token": {
"type": "string"
}
}
},
"message": {
"description": "返回信息"
}
}
},
"login.SsoSendSmsCodeParams": {
"type": "object",
"properties": {
"mobile": {
"type": "string"
}
}
} }
} }
}` }`

@ -4,7 +4,41 @@
"contact": {} "contact": {}
}, },
"paths": { "paths": {
"/api/v1/login/register": { "/api/v1/login/captcha": {
"post": {
"description": "该接口用于发送短信验证码,限制验证码的发送频率和每天发送的次数。",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"sms"
],
"summary": "发送短信验证码",
"parameters": [
{
"description": "发送短信验证码的请求参数",
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/login.SsoSendSmsCodeParams"
}
}
],
"responses": {
"200": {
"description": "短信验证码发送成功",
"schema": {
"$ref": "#/definitions/dapi.ResponseCommon"
}
}
}
}
},
"/api/v1/login/login": {
"post": { "post": {
"description": "该接口用于用户通过手机号和密码进行登录。如果登录失败,系统会记录错误信息并限制登录次数。", "description": "该接口用于用户通过手机号和密码进行登录。如果登录失败,系统会记录错误信息并限制登录次数。",
"consumes": [ "consumes": [
@ -19,18 +53,13 @@
"summary": "用户登录", "summary": "用户登录",
"parameters": [ "parameters": [
{ {
"type": "string", "description": "用户登录信息",
"description": "用户手机号", "name": "body",
"name": "mobile", "in": "body",
"in": "query", "required": true,
"required": true "schema": {
}, "$ref": "#/definitions/login.SsoLoginParams"
{ }
"type": "string",
"description": "用户密码",
"name": "password",
"in": "query",
"required": true
} }
], ],
"responses": { "responses": {
@ -42,9 +71,72 @@
} }
} }
} }
},
"/api/v1/login/register": {
"post": {
"description": "该接口用于用户通过手机号、密码、验证码等信息进行注册。如果注册成功返回用户的Token。",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"register"
],
"summary": "用户注册",
"parameters": [
{
"description": "用户注册信息",
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/login.SsoRegisterParams"
}
}
],
"responses": {
"200": {
"description": "注册成功返回Token",
"schema": {
"$ref": "#/definitions/login.SsoRegisterResponse"
}
}
}
}
} }
}, },
"definitions": { "definitions": {
"dapi.ResponseCommon": {
"type": "object",
"properties": {
"code": {
"description": "返回Code 200 成功 其他是失败",
"type": "integer"
},
"count": {
"description": "条数",
"type": "integer"
},
"message": {
"description": "返回信息"
}
}
},
"login.SsoLoginParams": {
"type": "object",
"properties": {
"mobile": {
"description": "登陆手机号",
"type": "string"
},
"passWord": {
"description": "密码",
"type": "string"
}
}
},
"login.SsoLoginResponse": { "login.SsoLoginResponse": {
"type": "object", "type": "object",
"properties": { "properties": {
@ -70,6 +162,63 @@
"description": "返回信息" "description": "返回信息"
} }
} }
},
"login.SsoRegisterParams": {
"type": "object",
"properties": {
"captcha": {
"description": "验证码",
"type": "string"
},
"email": {
"description": "邮箱(可选)",
"type": "string"
},
"invite": {
"description": "邀请码(可选)",
"type": "string"
},
"mobile": {
"description": "手机号",
"type": "string"
},
"password": {
"description": "密码",
"type": "string"
}
}
},
"login.SsoRegisterResponse": {
"type": "object",
"properties": {
"code": {
"description": "返回Code 200 成功 其他是失败",
"type": "integer"
},
"count": {
"description": "条数",
"type": "integer"
},
"data": {
"type": "object",
"properties": {
"token": {
"type": "string"
}
}
},
"message": {
"description": "返回信息"
}
}
},
"login.SsoSendSmsCodeParams": {
"type": "object",
"properties": {
"mobile": {
"type": "string"
}
}
} }
} }
} }

@ -1,4 +1,24 @@
definitions: definitions:
dapi.ResponseCommon:
properties:
code:
description: 返回Code 200 成功 其他是失败
type: integer
count:
description: 条数
type: integer
message:
description: 返回信息
type: object
login.SsoLoginParams:
properties:
mobile:
description: 登陆手机号
type: string
passWord:
description: 密码
type: string
type: object
login.SsoLoginResponse: login.SsoLoginResponse:
properties: properties:
code: code:
@ -17,25 +37,82 @@ definitions:
message: message:
description: 返回信息 description: 返回信息
type: object type: object
login.SsoRegisterParams:
properties:
captcha:
description: 验证码
type: string
email:
description: 邮箱(可选)
type: string
invite:
description: 邀请码(可选)
type: string
mobile:
description: 手机号
type: string
password:
description: 密码
type: string
type: object
login.SsoRegisterResponse:
properties:
code:
description: 返回Code 200 成功 其他是失败
type: integer
count:
description: 条数
type: integer
data:
properties:
token:
type: string
type: object
message:
description: 返回信息
type: object
login.SsoSendSmsCodeParams:
properties:
mobile:
type: string
type: object
info: info:
contact: {} contact: {}
paths: paths:
/api/v1/login/register: /api/v1/login/captcha:
post: post:
consumes: consumes:
- application/json - application/json
description: 该接口用于用户通过手机号和密码进行登录。如果登录失败,系统会记录错误信息并限制登录次数。 description: 该接口用于发送短信验证码,限制验证码的发送频率和每天发送的次数。
parameters: parameters:
- description: 用户手机号 - description: 发送短信验证码的请求参数
in: query in: body
name: mobile name: body
required: true required: true
type: string schema:
- description: 用户密码 $ref: '#/definitions/login.SsoSendSmsCodeParams'
in: query produces:
name: password - application/json
responses:
"200":
description: 短信验证码发送成功
schema:
$ref: '#/definitions/dapi.ResponseCommon'
summary: 发送短信验证码
tags:
- sms
/api/v1/login/login:
post:
consumes:
- application/json
description: 该接口用于用户通过手机号和密码进行登录。如果登录失败,系统会记录错误信息并限制登录次数。
parameters:
- description: 用户登录信息
in: body
name: body
required: true required: true
type: string schema:
$ref: '#/definitions/login.SsoLoginParams'
produces: produces:
- application/json - application/json
responses: responses:
@ -46,4 +123,26 @@ paths:
summary: 用户登录 summary: 用户登录
tags: tags:
- login - login
/api/v1/login/register:
post:
consumes:
- application/json
description: 该接口用于用户通过手机号、密码、验证码等信息进行注册。如果注册成功返回用户的Token。
parameters:
- description: 用户注册信息
in: body
name: body
required: true
schema:
$ref: '#/definitions/login.SsoRegisterParams'
produces:
- application/json
responses:
"200":
description: 注册成功返回Token
schema:
$ref: '#/definitions/login.SsoRegisterResponse'
summary: 用户注册
tags:
- register
swagger: "2.0" swagger: "2.0"

Loading…
Cancel
Save