63 lines
1.4 KiB
TypeScript
63 lines
1.4 KiB
TypeScript
|
|
/**
|
|||
|
|
* 邀请模型
|
|||
|
|
* TypeGoose 定义,符合 Tailchat 插件标准模式
|
|||
|
|
*/
|
|||
|
|
|
|||
|
|
import { db } from 'tailchat-server-sdk';
|
|||
|
|
const { getModelForClass, prop, modelOptions, TimeStamps, index } = db;
|
|||
|
|
|
|||
|
|
@modelOptions({ options: { customName: 'p_saleschat_invite' } })
|
|||
|
|
@index({ code: 1 }, { unique: true })
|
|||
|
|
@index({ salesId: 1 })
|
|||
|
|
@index({ expiresAt: 1 })
|
|||
|
|
@index({ status: 1 })
|
|||
|
|
export class Invite extends TimeStamps implements db.Base {
|
|||
|
|
_id: db.Types.ObjectId;
|
|||
|
|
id: string;
|
|||
|
|
|
|||
|
|
/** 邀请码 */
|
|||
|
|
@prop({ required: true, unique: true })
|
|||
|
|
code: string;
|
|||
|
|
|
|||
|
|
/** 销售 ID(关联用户) */
|
|||
|
|
@prop({ required: true, ref: 'User' })
|
|||
|
|
salesId: db.Types.ObjectId;
|
|||
|
|
|
|||
|
|
/** 群组 ID(关联群组) */
|
|||
|
|
@prop({ required: true, ref: 'Group' })
|
|||
|
|
groupId: db.Types.ObjectId;
|
|||
|
|
|
|||
|
|
/** 邀请链接 */
|
|||
|
|
@prop()
|
|||
|
|
link?: string;
|
|||
|
|
|
|||
|
|
/** 二维码 URL */
|
|||
|
|
@prop()
|
|||
|
|
qrCodeUrl?: string;
|
|||
|
|
|
|||
|
|
/** 过期时间 */
|
|||
|
|
@prop()
|
|||
|
|
expiresAt?: Date;
|
|||
|
|
|
|||
|
|
/** 点击次数 */
|
|||
|
|
@prop({ default: 0 })
|
|||
|
|
clickCount: number;
|
|||
|
|
|
|||
|
|
/** 扫码次数 */
|
|||
|
|
@prop({ default: 0 })
|
|||
|
|
scanCount: number;
|
|||
|
|
|
|||
|
|
/** 加入次数 */
|
|||
|
|
@prop({ default: 0 })
|
|||
|
|
joinCount: number;
|
|||
|
|
|
|||
|
|
/** 状态:active / inactive */
|
|||
|
|
@prop({ default: 'active' })
|
|||
|
|
status: 'active' | 'inactive';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
export type InviteDocument = db.DocumentType<Invite>;
|
|||
|
|
const model = getModelForClass(Invite);
|
|||
|
|
export type InviteModel = typeof model;
|
|||
|
|
export default model;
|