Files
2026-04-25 16:36:34 +08:00

50 lines
1.1 KiB
TypeScript
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.
/**
* 访问日志模型
* TypeGoose 定义,符合 Tailchat 插件标准模式
*/
import { db } from 'tailchat-server-sdk';
const { getModelForClass, prop, modelOptions, TimeStamps, index } = db;
@modelOptions({ options: { customName: 'p_saleschat_accesslog' } })
@index({ inviteCode: 1 })
@index({ timestamp: 1 })
@index({ inviteCode: 1, timestamp: -1 })
export class AccessLog extends TimeStamps implements db.Base {
_id: db.Types.ObjectId;
id: string;
/** 邀请码 */
@prop({ required: true })
inviteCode: string;
/** 访客 ID */
@prop()
visitorId?: string;
/** 访问类型click / scan / join */
@prop({ required: true })
accessType: 'click' | 'scan' | 'join';
/** 访问时间 */
@prop({ default: () => new Date() })
timestamp: Date;
/** IP 地址 */
@prop()
ipAddress?: string;
/** User-Agent */
@prop()
userAgent?: string;
/** 来源 */
@prop()
referrer?: string;
}
export type AccessLogDocument = db.DocumentType<AccessLog>;
const model = getModelForClass(AccessLog);
export type AccessLogModel = typeof model;
export default model;