goProject/trunk/center/usercenter/internal/wxuser/user.go

94 lines
3.7 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package wxuser
import (
"common/connection"
)
func init() {
//注册数据库
connection.RegisterDBModel(&WxUserInfo{})
connection.RegisterDBModel(&RecordLoginOfWxUser{})
connection.RegisterDBModel(&RecordWatchADOfWxUser{})
connection.RegisterDBModel(&WxUserSeverInfo{})
connection.RegisterDBModel(&WxUserSeverList{})
}
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 WxUserSeverList struct {
ID int64 `gorm:"column:id;primary_key;comment:自增索引;autoIncrementIncrement" json:"id"`
SeverId int32 `gorm:"column:severId;comment:区服Id" json:"severId"`
}
// 登录相关的记录
type RecordLoginOfWxUser struct {
ID int64 `gorm:"column:id;primary_key;comment:自增索引;autoIncrementIncrement" json:"id"`
Uid int64 `gorm:"column:uid;comment:用户唯一Id" json:"uid"`
SeverId int32 `gorm:"column:severId;comment:区服Id" json:"severId"`
RecordDate int64 `gorm:"column:recorddate;comment:记录日期" json:"recorddate"` //只记录当天0点的时间戳方便查询某一日的数据
LoginInTime int64 `gorm:"column:loginintime;comment:登录时间" json:"loginintime"`
LoginOutTime int64 `gorm:"column:loginouttime;comment:登出时间" json:"loginouttime"`
PlayTimes int64 `gorm:"column:playtimes;comment:游玩时长" json:"playtimes"`
//用于统计当日的总上线人数 0=否1=是
IsFirstLogin int32 `gorm:"column:isfirstlogin;comment:是否首次登录" json:"isfirstlogin"`
}
// 看广告相关记录
// 记录日期便于按天统计
type RecordWatchADOfWxUser struct {
ID int64 `gorm:"column:id;primary_key;comment:自增索引;autoIncrementIncrement" json:"id"`
RecordDate int64 `gorm:"column:recorddate;comment:记录日期" json:"recorddate"` //只记录当天0点的时间戳方便查询某一日的数据
Uid int64 `gorm:"column:uid;comment:用户唯一Id" json:"uid"`
SeverId int32 `gorm:"column:severId;comment:区服Id" json:"severId"`
WatchADNum int32 `gorm:"column:watchadnum;comment:看广告次数" json:"watchadnum"`
}
func (WxUserInfo) TableName() string {
return "wxuserinfo"
}
func (RecordLoginOfWxUser) TableName() string {
return "recordloginofwxuser"
}
func (RecordWatchADOfWxUser) TableName() string {
return "recordwatchadofwxuser"
}
func (WxUserSeverInfo) TableName() string {
return "wxuserseverinfo"
}
func (WxUserSeverList) TableName() string {
return "wxuserseverlist"
}