拍卖行:获取数据接口和出价接口部分功能

This commit is contained in:
liangtongchuan
2021-03-18 01:25:34 +08:00
parent ac4d2dbf84
commit 3cc1ff2760
8 changed files with 113 additions and 20 deletions
+14 -3
View File
@@ -8,7 +8,7 @@ import { genCode } from '../pubUtils/util';
**/
@modelOptions({ schemaOptions: { id: false } })
@index({ code: 1 })
@index({ guildCode: 1, createdAt: -1 })
@index({ guildCode: 1, begin: -1 })
export default class Lot extends BaseModel {
@prop({ required: true, default: 0 })
auctionStage: number; // 0:初始添加,1:军团拍卖,2:世界拍卖,3:拍卖结束
@@ -56,10 +56,21 @@ export default class Lot extends BaseModel {
return result;
}
public static async findGuildLotsByTime(guildCode: string, sourceType: number, time: Date) {
const results = await LotModel.find({ guildCode, sourceType, createdAt: { $gte: time } }).select('-_id -__v').lean();
public static async findGuildLotsByBegin(guildCode: string, time: Date) {
const results = await LotModel.find({ guildCode, begin: { $eq: time } }).select('-_id -__v').lean();
return results;
}
public static async findWorldLotsByBegin(serverId: number, time: Date) {
const results = await LotModel.find({ serverId, begin: { $eq: time } }).select('-_id -__v').lean();
return results;
}
public static async updateLot(data: LotParam) {
const code = data.code!;
const result: LotType = await LotModel.findOneAndUpdate({ code }, { ...data }, { new: true }).select('-_id -__v').lean();
return result;
}
}
export const LotModel = getModelForClass(Lot);