|
@@ -22,6 +22,24 @@ class MatchSmallGroupScheduleService extends CrudService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ async beforeCreate(body) {
|
|
|
+ // 检查数据是否有重复,如果符合检查重复条件,就把之前的删了,用新来的
|
|
|
+ const { match_id, group_id, project_id, team_id, player_one, player_two } = body;
|
|
|
+ const query = {
|
|
|
+ match_id,
|
|
|
+ group_id,
|
|
|
+ project_id,
|
|
|
+ team_id,
|
|
|
+ $or: [
|
|
|
+ { player_one, player_two },
|
|
|
+ { player_one: player_two, player_two: player_one },
|
|
|
+ ],
|
|
|
+ };
|
|
|
+ const d = await this.model.findOne(query);
|
|
|
+ if (d) await this.model.deleteOne(query);
|
|
|
+ return body;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
module.exports = MatchSmallGroupScheduleService;
|