活动:修改七天乐-成长活动的数据结构
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
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, id },
|
||||
{ $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, id: number) {
|
||||
await ActivityGrowthPointModel.deleteMany({ serverId, roleId, activityId, id });
|
||||
}
|
||||
}
|
||||
|
||||
export const ActivityGrowthPointModel = getModelForClass(Activity_Growth_Point);
|
||||
|
||||
export interface ActivityGrowthPointModelType extends Pick<DocumentType<Activity_Growth_Point>, keyof Activity_Growth_Point> { }
|
||||
export type ActivityGrowthPointModelTypeParam = Partial<ActivityGrowthPointModelType>; // 将所有字段变成可选项
|
||||
Reference in New Issue
Block a user