🐞 fix(gvg): 备战期等级奖励随人
This commit is contained in:
35
shared/db/GVGRoleData.ts
Normal file
35
shared/db/GVGRoleData.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop, DocumentType, } from '@typegoose/typegoose';
|
||||
|
||||
// 玩家跨联军保留数据
|
||||
|
||||
@index({ leagueCode: 1, roleId: 1, configId: 1 })
|
||||
export default class GVGRoleData extends BaseModel {
|
||||
|
||||
@prop({ required: true })
|
||||
roleId: string; // 玩家
|
||||
|
||||
@prop({ required: true })
|
||||
configId: number; // 赛季信息
|
||||
|
||||
@prop({ required: true, default: 0 })
|
||||
receivedLv: number; // 领取到的等级奖励
|
||||
|
||||
public static async findByRole(configId: number, roleId: string) {
|
||||
const result: GVGRoleDataType = await GVGRoleDataModel.findOneAndUpdate({ configId, roleId }, {}, { new: true, upsert: true}).lean();
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async receiveLv(configId: number, roleId: string, lv: number) {
|
||||
const result: GVGRoleDataType = await GVGRoleDataModel.findOneAndUpdate({ configId, roleId }, { $set: { receivedLv: lv }}, { new: true }).lean();
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export const GVGRoleDataModel = getModelForClass(GVGRoleData);
|
||||
|
||||
export interface GVGRoleDataType extends Pick<DocumentType<GVGRoleData>, keyof GVGRoleData> {
|
||||
id: number;
|
||||
};
|
||||
export type GVGRoleDataUpdate = Partial<GVGRoleDataType>; // 将所有字段变成可选项
|
||||
Reference in New Issue
Block a user