Commit a10d16dc authored by nanahira's avatar nanahira

fix

parent d4adb53d
...@@ -397,18 +397,24 @@ export class TournamentService extends CrudService(Tournament, { ...@@ -397,18 +397,24 @@ export class TournamentService extends CrudService(Tournament, {
updates: { id: T; seq: number }[], updates: { id: T; seq: number }[],
) { ) {
if (updates.length) { if (updates.length) {
await this.repo.manager if (updates.length > 1) {
.createQueryBuilder() await this.repo.manager
.update(Participant) .createQueryBuilder()
.set({ .update(Participant)
seq: () => ` .set({
seq: () => `
CASE id CASE id
${updates.map((p) => `WHEN ${p.id} THEN ${p.seq}`).join('\n')} ${updates.map((p) => `WHEN ${p.id} THEN ${p.seq}`).join('\n')}
END END
`, `,
}) })
.whereInIds(updates.map((p) => p.id)) .whereInIds(updates.map((p) => p.id))
.execute(); .execute();
} else {
await this.repo.manager.update(Participant, updates[0].id, {
seq: updates[0].seq,
});
}
} }
return new GenericReturnMessageDto( return new GenericReturnMessageDto(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment