// 自动生成模板TwiMetamask
package twi

import (
      "fmt"
      "time"

	"courseSign/server/global"
)

// TwiMetamask 结构体
type TwiMetamask struct {
      global.GVA_MODEL
      Address  string `json:"address" form:"address" gorm:"column:address;unique;not null;comment:metamask 地址;size:72;"`
      TwiName  string `json:"twiName" form:"twiName" gorm:"column:twi_name;comment:;size:128;"`
      TwiId  string `json:"twiId" form:"twiId" gorm:"column:twi_id;comment:;size:72;"`
      TwiUsername  string `json:"twiUsername" form:"twiUsername" gorm:"column:twi_username;comment:;size:128;"`
      TwiPhotoUrl string `json:"twiPhotoUrl" form:"twiPhotoUrl" gorm:"column:twi_photo_url;comment:;size:256;"`
      BindTime  *time.Time `json:"bindTime" form:"bindTime" gorm:"column:bind_time;comment:;"`
      IsTwiAuth *bool `json:"isTwiAuth" form:"isTwiAuth" gorm:"column:is_twi_auth;default:0;"`
      TeleFirstName string `json:"teleFirstName" form:"teleFirstName" gorm:"column:tele_first_name;"`
      TeleLastName string `json:"teleLastName" form:"teleLastName" gorm:"column:tele_last_name;"`
      TeleUsername string `json:"teleUsername" form:"teleUsername" gorm:"column:tele_username;"`
      TeleId  string `json:"teleId" form:"teleId" gorm:"column:tele_id;comment:;size:72;"`
      IsTeleAuth *bool `json:"isTeleAuth" form:"isTeleAuth" gorm:"column:is_tele_auth;default:0;"`
      TelePhotoUrl string `json:"telePhotoUrl" form:"telePhotoUrl" gorm:"column:tele_photo_url;size:256"`
      InvitorId int64 `json:"invitorId" form:"invitorId" gorm:"column:invitor_id;comment;"`
      Invitor  string `json:"invitor" form:"invitor" gorm:"column:invitor;comment:;size:72;"`

      TeleHash string `json:"tele_hash" from:"tele_hash" gorm:"-"`
      ReqToken string `json:"req_token" form:"req_token" gorm:"-"`
      ReqSecret string `json:"req_secret" form:"req_secret" gorm:"-"`
      AccessToken string `json:"access_token" form:"access_token" gorm:"-"`
      AccessSecret string `json:"access_secret" form:"access_secret" gorm:"-"`
      OauthToken string `json:"oauth_token" form:"oauth_token" gorm:"-"`
      OauthVerifier string `json:"oauth_verifier" form:"oauth_verifier" gorm:"-"`
      AuthUrl string `json:"auth_url" form:"auth_url" gorm:"-"`
}


// TableName TwiMetamask 表名
func (TwiMetamask) TableName() string {
  return "twi_metamask"
}

// type TwiMetamaskCallBack struct {
//       OauthToken string `json:"oauth_token" form:"oauth_token"`
//       OauthVerifier string `json:"oauth_verifier" form:"oauth_verifier"`
// }

func ConvertCommonInfo(user TwiMetamask) UserCommonInfo {
      info := UserCommonInfo{
            Id:            int64(user.ID),
            Addr:          user.Address,
            TwiName:       user.TwiName,
            TwiId:         user.TwiId,
            TwiUsername:   user.TwiUsername,
            TeleFirstName: user.TeleFirstName,
            TeleLastName:  user.TeleLastName,
            TeleUsername:  user.TeleUsername,
            TeleId:        user.TeleId,
      }
      if user.TwiUsername != "" && user.TeleUsername != "" {
            info.Url = fmt.Sprintf("%sinvitor=%s","https://bityuan.com/profile?",user.Address)
      }
      return info
}

type UserCommonInfo struct {
      Id int64 `json:"id" form:"id" gorm:"-"`
      Addr  string `json:"addr" form:"addr" gorm:"-"`
      TwiName  string `json:"twiName" form:"twiName" gorm:"-"`
      TwiId  string `json:"twiId" form:"twiId" gorm:"-"`
      TwiUsername  string `json:"twiUsername" form:"twiUsername" gorm:"-"`
      TeleFirstName string `json:"teleFirstName" form:"teleFirstName" gorm:"-"`
      TeleLastName string `json:"teleLastName" form:"teleLastName" gorm:"-"`
      TeleUsername string `json:"teleUsername" form:"teleUsername" gorm:"-"`
      TeleId  string `json:"teleId" form:"teleId" gorm:"-"`
      Url string `json:"url" form:"url" gorm:"-"`
}

type UserSimpleInfo struct {
      Id int64 `json:"id"`
      TwiUsername string `json:"twi_username"`
      TwiPhotoUrl string `json:"twi_photo_url"`
      TeleUsername string `json:"tele_username"`
      TelePhotoUrl string `json:"tele_photo_url"`
}

type UserActionInfo struct {
      Id int64 `json:"id" form:"id" gorm:"-"`
      Addr  string `json:"addr" form:"addr" gorm:"-"`
      TwiName  string `json:"twiName" form:"twiName" gorm:"-"`
      TwiId  string `json:"twiId" form:"twiId" gorm:"-"`
      TwiUsername  string `json:"twiUsername" form:"twiUsername" gorm:"-"`
      TeleFirstName string `json:"teleFirstName" form:"teleFirstName" gorm:"-"`
      TeleLastName string `json:"teleLastName" form:"teleLastName" gorm:"-"`
      TeleUsername string `json:"teleUsername" form:"teleUsername" gorm:"-"`
      TeleId  string `json:"teleId" form:"teleId" gorm:"-"`
      ActId int64 `json:"actId" form:"actId" gorm:"-"` // 活动编号
      TemplateId int64 `json:"templateId" form:"templateId" gorm:"-"` // 活动子任务编号
      TempFinishId int64 `json:"tempFinishId" form:"tempFinishId" gorm:"-"`  // 活动完成记录编号
      TempFinishStatus bool `json:"tempFinishStatus" form:"tempFinishStatus" gorm:"-"`  // 活动完成记录编号
}

type AddressInfo struct {

}

type AuthLogin struct {
      Type int64 `json:"type" form:"type"`
      Token string `json:"token" form:"token"`
}

const (
      AuthTypeTwitter = 1
      AuthTypeTele = 2
)

type TelegramUserCallback struct {
      Id int64 `json:"id" form:"id"`
      IsBot bool `json:"is_bot" form:"is_bot"`
      Hash string `json:"hash" form:"hash"`
      LastName string `json:"last_name" form:"last_name"`
      FirstName string `json:"first_name" form:"first_name"`
      Username string `json:"username" form:"username"`
      PhotoUrl string `json:"photo_url" form:"photo_url"`
      AuthDate int64 `json:"auth_date" form:"auth_date"`
      Type int64 `json:"type" form:"type"`
      Token string `json:"token" form:"token"`
}