🎨 swagger update
This commit is contained in:
@@ -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]
|
||||
|
@@ -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) {
|
||||
|
@@ -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 "登录成功"
|
||||
|
@@ -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) {
|
||||
|
@@ -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()
|
||||
}
|
||||
|
@@ -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)
|
||||
|
@@ -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]
|
||||
|
@@ -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{
|
||||
|
@@ -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链接")
|
||||
|
Reference in New Issue
Block a user