Skip to content

Commit 78f5b0f

Browse files
committed
support reprint
1 parent 3526ceb commit 78f5b0f

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

packages/server/handler/balloon.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,27 @@
11
/* eslint-disable no-await-in-loop */
2+
import { ValidationError } from '../error';
23
import { Context } from '../interface';
4+
import { Logger } from '../utils';
35
import { AuthHandler } from './misc';
46

7+
const logger = new Logger('handler/print');
8+
59
class BalloonAdminHandler extends AuthHandler {
610
async get() {
711
const balloons = await this.ctx.db.balloon.find({ shouldPrint: true }).sort({ time: -1 });
812
const clients = await this.ctx.db.client.find({ type: 'balloon' }).sort({ createAt: 1 });
913
this.response.body = { balloons, clients };
1014
}
15+
16+
async postReprint(params) {
17+
const balloon = await this.ctx.db.balloon.findOne({ balloonid: params.balloonid });
18+
if (!balloon) {
19+
logger.info(balloon, params.balloonid);
20+
throw new ValidationError('Balloon', params.balloonid, 'Balloon not found');
21+
}
22+
await this.ctx.db.balloon.updateOne({ balloonid: params.balloonid }, { $set: { printDone: 0 } });
23+
this.response.body = { success: true };
24+
}
1125
}
1226

1327
export async function apply(ctx: Context) {

0 commit comments

Comments
 (0)