File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change 1
1
/* eslint-disable no-await-in-loop */
2
+ import { ValidationError } from '../error' ;
2
3
import { Context } from '../interface' ;
4
+ import { Logger } from '../utils' ;
3
5
import { AuthHandler } from './misc' ;
4
6
7
+ const logger = new Logger ( 'handler/print' ) ;
8
+
5
9
class BalloonAdminHandler extends AuthHandler {
6
10
async get ( ) {
7
11
const balloons = await this . ctx . db . balloon . find ( { shouldPrint : true } ) . sort ( { time : - 1 } ) ;
8
12
const clients = await this . ctx . db . client . find ( { type : 'balloon' } ) . sort ( { createAt : 1 } ) ;
9
13
this . response . body = { balloons, clients } ;
10
14
}
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
+ }
11
25
}
12
26
13
27
export async function apply ( ctx : Context ) {
You can’t perform that action at this time.
0 commit comments