-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathDonationRecipient.ts
More file actions
74 lines (66 loc) · 1.88 KB
/
DonationRecipient.ts
File metadata and controls
74 lines (66 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import {
JsonController,
Post,
Authorized,
CurrentUser,
Body,
Get,
QueryParams,
Param,
Put,
Patch,
Delete,
OnUndefined,
OnNull,
} from 'routing-controllers';
import { ResponseSchema } from 'routing-controllers-openapi';
import {
User,
UserRole,
VerificationBaseFilter,
DonationRecipient,
DonationRecipientListChunk,
} from '../model';
import { VerificationService } from '../service';
@JsonController('/donation/recipient')
export class DonationRecipientController {
service = new VerificationService(DonationRecipient, ['name', 'remark']);
@Post()
@Authorized()
create(@CurrentUser() createdBy: User, @Body() data: DonationRecipient) {
return this.service.createOne(data, createdBy);
}
@Get()
@ResponseSchema(DonationRecipientListChunk)
getList(@QueryParams() filter: VerificationBaseFilter) {
return this.service.getList(filter);
}
@Get('/:id')
@ResponseSchema(DonationRecipient)
@OnNull(404)
getOne(@Param('id') id: number) {
return this.service.getOne(id);
}
@Put('/:id')
@Authorized()
@ResponseSchema(DonationRecipient)
edit(
@CurrentUser() updatedBy: User,
@Param('id') id: number,
@Body() clinic: DonationRecipient,
) {
return this.service.editOne(id, clinic, updatedBy);
}
@Patch('/:id/verification')
@Authorized([UserRole.Admin, UserRole.Worker])
@ResponseSchema(DonationRecipient)
verify(@CurrentUser() verifiedBy: User, @Param('id') id: number) {
return this.service.verifyOne(id, verifiedBy);
}
@Delete('/:id')
@Authorized()
@OnUndefined(204)
deleteOne(@Param('id') id: number, @CurrentUser() deletedBy: User) {
return this.service.deleteOne(id, deletedBy);
}
}