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 qbr = this.service.queryBuilder(qobj);
    const result = await this.service.query(qbr, others);
    return result;
  }

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