修改数据库

This commit is contained in:
邹景立 2022-10-28 10:49:12 +08:00
parent 9eb6077149
commit 58bbd06e15
4 changed files with 18 additions and 19 deletions

View File

@ -17,9 +17,9 @@ class InstallAdminData extends Migrator
*/
public function change()
{
$this->createUser();
$this->createMenu();
$this->createConf();
$this->insertUser();
$this->insertMenu();
$this->insertConf();
}
/**
@ -27,7 +27,7 @@ class InstallAdminData extends Migrator
* @return void
* @throws \think\db\exception\DbException
*/
private function createUser()
private function insertUser()
{
// 检查是否存在
$map = ['username' => 'admin'];
@ -37,7 +37,7 @@ class InstallAdminData extends Migrator
// 初始化默认数据
SystemUser::mk()->save([
'id' => 10000,
'id' => '10000',
'username' => 'admin',
'nickname' => '超级管理员',
'password' => '21232f297a57a5a743894a0e4a801fc3',
@ -47,12 +47,12 @@ class InstallAdminData extends Migrator
/**
* 初始化系统菜单
* @return bool
* @return void
*/
private function createMenu(): bool
private function insertMenu()
{
// 初始化菜单数据
return ToolsExtend::write2menu([
ToolsExtend::write2menu([
[
'name' => '系统管理',
'sort' => '100',
@ -85,7 +85,7 @@ class InstallAdminData extends Migrator
* @return void
* @throws \think\db\exception\DbException
*/
private function createConf()
private function insertConf()
{
// 检查数据
if (SystemConfig::mk()->count()) return;

View File

@ -11,21 +11,19 @@ class InstallWechatData extends Migrator
/**
* 初始化数据
* @return void
* @throws \think\db\exception\DbException
*/
public function change()
{
$this->createMenu();
$this->insertMenu();
}
/**
* 初始化菜单
* @return bool
*/
private function createMenu(): bool
private function insertMenu()
{
// 写入微信菜单
return ToolsExtend::write2menu([
ToolsExtend::write2menu([
[
'name' => '微信管理',
'sort' => '200',

View File

@ -13,16 +13,16 @@ class InstallUserData extends Migrator
*/
public function change()
{
$this->createMenu();
$this->insertMenu();
}
/**
* 创建菜单
* @return boolean
* @return void
*/
protected function createMenu(): bool
protected function insertMenu()
{
return ToolsExtend::write2menu([
ToolsExtend::write2menu([
[
'name' => '控制台',
'sort' => '300',

View File

@ -26,7 +26,8 @@ class InstallUserRegion extends Migrator
{
// 检查数据
$table = 'base_postage_region';
if (app()->db->table($table)->count() > 0) return;
$result = $this->fetchRow("select count(1) _count from $table");
if (isset($result['_count']) && $result['_count'] > 0) return;
// 写入数据
$this->execute(<<<SQL