1234567891011121314151617181920212223242526272829303132333435 |
- 'use strict';
- const { CrudService } = require('naf-framework-mongoose-free/lib/service');
- const { BusinessError, ErrorCode } = require('naf-core').Error;
- const _ = require('lodash');
- const assert = require('assert');
- // 初始化
- class InstallService extends CrudService {
- constructor(ctx) {
- super(ctx, 'install');
- this.model = this.ctx.model.Install;
- }
- async init() {
- // this.initAdmin();
- }
- async initAdmin() {
- console.log('开始=>初始化总管理员'.blue);
- const data = await this.ctx.model.Admin.findOne();
- if (!data) {
- // 没有管理员,初始化一个
- const data = {
- account: 'admin',
- is_super: true,
- password: { secret: '111111' },
- _tenant: 'master',
- };
- console.log('正在初始化总管理员'.blue);
- await this.ctx.model.Admin.create(data);
- console.log('初始化总管理员=>结束'.green);
- } else console.log('无需再次初始化总管理员'.yellow);
- }
- }
- module.exports = InstallService;
|