This repository was archived by the owner on Mar 30, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathschedule.controller.ts
More file actions
48 lines (46 loc) · 1.76 KB
/
Copy pathschedule.controller.ts
File metadata and controls
48 lines (46 loc) · 1.76 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
import { Controller, ForbiddenException, Get, Param } from '@nestjs/common';
import { ApiOperation, ApiTags } from '@nestjs/swagger';
import { AdminAuthGuard } from '@/common/decorator/auth-guard.decorator';
import { ScheduleType } from '@/enum/ScheduleType';
import { CosObjectUrlScheduleService } from '@/schedule/cos-object-url-schedule/cos-object-url-schedule.service';
import { InstagramScheduleService } from '@/schedule/instagram-schedule/instagram-schedule.service';
import { PinterestScheduleService } from '@/schedule/pinterest-schedule/pinterest-schedule.service';
import { PixivScheduleService } from '@/schedule/pixiv-schedule/pixiv-schedule.service';
@Controller('schedule')
@ApiTags('schedule')
@AdminAuthGuard()
export class ScheduleController {
constructor(
private pixivScheduleService: PixivScheduleService,
private instagramScheduleService: InstagramScheduleService,
private pinterestScheduleService: PinterestScheduleService,
private cosObjectUrlScheduleService: CosObjectUrlScheduleService,
) {}
@Get(':scheduleType')
@ApiOperation({
summary: '手动触发定时任务',
operationId: 'triggerSchedule',
})
async RunScheduleByRequest(
@Param('scheduleType')
scheduleType: ScheduleType,
) {
switch (scheduleType) {
case ScheduleType.instagram:
this.instagramScheduleService.main();
break;
case ScheduleType.pinterest:
this.pinterestScheduleService.main();
break;
case ScheduleType.pixiv:
this.pixivScheduleService.main();
break;
case ScheduleType.cosObjectUrlRefresh:
await this.cosObjectUrlScheduleService.main();
break;
default:
throw new ForbiddenException('scheduleType not found');
}
return 'action success';
}
}