Files
2026-11-03 11:13:55 +08:00

39 lines
2.2 KiB
Go
Raw Permalink 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 models
import "time"
// ==================== 游客(免登录模块)轻身份与通用数据 ====================
//
// 设计:免登录模块「不登录也要能存数据」。小程序用手机号授权换取游客轻身份
// (yz_guest_user),业务条目按 guest_id + module 文档式存入 yz_guest_data,
// 永久保留不清理;正式登录后按手机号把数据合并进正式账号(见 controllers/guest_merge.go)。
// GuestUser 游客轻身份,以微信验证手机号为唯一标识。
type GuestUser struct {
ID uint64 `orm:"column(id);pk;auto" json:"id"`
Phone string `orm:"column(phone);size(20)" json:"phone"`
OpenID string `orm:"column(openid);size(64);default('')" json:"openid"`
UnionID string `orm:"column(unionid);size(64);default('')" json:"unionid"`
CreateTime time.Time `orm:"column(create_time);type(datetime);auto_now_add" json:"create_time"`
LastActiveTime *time.Time `orm:"column(last_active_time);type(datetime);null" json:"last_active_time"`
MergedUID uint64 `orm:"column(merged_uid);default(0)" json:"merged_uid"`
MergedTime *time.Time `orm:"column(merged_time);type(datetime);null" json:"merged_time"`
}
func (*GuestUser) TableName() string { return "yz_guest_user" }
// GuestData 游客通用数据行:一条业务条目 = 一行 JSON 文档。
// module 取值与免登录业务对应(notebook / schedule / passwordStore / …),
// 新模块直接复用本表,无需再加业务表。
type GuestData struct {
ID uint64 `orm:"column(id);pk;auto" json:"id"`
GuestID uint64 `orm:"column(guest_id)" json:"guest_id"`
Module string `orm:"column(module);size(50)" json:"module"`
Payload string `orm:"column(payload);type(text)" json:"payload"`
IsDeleted int8 `orm:"column(is_deleted);default(0)" json:"is_deleted"` // 0正常 1已删除 2已合并
CreateTime time.Time `orm:"column(create_time);type(datetime);auto_now_add" json:"create_time"`
UpdateTime *time.Time `orm:"column(update_time);type(datetime);null" json:"update_time"`
}
func (*GuestData) TableName() string { return "yz_guest_data" }