修改数据库

This commit is contained in:
邹景立 2022-10-28 10:22:53 +08:00
parent 06ed50c94c
commit 9eb6077149
5 changed files with 15 additions and 21 deletions

2
.gitignore vendored
View File

@ -22,4 +22,4 @@
/public/static/theme/css/package-lock.json /public/static/theme/css/package-lock.json
/public/static/theme/css/console.*.css /public/static/theme/css/console.*.css
/public/static/theme/css/console.*.css.map /public/static/theme/css/console.*.css.map
/database/sqlite.db /database/sqlite.*

View File

@ -28,7 +28,6 @@
"endroid/qr-code": "^1.9", "endroid/qr-code": "^1.9",
"topthink/framework": "^6.0", "topthink/framework": "^6.0",
"topthink/think-view": "^1.0", "topthink/think-view": "^1.0",
"topthink/think-migration": "^3.0",
"zoujingli/ip2region": "^2.0", "zoujingli/ip2region": "^2.0",
"zoujingli/think-library": "6.0.x-dev", "zoujingli/think-library": "6.0.x-dev",
"zoujingli/wechat-developer": "^1.2" "zoujingli/wechat-developer": "^1.2"

View File

@ -47,12 +47,12 @@ class InstallAdminData extends Migrator
/** /**
* 初始化系统菜单 * 初始化系统菜单
* @return void * @return bool
*/ */
private function createMenu() private function createMenu(): bool
{ {
// 初始化菜单数据 // 初始化菜单数据
ToolsExtend::write2menu([ return ToolsExtend::write2menu([
[ [
'name' => '系统管理', 'name' => '系统管理',
'sort' => '100', 'sort' => '100',
@ -87,9 +87,10 @@ class InstallAdminData extends Migrator
*/ */
private function createConf() private function createConf()
{ {
if (SystemConfig::mk()->count()) { // 检查数据
return; if (SystemConfig::mk()->count()) return;
}
// 写入数据
SystemConfig::mk()->insertAll([ SystemConfig::mk()->insertAll([
['type' => 'base', 'name' => 'app_name', 'value' => 'ThinkAdmin'], ['type' => 'base', 'name' => 'app_name', 'value' => 'ThinkAdmin'],
['type' => 'base', 'name' => 'app_version', 'value' => 'v6'], ['type' => 'base', 'name' => 'app_version', 'value' => 'v6'],

View File

@ -1,7 +1,6 @@
<?php <?php
use think\admin\extend\ToolsExtend; use think\admin\extend\ToolsExtend;
use think\admin\model\SystemMenu;
use think\migration\Migrator; use think\migration\Migrator;
/** /**
@ -21,17 +20,12 @@ class InstallWechatData extends Migrator
/** /**
* 初始化菜单 * 初始化菜单
* @return void * @return bool
* @throws \think\db\exception\DbException
*/ */
private function createMenu() private function createMenu(): bool
{ {
// 检查菜单数据
$map = ['node' => 'wechat/config/options'];
if (SystemMenu::mk()->where($map)->count() > 0) return;
// 写入微信菜单 // 写入微信菜单
ToolsExtend::write2menu([ return ToolsExtend::write2menu([
[ [
'name' => '微信管理', 'name' => '微信管理',
'sort' => '200', 'sort' => '200',

View File

@ -1,6 +1,5 @@
<?php <?php
use think\admin\Library;
use think\migration\Migrator; use think\migration\Migrator;
/** /**
@ -9,12 +8,13 @@ use think\migration\Migrator;
class InstallUserRegion extends Migrator class InstallUserRegion extends Migrator
{ {
/** /**
* 写入默认区域数据
* @return void * @return void
* @throws \think\db\exception\DbException * @throws \think\db\exception\DbException
*/ */
public function change() public function change()
{ {
$this->createRegion(); $this->installRegion();
} }
/** /**
@ -22,11 +22,11 @@ class InstallUserRegion extends Migrator
* @return void * @return void
* @throws \think\db\exception\DbException * @throws \think\db\exception\DbException
*/ */
private function createRegion() private function installRegion()
{ {
// 检查数据 // 检查数据
$table = 'base_postage_region'; $table = 'base_postage_region';
if (Library::$sapp->db->table($table)->count() > 0) return; if (app()->db->table($table)->count() > 0) return;
// 写入数据 // 写入数据
$this->execute(<<<SQL $this->execute(<<<SQL