'use strict';
class AppBootHook {
  constructor(app) {
    this.app = app;
  }

  async willReady() {
    const data = await this.app.model.Admin.findOne();
    if (!data) {
      // 没有管理员,初始化一个
      const data = {
        account: 'admin',
        password: { secret: '123456' },
      };
      await this.app.model.Admin.create(data);
    }
  }

  async serverDidReady() {
    // 应用已经启动完毕
    const ctx = await this.app.createAnonymousContext();
    // 检查种子
    // await ctx.service.install.index();
    await ctx.service.util.rabbitMq.mission();
  }

}
module.exports = AppBootHook;