import { Body, Controller, Del, Get, Inject, Param, Post, Query, } from '@midwayjs/decorator'; import { BaseController } from 'free-midway-component'; import { CpcMessageService } from '../service/cpcMessage.service'; import { CDTO_cpcMessage, CVO_cpcMessage, FVO_cpcMessage, QDTO_cpcMessage, QVO_cpcMessage, UDTO_cpcMessage, UVAO_cpcMessage, ImportDTO, } from '../interface/cpcMessage.interface'; import { ApiResponse, ApiTags, ApiQuery } from '@midwayjs/swagger'; import { Validate } from '@midwayjs/validate'; @ApiTags(['国知局反馈信息']) @Controller('/cpcMessage') export class CpcMessageController extends BaseController { @Inject() service: CpcMessageService; @Post('/') @Validate() @ApiResponse({ type: CVO_cpcMessage }) async create(@Body() data: CDTO_cpcMessage) { const dbData = await this.service.create(data); const result = new CVO_cpcMessage(dbData); return result; } @Get('/') @ApiQuery({ name: 'query' }) @ApiResponse({ type: QVO_cpcMessage }) async query( @Query() filter: QDTO_cpcMessage, @Query('skip') skip: number, @Query('limit') limit: number ) { const list = await this.service.query(filter, { skip, limit }); const data = []; for (const i of list) { const newData = new QVO_cpcMessage(i); data.push(newData); } const total = await this.service.count(filter); return { data, total }; } @Get('/:id') @ApiResponse({ type: FVO_cpcMessage }) async fetch(@Param('id') id: string) { const data = await this.service.fetch(id); const result = new FVO_cpcMessage(data); return result; } @Post('/:id') @Validate() @ApiResponse({ type: UVAO_cpcMessage }) async update(@Param('id') id: string, @Body() body: UDTO_cpcMessage) { 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'; } @Post('/import') @Validate() async import(@Body() body: ImportDTO) { const result = await this.service.import(body); return result; } 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.'); } }