getuid.go 270 B

12345678910111213141516
  1. package unity
  2. import (
  3. "github.com/gin-gonic/gin"
  4. )
  5. func GetUId(c *gin.Context) int {
  6. //mustGet := c.MustGet("user")
  7. value, exists := c.Get("user")
  8. if exists {
  9. users := value.(map[string]interface{})
  10. id := int(users["ID"].(float64))
  11. return id
  12. }
  13. return 0
  14. }