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

94 lines
3.7 KiB
Go
Raw Normal View History

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