diff --git a/api/captcha_api/captcha_api.go b/api/captcha_api/captcha_api.go index 705d0e2..adba39f 100644 --- a/api/captcha_api/captcha_api.go +++ b/api/captcha_api/captcha_api.go @@ -228,9 +228,9 @@ func (CaptchaAPI) GenerateClickShapeCaptcha(c *gin.Context) { result.OkWithData(bt, c) } -// GenerateSlideBasicCaptData 验证点击形状验证码 -// @Summary 验证点击形状验证码 -// @Description 验证点击形状验证码 +// GenerateSlideBasicCaptData 生成点击形状基础验证码 +// @Summary 生成点击形状基础验证码 +// @Description 生成点击形状基础验证码 // @Tags 点击形状验证码 // @Success 200 {string} json // @Router /api/captcha/shape/check [get] @@ -315,9 +315,9 @@ func (CaptchaAPI) CheckSlideData(c *gin.Context) { result.FailWithMessage("fail", c) } -// GenerateSlideRegionCaptData 验证点击形状验证码 -// @Summary 验证点击形状验证码 -// @Description 验证点击形状验证码 +// GenerateSlideRegionCaptData 生成点击形状验证码 +// @Summary 生成点击形状验证码 +// @Description 生成点击形状验证码 // @Tags 点击形状验证码 // @Success 200 {string} json // @Router /api/captcha/shape/slide/region/get [get] diff --git a/api/oauth_api/gitee_api.go b/api/oauth_api/gitee_api.go index 542ab84..b6c2dbb 100644 --- a/api/oauth_api/gitee_api.go +++ b/api/oauth_api/gitee_api.go @@ -52,7 +52,7 @@ type GiteeUser struct { // GetGiteeRedirectUrl 获取Gitee登录地址 // @Summary 获取Gitee登录地址 // @Description 获取Gitee登录地址 -// @Tags OAuth +// @Tags Gitee OAuth // @Produce json // @Success 200 {string} string "登录地址" // @Router /api/oauth/gitee/get_url [get] @@ -131,7 +131,7 @@ func GetGiteeUserInfo(token *Token) (map[string]interface{}, error) { // GiteeCallback 处理Gitee回调 // @Summary 处理Gitee回调 // @Description 处理Gitee回调 -// @Tags OAuth +// @Tags Gitee OAuth // @Produce json // @Router /api/oauth/gitee/callback [get] func (OAuthAPI) GiteeCallback(c *gin.Context) { diff --git a/api/oauth_api/github_api.go b/api/oauth_api/github_api.go index a2a4099..592607e 100644 --- a/api/oauth_api/github_api.go +++ b/api/oauth_api/github_api.go @@ -55,7 +55,7 @@ type GitHubUser struct { // GetRedirectUrl 获取github登录url // @Summary 获取github登录url // @Description 获取github登录url -// @Tags OAuth +// @Tags Github OAuth // @Produce json // @Success 200 {string} string "登录url" // @Router /api/oauth/github/get_url [get] @@ -135,7 +135,7 @@ func GetUserInfo(token *Token) (map[string]interface{}, error) { // Callback 登录回调函数 // @Summary 登录回调函数 // @Description 登录回调函数 -// @Tags OAuth +// @Tags Github OAuth // @Produce json // @Param code query string true "code" // @Success 200 {string} string "登录成功" diff --git a/api/oauth_api/qq_api.go b/api/oauth_api/qq_api.go index bc20967..129725b 100644 --- a/api/oauth_api/qq_api.go +++ b/api/oauth_api/qq_api.go @@ -52,7 +52,7 @@ type QQUserInfo struct { // GetQQRedirectUrl 获取登录地址 // @Summary 获取QQ登录地址 // @Description 获取QQ登录地址 -// @Tags 登录 +// @Tags QQ OAuth // @Produce json // @Success 200 {string} string "登录地址" // @Router /api/oauth/qq/get_url [get] @@ -162,7 +162,7 @@ func GetQQUserUserInfo(token *QQToken, openId string) (map[string]interface{}, e // QQCallback QQ登录回调 // @Summary QQ登录回调 // @Description QQ登录回调 -// @Tags 登录 +// @Tags QQ OAuth // @Produce json // @Router /api/oauth/qq/callback [get] func (OAuthAPI) QQCallback(c *gin.Context) { diff --git a/api/oauth_api/wechat_api.go b/api/oauth_api/wechat_api.go index a527ba5..b9b4d27 100644 --- a/api/oauth_api/wechat_api.go +++ b/api/oauth_api/wechat_api.go @@ -32,34 +32,40 @@ import ( // GenerateClientId 生成客户端ID // @Summary 生成客户端ID // @Description 生成客户端ID +// @Tags 微信公众号 // @Produce json // @Router /api/oauth/generate_client_id [get] func (OAuthAPI) GenerateClientId(c *gin.Context) { - // 尝试从 X-Real-IP 头部获取真实 IP + // 获取客户端IP ip := c.GetHeader("X-Real-IP") - - // 如果 X-Real-IP 头部不存在,则尝试从 X-Forwarded-For 头部获取 if ip == "" { ip = c.GetHeader("X-Forwarded-For") } - // 如果两者都不存在,则使用默认的 ClientIP 方法获取 IP if ip == "" { ip = c.ClientIP() } + + // 从Redis获取客户端ID clientId := redis.Get(constant.UserLoginClientRedisKey + ip).Val() if clientId != "" { result.OkWithData(clientId, c) return } + + // 生成新的客户端ID v1 := uuid.NewV1() - redis.Set(constant.UserLoginClientRedisKey+ip, v1.String(), 0) + err := redis.Set(constant.UserLoginClientRedisKey+ip, v1.String(), 0).Err() + if err != nil { + global.LOG.Error(err) + return + } result.OkWithData(v1.String(), c) - return } -// CallbackNotify 微信回调验证 -// @Summary 微信回调验证 -// @Description 微信回调验证 +// CallbackNotify 微信回调 +// @Summary 微信回调 +// @Tags 微信公众号 +// @Description 微信回调 // @Produce json // @Router /api/oauth/callback_notify [POST] func (OAuthAPI) CallbackNotify(c *gin.Context) { @@ -132,6 +138,7 @@ func (OAuthAPI) CallbackNotify(c *gin.Context) { // CallbackVerify 微信回调验证 // @Summary 微信回调验证 +// @Tags 微信公众号 // @Description 微信回调验证 // @Produce json // @Router /api/oauth/callback_verify [get] @@ -145,20 +152,18 @@ func (OAuthAPI) CallbackVerify(c *gin.Context) { // GetTempQrCode 获取临时二维码 // @Summary 获取临时二维码 +// @Tags 微信公众号 // @Description 获取临时二维码 // @Produce json // @Param client_id query string true "客户端ID" // @Router /api/oauth/get_temp_qrcode [get] func (OAuthAPI) GetTempQrCode(c *gin.Context) { clientId := c.Query("client_id") - // 尝试从 X-Real-IP 头部获取真实 IP + // 获取客户端IP ip := c.GetHeader("X-Real-IP") - - // 如果 X-Real-IP 头部不存在,则尝试从 X-Forwarded-For 头部获取 if ip == "" { ip = c.GetHeader("X-Forwarded-For") } - // 如果两者都不存在,则使用默认的 ClientIP 方法获取 IP if ip == "" { ip = c.ClientIP() } diff --git a/api/sms_api/sms_api.go b/api/sms_api/sms_api.go index 8ce8817..c567a2f 100644 --- a/api/sms_api/sms_api.go +++ b/api/sms_api/sms_api.go @@ -28,6 +28,16 @@ func (SmsAPI) SendMessageByAli(c *gin.Context) { result.FailWithMessage(ginI18n.MustGetMessage(c, "PhoneNotEmpty"), c) return } + isPhone := utils.IsPhone(phone) + if !isPhone { + result.FailWithMessage(ginI18n.MustGetMessage(c, "PhoneErrorFormat"), c) + return + } + val := redis.Get(constant.UserLoginSmsRedisKey + phone).Val() + if val != "" { + result.FailWithMessage(ginI18n.MustGetMessage(c, "CaptchaTooOften"), c) + return + } sms := gosms.NewParser(gateways.Gateways{ ALiYun: aliyun.ALiYun{ Host: global.CONFIG.SMS.Ali.Host, @@ -36,6 +46,11 @@ func (SmsAPI) SendMessageByAli(c *gin.Context) { }, }) code := utils.GenValidateCode(6) + wrong := redis.Set(constant.UserLoginSmsRedisKey+phone, code, time.Minute).Err() + if wrong != nil { + global.LOG.Error(wrong) + return + } _, err := sms.Send(phone, gosms.MapStringAny{ "content": "您的验证码是:****。请不要把验证码泄露给其他人。", "template": global.CONFIG.SMS.Ali.TemplateID, @@ -55,7 +70,7 @@ func (SmsAPI) SendMessageByAli(c *gin.Context) { // SendMessageBySmsBao 短信宝发送短信验证码 // @Summary 短信宝发送短信验证码 -// @Description 发送短信验证码 +// @Description 短信宝发送短信验证码 // @Tags 短信验证码 // @Produce json // @Param phone query string true "手机号" @@ -66,6 +81,16 @@ func (SmsAPI) SendMessageBySmsBao(c *gin.Context) { result.FailWithMessage(ginI18n.MustGetMessage(c, "PhoneNotEmpty"), c) return } + isPhone := utils.IsPhone(phone) + if !isPhone { + result.FailWithMessage(ginI18n.MustGetMessage(c, "PhoneErrorFormat"), c) + return + } + val := redis.Get(constant.UserLoginSmsRedisKey + phone).Val() + if val != "" { + result.FailWithMessage(ginI18n.MustGetMessage(c, "CaptchaTooOften"), c) + return + } sms := gosms.NewParser(gateways.Gateways{ SmsBao: smsbao.SmsBao{ User: global.CONFIG.SMS.SmsBao.User, @@ -73,6 +98,11 @@ func (SmsAPI) SendMessageBySmsBao(c *gin.Context) { }, }) code := utils.GenValidateCode(6) + wrong := redis.Set(constant.UserLoginSmsRedisKey+phone, code, time.Minute).Err() + if wrong != nil { + global.LOG.Error(wrong) + return + } _, err := sms.Send(phone, gosms.MapStringAny{ "content": "您的验证码是:" + code + "。请不要把验证码泄露给其他人。", }, nil) diff --git a/api/user_api/user_api.go b/api/user_api/user_api.go index 26dd9cd..5665a6a 100644 --- a/api/user_api/user_api.go +++ b/api/user_api/user_api.go @@ -27,7 +27,7 @@ var roleService = service.Service.RoleService // GetUserList // @Summary 获取所有用户列表 -// @Tags 鉴权模块 +// @Tags 用户模块 // @Success 200 {string} json // @Router /api/auth/user/List [get] func (UserAPI) GetUserList(c *gin.Context) { @@ -37,7 +37,7 @@ func (UserAPI) GetUserList(c *gin.Context) { // QueryUserByUsername // @Summary 根据用户名查询用户 -// @Tags 鉴权模块 +// @Tags 用户模块 // @Param username query string true "用户名" // @Success 200 {string} json // @Router /api/auth/user/query_by_username [get] @@ -53,7 +53,7 @@ func (UserAPI) QueryUserByUsername(c *gin.Context) { // QueryUserByUuid // @Summary 根据uuid查询用户 -// @Tags 鉴权模块 +// @Tags 用户模块 // @Param uuid query string true "用户uuid" // @Success 200 {string} json // @Router /api/auth/user/query_by_uuid [get] @@ -73,7 +73,7 @@ func (UserAPI) QueryUserByUuid(c *gin.Context) { // DeleteUser 删除用户 // @Summary 删除用户 -// @Tags 鉴权模块 +// @Tags 用户模块 // @Param uuid query string true "用户uuid" // @Success 200 {string} json // @Router /api/auth/user/delete [delete] @@ -89,7 +89,7 @@ func (UserAPI) DeleteUser(c *gin.Context) { // QueryUserByPhone 根据手机号查询用户 // @Summary 根据手机号查询用户 -// @Tags 鉴权模块 +// @Tags 用户模块 // @Param phone query string true "手机号" // @Success 200 {string} json // @Router /api/auth/user/query_by_phone [get] @@ -105,7 +105,7 @@ func (UserAPI) QueryUserByPhone(c *gin.Context) { // AddUser 添加用户 // @Summary 添加用户 -// @Tags 鉴权模块 +// @Tags 用户模块 // @Param user body dto.AddUserRequest true "用户信息" // @Success 200 {string} json // @Router /api/user/add [post] @@ -161,7 +161,7 @@ func (UserAPI) AddUser(c *gin.Context) { // AccountLogin 账号登录 // @Summary 账号登录 -// @Tags 鉴权模块 +// @Tags 用户模块 // @Param user body dto.AccountLoginRequest true "用户信息" // @Success 200 {string} json // @Router /api/user/login [post] @@ -235,9 +235,8 @@ func (UserAPI) AccountLogin(c *gin.Context) { // PhoneLogin 手机号登录/注册 // @Summary 手机号登录/注册 -// @Tags 鉴权模块 -// @Param phone query string true "手机号" -// @Param captcha query string true "验证码" +// @Tags 用户模块 +// @Param user body dto.PhoneLoginRequest true "用户信息" // @Success 200 {string} json // @Router /api/user/phone_login [post] func (UserAPI) PhoneLogin(c *gin.Context) { @@ -311,7 +310,7 @@ func (UserAPI) PhoneLogin(c *gin.Context) { // RefreshHandler 刷新token // @Summary 刷新token -// @Tags 鉴权模块 +// @Tags 用户模块 // @Param refresh_token query string true "刷新token" // @Success 200 {string} json // @Router /api/token/refresh [post] @@ -427,7 +426,7 @@ func handelUserLogin(user model.ScaAuthUser, autoLogin bool, c *gin.Context) { // ResetPassword 重置密码 // @Summary 重置密码 -// @Tags 鉴权模块 +// @Tags 用户模块 // @Param user body dto.ResetPasswordRequest true "用户信息" // @Success 200 {string} json // @Router /api/user/reset_password [post] diff --git a/api/websocket_api/gws_api.go b/api/websocket_api/gws_api.go index eb63658..6d31ce6 100644 --- a/api/websocket_api/gws_api.go +++ b/api/websocket_api/gws_api.go @@ -16,6 +16,11 @@ const ( var Handler = NewWebSocket() +// NewGWSServer 创建websocket服务 +// @Summary 创建websocket服务 +// @Description 创建websocket服务 +// @Tags websocket +// @Router /api/ws/gws [get] func (WebsocketAPI) NewGWSServer(c *gin.Context) { upgrader := gws.NewUpgrader(Handler, &gws.ServerOption{ diff --git a/api/websocket_api/websocket_api.go b/api/websocket_api/websocket_api.go index 8cb622e..7ec75b7 100644 --- a/api/websocket_api/websocket_api.go +++ b/api/websocket_api/websocket_api.go @@ -20,7 +20,11 @@ var ( mux sync.Mutex ) -// NewSocketClient 建立websocket长链接接口处理函数 +// NewSocketClient 创建websocket服务 +// @Summary 创建websocket服务(gorilla) +// @Description 创建websocket服务 +// @Tags websocket +// @Router /api/ws/socket [get] func (WebsocketAPI) NewSocketClient(context *gin.Context) { id := context.Query("client_id") global.LOG.Println(id + "websocket链接") diff --git a/config/conf_swagger.go b/config/conf_swagger.go new file mode 100644 index 0000000..fe84eb6 --- /dev/null +++ b/config/conf_swagger.go @@ -0,0 +1,9 @@ +package config + +type Swagger struct { + Enabled bool `yaml:"enable"` + Title string `yaml:"title"` + Description string `yaml:"description"` + User string `yaml:"user"` + Password string `yaml:"password"` +} diff --git a/config/config.go b/config/config.go index f22c002..f8abe11 100644 --- a/config/config.go +++ b/config/config.go @@ -10,4 +10,5 @@ type Config struct { Encrypt Encrypt `yaml:"encrypt"` Wechat Wechat `yaml:"wechat"` OAuth OAuth `yaml:"oauth"` + Swagger Swagger `yaml:"swagger"` } diff --git a/docs/docs.go b/docs/docs.go index 3a23185..e744526 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -18,7 +18,7 @@ const docTemplate = `{ "/api/auth/user/List": { "get": { "tags": [ - "鉴权模块" + "用户模块" ], "summary": "获取所有用户列表", "responses": { @@ -34,7 +34,7 @@ const docTemplate = `{ "/api/auth/user/delete": { "delete": { "tags": [ - "鉴权模块" + "用户模块" ], "summary": "删除用户", "parameters": [ @@ -59,7 +59,7 @@ const docTemplate = `{ "/api/auth/user/query_by_phone": { "get": { "tags": [ - "鉴权模块" + "用户模块" ], "summary": "根据手机号查询用户", "parameters": [ @@ -84,7 +84,7 @@ const docTemplate = `{ "/api/auth/user/query_by_username": { "get": { "tags": [ - "鉴权模块" + "用户模块" ], "summary": "根据用户名查询用户", "parameters": [ @@ -109,7 +109,7 @@ const docTemplate = `{ "/api/auth/user/query_by_uuid": { "get": { "tags": [ - "鉴权模块" + "用户模块" ], "summary": "根据uuid查询用户", "parameters": [ @@ -183,11 +183,11 @@ const docTemplate = `{ }, "/api/captcha/shape/check": { "get": { - "description": "验证点击形状验证码", + "description": "生成点击形状基础验证码", "tags": [ "点击形状验证码" ], - "summary": "验证点击形状验证码", + "summary": "生成点击形状基础验证码", "responses": { "200": { "description": "OK", @@ -250,11 +250,11 @@ const docTemplate = `{ }, "/api/captcha/shape/slide/region/get": { "get": { - "description": "验证点击形状验证码", + "description": "生成点击形状验证码", "tags": [ "点击形状验证码" ], - "summary": "验证点击形状验证码", + "summary": "生成点击形状验证码", "responses": { "200": { "description": "OK", @@ -326,11 +326,14 @@ const docTemplate = `{ }, "/api/oauth/callback_notify": { "post": { - "description": "微信回调验证", + "description": "微信回调", "produces": [ "application/json" ], - "summary": "微信回调验证", + "tags": [ + "微信公众号" + ], + "summary": "微信回调", "responses": {} } }, @@ -340,6 +343,9 @@ const docTemplate = `{ "produces": [ "application/json" ], + "tags": [ + "微信公众号" + ], "summary": "微信回调验证", "responses": {} } @@ -350,6 +356,9 @@ const docTemplate = `{ "produces": [ "application/json" ], + "tags": [ + "微信公众号" + ], "summary": "生成客户端ID", "responses": {} } @@ -360,6 +369,9 @@ const docTemplate = `{ "produces": [ "application/json" ], + "tags": [ + "微信公众号" + ], "summary": "获取临时二维码", "parameters": [ { @@ -380,7 +392,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "OAuth" + "Gitee OAuth" ], "summary": "处理Gitee回调", "responses": {} @@ -393,7 +405,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "OAuth" + "Gitee OAuth" ], "summary": "获取Gitee登录地址", "responses": { @@ -413,7 +425,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "OAuth" + "Github OAuth" ], "summary": "登录回调函数", "parameters": [ @@ -442,7 +454,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "OAuth" + "Github OAuth" ], "summary": "获取github登录url", "responses": { @@ -462,7 +474,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "登录" + "QQ OAuth" ], "summary": "QQ登录回调", "responses": {} @@ -475,7 +487,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "登录" + "QQ OAuth" ], "summary": "获取QQ登录地址", "responses": { @@ -512,7 +524,7 @@ const docTemplate = `{ }, "/api/sms/smsbao/send": { "get": { - "description": "发送短信验证码", + "description": "短信宝发送短信验证码", "produces": [ "application/json" ], @@ -557,7 +569,7 @@ const docTemplate = `{ "/api/token/refresh": { "post": { "tags": [ - "鉴权模块" + "用户模块" ], "summary": "刷新token", "parameters": [ @@ -582,7 +594,7 @@ const docTemplate = `{ "/api/user/add": { "post": { "tags": [ - "鉴权模块" + "用户模块" ], "summary": "添加用户", "parameters": [ @@ -609,7 +621,7 @@ const docTemplate = `{ "/api/user/login": { "post": { "tags": [ - "鉴权模块" + "用户模块" ], "summary": "账号登录", "parameters": [ @@ -636,23 +648,18 @@ const docTemplate = `{ "/api/user/phone_login": { "post": { "tags": [ - "鉴权模块" + "用户模块" ], "summary": "手机号登录/注册", "parameters": [ { - "type": "string", - "description": "手机号", - "name": "phone", - "in": "query", - "required": true - }, - { - "type": "string", - "description": "验证码", - "name": "captcha", - "in": "query", - "required": true + "description": "用户信息", + "name": "user", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.PhoneLoginRequest" + } } ], "responses": { @@ -668,7 +675,7 @@ const docTemplate = `{ "/api/user/reset_password": { "post": { "tags": [ - "鉴权模块" + "用户模块" ], "summary": "重置密码", "parameters": [ @@ -691,6 +698,26 @@ const docTemplate = `{ } } } + }, + "/api/ws/gws": { + "get": { + "description": "创建websocket服务", + "tags": [ + "websocket" + ], + "summary": "创建websocket服务", + "responses": {} + } + }, + "/api/ws/socket": { + "get": { + "description": "创建websocket服务", + "tags": [ + "websocket" + ], + "summary": "创建websocket服务(gorilla)", + "responses": {} + } } }, "definitions": { @@ -700,6 +727,9 @@ const docTemplate = `{ "account": { "type": "string" }, + "auto_login": { + "type": "boolean" + }, "password": { "type": "string" } @@ -719,6 +749,20 @@ const docTemplate = `{ } } }, + "dto.PhoneLoginRequest": { + "type": "object", + "properties": { + "auto_login": { + "type": "boolean" + }, + "captcha": { + "type": "string" + }, + "phone": { + "type": "string" + } + } + }, "dto.ResetPasswordRequest": { "type": "object", "properties": { diff --git a/docs/swagger.json b/docs/swagger.json index 4d18633..0c483c2 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -7,7 +7,7 @@ "/api/auth/user/List": { "get": { "tags": [ - "鉴权模块" + "用户模块" ], "summary": "获取所有用户列表", "responses": { @@ -23,7 +23,7 @@ "/api/auth/user/delete": { "delete": { "tags": [ - "鉴权模块" + "用户模块" ], "summary": "删除用户", "parameters": [ @@ -48,7 +48,7 @@ "/api/auth/user/query_by_phone": { "get": { "tags": [ - "鉴权模块" + "用户模块" ], "summary": "根据手机号查询用户", "parameters": [ @@ -73,7 +73,7 @@ "/api/auth/user/query_by_username": { "get": { "tags": [ - "鉴权模块" + "用户模块" ], "summary": "根据用户名查询用户", "parameters": [ @@ -98,7 +98,7 @@ "/api/auth/user/query_by_uuid": { "get": { "tags": [ - "鉴权模块" + "用户模块" ], "summary": "根据uuid查询用户", "parameters": [ @@ -172,11 +172,11 @@ }, "/api/captcha/shape/check": { "get": { - "description": "验证点击形状验证码", + "description": "生成点击形状基础验证码", "tags": [ "点击形状验证码" ], - "summary": "验证点击形状验证码", + "summary": "生成点击形状基础验证码", "responses": { "200": { "description": "OK", @@ -239,11 +239,11 @@ }, "/api/captcha/shape/slide/region/get": { "get": { - "description": "验证点击形状验证码", + "description": "生成点击形状验证码", "tags": [ "点击形状验证码" ], - "summary": "验证点击形状验证码", + "summary": "生成点击形状验证码", "responses": { "200": { "description": "OK", @@ -315,11 +315,14 @@ }, "/api/oauth/callback_notify": { "post": { - "description": "微信回调验证", + "description": "微信回调", "produces": [ "application/json" ], - "summary": "微信回调验证", + "tags": [ + "微信公众号" + ], + "summary": "微信回调", "responses": {} } }, @@ -329,6 +332,9 @@ "produces": [ "application/json" ], + "tags": [ + "微信公众号" + ], "summary": "微信回调验证", "responses": {} } @@ -339,6 +345,9 @@ "produces": [ "application/json" ], + "tags": [ + "微信公众号" + ], "summary": "生成客户端ID", "responses": {} } @@ -349,6 +358,9 @@ "produces": [ "application/json" ], + "tags": [ + "微信公众号" + ], "summary": "获取临时二维码", "parameters": [ { @@ -369,7 +381,7 @@ "application/json" ], "tags": [ - "OAuth" + "Gitee OAuth" ], "summary": "处理Gitee回调", "responses": {} @@ -382,7 +394,7 @@ "application/json" ], "tags": [ - "OAuth" + "Gitee OAuth" ], "summary": "获取Gitee登录地址", "responses": { @@ -402,7 +414,7 @@ "application/json" ], "tags": [ - "OAuth" + "Github OAuth" ], "summary": "登录回调函数", "parameters": [ @@ -431,7 +443,7 @@ "application/json" ], "tags": [ - "OAuth" + "Github OAuth" ], "summary": "获取github登录url", "responses": { @@ -451,7 +463,7 @@ "application/json" ], "tags": [ - "登录" + "QQ OAuth" ], "summary": "QQ登录回调", "responses": {} @@ -464,7 +476,7 @@ "application/json" ], "tags": [ - "登录" + "QQ OAuth" ], "summary": "获取QQ登录地址", "responses": { @@ -501,7 +513,7 @@ }, "/api/sms/smsbao/send": { "get": { - "description": "发送短信验证码", + "description": "短信宝发送短信验证码", "produces": [ "application/json" ], @@ -546,7 +558,7 @@ "/api/token/refresh": { "post": { "tags": [ - "鉴权模块" + "用户模块" ], "summary": "刷新token", "parameters": [ @@ -571,7 +583,7 @@ "/api/user/add": { "post": { "tags": [ - "鉴权模块" + "用户模块" ], "summary": "添加用户", "parameters": [ @@ -598,7 +610,7 @@ "/api/user/login": { "post": { "tags": [ - "鉴权模块" + "用户模块" ], "summary": "账号登录", "parameters": [ @@ -625,23 +637,18 @@ "/api/user/phone_login": { "post": { "tags": [ - "鉴权模块" + "用户模块" ], "summary": "手机号登录/注册", "parameters": [ { - "type": "string", - "description": "手机号", - "name": "phone", - "in": "query", - "required": true - }, - { - "type": "string", - "description": "验证码", - "name": "captcha", - "in": "query", - "required": true + "description": "用户信息", + "name": "user", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.PhoneLoginRequest" + } } ], "responses": { @@ -657,7 +664,7 @@ "/api/user/reset_password": { "post": { "tags": [ - "鉴权模块" + "用户模块" ], "summary": "重置密码", "parameters": [ @@ -680,6 +687,26 @@ } } } + }, + "/api/ws/gws": { + "get": { + "description": "创建websocket服务", + "tags": [ + "websocket" + ], + "summary": "创建websocket服务", + "responses": {} + } + }, + "/api/ws/socket": { + "get": { + "description": "创建websocket服务", + "tags": [ + "websocket" + ], + "summary": "创建websocket服务(gorilla)", + "responses": {} + } } }, "definitions": { @@ -689,6 +716,9 @@ "account": { "type": "string" }, + "auto_login": { + "type": "boolean" + }, "password": { "type": "string" } @@ -708,6 +738,20 @@ } } }, + "dto.PhoneLoginRequest": { + "type": "object", + "properties": { + "auto_login": { + "type": "boolean" + }, + "captcha": { + "type": "string" + }, + "phone": { + "type": "string" + } + } + }, "dto.ResetPasswordRequest": { "type": "object", "properties": { diff --git a/docs/swagger.yaml b/docs/swagger.yaml index d6c0cc7..24992c3 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -3,6 +3,8 @@ definitions: properties: account: type: string + auto_login: + type: boolean password: type: string type: object @@ -15,6 +17,15 @@ definitions: username: type: string type: object + dto.PhoneLoginRequest: + properties: + auto_login: + type: boolean + captcha: + type: string + phone: + type: string + type: object dto.ResetPasswordRequest: properties: captcha: @@ -38,7 +49,7 @@ paths: type: string summary: 获取所有用户列表 tags: - - 鉴权模块 + - 用户模块 /api/auth/user/delete: delete: parameters: @@ -54,7 +65,7 @@ paths: type: string summary: 删除用户 tags: - - 鉴权模块 + - 用户模块 /api/auth/user/query_by_phone: get: parameters: @@ -70,7 +81,7 @@ paths: type: string summary: 根据手机号查询用户 tags: - - 鉴权模块 + - 用户模块 /api/auth/user/query_by_username: get: parameters: @@ -86,7 +97,7 @@ paths: type: string summary: 根据用户名查询用户 tags: - - 鉴权模块 + - 用户模块 /api/auth/user/query_by_uuid: get: parameters: @@ -102,7 +113,7 @@ paths: type: string summary: 根据uuid查询用户 tags: - - 鉴权模块 + - 用户模块 /api/captcha/rotate/check: post: description: 验证旋转验证码 @@ -138,13 +149,13 @@ paths: - 旋转验证码 /api/captcha/shape/check: get: - description: 验证点击形状验证码 + description: 生成点击形状基础验证码 responses: "200": description: OK schema: type: string - summary: 验证点击形状验证码 + summary: 生成点击形状基础验证码 tags: - 点击形状验证码 /api/captcha/shape/get: @@ -182,13 +193,13 @@ paths: - 点击形状验证码 /api/captcha/shape/slide/region/get: get: - description: 验证点击形状验证码 + description: 生成点击形状验证码 responses: "200": description: OK schema: type: string - summary: 验证点击形状验证码 + summary: 生成点击形状验证码 tags: - 点击形状验证码 /api/captcha/text/check: @@ -232,11 +243,13 @@ paths: - 基础文字验证码 /api/oauth/callback_notify: post: - description: 微信回调验证 + description: 微信回调 produces: - application/json responses: {} - summary: 微信回调验证 + summary: 微信回调 + tags: + - 微信公众号 /api/oauth/callback_verify: get: description: 微信回调验证 @@ -244,6 +257,8 @@ paths: - application/json responses: {} summary: 微信回调验证 + tags: + - 微信公众号 /api/oauth/generate_client_id: get: description: 生成客户端ID @@ -251,6 +266,8 @@ paths: - application/json responses: {} summary: 生成客户端ID + tags: + - 微信公众号 /api/oauth/get_temp_qrcode: get: description: 获取临时二维码 @@ -264,6 +281,8 @@ paths: - application/json responses: {} summary: 获取临时二维码 + tags: + - 微信公众号 /api/oauth/gitee/callback: get: description: 处理Gitee回调 @@ -272,7 +291,7 @@ paths: responses: {} summary: 处理Gitee回调 tags: - - OAuth + - Gitee OAuth /api/oauth/gitee/get_url: get: description: 获取Gitee登录地址 @@ -285,7 +304,7 @@ paths: type: string summary: 获取Gitee登录地址 tags: - - OAuth + - Gitee OAuth /api/oauth/github/callback: get: description: 登录回调函数 @@ -304,7 +323,7 @@ paths: type: string summary: 登录回调函数 tags: - - OAuth + - Github OAuth /api/oauth/github/get_url: get: description: 获取github登录url @@ -317,7 +336,7 @@ paths: type: string summary: 获取github登录url tags: - - OAuth + - Github OAuth /api/oauth/qq/callback: get: description: QQ登录回调 @@ -326,7 +345,7 @@ paths: responses: {} summary: QQ登录回调 tags: - - 登录 + - QQ OAuth /api/oauth/qq/get_url: get: description: 获取QQ登录地址 @@ -339,7 +358,7 @@ paths: type: string summary: 获取QQ登录地址 tags: - - 登录 + - QQ OAuth /api/sms/ali/send: get: description: 发送短信验证码 @@ -357,7 +376,7 @@ paths: - 短信验证码 /api/sms/smsbao/send: get: - description: 发送短信验证码 + description: 短信宝发送短信验证码 parameters: - description: 手机号 in: query @@ -400,7 +419,7 @@ paths: type: string summary: 刷新token tags: - - 鉴权模块 + - 用户模块 /api/user/add: post: parameters: @@ -417,7 +436,7 @@ paths: type: string summary: 添加用户 tags: - - 鉴权模块 + - 用户模块 /api/user/login: post: parameters: @@ -434,20 +453,16 @@ paths: type: string summary: 账号登录 tags: - - 鉴权模块 + - 用户模块 /api/user/phone_login: post: parameters: - - description: 手机号 - in: query - name: phone + - description: 用户信息 + in: body + name: user required: true - type: string - - description: 验证码 - in: query - name: captcha - required: true - type: string + schema: + $ref: '#/definitions/dto.PhoneLoginRequest' responses: "200": description: OK @@ -455,7 +470,7 @@ paths: type: string summary: 手机号登录/注册 tags: - - 鉴权模块 + - 用户模块 /api/user/reset_password: post: parameters: @@ -472,5 +487,19 @@ paths: type: string summary: 重置密码 tags: - - 鉴权模块 + - 用户模块 + /api/ws/gws: + get: + description: 创建websocket服务 + responses: {} + summary: 创建websocket服务 + tags: + - websocket + /api/ws/socket: + get: + description: 创建websocket服务 + responses: {} + summary: 创建websocket服务(gorilla) + tags: + - websocket swagger: "2.0" diff --git a/router/modules/swagger_router.go b/router/modules/swagger_router.go index 58d53ca..0e88dd7 100644 --- a/router/modules/swagger_router.go +++ b/router/modules/swagger_router.go @@ -5,9 +5,15 @@ import ( swaggerFiles "github.com/swaggo/files" ginSwagger "github.com/swaggo/gin-swagger" "schisandra-cloud-album/docs" + "schisandra-cloud-album/global" ) func SwaggerRouter(router *gin.Engine) { docs.SwaggerInfo.BasePath = "" - router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler)) + docs.SwaggerInfo.Description = global.CONFIG.Swagger.Description + router.GET("/api/doc/*any", ginSwagger.WrapHandler(swaggerFiles.Handler, func(config *ginSwagger.Config) { + config.Title = global.CONFIG.Swagger.Title + }), gin.BasicAuth(gin.Accounts{ + global.CONFIG.Swagger.User: global.CONFIG.Swagger.Password, + })) } diff --git a/tmp/schisandra_cloud_album_linux_linux b/tmp/schisandra_cloud_album_linux_linux deleted file mode 100644 index e0c3dd3..0000000 Binary files a/tmp/schisandra_cloud_album_linux_linux and /dev/null differ