🎨 swagger update

This commit is contained in:
landaiqing
2024-08-21 23:52:01 +08:00
parent 78346f6a12
commit e0f0c4c466
16 changed files with 318 additions and 142 deletions

View File

@@ -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) {

View File

@@ -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 "登录成功"

View File

@@ -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) {

View File

@@ -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()
}