44 lines
1.1 KiB
TypeScript
44 lines
1.1 KiB
TypeScript
import { dbconn } from 'decorators/dbconn'
|
|
import { getModelForClass, index, modelOptions, mongoose, prop } from '@typegoose/typegoose'
|
|
import { Severity } from '@typegoose/typegoose/lib/internal/constants'
|
|
import { BaseModule } from './Base'
|
|
|
|
/**
|
|
* 用户抽奖状态
|
|
*/
|
|
@dbconn()
|
|
@index({ user: 1, activity: 1, dateTag: 1 }, { unique: false })
|
|
@modelOptions({
|
|
schemaOptions: { collection: 'lottery_stats', timestamps: true },
|
|
options: { allowMixed: Severity.ALLOW },
|
|
})
|
|
export class LotteryStatsClass extends BaseModule {
|
|
@prop()
|
|
public user: string
|
|
@prop()
|
|
public activity: string
|
|
@prop({ default: 0 })
|
|
public amount: number
|
|
@prop({ default: 0 })
|
|
public daily: number
|
|
@prop({ default: 0 })
|
|
public gacha: number
|
|
@prop({ default: 0 })
|
|
public share: number
|
|
@prop({ default: 0 })
|
|
public used: number
|
|
@prop()
|
|
public dateTag: string
|
|
|
|
public toJson() {
|
|
return {
|
|
amount: this.amount,
|
|
daily: this.daily,
|
|
gacha: this.gacha,
|
|
used: this.used,
|
|
day: this.dateTag,
|
|
}
|
|
}
|
|
}
|
|
export const LotteryStats = getModelForClass(LotteryStatsClass, { existingConnection: LotteryStatsClass['db'] })
|