1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- import { Body, Controller, Del, Get, Inject, Param, Post, Query } from '@midwayjs/decorator';
- import { BaseController } from 'free-midway-component';
- import { DataLogsService } from '../../service/record/dataLogs.service';
- import { CDTO_dataLogs, CVO_dataLogs, FVO_dataLogs, QDTO_dataLogs, QVO_dataLogs, UDTO_dataLogs, UVAO_dataLogs } from '../../interface/record/dataLogs.interface';
- import { ApiResponse, ApiTags, ApiQuery } from '@midwayjs/swagger';
- import { Validate } from '@midwayjs/validate';
- @ApiTags(['mongodb oplog'])
- @Controller('/dataLogs')
- export class DataLogsController extends BaseController {
- @Inject()
- service: DataLogsService;
- @Post('/')
- @Validate()
- @ApiResponse({ type: CVO_dataLogs })
- async create(@Body() data: CDTO_dataLogs) {
- const dbData = await this.service.create(data);
- const result = new CVO_dataLogs(dbData);
- return result;
- }
- @Get('/')
- @ApiQuery({ name: 'query' })
- @ApiResponse({ type: QVO_dataLogs })
- async query(@Query() filter: QDTO_dataLogs, @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_dataLogs(i);
- data.push(newData);
- }
- const total = await this.service.count(filter);
- return { data, total };
- }
- @Get('/:id')
- @ApiResponse({ type: FVO_dataLogs })
- async fetch(@Param('id') id: string) {
- const data = await this.service.fetch(id);
- const result = new FVO_dataLogs(data);
- return result;
- }
- @Post('/:id')
- @Validate()
- @ApiResponse({ type: UVAO_dataLogs })
- async update(@Param('id') id: string, @Body() body: UDTO_dataLogs) {
- 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.');
- }
- }
|