重构core包

This commit is contained in:
2025-10-26 15:48:38 +08:00
parent 6a8e8f1f7d
commit 40eb57ee47
6 changed files with 444 additions and 333 deletions

View File

@@ -13,19 +13,19 @@ type Claims struct {
jwt.RegisteredClaims
}
// TokenService 定义了 token 操作的接口
type TokenService interface {
// Service 定义了 token 操作的接口
type Service interface {
GenerateToken(userID uint) (string, error)
ParseToken(tokenString string) (*Claims, error)
}
// tokenService 是 TokenService 接口的实现
// tokenService 是 Service 接口的实现
type tokenService struct {
secret []byte
}
// NewTokenService 创建并返回一个新的 TokenService 实例
func NewTokenService(secret []byte) TokenService {
// NewTokenService 创建并返回一个新的 Service 实例
func NewTokenService(secret []byte) Service {
return &tokenService{secret: secret}
}