✨ feat(gvg): 动态
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop, DocumentType, } from '@typegoose/typegoose';
|
||||
import { GVG_REC_TYPE } from '../consts';
|
||||
|
||||
@index({ leagueCode: 1, guildCode: 1, configId: 1 })
|
||||
@index({ createTime: -1 })
|
||||
export default class GVGRec extends BaseModel {
|
||||
|
||||
@prop({ required: true, default: '' })
|
||||
leagueCode: string; // 联军id
|
||||
|
||||
@prop({ required: false, default: '' })
|
||||
roleId: string; // 玩家id
|
||||
|
||||
@prop({ required: false, default: '' })
|
||||
cityId: number; // 所处城池
|
||||
|
||||
@prop({ required: true, default: 0 })
|
||||
configId: number; // 赛期
|
||||
|
||||
@prop({ required: true, default: 0 })
|
||||
type: number; // 1-备战期联军动态 2-激战期我的战报 3-激战期城池战报 4-激战期军团战报
|
||||
|
||||
@prop({ required: true, default: 0 })
|
||||
recId: number; // 配在动态策划表中的id
|
||||
|
||||
@prop({ required: true, default: [], type: String })
|
||||
params: string[]; // 显示的参数问题,替代%d的
|
||||
|
||||
@prop({ required: true, default: 0 })
|
||||
createTime: number; // 时间
|
||||
|
||||
public static async addRec(param: GVGRecUpdate) {
|
||||
await GVGRecModel.insertMany([param]);
|
||||
}
|
||||
|
||||
public static async addRecs(params: GVGRecUpdate[]) {
|
||||
await GVGRecModel.insertMany(params);
|
||||
}
|
||||
|
||||
public static async findByLeague(leagueCode: string, type: GVG_REC_TYPE) {
|
||||
const result: GVGRecType[] = await GVGRecModel.find({ leagueCode, type }, { _id: 0, recId: 1, params: 1, createTime: 1 }).sort({ createTime: -1 }).limit(50).lean();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
export const GVGRecModel = getModelForClass(GVGRec);
|
||||
|
||||
export interface GVGRecType extends Pick<DocumentType<GVGRec>, keyof GVGRec> {
|
||||
id: number;
|
||||
};
|
||||
export type GVGRecUpdate = Partial<GVGRecType>; // 将所有字段变成可选项
|
||||
Reference in New Issue
Block a user