import BaseModel from './BaseModel'; import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose'; /** * 活动系统 - 成长任务活动积分点兑换奖励 */ @index({ roleId: 1 }) export default class Activity_Growth_Point extends BaseModel { @prop({ required: true }) serverId: number; // 活动Id @prop({ required: true }) activityId: number; // 活动Id @prop({ required: true }) roleId: string; // 用户Id @prop({ required: true }) ids: number[]; // id数组,领取过的奖励id //当日奖章领取记录 public static async addRecord(serverId: number, activityId: number, roleId: string, id: number) { let result: ActivityGrowthPointModelType = await ActivityGrowthPointModel.findOneAndUpdate({ serverId, roleId, activityId }, { $push: { ids: id } }, { upsert: true, new: true }).lean(true); return result; } //根据活动id查询活动数据 public static async findData(serverId: number, activityId: number, roleId: string) { let result: ActivityGrowthPointModelType = await ActivityGrowthPointModel.findOne({ serverId, roleId, activityId }).lean(true); return result; } //删除活动领取记录 public static async deleteActivity(serverId: number, activityId: number, roleId: string) { await ActivityGrowthPointModel.deleteMany({ serverId, roleId, activityId }); } } export const ActivityGrowthPointModel = getModelForClass(Activity_Growth_Point); export interface ActivityGrowthPointModelType extends Pick, keyof Activity_Growth_Point> { } export type ActivityGrowthPointModelTypeParam = Partial; // 将所有字段变成可选项