mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-06 01:52:48 +08:00
项目完成服务器信息和配置文件;
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Migrator;
|
||||
use think\migration\db\Column;
|
||||
|
||||
class CreateTableUploadFiles extends Migrator
|
||||
{
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
* Write your reversible migrations using this method.
|
||||
*
|
||||
* More information on writing migrations is available here:
|
||||
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
|
||||
*
|
||||
* The following commands can be used in this method and Phinx will
|
||||
* automatically reverse them when rolling back:
|
||||
*
|
||||
* createTable
|
||||
* renameTable
|
||||
* addColumn
|
||||
* renameColumn
|
||||
* addIndex
|
||||
* addForeignKey
|
||||
*
|
||||
* Remember to call "create()" or "update()" and NOT "save()" when working
|
||||
* with the Table class.
|
||||
*/
|
||||
public function change()
|
||||
{
|
||||
$table = $this->table('upload_files',['comment'=>'上传的文件']);
|
||||
$table->addColumn('save_name','string',['limit'=>100,'comment'=>'文件存储地址']);
|
||||
$table->addColumn('file_name','string',['limit'=>100,'comment'=>'文件原始名称']);
|
||||
$table->addColumn('mime_type','string',['limit'=>30,'comment'=>'mime type 类型']);
|
||||
$table->addColumn('file_size','integer',['limit'=>30,'comment'=>'文件大小']);
|
||||
$table->addColumn('ext_name','string',['limit'=>10,'comment'=>'扩展名']);
|
||||
$table->addColumn('file_md5','string',['limit'=>32,'comment'=>'文件md5值']);
|
||||
$table->addColumn('file_sha1','string',['limit'=>40,'comment'=>'文件sha1值']);
|
||||
$table->addColumn('create_time','integer',['limit'=>10,'comment'=>'上传时间']);
|
||||
$table->addColumn('used_time','integer',['limit'=>10,'comment'=>'标记使用时间,如果为空,可能仅作为了预览图']);
|
||||
$table->addColumn('delete_time','integer',['limit'=>10,'comment'=>'删除时间']);
|
||||
$table->addColumn('clear_time','integer',['limit'=>10,'comment'=>'清空时间']);
|
||||
$table->addColumn('type','integer',['limit'=>2,'default'=>1,'comment'=>'文件类型,1:系统logo;2:微信公众号授权二维码;3:微信公众号授权头像;4:应用文章图片;5:应用封面']);
|
||||
$table->addIndex('save_name');
|
||||
$table->addIndex('create_time');
|
||||
$table->addIndex('used_time');
|
||||
$table->addIndex('delete_time');
|
||||
$table->addIndex('clear_time');
|
||||
$table->addIndex('type');
|
||||
$table->create();
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Migrator;
|
||||
use think\migration\db\Column;
|
||||
|
||||
class CreateTableSystemConfig extends Migrator
|
||||
{
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
* Write your reversible migrations using this method.
|
||||
*
|
||||
* More information on writing migrations is available here:
|
||||
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
|
||||
*
|
||||
* The following commands can be used in this method and Phinx will
|
||||
* automatically reverse them when rolling back:
|
||||
*
|
||||
* createTable
|
||||
* renameTable
|
||||
* addColumn
|
||||
* renameColumn
|
||||
* addIndex
|
||||
* addForeignKey
|
||||
*
|
||||
* Remember to call "create()" or "update()" and NOT "save()" when working
|
||||
* with the Table class.
|
||||
*/
|
||||
public function change()
|
||||
{
|
||||
$table = $this->table('system_config',['comment'=>'系统配置表']);
|
||||
$table->addColumn('name','string',['limit'=>30,'comment'=>'配置名称']);
|
||||
$table->addColumn('value','string',['limit'=>200,'comment'=>'值']);
|
||||
$table->addIndex('name');
|
||||
$table->save();
|
||||
}
|
||||
}
|
||||
43
database/migrations/20190822043811_create_table_admin.php
Normal file
43
database/migrations/20190822043811_create_table_admin.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Migrator;
|
||||
use think\migration\db\Column;
|
||||
|
||||
class CreateTableAdmin extends Migrator
|
||||
{
|
||||
/**
|
||||
* Change Method.
|
||||
*
|
||||
* Write your reversible migrations using this method.
|
||||
*
|
||||
* More information on writing migrations is available here:
|
||||
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
|
||||
*
|
||||
* The following commands can be used in this method and Phinx will
|
||||
* automatically reverse them when rolling back:
|
||||
*
|
||||
* createTable
|
||||
* renameTable
|
||||
* addColumn
|
||||
* renameColumn
|
||||
* addIndex
|
||||
* addForeignKey
|
||||
*
|
||||
* Remember to call "create()" or "update()" and NOT "save()" when working
|
||||
* with the Table class.
|
||||
*/
|
||||
public function change()
|
||||
{
|
||||
$table = $this->table('admin',['comment'=>'管理员表','signed'=>false]);
|
||||
$table->addColumn('account','string',['limit'=>20,'comment'=>'用户帐号']);
|
||||
$table->addColumn('password','string',['limit'=>32,'comment'=>'密码']);
|
||||
$table->addColumn('salt','string',['limit'=>6,'comment'=>'密码盐']);
|
||||
$table->addColumn('nickname','string',['limit'=>10,'comment'=>'昵称']);
|
||||
$table->addColumn('avatar','string',['limit'=>40,'comment'=>'头像地址']);
|
||||
$table->addColumn('create_time','integer',['limit'=>10,'default'=>0,'comment'=>'添加时间']);
|
||||
$table->addColumn('delete_time','integer',['limit'=>10,'default'=>0,'comment'=>'删除时间']);
|
||||
$table->addIndex('account');
|
||||
$table->addIndex('delete_time');
|
||||
$table->create();
|
||||
}
|
||||
}
|
||||
32
database/seeds/InitAdmin.php
Normal file
32
database/seeds/InitAdmin.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Seeder;
|
||||
use app\model\Admin;
|
||||
use think\helper\Str;
|
||||
|
||||
class InitAdmin extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run Method.
|
||||
*
|
||||
* Write your database seeder using this method.
|
||||
*
|
||||
* More information on writing seeders is available here:
|
||||
* http://docs.phinx.org/en/latest/seeding.html
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$account['account'] = 'admin';
|
||||
$account['salt'] = Str::random(6);
|
||||
$account['password'] = md5('123456'.$account['salt']);
|
||||
$account['avatar'] = '/static/images/avatar.jpeg';
|
||||
|
||||
$model_admin = Admin::where('account',$account['account'])->find();
|
||||
|
||||
if(empty($model_admin)){
|
||||
$model_admin = new Admin;
|
||||
$model_admin->data($account);
|
||||
$model_admin->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user