活动:任务完成关联活动积分点数

This commit is contained in:
qiaoxin
2021-06-30 12:10:03 +08:00
parent 0cf40ec783
commit 730aeae370
2 changed files with 55 additions and 8 deletions

View File

@@ -0,0 +1,47 @@
import BaseModel from './BaseModel';
import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
/**
* 游戏中的任务完成后,增加的积分点数关联到活动数据
*/
@index({ taskId: 1 })
export default class Activity_Task_Point extends BaseModel {
// @prop({ required: true })
// serverId: number; // 服Id
@prop({ required: true })
taskType: number; // 任务类型TASK_FUN_TYPE 1.主线2每日3.成就
@prop({ required: true })
taskId: number; // 任务id
@prop({ required: true })
activityId: number; // 关联的活动id
@prop({ required: true })
point: number; // 增加点数
//更新活动数据
public static async updateData(taskType: number, taskId: number, activityId: number, point: number) {
let result: ActivityTaskPointModelType = await ActivityTaskPointModel.findOneAndUpdate(
{ taskType, taskId }, { $set: { activityId, point } }, { upsert: true, new: true }
).lean(true);
return result;
}
//查询数据
public static async findData(taskType: number, taskId: number) {
let result: ActivityTaskPointModelType = await ActivityTaskPointModel.findOne(
{ taskType, taskId }).lean(true);
return result;
}
//删除数据
public static async deleteData(taskType: number, taskId: number, activityId: number) {
await ActivityTaskPointModel.deleteOne({ taskType, taskId, activityId });
}
}
export const ActivityTaskPointModel = getModelForClass(Activity_Task_Point);
export interface ActivityTaskPointModelType extends Pick<DocumentType<Activity_Task_Point>, keyof Activity_Task_Point> { }
export type ActivityTaskPointModelTypeParam = Partial<ActivityTaskPointModelType>; // 将所有字段变成可选项