初始化仓库
This commit is contained in:
3
console/config/.gitignore
vendored
Normal file
3
console/config/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
main-local.php
|
||||
params-local.php
|
||||
test-local.php
|
||||
1
console/config/bootstrap.php
Normal file
1
console/config/bootstrap.php
Normal file
@@ -0,0 +1 @@
|
||||
<?php
|
||||
36
console/config/main.php
Normal file
36
console/config/main.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
$params = array_merge(
|
||||
require __DIR__ . '/../../common/config/params.php',
|
||||
require __DIR__ . '/../../common/config/params-local.php',
|
||||
require __DIR__ . '/params.php',
|
||||
require __DIR__ . '/params-local.php'
|
||||
);
|
||||
|
||||
return [
|
||||
'id' => 'app-console',
|
||||
'basePath' => dirname(__DIR__),
|
||||
'bootstrap' => ['log'],
|
||||
'controllerNamespace' => 'console\controllers',
|
||||
'aliases' => [
|
||||
'@bower' => '@vendor/bower-asset',
|
||||
'@npm' => '@vendor/npm-asset',
|
||||
],
|
||||
'controllerMap' => [
|
||||
'fixture' => [
|
||||
'class' => \yii\console\controllers\FixtureController::class,
|
||||
'namespace' => 'common\fixtures',
|
||||
],
|
||||
],
|
||||
'components' => [
|
||||
// 'log' => [
|
||||
// 'targets' => [
|
||||
// [
|
||||
// 'class' => \yii\log\FileTarget::class,
|
||||
// 'levels' => ['error', 'warning'],
|
||||
// ],
|
||||
// ],
|
||||
// ],
|
||||
],
|
||||
'params' => $params,
|
||||
];
|
||||
5
console/config/params.php
Normal file
5
console/config/params.php
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'adminEmail' => 'admin@example.com',
|
||||
];
|
||||
4
console/config/test.php
Normal file
4
console/config/test.php
Normal file
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
];
|
||||
0
console/controllers/.gitkeep
Normal file
0
console/controllers/.gitkeep
Normal file
36
console/controllers/AdminController.php
Normal file
36
console/controllers/AdminController.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace console\controllers;
|
||||
|
||||
use admin\models\Admin;
|
||||
use common\helpers\StringHelper;
|
||||
use common\models\admin\Member;
|
||||
use Yii;
|
||||
use yii\console\Controller;
|
||||
use yii\helpers\Console;
|
||||
|
||||
class AdminController extends Controller
|
||||
{
|
||||
public function actionCreate()
|
||||
{
|
||||
$count = (int)Admin::find()->where(['role' => 0])->count();
|
||||
if ($count===0) {
|
||||
$model = new Admin();
|
||||
$model->username = StringHelper::random(6);
|
||||
$model->generateAuthKey();
|
||||
$password_hash = StringHelper::random(10);
|
||||
$model->setPassword($password_hash);
|
||||
if ($model->save()) {
|
||||
Console::output('username; ' . $model->username);
|
||||
Console::output('password; ' . $password_hash);
|
||||
exit();
|
||||
}
|
||||
|
||||
Console::stdout('Password initialization failed');
|
||||
exit();
|
||||
}
|
||||
|
||||
Console::stdout('已经有超管账号');
|
||||
exit();
|
||||
}
|
||||
}
|
||||
24
console/controllers/TestController.php
Normal file
24
console/controllers/TestController.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace console\controllers;
|
||||
|
||||
use common\helpers\FuncHelper;
|
||||
use common\jobs\OrderOverJob;
|
||||
use common\jobs\OrderPayImJob;
|
||||
use common\jobs\OrderRefundJob;
|
||||
use yii\console\Controller;
|
||||
|
||||
|
||||
class TestController extends Controller
|
||||
{
|
||||
public function actionTest()
|
||||
{
|
||||
// \Yii::$app->queue->delay(0)->push(new OrderPayImJob([
|
||||
// 'orderId' => 10,
|
||||
// ]));
|
||||
|
||||
|
||||
$job = new OrderPayImJob();
|
||||
$job->exec(114);
|
||||
}
|
||||
}
|
||||
33
console/migrations/m130524_201442_init.php
Normal file
33
console/migrations/m130524_201442_init.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
|
||||
class m130524_201442_init extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
$tableOptions = null;
|
||||
if ($this->db->driverName === 'mysql') {
|
||||
// http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
|
||||
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
|
||||
}
|
||||
|
||||
$this->createTable('{{%user}}', [
|
||||
'id' => $this->primaryKey(),
|
||||
'username' => $this->string()->notNull()->unique(),
|
||||
'auth_key' => $this->string(32)->notNull(),
|
||||
'password_hash' => $this->string()->notNull(),
|
||||
'password_reset_token' => $this->string()->unique(),
|
||||
'email' => $this->string()->notNull()->unique(),
|
||||
|
||||
'status' => $this->smallInteger()->notNull()->defaultValue(10),
|
||||
'created_at' => $this->integer()->notNull(),
|
||||
'updated_at' => $this->integer()->notNull(),
|
||||
], $tableOptions);
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$this->dropTable('{{%user}}');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
use \yii\db\Migration;
|
||||
|
||||
class m190124_110200_add_verification_token_column_to_user_table extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
$this->addColumn('{{%user}}', 'verification_token', $this->string()->defaultValue(null));
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$this->dropColumn('{{%user}}', 'verification_token');
|
||||
}
|
||||
}
|
||||
183
console/migrations/m221104_020506_init2.php
Normal file
183
console/migrations/m221104_020506_init2.php
Normal file
@@ -0,0 +1,183 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
|
||||
/**
|
||||
* Class m221104_020506_init2
|
||||
*/
|
||||
class m221104_020506_init2 extends Migration
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeUp()
|
||||
{
|
||||
$this->createTable('{{%admin}}', [
|
||||
'id' => $this->primaryKey(),
|
||||
'username' => $this->char(16)->notNull()->comment('用户名'),
|
||||
'password' => $this->char(60)->notNull()->comment('密码'),
|
||||
'role' => $this->tinyInteger(1)->notNull()->defaultValue(0)->comment('角色1为官方管理'),
|
||||
'mall_id' => $this->integer(11)->notNull()->defaultValue(0)->comment('商城ID'),
|
||||
'salt' => $this->char(32)->notNull()->comment('密码干扰字符'),
|
||||
'email' => $this->char(32)->notNull()->defaultValue('')->comment('用户邮箱'),
|
||||
'mobile' => $this->char(15)->notNull()->defaultValue('')->comment('用户手机'),
|
||||
'reg_time' => $this->integer(11)->notNull()->defaultValue(0)->comment('注册时间'),
|
||||
'reg_ip' => $this->bigInteger(20)->notNull()->defaultValue(0)->comment('注册IP'),
|
||||
'last_login_time' => $this->integer(11)->notNull()->defaultValue(0)->comment('最后登录时间'),
|
||||
'last_login_ip' => $this->bigInteger(20)->notNull()->defaultValue(0)->comment('最后登录IP'),
|
||||
'update_time' => $this->integer(11)->notNull()->defaultValue(0)->comment('更新时间'),
|
||||
'is_sub' => $this->tinyInteger(1)->notNull()->defaultValue(0)->comment('是否子账号'),
|
||||
'is_delete' => $this->tinyInteger(1)->notNull()->defaultValue(0)->comment('是否删除'),
|
||||
'status' => $this->tinyInteger(1)->notNull()->defaultValue(1)->comment('用户状态 1正常 0禁用'),
|
||||
]);
|
||||
|
||||
$this->createTable('{{%admin_access_token}}', [
|
||||
'id' => $this->primaryKey(),
|
||||
'access_token' => $this->string(60)->notNull()->comment('授权令牌'),
|
||||
'admin_id' => $this->integer(11)->notNull()->defaultValue(0)->comment('admin用户id'),
|
||||
'group' => $this->string(100)->notNull()->defaultValue('')->comment('组别'),
|
||||
'status' => $this->tinyInteger(1)->notNull()->defaultValue(1)->comment('状态[-1:删除;0:禁用;1启用]'),
|
||||
'expired_at' => $this->integer(11)->notNull()->defaultValue(0)->comment('过期时间'),
|
||||
'created_at' => $this->integer(11)->notNull()->defaultValue(0)->comment('创建时间'),
|
||||
'updated_at' => $this->integer(11)->notNull()->defaultValue(0)->comment('修改时间'),
|
||||
]);
|
||||
|
||||
$this->createTable('{{%attachment_group}}', [
|
||||
'id' => $this->primaryKey(),
|
||||
'mall_id' => $this->integer(11)->notNull()->defaultValue(0),
|
||||
'name' => $this->string(64)->notNull()->defaultValue('')->comment('组别'),
|
||||
'is_delete' => $this->tinyInteger(1)->notNull()->defaultValue(0),
|
||||
'created_at' => $this->integer(11)->notNull()->defaultValue(0),
|
||||
'updated_at' => $this->integer(11)->notNull()->defaultValue(0),
|
||||
'deleted_at' => $this->integer(11)->notNull()->defaultValue(0),
|
||||
'is_recycle' => $this->tinyInteger(1)->notNull()->defaultValue(0)->comment('是否加入回收站 0.否|1.是'),
|
||||
'type' => $this->tinyInteger(1)->notNull()->defaultValue(0)->comment('0 图片 1商品'),
|
||||
]);
|
||||
|
||||
$this->createTable('{{%attachment}}', [
|
||||
'id' => $this->primaryKey(),
|
||||
'storage_id' => $this->integer(11)->notNull(),
|
||||
'attachment_group_id' => $this->integer(11)->notNull()->defaultValue(0),
|
||||
'user_id' => $this->integer(11)->notNull(),
|
||||
'mall_id' => $this->integer(11)->notNull()->defaultValue(0),
|
||||
'name' => $this->string(128)->notNull(),
|
||||
'size' => $this->integer(11)->notNull()->comment('大小:字节'),
|
||||
'url' => $this->string(2080)->notNull(),
|
||||
'thumb_url' => $this->string(2080)->notNull()->defaultValue(''),
|
||||
'type' => $this->tinyInteger(2)->notNull()->comment('类型:1=图片,2=视频'),
|
||||
'created_at' => $this->integer(11)->notNull()->defaultValue(0),
|
||||
'updated_at' => $this->integer(11)->notNull()->defaultValue(0),
|
||||
'deleted_at' => $this->integer(11)->notNull()->defaultValue(0),
|
||||
'is_delete' => $this->tinyInteger(2)->notNull()->defaultValue(0),
|
||||
'is_recycle' => $this->tinyInteger(2)->notNull()->defaultValue(0)->comment('是否加入回收站 0.否|1.是'),
|
||||
]);
|
||||
|
||||
$this->createTable('{{%role}}', [
|
||||
'id' => $this->primaryKey(),
|
||||
'name' => $this->string(50),
|
||||
'role_code' => $this->string(50),
|
||||
'description' => $this->string(255),
|
||||
'created_at' => $this->integer(11)->notNull()->defaultValue(0),
|
||||
'updated_at' => $this->integer(11)->notNull()->defaultValue(0),
|
||||
]);
|
||||
|
||||
$this->createTable('{{%role_menu}}', [
|
||||
'id' => $this->primaryKey(),
|
||||
'role_id' => $this->integer(11),
|
||||
'menuUrl' => $this->string(50),
|
||||
'created_at' => $this->integer(11)->notNull()->defaultValue(0),
|
||||
'updated_at' => $this->integer(11)->notNull()->defaultValue(0),
|
||||
]);
|
||||
|
||||
$this->createTable('{{%menu}}', [
|
||||
// 'id' => $this->primaryKey(),
|
||||
'menuUrl' => $this->string(50)->notNull()->defaultValue('')->comment('菜单地址'),
|
||||
'menuName' => $this->string(50)->notNull()->defaultValue('')->comment('菜单名称'),
|
||||
'parentPath' => $this->string(50)->notNull()->defaultValue('')->comment('上级路由'),
|
||||
'routeName' => $this->string(50)->notNull()->defaultValue('')->comment('路由name'),
|
||||
'redirect' => $this->string(255)->notNull()->defaultValue(''),
|
||||
'icon' => $this->string(50)->defaultValue('')->comment('菜单图标'),
|
||||
'sort' => $this->integer(11)->notNull()->defaultValue(0),
|
||||
'cacheable' => $this->tinyInteger(1)->notNull()->defaultValue(0)->comment('是否缓存'),
|
||||
'hidden' => $this->tinyInteger(1)->notNull()->defaultValue(0)->comment('是否隐藏'),
|
||||
'affix' => $this->tinyInteger(1)->notNull()->defaultValue(0)->comment('是否固定标题栏'),
|
||||
]);
|
||||
|
||||
$this->addPrimaryKey('menuUrl','{{%menu}}','menuUrl');
|
||||
|
||||
$this->createTable('{{%sub_account_menu}}', [
|
||||
'id' => $this->primaryKey(),
|
||||
'admin_id' => $this->integer(11),
|
||||
'menuUrl' => $this->string(50),
|
||||
'created_at' => $this->integer(11)->notNull()->defaultValue(0),
|
||||
'updated_at' => $this->integer(11)->notNull()->defaultValue(0),
|
||||
]);
|
||||
|
||||
$this->createTable('{{%config}}', [
|
||||
'id' => $this->primaryKey(),
|
||||
'name' => $this->string(30)->notNull()->defaultValue('')->comment('配置名称'),
|
||||
'title' => $this->string(50)->notNull()->defaultValue('')->comment('配置标题'),
|
||||
'group' => $this->tinyInteger(3)->notNull()->defaultValue(0)->comment('配置分组'),
|
||||
'type' => $this->tinyInteger(3)->notNull()->defaultValue(0)->comment('配置类型'),
|
||||
'value' => $this->text()->comment('配置值'),
|
||||
'extra' => $this->string(255)->comment('配置值'),
|
||||
'remark' => $this->string(100)->comment('配置说明'),
|
||||
'created_at' => $this->integer(11)->notNull()->defaultValue(0),
|
||||
'updated_at' => $this->integer(11)->notNull()->defaultValue(0),
|
||||
'sort' => $this->integer(11)->notNull()->defaultValue(0),
|
||||
'status' => $this->tinyInteger(2)->notNull()->defaultValue(1),
|
||||
]);
|
||||
|
||||
$this->dropTable('{{%user}}');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeDown()
|
||||
{
|
||||
$this->dropTable('{{%admin}}');
|
||||
$this->dropTable('{{%admin_access_token}}');
|
||||
$this->dropTable('{{%attachment_group}}');
|
||||
$this->dropTable('{{%attachment}}');
|
||||
$this->dropTable('{{%role}}');
|
||||
$this->dropTable('{{%role_menu}}');
|
||||
$this->dropTable('{{%menu}}');
|
||||
$this->dropTable('{{%sub_account_menu}}');
|
||||
$this->dropTable('{{%config}}');
|
||||
|
||||
$tableOptions = null;
|
||||
if ($this->db->driverName === 'mysql') {
|
||||
// http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
|
||||
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
|
||||
}
|
||||
$this->createTable('{{%user}}', [
|
||||
'id' => $this->primaryKey(),
|
||||
'username' => $this->string()->notNull()->unique(),
|
||||
'auth_key' => $this->string(32)->notNull(),
|
||||
'password_hash' => $this->string()->notNull(),
|
||||
'password_reset_token' => $this->string()->unique(),
|
||||
'email' => $this->string()->notNull()->unique(),
|
||||
|
||||
'status' => $this->smallInteger()->notNull()->defaultValue(10),
|
||||
'created_at' => $this->integer()->notNull(),
|
||||
'updated_at' => $this->integer()->notNull(),
|
||||
'verification_token' => $this->string()->defaultValue(null)
|
||||
], $tableOptions);
|
||||
}
|
||||
|
||||
/*
|
||||
// Use up()/down() to run migration code without a transaction.
|
||||
public function up()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
echo "m221104_020506_init2 cannot be reverted.\n";
|
||||
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
|
||||
/**
|
||||
* Class m230520_025427_create_tablename_categories
|
||||
*/
|
||||
class m230520_025427_create_tablename_categories extends Migration
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeUp()
|
||||
{
|
||||
//设置数据表的属性
|
||||
$tableOptions = null;
|
||||
if ($this->db->driverName === 'mysql') {
|
||||
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB';
|
||||
}
|
||||
|
||||
//创建一个表
|
||||
$this->createTable('{{yii_categories}}', [
|
||||
'id' => $this->primaryKey(),
|
||||
'name' => $this->string(200)->notNull()->defaultValue('')->comment('分类'),
|
||||
'level' => $this->tinyInteger(2)->notNull()->defaultValue(0)->comment('级别'),
|
||||
'pid' => $this->tinyInteger(2)->notNull()->defaultValue(0)->comment('父级id'),
|
||||
'created_at' => $this->integer(11)->notNull()->defaultValue(0)->comment('创建时间'),
|
||||
'updated_at' => $this->integer(11)->notNull()->defaultValue(0)->comment('修改时间'),
|
||||
], $tableOptions);
|
||||
|
||||
//增加或者修改一个表备注
|
||||
$this->addCommentOnTable('{{yii_categories}}', '分类表');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeDown()
|
||||
{
|
||||
echo "m230520_025427_create_tablename_categories cannot be reverted.\n";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
// Use up()/down() to run migration code without a transaction.
|
||||
public function up()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
echo "m230520_025427_create_tablename_categories cannot be reverted.\n";
|
||||
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
}
|
||||
1
console/models/.gitkeep
Normal file
1
console/models/.gitkeep
Normal file
@@ -0,0 +1 @@
|
||||
*
|
||||
Reference in New Issue
Block a user