123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- import {
- Body,
- Controller,
- Del,
- Get,
- Inject,
- Param,
- Post,
- Query,
- } from '@midwayjs/decorator';
- import { BaseController } from 'free-midway-component';
- import { PatentService } from '../service/patent.service';
- import {
- CDTO_patent,
- CVO_patent,
- FVO_patent,
- QDTO_patent,
- QVO_patent,
- UDTO_patent,
- UVAO_patent,
- ImportDTO,
- } from '../interface/patent.interface';
- import { ApiResponse, ApiTags, ApiQuery } from '@midwayjs/swagger';
- import { Validate } from '@midwayjs/validate';
- @ApiTags(['e专利'])
- @Controller('/patent')
- export class PatentController extends BaseController {
- @Inject()
- service: PatentService;
- @Post('/')
- @Validate()
- @ApiResponse({ type: CVO_patent })
- async create(@Body() data: CDTO_patent) {
- const dbData = await this.service.create(data);
- const result = new CVO_patent(dbData);
- return result;
- }
- @Get('/')
- @ApiQuery({ name: 'query' })
- @ApiResponse({ type: QVO_patent })
- async query(
- @Query() filter: QDTO_patent,
- @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_patent(i);
- data.push(newData);
- }
- const total = await this.service.count(filter);
- return { data, total };
- }
- @Get('/:id')
- @ApiResponse({ type: FVO_patent })
- async fetch(@Param('id') id: string) {
- const data = await this.service.fetch(id);
- const result = new FVO_patent(data);
- return result;
- }
- @Post('/:id')
- @Validate()
- @ApiResponse({ type: UVAO_patent })
- async update(@Param('id') id: string, @Body() body: UDTO_patent) {
- 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;
- }
- @Post('/export')
- @Validate()
- async export(@Body() body: any) {
- const result = await this.service.export(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.');
- }
- }
|