getuid.go 209 B

123456789101112
  1. package utils
  2. import (
  3. "github.com/gin-gonic/gin"
  4. )
  5. func GetUId(c *gin.Context) int {
  6. mustGet := c.MustGet("user")
  7. users := mustGet.(map[string]interface{})
  8. id := int(users["ID"].(float64))
  9. return id
  10. }