81 lines
2.9 KiB
Go
81 lines
2.9 KiB
Go
package wxuser
|
|
|
|
import (
|
|
"common/connection"
|
|
"time"
|
|
|
|
"github.com/jinzhu/gorm"
|
|
)
|
|
|
|
func init() {
|
|
//注册数据库
|
|
connection.RegisterDBModel(&WxUserInfo{})
|
|
connection.RegisterDBModel(&RecordLoginOfWxUser{})
|
|
connection.RegisterDBModel(&RecordWatchADOfWxUser{})
|
|
connection.RegisterDBModel(&WxUserSeverInfo{})
|
|
}
|
|
|
|
type WechatTokens struct {
|
|
Errcode int32 `json:"errcode"`
|
|
Errmsg string `json:"errmsg"`
|
|
AccessToken string `json:"access_token"`
|
|
RefreshToken string `json:"refresh_token"`
|
|
ExpiresIn int64 `json:"expires_in"`
|
|
OpenId string `json:"openid"`
|
|
UnionId string `json:"unionid"`
|
|
}
|
|
|
|
type WxUserInfo struct {
|
|
Nickname string `gorm:"column:nickname;comment:昵称" json:"nickname"`
|
|
Sex string `gorm:"column:sex;comment:性别" json:"sex"`
|
|
Language int64 `gorm:"column:language;comment:语言" json:"language"`
|
|
city string `gorm:"column:city;comment:城市" json:"city"`
|
|
province string `gorm:"column:province;comment:省份" json:"province"`
|
|
country string `gorm:"column:country;comment:国籍" json:"country"`
|
|
headimgurl string `gorm:"column:headimgurl;comment:头像" json:"headimgurl"`
|
|
OpenId string `gorm:"column:openId;comment:openId;primaryKey" json:"openid"`
|
|
UnionId string `gorm:"column:unionId;comment:unionId" json:"unionid"`
|
|
}
|
|
|
|
// 同一个玩家在不同的区服Uid是不同的
|
|
type WxUserSeverInfo struct {
|
|
ID int64 `gorm:"column:id;primary_key;comment:自增索引;autoIncrementIncrement" json:"id"`
|
|
OpenId string `gorm:"column:openId;comment:openId" json:"openId"`
|
|
SeverId int32 `gorm:"column:severId;comment:区服Id" json:"severId"`
|
|
Uid int64 `gorm:"column:uid;comment:用户唯一Id" json:"uid"`
|
|
}
|
|
|
|
// 登录相关的记录
|
|
type RecordLoginOfWxUser struct {
|
|
ID int64 `gorm:"column:id;primary_key;comment:自增索引;autoIncrementIncrement" json:"id"`
|
|
Uid int64 `gorm:"column:uid;comment:用户唯一Id" json:"uid"`
|
|
LoginInTime int64 `gorm:"column:loginintime;comment:登录时间" json:"loginintime"`
|
|
LoginOutTime int64 `gorm:"column:loginouttime;comment:登出时间" json:"loginouttime"`
|
|
PlayTimes int64 `gorm:"column:playtimes;comment:游玩时长" json:"playtimes"`
|
|
}
|
|
|
|
// 看广告相关记录
|
|
// 记录日期便于按天统计
|
|
type RecordWatchADOfWxUser struct {
|
|
ID int64 `gorm:"column:id;primary_key;comment:自增索引;autoIncrementIncrement" json:"id"`
|
|
RecordDate time.Time `gorm:"column:recorddate;type:date;comment:记录日期" json:"recorddate"`
|
|
Uid int64 `gorm:"column:uid;comment:用户唯一Id" json:"uid"`
|
|
WatchADNum int32 `gorm:"column:watchadnum;comment:看广告次数" json:"watchadnum"`
|
|
}
|
|
|
|
func (WxUserInfo) TableName() string {
|
|
return "wxuserinfo"
|
|
}
|
|
|
|
func (r RecordLoginOfWxUser) TableName(db *gorm.DB) string {
|
|
return "recordloginofwxuser"
|
|
}
|
|
|
|
func (RecordWatchADOfWxUser) TableName() string {
|
|
return "recordwatchadofwxuser"
|
|
}
|
|
|
|
func (WxUserSeverInfo) TableName() string {
|
|
return "wxuserseverinfo"
|
|
}
|