m
This commit is contained in:
+24
-1
@@ -26,6 +26,7 @@ const typeorm_2 = require("typeorm");
|
||||
const data_source_context_1 = require("../../common/context/data_source.context");
|
||||
const im_help_1 = require("../../common/util/im_help");
|
||||
const app_env_1 = require("../../../app.env");
|
||||
const admin_model_1 = require("../../../model/admin.model");
|
||||
let TaskInstallService = TaskInstallService_1 = class TaskInstallService {
|
||||
systemConfigModel;
|
||||
userModel;
|
||||
@@ -33,15 +34,17 @@ let TaskInstallService = TaskInstallService_1 = class TaskInstallService {
|
||||
teamRelationModel;
|
||||
inviteCodePoolModel;
|
||||
userSignInModel;
|
||||
adminModel;
|
||||
dataSource;
|
||||
logger = new common_1.Logger(TaskInstallService_1.name);
|
||||
constructor(systemConfigModel, userModel, walletModel, teamRelationModel, inviteCodePoolModel, userSignInModel, dataSource) {
|
||||
constructor(systemConfigModel, userModel, walletModel, teamRelationModel, inviteCodePoolModel, userSignInModel, adminModel, dataSource) {
|
||||
this.systemConfigModel = systemConfigModel;
|
||||
this.userModel = userModel;
|
||||
this.walletModel = walletModel;
|
||||
this.teamRelationModel = teamRelationModel;
|
||||
this.inviteCodePoolModel = inviteCodePoolModel;
|
||||
this.userSignInModel = userSignInModel;
|
||||
this.adminModel = adminModel;
|
||||
this.dataSource = dataSource;
|
||||
}
|
||||
onModuleInit() {
|
||||
@@ -58,12 +61,30 @@ let TaskInstallService = TaskInstallService_1 = class TaskInstallService {
|
||||
else {
|
||||
this.logger.verbose('系统配置已存在,跳过初始化');
|
||||
}
|
||||
await this.createAdminUser();
|
||||
this.logger.verbose('开始创建顶级用户...');
|
||||
const topUser = await this.createTopUser();
|
||||
await this.initImGroup(topUser.id);
|
||||
this.logger.verbose('安装任务执行完成,即将退出进程');
|
||||
process.exit(0);
|
||||
}
|
||||
async createAdminUser() {
|
||||
this.logger.verbose('开始创建管理员账号...');
|
||||
const old = await this.adminModel.findOneBy({
|
||||
username: 'admin',
|
||||
});
|
||||
if (old) {
|
||||
this.logger.verbose('管理员账号已存在');
|
||||
}
|
||||
else {
|
||||
const admin = this.adminModel.create({
|
||||
username: 'admin',
|
||||
password: 'Aa123123.',
|
||||
});
|
||||
await this.adminModel.save(admin);
|
||||
this.logger.verbose('管理员账号创建完成');
|
||||
}
|
||||
}
|
||||
async createTopUser() {
|
||||
const queryRunner = this.dataSource.createQueryRunner();
|
||||
return await data_source_context_1.DataSourceContext.startTransactionToQueryRunner(queryRunner, async (transaction) => {
|
||||
@@ -147,12 +168,14 @@ exports.TaskInstallService = TaskInstallService = TaskInstallService_1 = __decor
|
||||
__param(3, (0, typeorm_1.InjectRepository)(team_relation_model_1.TeamRelationModel)),
|
||||
__param(4, (0, typeorm_1.InjectRepository)(invite_code_pool_model_1.InviteCodePoolModel)),
|
||||
__param(5, (0, typeorm_1.InjectRepository)(user_sign_in_model_1.UserSignInModel)),
|
||||
__param(6, (0, typeorm_1.InjectRepository)(admin_model_1.AdminModel)),
|
||||
__metadata("design:paramtypes", [typeorm_2.Repository,
|
||||
typeorm_2.Repository,
|
||||
typeorm_2.Repository,
|
||||
typeorm_2.Repository,
|
||||
typeorm_2.Repository,
|
||||
typeorm_2.Repository,
|
||||
typeorm_2.Repository,
|
||||
typeorm_2.DataSource])
|
||||
], TaskInstallService);
|
||||
//# sourceMappingURL=task_install.service.js.map
|
||||
Reference in New Issue
Block a user