[bugfix/backend] use int64 in userid
This commit is contained in:
parent
287895347b
commit
34ebb05808
1 changed files with 12 additions and 0 deletions
|
@ -176,6 +176,18 @@ func (h *Handler) GetCurrentUser(c *gin.Context) {
|
|||
id = int64(v)
|
||||
case float64:
|
||||
id = int64(v)
|
||||
case string:
|
||||
// 尝试将字符串转换为int64
|
||||
parsedID, err := strconv.ParseInt(v, 10, 64)
|
||||
if err != nil {
|
||||
log.Error().
|
||||
Err(err).
|
||||
Str("user_id", v).
|
||||
Msg("Failed to parse user_id string")
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "Invalid user_id format"})
|
||||
return
|
||||
}
|
||||
id = parsedID
|
||||
default:
|
||||
log.Error().
|
||||
Str("type", fmt.Sprintf("%T", userID)).
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue