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