package login

import (
	"errors"
	"github.com/gin-gonic/gin"
)

type WxUser struct {
	OpenID string `json:"openID"`
	GHID   string `json:"gHID"`
}

type Info struct {
	ID                 uint64 `json:"ID"`
	Status             int32  `json:"status"`
	Name               string `json:"name"`
	Sex                string `json:"sex"`
	Nationality        string `json:"nationality"`
	DocumentType       int32  `json:"documentType"`
	CertificatePicture string `json:"certificatePicture"`
	Validity           string `json:"validity"`
	PlaceOfResidence   string `json:"placeOfResidence"`
	GroupPhoto         string `json:"groupPhoto"`
	Attachment         string `json:"attachment"`
	SubNum             string `json:"subNum"`
	NotPassRemarks     string `json:"notPassRemarks"`
	Domain             string `json:"domain"`
	TelNum             string `json:"telNum"`
	SubscriberNumber   string `json:"subscriberNumber"`
}

func GetUserInfoFromC(c *gin.Context) Info {
	userInfoAny, _ := c.Get("jwtInfo")
	userInfo := userInfoAny.(Info)
	return userInfo
}

func GetUserInfoFromCtx(c *gin.Context) (Info, error) {
	userInfoAny, _ := c.Get("jwtInfo")
	if userInfoAny != nil {
		userInfo := userInfoAny.(Info)
		return userInfo, nil
	} else {
		return Info{}, errors.New("not login")
	}
}
