You've already forked jianlizaojia
[Staff]角色在系统内设置及迁移脚本
This commit is contained in:
@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
|
||||
use jerryyan\staff\Service;
|
||||
use think\admin\extend\PhinxExtend;
|
||||
use think\migration\Migrator;
|
||||
|
||||
@set_time_limit(0);
|
||||
@ini_set('memory_limit', -1);
|
||||
|
||||
/**
|
||||
* 系统模块数据
|
||||
*/
|
||||
class InstallStaffDb extends Migrator
|
||||
{
|
||||
|
||||
/**
|
||||
* 获取脚本名称
|
||||
* @return string
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return 'StaffPlugin';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 创建数据库
|
||||
*/
|
||||
public function change()
|
||||
{
|
||||
$this->_create_staff_dept();
|
||||
$this->_create_staff_user();
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建数据对象
|
||||
* @class StaffDept
|
||||
* @table staff_dept
|
||||
* @return void
|
||||
*/
|
||||
private function _create_staff_dept()
|
||||
{
|
||||
// 创建数据表对象
|
||||
$table = $this->table('staff_dept', [
|
||||
'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '部门员工',
|
||||
]);
|
||||
// 创建或更新数据表
|
||||
PhinxExtend::upgrade($table, [
|
||||
['name', 'string', ['limit' => 255, 'default' => NULL, 'null' => false, 'comment' => '部门名称']],
|
||||
['pid', 'integer', ['limit' => 11, 'default' => 0, 'null' => false, 'comment' => '上级部门ID']],
|
||||
['headman_id', 'integer', ['default' => NULL, 'null' => true, 'comment' => '领导人ID']],
|
||||
['sort', 'integer', ['limit' => 9, 'default' => 100, 'null' => false, 'comment' => '排序权重']],
|
||||
['status', 'integer', ['limit' => 11, 'default' => 1, 'null' => false, 'comment' => '状态(0禁用,1启用)']],
|
||||
['is_deleted', 'integer', ['limit' => 11, 'default' => 0, 'null' => false, 'comment' => '删除(1删除,0未删)']],
|
||||
['create_at', 'timestamp', ['default' => 'CURRENT_TIMESTAMP', 'null' => true, 'comment' => '创建时间']],
|
||||
], [
|
||||
|
||||
], false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建数据对象
|
||||
* @class StaffUser
|
||||
* @table staff_user
|
||||
* @return void
|
||||
*/
|
||||
private function _create_staff_user()
|
||||
{
|
||||
// 创建数据表对象
|
||||
$table = $this->table('staff_user', [
|
||||
'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '部门员工',
|
||||
]);
|
||||
// 创建或更新数据表
|
||||
PhinxExtend::upgrade($table, [
|
||||
['name', 'string', ['limit' => 255, 'default' => NULL, 'null' => false, 'comment' => '员工名称']],
|
||||
['gender', 'tinyinteger', ['limit' => 4, 'default' => 0, 'null' => true, 'comment' => '性别(0男,1女)']],
|
||||
['phone', 'string', ['limit' => 255, 'default' => NULL, 'null' => false, 'comment' => '手机号']],
|
||||
['email', 'string', ['limit' => 255, 'default' => NULL, 'null' => true, 'comment' => '电子邮箱']],
|
||||
['dept_id', 'integer', ['limit' => 11, 'default' => 0, 'null' => true, 'comment' => '所属部门']],
|
||||
['status', 'integer', ['default' => '1', 'null' => false, 'comment' => '状态(0禁用,1启用)']],
|
||||
['is_deleted', 'integer', ['default' => '0', 'null' => false, 'comment' => '删除(1删除,0未删)']],
|
||||
['create_at', 'timestamp', ['default' => 'CURRENT_TIMESTAMP', 'null' => true, 'comment' => '创建时间']],
|
||||
], [
|
||||
|
||||
], false);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user