拍卖行:出价、关注接口和测试用例
This commit is contained in:
+23
-4
@@ -34,10 +34,14 @@ export default class Lot extends BaseModel {
|
||||
maxPrice: number; // 一口价,最高价格
|
||||
@prop({ required: true, type: BidRec, default: [] })
|
||||
bidRoles: BidRec[];
|
||||
@prop({ required: true, type: String, default: [] })
|
||||
watchingRoles: string[];
|
||||
@prop({ required: true })
|
||||
begin: Date; // 竞拍开始时间
|
||||
@prop({ required: true })
|
||||
end: Date; // 竞拍结束时间
|
||||
@prop({ required: true, default: 0 })
|
||||
status: number; // 拍品状态,0:无人竞拍;1:竞拍中;2:已拍
|
||||
|
||||
public static async createRec(data: LotParam) {
|
||||
const code = genCode(8);
|
||||
@@ -56,13 +60,18 @@ export default class Lot extends BaseModel {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async findGuildLotsByBegin(guildCode: string, time: Date) {
|
||||
const results = await LotModel.find({ guildCode, begin: { $eq: time } }).select('-_id -__v').lean();
|
||||
public static async findGuildLotsByBegin(guildCode: string, begin: Date) {
|
||||
const results = await LotModel.find({ guildCode, begin }).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();
|
||||
public static async findWorldLotsByBegin(serverId: number, begin: Date) {
|
||||
const results = await LotModel.find({ serverId, begin }).select('-_id -__v').lean();
|
||||
return results;
|
||||
}
|
||||
|
||||
public static async findWatchingLotsByBegin(roleId: string, serverId: number, begin: Date) {
|
||||
const results = await LotModel.find({ serverId, begin, watchingRoles: roleId }, { new: true }).select('-_id -__v').lean();
|
||||
return results;
|
||||
}
|
||||
|
||||
@@ -71,6 +80,16 @@ export default class Lot extends BaseModel {
|
||||
const result: LotType = await LotModel.findOneAndUpdate({ code }, { ...data }, { new: true }).select('-_id -__v').lean();
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async watchLot(code: string, roleId: string) {
|
||||
const result: LotType = await LotModel.findOneAndUpdate({ code }, { $addToSet: { watchingRoles: roleId } }, { new: true }).select('-_id -__v').lean();
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async unWatchLot(code: string, roleId: string) {
|
||||
const result: LotType = await LotModel.findOneAndUpdate({ code }, { $pull: { watchingRoles: roleId } }, { new: true }).select('-_id -__v').lean();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
export const LotModel = getModelForClass(Lot);
|
||||
|
||||
Reference in New Issue
Block a user