书籍列表接口新增参数

This commit is contained in:
2025-08-13 15:19:42 +08:00
parent 6ccc87f2bf
commit 8afe651c64
201 changed files with 6987 additions and 1066 deletions

View File

@ -1,7 +1,9 @@
package jwt
import (
"context"
"errors"
"github.com/gogf/gf/v2/frame/g"
"server/utility/ecode"
"strings"
"time"
@ -70,9 +72,23 @@ func ParseToken(tokenString string) (*TokenOut, error) {
return nil, ecode.InvalidOperation.Sub("invalid_token")
}
blacklist, err := isBlacklist(claims.JTI)
if err != nil {
return nil, ecode.Fail.Sub("token_parse_failed")
}
if blacklist {
return nil, ecode.InvalidOperation.Sub("token_expired")
}
return &TokenOut{
UserId: claims.UserId,
Role: claims.Role,
JTI: claims.JTI,
}, nil
}
func isBlacklist(uuid string) (bool, error) {
exitst, err := g.Redis().Exists(context.Background(), "blacklist:"+uuid)
if err != nil {
return false, err
}
return exitst > 0, nil
}