活动:成长基金添加购买记录
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
|
||||
|
||||
/**
|
||||
* 活动购买记录
|
||||
*/
|
||||
@index({ roleId: 1 })
|
||||
|
||||
export default class ActivityBuyRecords extends BaseModel {
|
||||
@prop({ required: true })
|
||||
acvitityId: number; // 活动Id
|
||||
@prop({ required: true })
|
||||
roleId: string; // 用户Id
|
||||
@prop({ required: true })
|
||||
type: number; // 活动类型
|
||||
@prop({ required: true })
|
||||
pageIndex: number; // 第几页(成长基金使用)
|
||||
|
||||
|
||||
//添加购买记录
|
||||
public static async addRecord(acvitityId: number, roleId: string, type: number, pageIndex: number, lean = true) {
|
||||
let result: ActivityBuyRecordsModelType = await ActivityBuyRecordsModel.findOneAndUpdate({ roleId, acvitityId, type, pageIndex },
|
||||
{}, { upsert: true, new: true }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//根据活动id查询数据
|
||||
public static async findRecordsByActivityId(acvitityId: number, roleId: string, lean = true) {
|
||||
let result: ActivityBuyRecordsModelType[] = await ActivityBuyRecordsModel.find({ roleId, acvitityId }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//查询第几页的活动数据
|
||||
public static async findDataBypageIndex(acvitityId: number, type: number, roleId: string, pageIndex: number, lean = true) {
|
||||
let result: ActivityBuyRecordsModelType[] = await ActivityBuyRecordsModel.find({ roleId, type, acvitityId, pageIndex }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//删除活动购买记录
|
||||
public static async deleteActivity(acvitityId: number, roleId: string, pageIndex: number, cellIndex: number) {
|
||||
await ActivityBuyRecordsModel.deleteMany({ roleId, acvitityId, pageIndex, cellIndex });
|
||||
}
|
||||
}
|
||||
|
||||
export const ActivityBuyRecordsModel = getModelForClass(ActivityBuyRecords);
|
||||
|
||||
export interface ActivityBuyRecordsModelType extends Pick<DocumentType<ActivityBuyRecords>, keyof ActivityBuyRecords> { }
|
||||
export type ActivityBuyRecordsModelTypeParam = Partial<ActivityBuyRecordsModelType>; // 将所有字段变成可选项
|
||||
Reference in New Issue
Block a user