1234567891011121314151617 |
- package unity
- import (
- "github.com/gin-gonic/gin"
- )
- func GetUId(c *gin.Context) (id int, name, role string) {
- value, exists := c.Get("user")
- if exists {
- users := value.(map[string]interface{})
- id = int(users["ID"].(float64))
- name = users["username"].(string)
- role = users["role"].(string)
- return id, name, role
- }
- return 0, "", ""
- }
|