34 lines
831 B
Go
34 lines
831 B
Go
package pg
|
|
|
|
import (
|
|
"database/sql/driver"
|
|
"encoding/json"
|
|
"errors"
|
|
)
|
|
|
|
type UserOAuth struct {
|
|
AccessToken string `json:"access_token,omitempty"`
|
|
ExpiresIn int64 `json:"expires_in,omitempty"`
|
|
IsSnapshotuser int64 `json:"is_snapshotuser,omitempty"`
|
|
Openid string `json:"openid,omitempty"`
|
|
RefreshToken string `json:"refresh_token,omitempty"`
|
|
Scope string `json:"scope,omitempty"`
|
|
Unionid string `json:"unionid,omitempty"`
|
|
}
|
|
|
|
func (x UserOAuth) Scan(value interface{}) (err error) {
|
|
switch v := value.(type) {
|
|
case string:
|
|
return json.Unmarshal([]byte(v), &x)
|
|
case []byte:
|
|
return json.Unmarshal(v, &x)
|
|
case *string:
|
|
return json.Unmarshal([]byte(*v), &x)
|
|
}
|
|
return errors.New("Unknown type for ")
|
|
}
|
|
|
|
func (x UserOAuth) Value() (driver.Value, error) {
|
|
return json.Marshal(x)
|
|
}
|