| 1 | /* |
| 2 | * @Author: nevin |
| 3 | * @Date: 2024-06-17 19:19:20 |
| 4 | * @LastEditTime: 2024-12-23 12:45:22 |
| 5 | * @LastEditors: nevin |
| 6 | * @Description: 通用工具 |
| 7 | */ |
| 8 | import { Body, Controller, Post } from '@nestjs/common'; |
| 9 | import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger'; |
| 10 | import { ParamsValidationPipe } from 'src/validation.pipe'; |
| 11 | import { TmsService } from 'src/lib/tms/tms.service'; |
| 12 | import { KwaiSignDto, TextModerationDto } from './dto/tools.dto'; |
| 13 | import { KwaiSginService } from './kwaiSign/kwaiSgin.service'; |
| 14 | import { Public } from '../../auth/auth.guard'; |
| 15 | |
| 16 | @ApiTags('通用工具') |
| 17 | @Controller('tools/common') |
| 18 | export class ToolsController { |
| 19 | constructor( |
| 20 | private readonly tmsService: TmsService, |
| 21 | private readonly kwaiSginService: KwaiSginService, |
| 22 | ) {} |
| 23 | |
| 24 | @ApiOperation({ |
| 25 | summary: '内容安全检测', |
| 26 | description: '内容安全检测', |
| 27 | }) |
| 28 | @ApiResponse({ |
| 29 | description: '是否通过检测', |
| 30 | type: Boolean, |
| 31 | }) |
| 32 | @Post('text/moderation') |
| 33 | async textModeration( |
| 34 | @Body(new ParamsValidationPipe()) body: TextModerationDto, |
| 35 | ) { |
| 36 | const res = await this.tmsService.textModeration(body.content); |
| 37 | return res; |
| 38 | } |
| 39 | |
| 40 | @ApiOperation({ |
| 41 | summary: '快手签名', |
| 42 | description: |
| 43 | '快手签名,注意,json中必须要有 ‘kuaishou.web.cp.api_ph’ 字段,此字段是从cookie获取的,type为 form-data 或 json', |
| 44 | }) |
| 45 | @Public() |
| 46 | @Post('kwaiSign') |
| 47 | async kwaiSignCore(@Body(new ParamsValidationPipe()) body: KwaiSignDto) { |
| 48 | return await this.kwaiSginService.sign(body); |
| 49 | } |
| 50 | } |
| 51 |