63 lines
1.9 KiB
Go
63 lines
1.9 KiB
Go
package user_core_client
|
||
|
||
import "time"
|
||
|
||
type TokenClaims struct {
|
||
UserID string `json:"userId"`
|
||
PlatformCode string `json:"platformCode"`
|
||
}
|
||
|
||
// Event 接口定义了所有事件应具备的基本元数据
|
||
type Event interface {
|
||
GetEventID() string // 获取事件唯一ID
|
||
GetEventType() string // 获取事件类型
|
||
GetTimestamp() time.Time // 获取事件发生时间
|
||
}
|
||
|
||
// User 用户数据模型
|
||
type User struct {
|
||
ID int64 `json:"id" ` // 主键ID
|
||
CreatedAt time.Time `json:"created_at"` // 创建时间
|
||
UpdatedAt time.Time `json:"updated_at"` // 更新时间
|
||
DeletedAt uint `json:"deleted_at"` // 软删除时间 毫秒 0 表示未删除
|
||
|
||
EncryptedPhone string `json:"encrypted_phone" ` // 加密后的手机号
|
||
PhoneMask string `json:"phone_mask" ` // 手机号掩码(前三后四位)
|
||
|
||
Username string `json:"username" ` // 用户名(可重复)
|
||
LoginName string `json:"login_name" ` // 登录名
|
||
|
||
Gender string `json:"gender" ` // 性别 (male 男性, female 女性, unknown 未知)
|
||
Status string `json:"status" ` // 用户状态,enabled/disabled
|
||
}
|
||
|
||
type BaseEvent struct {
|
||
EventID string `json:"event_id"` // 事件ID
|
||
EventType string `json:"event_type"` // 事件类型
|
||
Timestamp time.Time `json:"timestamp"` // 事件时间戳
|
||
}
|
||
|
||
func (b *BaseEvent) GetEventID() string {
|
||
return b.EventID
|
||
}
|
||
|
||
func (b *BaseEvent) GetEventType() string {
|
||
return b.EventType
|
||
}
|
||
|
||
func (b *BaseEvent) GetTimestamp() time.Time {
|
||
return b.Timestamp
|
||
}
|
||
|
||
// UserEvent 用户事件结构
|
||
// 用于在Kafka消息中传输用户相关事件
|
||
type UserEvent struct {
|
||
BaseEvent
|
||
|
||
PlatformCode string `json:"platform_code"` // 平台代码
|
||
|
||
UserID int64 `json:"user_id"` // 用户ID
|
||
Username string `json:"username"` // 用户名
|
||
UserData *User `json:"user_data,omitempty"` // 用户数据,改为具体类型
|
||
}
|