import { Config, Controller, Get, Inject, Query } from '@midwayjs/core';
import { InitTwoService } from '../service/initData/initTwo.service';
import { InitRegionService } from '../service/initData/initRegion.service';
import { InitOneService } from '../service/initData/initOne.service';
import { QichachaService } from '../service/thirdParty/qichacha.service';
import { InitThreeService } from '../service/initData/initThree.service';
import { DataDealService } from '../service/initData/dataDeal.service';
import { TestsService } from '../service/tests.service';
import { ESService } from '../service/elasticsearch/es.service';
import { Opera } from '../frame/dbOpera';
@Controller('/')
export class HomeController {
  @Inject()
  threeService: InitThreeService;
  @Inject()
  twoService: InitTwoService;
  @Inject()
  oneService: InitOneService;
  @Inject()
  regionService: InitRegionService;
  @Inject()
  qichachaService: QichachaService;
  @Inject()
  dataDealService: DataDealService;
  @Inject()
  testService: TestsService;
  @Inject()
  esService: ESService;

  Opera = Opera;

  @Get('/')
  async home(@Query() query: object): Promise<any> {
    // await this.esService.initES()
    // await this.dataDealService.initUserMenus();
    // await this.dataDealService.initRoleMenus();
    // await this.oneService.addTags();
    // await this.oneService.addImportDataTags();
    // await this.twoService.addTags();
    // await this.twoService.addImportDataTags();
    // await this.oneService.dataToUse();
    // await this.twoService.dataToUse();
    // await this.threeService.dataToUse();
    // const data = await this.qichachaService.searchByName('长春市福瑞科技');
    // await this.threeService.import2021Company();
    // await this.threeService.import2024Company();
    // await this.threeService.importMatching();
    // await this.dataDealService.JsonbAddDefault();
    // const sq = { 'props.hobby': '睡觉1' };
    // const operas = { 'props.hobby': Opera.JsonObject };
    // const res = await this.testService.query(sq, null, operas);
    // const body = {
    //   nick_name: '测试20240806_1',
    //   account: '测试20240806_1',
    //   age: 20,
    //   hobby: ['上班'],
    //   time: '2024-09-01',
    //   tags: ['黑奴'],
    // };
    // const res = await this.testService.create(body);
    // const id = 9;
    // const res = await this.testService.update({ id }, { age: 21 });
    // const res = await this.testService.fetch({ id });
    // const res = await this.testService.delete({ id });
    // return res;
    return 'starting...';
  }
  // @Get('/:method')
  // async test(@Param('method') method: string, @Query() query: object) {
  //   const result: any = await this.adminService[method](query);
  //   return result;
  // }
}
