拍卖行:领取奖励、查看关注、查看出价的接口实现和测试用例
This commit is contained in:
@@ -2,6 +2,7 @@ import { BidRec } from './../domain/dbGeneral';
|
||||
import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop, DocumentType, modelOptions } from '@typegoose/typegoose';
|
||||
import { genCode } from '../pubUtils/util';
|
||||
import { BID_REC_COUNT } from '../consts';
|
||||
|
||||
/**
|
||||
* 竞拍物品表
|
||||
@@ -9,6 +10,7 @@ import { genCode } from '../pubUtils/util';
|
||||
@modelOptions({ schemaOptions: { id: false } })
|
||||
@index({ code: 1 })
|
||||
@index({ guildCode: 1, begin: -1 })
|
||||
@index({ serverId: 1, begin: -1, watchingRoles: 1 })
|
||||
export default class Lot extends BaseModel {
|
||||
@prop({ required: true, default: 0 })
|
||||
auctionStage: number; // 0:初始添加,1:军团拍卖,2:世界拍卖,3:拍卖结束
|
||||
@@ -90,6 +92,16 @@ export default class Lot extends BaseModel {
|
||||
const result: LotType = await LotModel.findOneAndUpdate({ code }, { $pull: { watchingRoles: roleId } }, { new: true }).select('-_id -__v').lean();
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async watchingLotsByBegin(serverId: number, roleId: string, begin: Date) {
|
||||
const results: LotType[] = await LotModel.find({ serverId, begin, watchingRoles: roleId }).select('-_id -__v').lean();
|
||||
return results;
|
||||
}
|
||||
|
||||
public static async recentBidLots(serverId: number, roleId: string, count = BID_REC_COUNT) {
|
||||
const results: LotType[] = await LotModel.find({ serverId, 'bidRoles.roleId': roleId }).select('-_id -__v').limit(count).lean();
|
||||
return results;
|
||||
}
|
||||
}
|
||||
|
||||
export const LotModel = getModelForClass(Lot);
|
||||
|
||||
Reference in New Issue
Block a user