🐞 fix(战报): 修复pvp上传战报时记录还未创建的问题
This commit is contained in:
@@ -143,16 +143,21 @@ export default class PvpRecord extends BaseModel {
|
||||
@prop({ required: true, default: 0 })
|
||||
timeout: boolean;
|
||||
|
||||
public static async createRec(param: { roleId1: string, roleId2: string, battleCode: string, warId: number, attackInfo: PvpRecordPlayerInfo, defenseInfo: PvpRecordPlayerInfo, createTime: number, timeout?: boolean }) {
|
||||
public static async createRec(roleId1: string, roleId2: string, battleCode: string) {
|
||||
await this.delPvpRecords();
|
||||
let code = genCode(6);
|
||||
const result = await PvpRecordModel.findOneAndUpdate({ code }, param, { new: true, upsert: true }).lean();
|
||||
const result = await PvpRecordModel.findOneAndUpdate({ code }, { $set: { roleId1, roleId2, battleCode } }, { new: true, upsert: true }).lean();
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async updateByBattleCode(battleCode: string, param: { warId: number, attackInfo: PvpRecordPlayerInfo, defenseInfo: PvpRecordPlayerInfo, createTime: number, timeout?: boolean }) {
|
||||
const result = await PvpRecordModel.findOneAndUpdate({ battleCode }, param, { new: true }).lean();
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async getRecByRoleId( roleId: string, limit = 15, lean = true) {
|
||||
await this.delPvpRecords();
|
||||
const result: PvpRecord[] = await PvpRecordModel.find({ $or:[{roleId1: roleId}, {roleId2: roleId}] }).select('-_id -__v -createdAt -updatedAt').limit(limit).sort({createTime: -1}).lean(lean);
|
||||
const result: PvpRecord[] = await PvpRecordModel.find({ $or:[{roleId1: roleId}, {roleId2: roleId}], createTime: { $gt: 0 } }).select('-_id -__v -createdAt -updatedAt').limit(limit).sort({createTime: -1}).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user