-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(shared): disable eslint rule for a entry file
- Loading branch information
Showing
16 changed files
with
129 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,107 @@ | ||
import { Body, Controller, Delete, Get, Inject, Param, Patch, Post, Put } from "@nestjs/common"; | ||
import { ClientProxy } from "@nestjs/microservices"; | ||
import { ApiOperation } from "@nestjs/swagger"; | ||
import { ScheduleDto } from "~/libs/config/src/config.dto"; | ||
import { ApiName } from "~/shared/common/decorator/openapi.decorator"; | ||
import { NotificationEvents } from "~/shared/constants/event.constant"; | ||
import { ServicesEnum } from "~/shared/constants/services.constant"; | ||
import { transportReqToMicroservice } from "~/shared/microservice.transporter"; | ||
import { | ||
Body, | ||
Controller, | ||
Delete, | ||
Get, | ||
Inject, | ||
Param, | ||
Patch, | ||
Post, | ||
Put, | ||
} from '@nestjs/common'; | ||
import { ClientProxy } from '@nestjs/microservices'; | ||
import { ApiOperation } from '@nestjs/swagger'; | ||
import { ScheduleDto } from '~/libs/config/src/config.dto'; | ||
import { ApiName } from '~/shared/common/decorator/openapi.decorator'; | ||
import { NotificationEvents } from '~/shared/constants/event.constant'; | ||
import { ServicesEnum } from '~/shared/constants/services.constant'; | ||
import { transportReqToMicroservice } from '~/shared/microservice.transporter'; | ||
|
||
@Controller("schedule") | ||
@Controller('schedule') | ||
@ApiName | ||
export class ScheduleController { | ||
constructor( | ||
@Inject(ServicesEnum.notification) private readonly notification: ClientProxy | ||
){} | ||
@Inject(ServicesEnum.notification) | ||
private readonly notification: ClientProxy, | ||
) {} | ||
|
||
@Post("") | ||
@ApiOperation({ summary: "创建定时任务" }) | ||
@Post('') | ||
@ApiOperation({ summary: '创建定时任务' }) | ||
// @Auth() | ||
async createSchedule(@Body() body: ScheduleDto) { | ||
return transportReqToMicroservice(this.notification, NotificationEvents.ScheduleCreateByMaster, body) | ||
return transportReqToMicroservice( | ||
this.notification, | ||
NotificationEvents.ScheduleCreateByMaster, | ||
body, | ||
); | ||
} | ||
|
||
@Delete("/:token") | ||
@ApiOperation({ summary: "删除定时任务" }) | ||
@Delete('/:token') | ||
@ApiOperation({ summary: '删除定时任务' }) | ||
// @Auth() | ||
async deleteSchedule(@Param("token") token: string) { | ||
return transportReqToMicroservice(this.notification, NotificationEvents.ScheduleDeleteByMaster, token) | ||
async deleteSchedule(@Param('token') token: string) { | ||
return transportReqToMicroservice( | ||
this.notification, | ||
NotificationEvents.ScheduleDeleteByMaster, | ||
token, | ||
); | ||
} | ||
|
||
@Put("/:token") | ||
@ApiOperation({ summary: "更新定时任务" }) | ||
@Put('/:token') | ||
@ApiOperation({ summary: '更新定时任务' }) | ||
// @Auth() | ||
async updateSchedule(@Param("token") token: string, @Body() body: ScheduleDto) { | ||
return transportReqToMicroservice(this.notification, NotificationEvents.ScheduleUpdateByMaster, { token, body }) | ||
async updateSchedule( | ||
@Param('token') token: string, | ||
@Body() body: ScheduleDto, | ||
) { | ||
return transportReqToMicroservice( | ||
this.notification, | ||
NotificationEvents.ScheduleUpdateByMaster, | ||
{ token, body }, | ||
); | ||
} | ||
|
||
@Get("/:token/run") | ||
@ApiOperation({ summary: "立即运行定时任务" }) | ||
@Get('/:token/run') | ||
@ApiOperation({ summary: '立即运行定时任务' }) | ||
// @Auth() | ||
async runSchedule(@Param("token") token: string) { | ||
return transportReqToMicroservice(this.notification, NotificationEvents.ScheduleRunByMaster, token) | ||
async runSchedule(@Param('token') token: string) { | ||
return transportReqToMicroservice( | ||
this.notification, | ||
NotificationEvents.ScheduleRunByMaster, | ||
token, | ||
); | ||
} | ||
|
||
@Get("/:token") | ||
@ApiOperation({ summary: "获取定时任务详情" }) | ||
@Get('/:token') | ||
@ApiOperation({ summary: '获取定时任务详情' }) | ||
// @Auth() | ||
async getSchedule(@Param("token") token: string) { | ||
return transportReqToMicroservice(this.notification, NotificationEvents.ScheduleGetByMaster, token) | ||
async getSchedule(@Param('token') token: string) { | ||
return transportReqToMicroservice( | ||
this.notification, | ||
NotificationEvents.ScheduleGetByMaster, | ||
token, | ||
); | ||
} | ||
|
||
@Get("") | ||
@ApiOperation({ summary: "获取所有定时任务" }) | ||
@Get('') | ||
@ApiOperation({ summary: '获取所有定时任务' }) | ||
// @Auth() | ||
async getSchedules() { | ||
return transportReqToMicroservice(this.notification, NotificationEvents.SchedulesGetAllByMaster, {}) | ||
return transportReqToMicroservice( | ||
this.notification, | ||
NotificationEvents.SchedulesGetAllByMaster, | ||
{}, | ||
); | ||
} | ||
|
||
@Patch("/:token") | ||
@ApiOperation({ summary: "切换定时任务状态" }) | ||
@Patch('/:token') | ||
@ApiOperation({ summary: '切换定时任务状态' }) | ||
// @Auth() | ||
async toggleSchedule(@Param("token") token: string) { | ||
return transportReqToMicroservice(this.notification, NotificationEvents.ScheduleToggleByMaster, token) | ||
async toggleSchedule(@Param('token') token: string) { | ||
return transportReqToMicroservice( | ||
this.notification, | ||
NotificationEvents.ScheduleToggleByMaster, | ||
token, | ||
); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
import { Module } from "@nestjs/common"; | ||
import { ClientsModule } from "@nestjs/microservices"; | ||
import { ServicesEnum } from "~/shared/constants/services.constant"; | ||
import { REDIS_TRANSPORTER } from "~/shared/constants/transporter.constants"; | ||
import { ScheduleController } from "./schedule.controller"; | ||
import { Module } from '@nestjs/common'; | ||
import { ClientsModule } from '@nestjs/microservices'; | ||
import { ServicesEnum } from '~/shared/constants/services.constant'; | ||
import { REDIS_TRANSPORTER } from '~/shared/constants/transporter.constants'; | ||
import { ScheduleController } from './schedule.controller'; | ||
|
||
@Module({ | ||
imports: [ | ||
ClientsModule.register([ | ||
{ | ||
name: ServicesEnum.notification, | ||
...REDIS_TRANSPORTER, | ||
} | ||
]) | ||
}, | ||
]), | ||
], | ||
controllers: [ScheduleController] | ||
controllers: [ScheduleController], | ||
}) | ||
export class ScheduleModule{} | ||
export class ScheduleModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters