import { Controller, Get, Inject } from '@midwayjs/core';
import { InitSystemDataService } from '../service/initData/initSystemData.service';
import { DataDealService } from '../service/initData/dataDeal.service';
import { NeedAdminMiddleware } from '../middleware/needAdmin.middleware';
import { ESService } from '../service/elasticsearch/es.service';

/**所有的操作都不需要await.目前是 下达一个无监控的任务进程 */
@Controller('/system/func', { middleware: [NeedAdminMiddleware] })
export class SystemFuncController {
  @Inject()
  InitSystemData: InitSystemDataService;
  @Inject()
  DataDeal: DataDealService;
  @Inject()
  es: ESService;

  @Get('/')
  async index() {
    console.log('in');
  }

  @Get('/initES')
  async initES() {
    this.es.initES();
  }

  /**修正导入的数据为 richText的数据 */
  @Get('/cid')
  async correctImportData() {
    this.DataDeal.correctImportData();
  }

  /**初始化后台目录 */
  @Get('/ism')
  async initSystemMenus() {
    this.InitSystemData.initSystemMenus();
  }

  /**初始化用户目录 */
  @Get('/ium')
  async initUserMenus() {
    this.InitSystemData.initUserMenus();
  }
  /**初始化角色数据 */
  @Get('/ir')
  async initRoleData() {
    this.InitSystemData.initRoleData();
  }
  /**初始化角色的菜单(不包含管理员) */
  @Get('/irm')
  async initRoleMenus() {
    this.InitSystemData.initRoleMenus();
  }
}
