12345678910111213141516171819202122232425262728293031323334 |
- import { Body, Controller, Post, Get, Header, HttpCode } from '@nestjs/common'
- import { TencentCloudService } from './tencent-cloud.service'
- @Controller('tencentCloud')
- export class TencentCloudController {
- constructor(private readonly tencentCloudService: TencentCloudService) {}
- @Post('chat')
- @Header('Access-Control-Allow-Origin', '*')
- @Header('Content-type', 'application/json')
- @HttpCode(200)
- async chat(@Body() { ctx, chat }) {
- if (!chat) {
- return {
- code: -1,
- msg: '请求成功',
- data: '无当前对话'
- }
- }
- const data = await this.tencentCloudService.chat(ctx, chat)
- return {
- code: 0,
- msg: '请求成功',
- data
- }
- }
- @Get('test')
- test() {
- return '接口测试'
- }
- }
|