【私域操盘手】手机短信验证码登录

This commit is contained in:
eison
2025-03-16 19:24:37 +08:00
parent 1d7a87f29f
commit 5ce78d648e
39 changed files with 10304 additions and 13996 deletions

View File

@@ -0,0 +1,79 @@
<?php
use think\migration\Migrator;
use think\migration\db\Column;
class CreateUsersTable extends Migrator
{
/**
* 创建用户表
*/
public function up()
{
$table = $this->table('users', [
'engine' => 'InnoDB',
'comment' => '用户表',
'id' => 'id',
'signed' => false,
]);
$table->addColumn('username', 'string', [
'limit' => 50,
'null' => false,
'comment' => '用户名',
])
->addColumn('password', 'string', [
'limit' => 60,
'null' => false,
'comment' => '密码',
])
->addColumn('mobile', 'string', [
'limit' => 11,
'null' => true,
'comment' => '登录手机号',
])
->addColumn('identity_id', 'integer', [
'limit' => 10,
'null' => true,
'comment' => '身份信息',
])
->addColumn('auth_id', 'integer', [
'limit' => 10,
'null' => true,
'comment' => '权限id',
])
->addColumn('create_at', 'timestamp', [
'null' => false,
'default' => 'CURRENT_TIMESTAMP',
'comment' => '创建时间',
])
->addColumn('update_at', 'timestamp', [
'null' => false,
'default' => 'CURRENT_TIMESTAMP',
'update' => 'CURRENT_TIMESTAMP',
'comment' => '修改时间',
])
->addColumn('delete_at', 'timestamp', [
'null' => true,
'default' => null,
'comment' => '删除时间',
])
->addIndex(['username'], [
'unique' => true,
'name' => 'idx_username',
])
->addIndex(['mobile'], [
'unique' => true,
'name' => 'idx_mobile',
])
->create();
}
/**
* 删除用户表
*/
public function down()
{
$this->dropTable('users');
}
}

View File

@@ -0,0 +1,19 @@
-- 创建用户表
CREATE TABLE IF NOT EXISTS `tk_users` (
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'ID',
`username` varchar(50) NOT NULL COMMENT '用户名',
`password` varchar(60) NOT NULL COMMENT '密码',
`mobile` varchar(11) DEFAULT NULL COMMENT '登录手机号',
`identity_id` int(10) DEFAULT NULL COMMENT '身份信息',
`auth_id` int(10) DEFAULT NULL COMMENT '权限id',
`create_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
`delete_at` timestamp NULL DEFAULT NULL COMMENT '删除时间',
PRIMARY KEY (`id`),
UNIQUE KEY `idx_username` (`username`),
UNIQUE KEY `idx_mobile` (`mobile`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户表';
-- 插入测试数据
INSERT INTO `tk_users` (`username`, `password`, `mobile`, `identity_id`, `auth_id`) VALUES
('admin', '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', '13800138000', 1, 1); -- 密码为password