package user import ( "github.com/gin-gonic/gin" "leafdev.top/leaf/rag/internal/logic" "leafdev.top/leaf/rag/models" "net/http" ) var AuthLogic = logic.NewAuthLogic() type Controller struct{} func NewUserController() *Controller { return &Controller{} } // CurrentUser 获取当前用户 godoc // @Summary 获取当前用户的请求 // @Success 200 {object} models.CurrentUserResponse // @Router /user [get] func (c *Controller) CurrentUser(ctx *gin.Context) { var user = AuthLogic.GinUser(ctx) ctx.JSON(http.StatusOK, models.CurrentUserResponse{ IP: ctx.ClientIP(), Valid: user.Valid, UserEmail: user.Token.Email, UserId: user.Token.Sub, }) }