import { Body, Controller, Del, Get, Inject, Param, Post, Query, } from '@midwayjs/decorator'; import { BaseController } from 'free-midway-component'; import { TeamService } from '../service/team.service'; import { CDTO_team, CVO_team, FVO_team, QVO_team, UDTO_team, UVAO_team, } from '../interface/team.interface'; import { ApiResponse, ApiTags, ApiQuery } from '@midwayjs/swagger'; import { Validate } from '@midwayjs/validate'; @ApiTags(['团队']) @Controller('/team') export class TeamController extends BaseController { @Inject() service: TeamService; @Post('/') @Validate() @ApiResponse({ type: CVO_team }) async create(@Body() data: CDTO_team) { const dbData = await this.service.create(data); const result = new CVO_team(dbData); return result; } @Get('/') @ApiQuery({ name: 'query' }) @ApiResponse({ type: QVO_team }) async query(@Query() filter: any) { const list = await this.service.specialQuery(filter); const data = []; for (const i of list.data) { const newData = new QVO_team(i); data.push(newData); } const total = list.total; return { data, total }; } @Get('/:id') @ApiResponse({ type: FVO_team }) async fetch(@Param('id') id: string) { const data = await this.service.fetch(id); const result = new FVO_team(data); return result; } @Post('/:id') @Validate() @ApiResponse({ type: UVAO_team }) async update(@Param('id') id: string, @Body() body: UDTO_team) { const result = await this.service.updateOne(id, body); return result; } @Del('/:id') @Validate() async delete(@Param('id') id: string) { await this.service.delete(id); return 'ok'; } async createMany(...args: any[]) { throw new Error('Method not implemented.'); } async updateMany(...args: any[]) { throw new Error('Method not implemented.'); } async deleteMany(...args: any[]) { throw new Error('Method not implemented.'); } }