Skip to content

Commit

Permalink
更新:优化安装命令,支持自动填充数据
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuchunshu committed Jan 18, 2023
1 parent d76f595 commit 6a07f4d
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 1 deletion.
42 changes: 41 additions & 1 deletion app/CodeFec/Install.php
Expand Up @@ -195,9 +195,29 @@ public function step_3()

$exitCode = $application->run($input, $output);

$this->command->info('数据库迁移成功!');


// 数据填充
$command = 'db:seed';

$params = ['command' => $command];

$input = new ArrayInput($params);
$output = new NullOutput();

$container = \Hyperf\Utils\ApplicationContext::getContainer();

/** @var Application $application */
$application = $container->get(\Hyperf\Contract\ApplicationInterface::class);
$application->setAutoExit(false);

$exitCode = $application->run($input, $output);

// 下一步
$this->addStep();

$this->command->info('数据库迁移成功!');
$this->command->info('数据库填充成功!');
$this->command->info("\n请重新运行此命令!");
}

Expand Down Expand Up @@ -252,6 +272,26 @@ public function step_4()
'SERVER_WEB_PORT' => $web,
'SERVER_WS_PORT' => $ws,
]);

// gen auth-env

// 数据填充
$command = 'gen:auth-env';

$params = ['command' => $command];

$input = new ArrayInput($params);
$output = new NullOutput();

$container = \Hyperf\Utils\ApplicationContext::getContainer();

/** @var Application $application */
$application = $container->get(\Hyperf\Contract\ApplicationInterface::class);
$application->setAutoExit(false);

$exitCode = $application->run($input, $output);


$this->addStep();
$this->command->info('配置成功!');
$this->command->info("\nWEB服务端口:" . $web . "\nWEBSOCKET服务端口:" . $ws);
Expand Down
32 changes: 32 additions & 0 deletions seeders/topic_tag_seeder.php
@@ -0,0 +1,32 @@
<?php

declare(strict_types=1);

use Hyperf\Database\Seeders\Seeder;

class TopicTagSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
\Hyperf\DbConnection\Db::table('topic_tag')->insert([
'name' => '默认板块',
'color' => '#000000',
'icon' => '<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-message" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
<path d="M4 21v-13a3 3 0 0 1 3 -3h10a3 3 0 0 1 3 3v6a3 3 0 0 1 -3 3h-9l-4 4"></path>
<line x1="8" y1="9" x2="16" y2="9"></line>
<line x1="8" y1="13" x2="14" y2="13"></line>
</svg>',
'description' => '默认板块描述',
'type' => null,
'created_at' => date("Y-m-d H:i:s"),
'updated_at' => date("Y-m-d H:i:s"),
'font_color' => '#FFFFFF'
]);
}
}
33 changes: 33 additions & 0 deletions seeders/user_class_seeder.php
@@ -0,0 +1,33 @@
<?php

declare(strict_types=1);

use Hyperf\Database\Seeders\Seeder;

class UserClassSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
//
\Hyperf\DbConnection\Db::table('user_class')->insert([
'name' => '默认用户组',
'color' => '#206bc4',
'icon' => '<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-users" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
<circle cx="9" cy="7" r="4"></circle>
<path d="M3 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2"></path>
<path d="M16 3.13a4 4 0 0 1 0 7.75"></path>
<path d="M21 21v-2a4 4 0 0 0 -3 -3.85"></path>
</svg>',
'quanxian' => '["comment_caina","comment_create","comment_edit","comment_remove","report_comment","report_topic","topic_create","topic_delete","topic_edit","topic_tag_create"]',
'permission-value' => '1',
'created_at' => date("Y-m-d H:i:s"),
'updated_at' => date("Y-m-d H:i:s")
]);
}
}

0 comments on commit 6a07f4d

Please sign in to comment.