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"`
}
// 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 {
redisCodeKey := fmt.Sprintf("smscode:%s", params.Mobile)
redisDailyKey := fmt.Sprintf("smscode_daily:%s", params.Mobile)

@ -28,7 +28,15 @@ type SsoRegisterResponse struct {
} `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 {
if len(data.Mobile) == 0 {
return a.ReturnPublicErrorResponse(a.Translate("mobile_required"))

@ -27,10 +27,9 @@ type SsoLoginResponse struct {
// @Tags login
// @Accept json
// @Produce json
// @Param mobile query string true "用户手机号"
// @Param password query string true "用户密码"
// @Param body body SsoLoginParams true "用户登录信息"
// @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 {
Response := SsoLoginResponse{}

@ -15,7 +15,41 @@ const docTemplate = `{
"host": "{{.Host}}",
"basePath": "{{.BasePath}}",
"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": {
"description": "该接口用于用户通过手机号和密码进行登录。如果登录失败,系统会记录错误信息并限制登录次数。",
"consumes": [
@ -30,18 +64,13 @@ const docTemplate = `{
"summary": "用户登录",
"parameters": [
{
"type": "string",
"description": "用户手机号",
"name": "mobile",
"in": "query",
"required": true
},
{
"type": "string",
"description": "用户密码",
"name": "password",
"in": "query",
"required": true
"description": "用户登录信息",
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/login.SsoLoginParams"
}
}
],
"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": {
"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": {
"type": "object",
"properties": {
@ -81,6 +173,63 @@ const docTemplate = `{
"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": {}
},
"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": {
"description": "该接口用于用户通过手机号和密码进行登录。如果登录失败,系统会记录错误信息并限制登录次数。",
"consumes": [
@ -19,18 +53,13 @@
"summary": "用户登录",
"parameters": [
{
"type": "string",
"description": "用户手机号",
"name": "mobile",
"in": "query",
"required": true
},
{
"type": "string",
"description": "用户密码",
"name": "password",
"in": "query",
"required": true
"description": "用户登录信息",
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/login.SsoLoginParams"
}
}
],
"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": {
"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": {
"type": "object",
"properties": {
@ -70,6 +162,63 @@
"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:
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:
properties:
code:
@ -17,25 +37,82 @@ definitions:
message:
description: 返回信息
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:
contact: {}
paths:
/api/v1/login/register:
/api/v1/login/captcha:
post:
consumes:
- application/json
description: 该接口用于用户通过手机号和密码进行登录。如果登录失败,系统会记录错误信息并限制登录次数。
description: 该接口用于发送短信验证码,限制验证码的发送频率和每天发送的次数。
parameters:
- description: 用户手机号
in: query
name: mobile
- description: 发送短信验证码的请求参数
in: body
name: body
required: true
type: string
- description: 用户密码
in: query
name: password
schema:
$ref: '#/definitions/login.SsoSendSmsCodeParams'
produces:
- 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
type: string
schema:
$ref: '#/definitions/login.SsoLoginParams'
produces:
- application/json
responses:
@ -46,4 +123,26 @@ paths:
summary: 用户登录
tags:
- 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"

Loading…
Cancel
Save