优化结构

This commit is contained in:
Yvan
2026-08-20 23:02:06 +08:00
parent 63dbb4cfbc
commit e65cf0b1d0
338 changed files with 622 additions and 481 deletions
-24
View File
@@ -1,24 +0,0 @@
package handler
import (
"kra/internal/server/httpx"
"kra/internal/service"
"github.com/gin-gonic/gin"
)
type Session struct{ tokens *service.TokenService }
func NewSession(tokens *service.TokenService) *Session { return &Session{tokens: tokens} }
func (h *Session) Logout(c *gin.Context) {
token := c.GetHeader("x-token")
if token == "" {
token, _ = c.Cookie("x-token")
}
if err := h.tokens.BlacklistToken(c.Request.Context(), token); err != nil {
httpx.Fail(c, "jwt作废失败")
return
}
httpx.SetTokenCookie(c, "", -1)
httpx.Write(c, httpx.CodeSuccess, gin.H{}, "jwt作废成功")
}