41 lines
1.0 KiB
TypeScript
41 lines
1.0 KiB
TypeScript
import { prop } from '@typegoose/typegoose';
|
|
import { ActivityModelType } from '../../db/Activity';
|
|
import { ActivityBase } from './activityField';
|
|
|
|
|
|
// 每日配置数据
|
|
export class SevenDayItem {
|
|
@prop({ required: true })
|
|
id: number = 0;
|
|
@prop({ required: true })
|
|
count: number = 0;
|
|
@prop({ required: true })
|
|
total: number = 0;
|
|
@prop({ required: true })
|
|
isReceive: boolean = false;
|
|
|
|
constructor(id: number, count: number, total: number, isReceive: boolean) {
|
|
this.id = id;
|
|
this.count = count;
|
|
this.total = total;
|
|
this.isReceive = isReceive;
|
|
}
|
|
}
|
|
|
|
|
|
// 七天乐活动数据
|
|
export class SevenDaysData extends ActivityBase {
|
|
@prop({ required: true })
|
|
items: Array<SevenDayItem> = [];
|
|
|
|
public initData(data: string) {
|
|
let arr = JSON.parse(data);
|
|
for (let obj of arr) {
|
|
this.items.push(new SevenDayItem(obj.id, obj.count, 0, false));
|
|
}
|
|
}
|
|
|
|
constructor(activityData: ActivityModelType) {
|
|
super(activityData)
|
|
}
|
|
} |