活动:成长基金-主线
This commit is contained in:
56
shared/db/ActivityGrowthFund.ts
Normal file
56
shared/db/ActivityGrowthFund.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
|
||||
|
||||
/**
|
||||
* 成长基金活动
|
||||
*/
|
||||
@index({ roleId: 1 })
|
||||
|
||||
export default class ActivityGrowthFund extends BaseModel {
|
||||
@prop({ required: true })
|
||||
acvitityId: number; // 活动Id
|
||||
@prop({ required: true })
|
||||
roleId: string; // 用户Id
|
||||
@prop({ required: true })
|
||||
pageIndex: number; // 第几页
|
||||
@prop({ required: true })
|
||||
cellIndex: number; // 第*页的第几个奖励
|
||||
@prop({ required: true })
|
||||
isReceive: boolean; // 是否领取过奖励
|
||||
|
||||
|
||||
//添加领取记录
|
||||
public static async addRecord(acvitityId: number, roleId: string, pageIndex: number, cellIndex: number, lean = true) {
|
||||
let result: ActivityGrowthFundModelType = await ActivityGrowthFundModel.findOneAndUpdate({ roleId, acvitityId, pageIndex, cellIndex },
|
||||
{ $set: { isReceive: true } }, { upsert: true, new: true }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//根据活动id查询活动数据
|
||||
public static async findData(acvitityId: number, roleId: string, lean = true) {
|
||||
let result: ActivityGrowthFundModelType[] = await ActivityGrowthFundModel.find({ roleId, acvitityId }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//查询第几页的活动数据
|
||||
public static async findDataBypageIndex(acvitityId: number, roleId: string, pageIndex: number, lean = true) {
|
||||
let result: ActivityGrowthFundModelType[] = await ActivityGrowthFundModel.find({ roleId, acvitityId, pageIndex }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//查询第*页的某个的活动数据
|
||||
public static async findDataByCellIndex(acvitityId: number, roleId: string, pageIndex: number, cellIndex: number, lean = true) {
|
||||
let result: ActivityGrowthFundModelType[] = await ActivityGrowthFundModel.find({ roleId, acvitityId, pageIndex, cellIndex }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//删除活动领取记录
|
||||
public static async deleteActivity(acvitityId: number, roleId: string, pageIndex: number, cellIndex: number) {
|
||||
await ActivityGrowthFundModel.deleteMany({ roleId, acvitityId, pageIndex, cellIndex });
|
||||
}
|
||||
}
|
||||
|
||||
export const ActivityGrowthFundModel = getModelForClass(ActivityGrowthFund);
|
||||
|
||||
export interface ActivityGrowthFundModelType extends Pick<DocumentType<ActivityGrowthFund>, keyof ActivityGrowthFund> { }
|
||||
export type ActivityGrowthFundModelTypeParam = Partial<ActivityGrowthFundModelType>; // 将所有字段变成可选项
|
||||
Reference in New Issue
Block a user