feat: swagger
This commit is contained in:
+22
-4
@@ -17,7 +17,14 @@ var store = base64Captcha.DefaultMemStore
|
||||
|
||||
type AuthApi struct{}
|
||||
|
||||
// Login api
|
||||
// Login
|
||||
// @Tags 登录相关
|
||||
// @Summary pc登录
|
||||
// @accept application/json
|
||||
// @Produce application/json
|
||||
// @Param data body systemReq.Login true "用户名, 密码, 验证码,验证码id"
|
||||
// @Success 200 {object} response.Response{msg=string} "登录成功"
|
||||
// @Router /api/auth/login [post]
|
||||
func (a *AuthApi) Login(c *gin.Context) {
|
||||
var l systemReq.Login
|
||||
err := c.ShouldBindJSON(&l)
|
||||
@@ -39,7 +46,13 @@ func (a *AuthApi) Login(c *gin.Context) {
|
||||
response.FailWithMsg("验证码错误", c)
|
||||
}
|
||||
|
||||
// 登出
|
||||
// Logout
|
||||
// @Tags 登录相关
|
||||
// @Summary pc登出
|
||||
// @Security ApiKeyAuth
|
||||
// @Produce application/json
|
||||
// @Success 200 {object} response.Response{msg=string} "登出成功"
|
||||
// @Router /api/auth/logout [get]
|
||||
func (a *AuthApi) Logout(c *gin.Context) {
|
||||
token := jwt.GetToken(c)
|
||||
userId := jwt.GetUserId(c)
|
||||
@@ -54,7 +67,12 @@ func (a *AuthApi) Logout(c *gin.Context) {
|
||||
|
||||
}
|
||||
|
||||
// Captcha api 生成验证码
|
||||
// Captcha
|
||||
// @Tags 登录相关
|
||||
// @Summary 获取验证码
|
||||
// @Produce application/json
|
||||
// @Success 200 {object} response.Response{data=systemRes.CaptchaRes} "获取验证码"
|
||||
// @Router /api/auth/captcha [get]
|
||||
func (u *AuthApi) Captcha(c *gin.Context) {
|
||||
var driver = base64Captcha.DriverString{
|
||||
Height: 80,
|
||||
@@ -62,7 +80,7 @@ func (u *AuthApi) Captcha(c *gin.Context) {
|
||||
NoiseCount: 2,
|
||||
ShowLineOptions: 4,
|
||||
Length: 4,
|
||||
Source: "1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM",
|
||||
Source: "1234567890",
|
||||
}
|
||||
|
||||
cp := base64Captcha.NewCaptcha(&driver, store)
|
||||
|
||||
Reference in New Issue
Block a user