import { Controller, Get, Inject, Param, Query } from '@midwayjs/core';
import { OperaService } from '../../service/log/opera.service';
import { omit, pick } from 'lodash';
const namePrefix = '操作日志';
@Controller('/log/opera')
export class OperaController {
  @Inject()
  service: OperaService;
  @Get('/', { routerName: `查询${namePrefix}` })
  async index(@Query() query: object) {
    const qobj = omit(query, ['skip', 'limit']);
    const others = pick(query, ['skip', 'limit']);
    const result = await this.service.query(qobj, others);
    return result;
  }

  @Get('/:id', { routerName: `${namePrefix}` })
  async fetch(@Param('id') id: number) {
    const data = await this.service.fetch({ id });
    return data;
  }
}
