package common

import (
	"errors"
	"gin-vue-admin/model/request"

	"github.com/gin-gonic/gin"
)

func GetUserPhone(c *gin.Context) (string, error) {
	if claims, exists := c.Get("claims"); exists {
		//global.GVA_LOG.Error("从Gin的Context中获取从jwt解析出来的用户ID失败, 请检查路由是否使用jwt中间件!")
		waitUse := claims.(*request.CustomClaims)
		if len(waitUse.Mobile) != 11 {
			return "", errors.New("账号错误")
		}
		return waitUse.Mobile, nil
	}

	return "", errors.New("参数错误")
}
