import BaseModel from './BaseModel'; import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose'; /** * 活动系统 - 每日关卡活动 */ @index({ roleId: 1, activityId: 1 }) export default class Activity_Daily_GK extends BaseModel { @prop({ required: true }) serverId: number; // 服id @prop({ required: true }) activityId: number; // 活动Id @prop({ required: true }) roleId: string; // 用户Id @prop({ required: true }) days: number[]; // 第几天的通关 //通关记录 public static async addRecord(serverId: number, activityId: number, roleId: string, day: number) { let result: ActivityDailyGKModelType = await ActivityDailyGKModel.findOneAndUpdate({ serverId, roleId, activityId }, { $push: { days: day } }, { upsert: true, new: true }).lean(true); return result; } //根据活动id查询活动数据 public static async findData(serverId: number, activityId: number, roleId: string) { let result: ActivityDailyGKModelType = await ActivityDailyGKModel.findOne({ serverId, roleId, activityId }).lean(true); return result; } //删除活动领取记录 public static async deleteActivity(serverId: number, activityId: number, roleId: string) { await ActivityDailyGKModel.deleteMany({ serverId, roleId, activityId }); } } export const ActivityDailyGKModel = getModelForClass(Activity_Daily_GK); export interface ActivityDailyGKModelType extends Pick, keyof Activity_Daily_GK> { } export type ActivityDailyGKModelTypeParam = Partial; // 将所有字段变成可选项