✨ feat(gvg): 准备期征战中原初始
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
|
||||
import { getZeroPoint } from '../pubUtils/timeUtil';
|
||||
|
||||
class Vestige {
|
||||
@prop({ required: true })
|
||||
vestigeId: number; // 遗迹点
|
||||
|
||||
@prop({ required: true })
|
||||
position: string; // 遗迹点位置
|
||||
}
|
||||
|
||||
@index({ groupId: 1, day: 1 })
|
||||
export default class GVGVestige extends BaseModel {
|
||||
|
||||
@prop({ required: true })
|
||||
groupId: number; // 战区id
|
||||
|
||||
@prop({ required: true })
|
||||
type: number; // 1-单服 2-跨服
|
||||
|
||||
@prop({ required: true, type: Vestige, _id: false })
|
||||
vestiges: Vestige[]; // 今天的遗迹点
|
||||
|
||||
@prop({ required: true })
|
||||
day: number; // 每天5点
|
||||
|
||||
public static async getVestigate(groupId: number) {
|
||||
let day = getZeroPoint();
|
||||
let result: GVGVestigeType = await GVGVestigeModel.findOne({ groupId, day }).lean();
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async initTodayVestigate(groupId: number, type: number, vestiges: Vestige[]) {
|
||||
let day = getZeroPoint();
|
||||
let result: GVGVestigeType = await GVGVestigeModel.findOneAndUpdate({ groupId, day }, { $setOnInsert: { type, vestiges } }, { new: true, upsert: true }).lean();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
export const GVGVestigeModel = getModelForClass(GVGVestige);
|
||||
|
||||
export interface GVGVestigeType extends Pick<DocumentType<GVGVestige>, keyof GVGVestige> {
|
||||
id: number;
|
||||
};
|
||||
export type GVGVestigeUpdate = Partial<GVGVestigeType>; // 将所有字段变成可选项
|
||||
Reference in New Issue
Block a user