diff --git a/application/admin/command/Crud.php b/application/admin/command/Crud.php index 741d7e25..0945db81 100644 --- a/application/admin/command/Crud.php +++ b/application/admin/command/Crud.php @@ -9,6 +9,7 @@ use think\console\Input; use think\console\input\Option; use think\console\Output; use think\Db; +use think\Exception; use think\Lang; class Crud extends Command @@ -41,8 +42,7 @@ class Crud extends Command $local = $input->getOption('local'); if (!$table) { - $output->error('table name can\'t empty'); - return; + throw new Exception('table name can\'t empty'); } $dbname = Config::get('database.database'); $prefix = Config::get('database.prefix'); @@ -50,8 +50,7 @@ class Crud extends Command $tableInfo = Db::query("SHOW TABLE STATUS LIKE '{$tableName}'", [], TRUE); if (!$tableInfo) { - $output->error("table not found"); - return; + throw new Exception("table not found"); } $tableInfo = $tableInfo[0]; @@ -69,8 +68,7 @@ class Crud extends Command //非覆盖模式时如果存在控制器文件则报错 if (is_file($controllerFile) && !$force) { - $output->error('controller already exists'); - return; + throw new Exception('controller already exists'); } //模型默认以表名进行处理,以下划线进行分隔,如果需要自定义则需要传入model,不支持目录层级 @@ -91,8 +89,7 @@ class Crud extends Command //非覆盖模式时如果存在模型文件则报错 if (is_file($modelFile) && !$force) { - $output->error('model already exists'); - return; + throw new Exception('model already exists'); } //从数据库中获取表字段信息 diff --git a/application/admin/command/Install.php b/application/admin/command/Install.php new file mode 100644 index 00000000..85baa5e1 --- /dev/null +++ b/application/admin/command/Install.php @@ -0,0 +1,49 @@ +setName('install') + ->addOption('force', 'f', Option::VALUE_OPTIONAL, 'force override', FALSE) + ->setDescription('New installation of FastAdmin'); + } + + protected function execute(Input $input, Output $output) + { + + //覆盖安装 + $force = $input->getOption('force'); + + $installLockFile = __DIR__ . "/Install/install.lock"; + if (is_file($installLockFile) && !$force) + { + throw new Exception("\nFastAdmin already installed!\nIf you need to reinstall again, use the parameter --force=true "); + } + + $sql = file_get_contents(__DIR__ . '/Install/fastadmin.sql'); + + // 查询一次SQL,判断连接是否正常 + Db::execute("SELECT 1"); + + // 调用原生PDO对象进行批量查询 + Db::getPdo()->exec($sql); + + file_put_contents($installLockFile, 1); + $output->info("Install Successed!"); + } + +} diff --git a/application/admin/command/Install/fastadmin.sql b/application/admin/command/Install/fastadmin.sql new file mode 100644 index 00000000..b009aae5 --- /dev/null +++ b/application/admin/command/Install/fastadmin.sql @@ -0,0 +1,417 @@ +/* + FastAdmin Install SQL + + 官网: http://www.fastadmin.net + 演示: http://demo.fastadmin.net + + Date: 04/15/2017 00:15:20 AM +*/ + +SET FOREIGN_KEY_CHECKS = 0; + +-- ---------------------------- +-- Table structure for `fa_admin` +-- ---------------------------- +DROP TABLE IF EXISTS `fa_admin`; +CREATE TABLE `fa_admin` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID', + `username` varchar(20) NOT NULL DEFAULT '' COMMENT '用户名', + `nickname` varchar(50) NOT NULL DEFAULT '' COMMENT '昵称', + `password` varchar(32) NOT NULL DEFAULT '' COMMENT '密码', + `salt` varchar(30) NOT NULL DEFAULT '' COMMENT '密码盐', + `avatar` varchar(100) NOT NULL DEFAULT '' COMMENT '头像', + `email` varchar(100) NOT NULL DEFAULT '' COMMENT '电子邮箱', + `loginfailure` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '失败次数', + `logintime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '登录时间', + `createtime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间', + `updatetime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间', + `token` varchar(59) NOT NULL DEFAULT '' COMMENT 'Session标识', + `status` varchar(30) NOT NULL DEFAULT 'normal' COMMENT '状态', + PRIMARY KEY (`id`), + UNIQUE KEY `username` (`username`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='管理员表'; + +-- ---------------------------- +-- Records of `fa_admin` +-- ---------------------------- +BEGIN; +INSERT INTO `fa_admin` VALUES ('1', 'admin', 'Admin', '075eaec83636846f51c152f29b98a2fd', 's4f3', '/assets/img/avatar.png', 'admin@fastadmin.net', '0', '1492185129', '1492186163', '1492185129', '6780cd73-f650-4627-9371-60d3739f4e77', 'normal'), ('2', 'admin2', 'admin2', '9a28ce07ce875fbd14172a9ca5357d3c', '2dHDmj', '/assets/img/avatar.png', 'admin2@fastadmin.net', '0', '0', '1492186163', '1492186163', '', 'normal'), ('3', 'admin3', 'admin3', '1c11f945dfcd808a130a8c2a8753fe62', 'WOKJEn', '/assets/img/avatar.png', 'admin3@fastadmin.net', '0', '0', '1492186201', '1492186201', '', 'normal'), ('4', 'admin22', 'admin22', '1c1a0aa0c3c56a8c1a908aab94519648', 'Aybcn5', '/assets/img/avatar.png', 'admin22@fastadmin.net', '0', '0', '1492186240', '1492186240', '', 'normal'), ('5', 'admin32', 'admin32', 'ade94d5d7a7033afa7d84ac3066d0a02', 'FvYK0u', '/assets/img/avatar.png', 'admin32@fastadmin.net', '0', '0', '1492186263', '1492186263', '', 'normal'); +COMMIT; + +-- ---------------------------- +-- Table structure for `fa_admin_log` +-- ---------------------------- +DROP TABLE IF EXISTS `fa_admin_log`; +CREATE TABLE `fa_admin_log` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID', + `admin_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '管理员ID', + `username` varchar(30) NOT NULL DEFAULT '' COMMENT '管理员名字', + `url` varchar(100) NOT NULL DEFAULT '' COMMENT '操作页面', + `title` varchar(100) NOT NULL DEFAULT '' COMMENT '日志标题', + `content` text NOT NULL COMMENT '内容', + `createtime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '操作时间', + PRIMARY KEY (`id`), + KEY `name` (`username`) +) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='管理员日志表'; + +-- ---------------------------- +-- Table structure for `fa_article` +-- ---------------------------- +DROP TABLE IF EXISTS `fa_article`; +CREATE TABLE `fa_article` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID', + `category_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '分类ID', + `flag` set('h','i','r') NOT NULL DEFAULT '' COMMENT '标志', + `title` varchar(50) NOT NULL DEFAULT '' COMMENT '标题', + `content` text NOT NULL COMMENT '内容', + `image` varchar(100) NOT NULL DEFAULT '' COMMENT '图片', + `keywords` varchar(255) NOT NULL DEFAULT '' COMMENT '关键字', + `description` varchar(255) NOT NULL DEFAULT '' COMMENT '描述', + `views` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '点击', + `comments` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '评论数', + `createtime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间', + `updatetime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间', + `weigh` int(10) NOT NULL DEFAULT '0' COMMENT '权重', + `status` varchar(30) NOT NULL DEFAULT '' COMMENT '状态', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='文章表'; + +-- ---------------------------- +-- Table structure for `fa_attachment` +-- ---------------------------- +DROP TABLE IF EXISTS `fa_attachment`; +CREATE TABLE `fa_attachment` ( + `id` int(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID', + `url` varchar(255) NOT NULL DEFAULT '' COMMENT '物理路径', + `imagewidth` varchar(30) NOT NULL DEFAULT '' COMMENT '宽度', + `imageheight` varchar(30) NOT NULL DEFAULT '' COMMENT '宽度', + `imagetype` varchar(30) NOT NULL DEFAULT '' COMMENT '图片类型', + `imageframes` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '图片帧数', + `filesize` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '文件大小', + `mimetype` varchar(30) NOT NULL DEFAULT '' COMMENT 'mime类型', + `extparam` varchar(255) NOT NULL DEFAULT '' COMMENT '透传数据', + `createtime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '创建日期', + `updatetime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间', + `uploadtime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '上传时间', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='附件表'; + +-- ---------------------------- +-- Table structure for `fa_auth_group` +-- ---------------------------- +DROP TABLE IF EXISTS `fa_auth_group`; +CREATE TABLE `fa_auth_group` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `pid` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '父组别', + `name` varchar(100) NOT NULL DEFAULT '' COMMENT '组名', + `rules` text NOT NULL COMMENT '规则ID', + `createtime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间', + `updatetime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间', + `status` varchar(30) NOT NULL DEFAULT '' COMMENT '状态', + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COMMENT='分组表'; + +-- ---------------------------- +-- Records of `fa_auth_group` +-- ---------------------------- +BEGIN; +INSERT INTO `fa_auth_group` VALUES ('1', '0', '超级管理员', '*', '1490883540', '1490883540', 'normal'), ('2', '1', '二级管理员', '10400,10401,10402,10403,10404,10405,10406,10407,10408,10409,10410,10411,10412,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424,10425,10426,10427,10428,10429,10430,10431,10432,10433,10434,10435,10436,10437,10438,10439,10440,10441,10442,10443,10444,10445,10446,10447,10448,10449,10450,10451,10452,10453,10454,10455,10456,10457,10458,10459,10460,10461,10462,10463', '1490883540', '1492186066', 'normal'), ('3', '2', '三级管理员', '10400,10401,10402,10403,10404,10405,10412,10413,10414,10415,10416,10417,10418,10419,10420,10421,10422,10423,10424,10425,10426,10427,10428,10429,10430', '1490883540', '1492186072', 'normal'), ('4', '1', '二级管理员2', '10400,10401,10402,10403,10404,10405,10406,10407,10408,10409,10410,10411,10431,10432,10433,10434,10435,10436,10437,10438,10439,10440,10441,10442,10443,10444,10445,10446,10447,10448,10449,10450,10451,10452,10453,10454,10455,10456,10457,10458,10459,10460,10461,10462,10463,10464,10465,10466,10467,10468,10469,10470,10471,10472,10473,10474,10475,10476,10477,10478,10479,10480,10481,10482,10483,10484,10485,10486,10487,10488,10489,10490', '1490883540', '1492186059', 'normal'), ('5', '2', '三级管理员2', '10400,10401,10402,10403,10404,10405', '1490883540', '1492186095', 'normal'); +COMMIT; + +-- ---------------------------- +-- Table structure for `fa_auth_group_access` +-- ---------------------------- +DROP TABLE IF EXISTS `fa_auth_group_access`; +CREATE TABLE `fa_auth_group_access` ( + `uid` int(10) unsigned NOT NULL COMMENT '会员ID', + `group_id` int(10) unsigned NOT NULL COMMENT '级别ID', + UNIQUE KEY `uid_group_id` (`uid`,`group_id`), + KEY `uid` (`uid`), + KEY `group_id` (`group_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='权限分组表'; + +-- ---------------------------- +-- Records of `fa_auth_group_access` +-- ---------------------------- +BEGIN; +INSERT INTO `fa_auth_group_access` VALUES ('1', '1'), ('2', '2'), ('3', '3'), ('4', '5'), ('5', '5'); +COMMIT; + +-- ---------------------------- +-- Table structure for `fa_auth_rule` +-- ---------------------------- +DROP TABLE IF EXISTS `fa_auth_rule`; +CREATE TABLE `fa_auth_rule` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `type` enum('menu','file') NOT NULL DEFAULT 'file' COMMENT 'menu为菜单,file为权限节点', + `pid` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '父ID', + `name` varchar(100) NOT NULL DEFAULT '' COMMENT '规则名称', + `title` varchar(50) NOT NULL DEFAULT '' COMMENT '规则名称', + `icon` varchar(50) NOT NULL DEFAULT '' COMMENT '图标', + `condition` varchar(255) NOT NULL DEFAULT '' COMMENT '条件', + `remark` varchar(255) NOT NULL DEFAULT '' COMMENT '备注', + `ismenu` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否为菜单', + `createtime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间', + `updatetime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间', + `weigh` int(10) NOT NULL COMMENT '权重', + `status` varchar(30) NOT NULL DEFAULT '' COMMENT '状态', + PRIMARY KEY (`id`), + UNIQUE KEY `name` (`name`) USING BTREE, + KEY `pid` (`pid`), + KEY `weigh` (`weigh`) +) ENGINE=InnoDB AUTO_INCREMENT=10491 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='节点表'; + +-- ---------------------------- +-- Records of `fa_auth_rule` +-- ---------------------------- +BEGIN; +INSERT INTO `fa_auth_rule` VALUES ('10400', 'file', '0', '/admin/dashboard', '控制台', 'fa fa-dashboard', '', '用于展示当前系统中的统计数据、统计报表及重要实时数据\r\n', '1', '1491655325', '1492184975', '0', 'normal'), ('10401', 'file', '10400', '/admin/dashboard/index', '查看', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10402', 'file', '10400', '/admin/dashboard/add', '添加', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10403', 'file', '10400', '/admin/dashboard/edit', '编辑', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10404', 'file', '10400', '/admin/dashboard/del', '删除', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10405', 'file', '10400', '/admin/dashboard/multi', '批量更新', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10406', 'file', '0', '/admin/page', '单页管理', 'fa fa-circle-o', '', '用于管理普通的单页面,通常用于关于我们、联系我们、商务合作等单一页面\r\n', '1', '1491655325', '1492185158', '0', 'normal'), ('10407', 'file', '10406', '/admin/page/index', '查看', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10408', 'file', '10406', '/admin/page/add', '添加', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10409', 'file', '10406', '/admin/page/edit', '编辑', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10410', 'file', '10406', '/admin/page/del', '删除', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10411', 'file', '10406', '/admin/page/multi', '批量更新', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10412', 'file', '0', '/admin/auth', '权限管理', 'fa fa-list', '', '', '1', '1491655325', '1492184594', '0', 'normal'), ('10413', 'file', '10412', '/admin/auth/admin', '管理员管理', 'fa fa-users', '', '一个管理员可以有多个角色组,左侧的菜单根据管理员所拥有的权限进行生成', '1', '1491655325', '1491655325', '0', 'normal'), ('10414', 'file', '10413', '/admin/auth/admin/add', '添加', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10415', 'file', '10413', '/admin/auth/admin/edit', '编辑', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10416', 'file', '10413', '/admin/auth/admin/del', '删除', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10417', 'file', '10413', '/admin/auth/admin/index', '查看', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10418', 'file', '10413', '/admin/auth/admin/multi', '批量更新', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10419', 'file', '10412', '/admin/auth/group', '角色组', 'fa fa-group', '', '角色组可以有多个,角色有上下级层级关系,如果子角色有角色组和管理员的权限则可以派生属于自己组别下级的角色组或管理员', '1', '1491655325', '1491655325', '0', 'normal'), ('10420', 'file', '10419', '/admin/auth/group/index', '查看', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10421', 'file', '10419', '/admin/auth/group/add', '添加', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10422', 'file', '10419', '/admin/auth/group/edit', '编辑', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10423', 'file', '10419', '/admin/auth/group/del', '删除', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10424', 'file', '10419', '/admin/auth/group/multi', '批量更新', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10425', 'file', '10412', '/admin/auth/rule', '规则管理', 'fa fa-list', '', '规则通常对应一个控制器的方法,同时左侧的菜单栏数据也从规则中体现,通常建议通过控制台进行生成规则节点', '1', '1491655325', '1491655325', '0', 'normal'), ('10426', 'file', '10425', '/admin/auth/rule/index', '查看', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10427', 'file', '10425', '/admin/auth/rule/add', '添加', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10428', 'file', '10425', '/admin/auth/rule/edit', '编辑', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10429', 'file', '10425', '/admin/auth/rule/del', '删除', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10430', 'file', '10425', '/admin/auth/rule/multi', '批量更新', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10431', 'file', '0', '/admin/general', '常规管理', 'fa fa-list', '', '', '1', '1491655325', '1492184604', '0', 'normal'), ('10432', 'file', '10431', '/admin/general/attachment', '附件管理', 'fa fa-circle-o\r', '', '主要用于管理上传到又拍云的数据或上传至本服务的上传数据\r', '1', '1491655325', '1491655325', '0', 'normal'), ('10433', 'file', '10432', '/admin/general/attachment/index', '查看', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10434', 'file', '10432', '/admin/general/attachment/add', '添加', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10435', 'file', '10432', '/admin/general/attachment/edit', '编辑', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10436', 'file', '10432', '/admin/general/attachment/del', '删除', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10437', 'file', '10432', '/admin/general/attachment/multi', '批量更新', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10438', 'file', '10431', '/admin/general/configvalue', '基本配置', 'fa fa-cog', '', '用于管理一些字典数据,通常以键值格式进行录入,保存的数据格式为JSON', '1', '1491655325', '1491655325', '0', 'normal'), ('10439', 'file', '10438', '/admin/general/configvalue/index', '查看', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10440', 'file', '10438', '/admin/general/configvalue/add', '添加', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10441', 'file', '10438', '/admin/general/configvalue/edit', '编辑', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10442', 'file', '10438', '/admin/general/configvalue/del', '删除', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10443', 'file', '10438', '/admin/general/configvalue/multi', '批量更新', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10444', 'file', '10431', '/admin/general/crontab', '定时任务', 'fa fa-tasks', '', '类似于Linux的Crontab定时任务,可以按照设定的时间进行任务的执行,目前仅支持三种任务:请求URL、执行SQL、执行Shell', '1', '1491655325', '1491655325', '0', 'normal'), ('10445', 'file', '10444', '/admin/general/crontab/index', '查看', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10446', 'file', '10444', '/admin/general/crontab/add', '添加', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10447', 'file', '10444', '/admin/general/crontab/edit', '编辑', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10448', 'file', '10444', '/admin/general/crontab/del', '删除', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10449', 'file', '10444', '/admin/general/crontab/multi', '批量更新', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10450', 'file', '10431', '/admin/general/database', '数据库管理', 'fa fa-database', '', '可在线进行一些简单的数据库表优化或修复,查看表结构和数据。也可以进行SQL语句的操作', '1', '1491655325', '1491655325', '0', 'normal'), ('10451', 'file', '10450', '/admin/general/database/index', '查看', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10452', 'file', '10450', '/admin/general/database/query', 'SQL查询', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10453', 'file', '10450', '/admin/general/database/add', '添加', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10454', 'file', '10450', '/admin/general/database/edit', '编辑', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10455', 'file', '10450', '/admin/general/database/del', '删除', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10456', 'file', '10450', '/admin/general/database/multi', '批量更新', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10457', 'file', '10431', '/admin/general/profile', '个人配置', 'fa fa-user\r', '', '', '1', '1491655325', '1491655325', '0', 'normal'), ('10458', 'file', '10457', '/admin/general/profile/index', '查看', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10459', 'file', '10457', '/admin/general/profile/update', '更新个人信息', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10460', 'file', '10457', '/admin/general/profile/add', '添加', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10461', 'file', '10457', '/admin/general/profile/edit', '编辑', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10462', 'file', '10457', '/admin/general/profile/del', '删除', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10463', 'file', '10457', '/admin/general/profile/multi', '批量更新', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10464', 'file', '0', '/admin/wechat', '微信管理', 'fa fa-list', '', '', '1', '1491655325', '1492184609', '0', 'normal'), ('10465', 'file', '10464', '/admin/wechat/autoreply', '微信自动回复管理', 'fa fa-circle-o\r', '', '', '1', '1491655325', '1491655325', '0', 'normal'), ('10466', 'file', '10465', '/admin/wechat/autoreply/edit', '编辑', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10467', 'file', '10465', '/admin/wechat/autoreply/index', '查看', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10468', 'file', '10465', '/admin/wechat/autoreply/add', '添加', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10469', 'file', '10465', '/admin/wechat/autoreply/del', '删除', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10470', 'file', '10465', '/admin/wechat/autoreply/multi', '批量更新', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10471', 'file', '10464', '/admin/wechat/config', '配置管理', 'fa fa-list-alt', '', '', '1', '1491655325', '1491655325', '0', 'normal'), ('10472', 'file', '10471', '/admin/wechat/config/index', '查看', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10473', 'file', '10471', '/admin/wechat/config/add', '添加', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10474', 'file', '10471', '/admin/wechat/config/edit', '编辑', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10475', 'file', '10471', '/admin/wechat/config/del', '删除', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10476', 'file', '10471', '/admin/wechat/config/multi', '批量更新', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10477', 'file', '10464', '/admin/wechat/menu', '菜单管理', 'fa fa-list-alt', '', '', '1', '1491655325', '1491655325', '0', 'normal'), ('10478', 'file', '10477', '/admin/wechat/menu/index', '查看', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10479', 'file', '10477', '/admin/wechat/menu/edit', '修改', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10480', 'file', '10477', '/admin/wechat/menu/sync', '同步', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10481', 'file', '10477', '/admin/wechat/menu/add', '添加', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10482', 'file', '10477', '/admin/wechat/menu/del', '删除', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10483', 'file', '10477', '/admin/wechat/menu/multi', '批量更新', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10484', 'file', '10464', '/admin/wechat/response', '资源管理', 'fa fa-list-alt', '', '', '1', '1491655325', '1491655325', '0', 'normal'), ('10485', 'file', '10484', '/admin/wechat/response/select', '选择素材', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10486', 'file', '10484', '/admin/wechat/response/add', '添加', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10487', 'file', '10484', '/admin/wechat/response/edit', '编辑', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10488', 'file', '10484', '/admin/wechat/response/index', '查看', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10489', 'file', '10484', '/admin/wechat/response/del', '删除', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'), ('10490', 'file', '10484', '/admin/wechat/response/multi', '批量更新', 'fa fa-circle-o', '', '', '0', '1491655325', '1491655325', '0', 'normal'); +COMMIT; + +-- ---------------------------- +-- Table structure for `fa_category` +-- ---------------------------- +DROP TABLE IF EXISTS `fa_category`; +CREATE TABLE `fa_category` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `pid` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '父ID', + `type` varchar(30) NOT NULL DEFAULT '' COMMENT '栏目类型', + `name` varchar(30) NOT NULL DEFAULT '', + `nickname` varchar(50) NOT NULL DEFAULT '', + `flag` set('h','i','r') NOT NULL DEFAULT '', + `image` varchar(100) NOT NULL DEFAULT '' COMMENT '图片', + `keywords` varchar(255) NOT NULL DEFAULT '' COMMENT '关键字', + `description` varchar(255) NOT NULL DEFAULT '' COMMENT '描述', + `diyname` varchar(30) NOT NULL DEFAULT '' COMMENT '自定义名称', + `createtime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间', + `updatetime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间', + `weigh` int(10) NOT NULL DEFAULT '0' COMMENT '权重', + `status` varchar(30) NOT NULL DEFAULT '' COMMENT '状态', + PRIMARY KEY (`id`), + KEY `weigh` (`weigh`,`id`), + KEY `pid` (`pid`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='分类表'; + +-- ---------------------------- +-- Table structure for `fa_configvalue` +-- ---------------------------- +DROP TABLE IF EXISTS `fa_configvalue`; +CREATE TABLE `fa_configvalue` ( + `id` varchar(30) NOT NULL DEFAULT '' COMMENT '配置ID', + `name` varchar(300) NOT NULL DEFAULT '' COMMENT '配置名称', + `content` varchar(1500) NOT NULL DEFAULT '' COMMENT '配置内容', + `createtime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间', + `updatetime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间', + `weigh` int(10) NOT NULL DEFAULT '0' COMMENT '权重', + `status` varchar(30) NOT NULL DEFAULT 'normal' COMMENT '状态', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='配置表'; + +-- ---------------------------- +-- Records of `fa_configvalue` +-- ---------------------------- +BEGIN; +INSERT INTO `fa_configvalue` VALUES ('wechat', '微信菜单', '{\"menu\":[{\"name\":\"极速后台\",\"sub_button\":[{\"name\":\"官网\",\"type\":\"view\",\"url\":\"http:\\/\\/www.fastadmin.net\"},{\"name\":\"演示站\",\"type\":\"view\",\"url\":\"http:\\/\\/demo.fastadmin.net\"}]},{\"name\":\"联系客户\",\"type\":\"click\",\"key\":\"58cb852984970\"},{\"name\":\"关于我们\",\"type\":\"click\",\"key\":\"58bf944aa0777\"}],\"config\":[{\"id\":\"default.subscribe.message\",\"name\":\"关注后自动推送内容\",\"value\":\"欢迎关注我们!\"},{\"id\":\"cccdddd\",\"name\":\"dfsdffdsfdsdfsdfs\",\"value\":\"fsfsfsdfsdfdsfdsgggg\"}]}', '0', '1492186828', '5', 'normal'); +COMMIT; + +-- ---------------------------- +-- Table structure for `fa_crontab` +-- ---------------------------- +DROP TABLE IF EXISTS `fa_crontab`; +CREATE TABLE `fa_crontab` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID', + `type` varchar(10) NOT NULL DEFAULT '' COMMENT '事件类型', + `title` varchar(100) NOT NULL DEFAULT '' COMMENT '事件标题', + `content` text NOT NULL COMMENT '事件内容', + `schedule` varchar(100) NOT NULL DEFAULT '' COMMENT 'Crontab格式', + `sleep` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '延迟秒数执行', + `maximums` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '最大执行次数 0为不限', + `executes` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '已经执行的次数', + `createtime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间', + `updatetime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间', + `begintime` int(10) NOT NULL DEFAULT '0' COMMENT '开始时间', + `endtime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '结束时间', + `executetime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '最后执行时间', + `weigh` int(10) NOT NULL DEFAULT '0' COMMENT '权重', + `status` enum('completed','expired','hidden','normal') NOT NULL DEFAULT 'normal' COMMENT '状态', + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='定时任务表'; + +-- ---------------------------- +-- Table structure for `fa_page` +-- ---------------------------- +DROP TABLE IF EXISTS `fa_page`; +CREATE TABLE `fa_page` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID', + `category_id` int(10) NOT NULL DEFAULT '0' COMMENT '分类ID', + `title` varchar(50) NOT NULL DEFAULT '' COMMENT '标题', + `keywords` varchar(255) NOT NULL DEFAULT '' COMMENT '关键字', + `flag` set('h','i','s') NOT NULL DEFAULT '' COMMENT '标志', + `image` varchar(255) NOT NULL DEFAULT '' COMMENT '头像', + `content` text NOT NULL COMMENT '内容', + `icon` varchar(50) NOT NULL DEFAULT '' COMMENT '图标', + `views` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '点击', + `comments` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '评论', + `weigh` int(10) NOT NULL DEFAULT '0' COMMENT '权重', + `status` varchar(30) NOT NULL DEFAULT '' COMMENT '状态', + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='单页表'; + +-- ---------------------------- +-- Table structure for `fa_user` +-- ---------------------------- +DROP TABLE IF EXISTS `fa_user`; +CREATE TABLE `fa_user` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID', + `username` varchar(32) NOT NULL DEFAULT '' COMMENT '用户名', + `nickname` varchar(50) NOT NULL DEFAULT '' COMMENT '昵称', + `password` varchar(32) NOT NULL DEFAULT '' COMMENT '密码', + `salt` varchar(30) NOT NULL DEFAULT '' COMMENT '密码盐', + `email` varchar(100) NOT NULL DEFAULT '' COMMENT '电子邮箱', + `mobile` varchar(11) NOT NULL DEFAULT '' COMMENT '手机号', + `avatar` varchar(255) NOT NULL DEFAULT '' COMMENT '头像', + `level` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '等级', + `gender` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '性别', + `birthday` date NOT NULL COMMENT '生日', + `score` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '积分', + `prevtime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '上次登录时间', + `loginfailure` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '失败次数', + `logintime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '登录时间', + `loginip` varchar(50) NOT NULL DEFAULT '' COMMENT '登录IP', + `joinip` varchar(50) NOT NULL DEFAULT '' COMMENT '加入时间', + `jointime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '加入时间', + `status` varchar(30) NOT NULL DEFAULT '' COMMENT '状态', + PRIMARY KEY (`id`), + KEY `username` (`username`), + KEY `email` (`email`), + KEY `mobile` (`mobile`) +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='会员表'; + +-- ---------------------------- +-- Records of `fa_user` +-- ---------------------------- +BEGIN; +INSERT INTO `fa_user` VALUES ('3', 'admin', 'admin', 'c13f62012fd6a8fdf06b3452a94430e5', 'rpR6Bv', 'admin@163.com', '13888888888', '/assets/img/avatar.png', '0', '0', '2017-04-15', '0', '1491822015', '0', '1491822038', '127.0.0.1', '127.0.0.1', '1491461418', 'normal'); +COMMIT; + +-- ---------------------------- +-- Table structure for `fa_user_signin` +-- ---------------------------- +DROP TABLE IF EXISTS `fa_user_signin`; +CREATE TABLE `fa_user_signin` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID', + `user_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '会员ID', + `successions` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '连续签到次数', + `createtime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间', + PRIMARY KEY (`id`), + KEY `user_id` (`user_id`) +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='会员签到表'; + +-- ---------------------------- +-- Table structure for `fa_user_third` +-- ---------------------------- +DROP TABLE IF EXISTS `fa_user_third`; +CREATE TABLE `fa_user_third` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID', + `user_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '会员ID', + `platform` enum('weibo','wechat','qq') NOT NULL COMMENT '第三方应用', + `openid` varchar(50) NOT NULL DEFAULT '' COMMENT '第三方唯一ID', + `openname` varchar(50) NOT NULL DEFAULT '' COMMENT '第三方会员昵称', + `access_token` varchar(100) NOT NULL DEFAULT '', + `refresh_token` varchar(100) NOT NULL DEFAULT '', + `expires_in` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '有效期', + `createtime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间', + `updatetime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间', + `logintime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '登录时间', + `expiretime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '过期时间', + PRIMARY KEY (`id`), + UNIQUE KEY `platform` (`platform`,`openid`), + KEY `user_id` (`user_id`,`platform`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='会员连接表'; + +-- ---------------------------- +-- Table structure for `fa_version` +-- ---------------------------- +DROP TABLE IF EXISTS `fa_version`; +CREATE TABLE `fa_version` ( + `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID', + `oldversion` varchar(30) NOT NULL DEFAULT '' COMMENT '旧版本号', + `newversion` varchar(30) NOT NULL DEFAULT '' COMMENT '新版本号', + `packagesize` varchar(30) NOT NULL DEFAULT '' COMMENT '包大小', + `content` varchar(500) NOT NULL DEFAULT '' COMMENT '升级内容', + `downloadurl` varchar(255) NOT NULL DEFAULT '' COMMENT '下载地址', + `enforce` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '强制更新', + `createtime` int(10) NOT NULL DEFAULT '0' COMMENT '创建时间', + `updatetime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间', + `weigh` int(10) NOT NULL DEFAULT '0' COMMENT '权重', + `status` varchar(30) NOT NULL DEFAULT '' COMMENT '状态', + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='版本表'; + +-- ---------------------------- +-- Records of `fa_version` +-- ---------------------------- +BEGIN; +INSERT INTO `fa_version` VALUES ('1', '1.1.1,2', '1.2.1', '20M', '更新内容', 'http://www.downloadurl.com', '1', '1400000000', '0', '0', 'normal'); +COMMIT; + +-- ---------------------------- +-- Table structure for `fa_wechat_autoreply` +-- ---------------------------- +DROP TABLE IF EXISTS `fa_wechat_autoreply`; +CREATE TABLE `fa_wechat_autoreply` ( + `id` int(10) NOT NULL AUTO_INCREMENT, + `title` varchar(100) NOT NULL DEFAULT '' COMMENT '标题', + `text` varchar(100) NOT NULL DEFAULT '' COMMENT '触发文本', + `eventkey` varchar(50) NOT NULL DEFAULT '' COMMENT '响应事件', + `remark` varchar(255) NOT NULL DEFAULT '' COMMENT '备注', + `createtime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '添加时间', + `updatetime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间', + `status` varchar(30) NOT NULL DEFAULT '' COMMENT '状态', + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='微信自动回复表'; + +-- ---------------------------- +-- Table structure for `fa_wechat_context` +-- ---------------------------- +DROP TABLE IF EXISTS `fa_wechat_context`; +CREATE TABLE `fa_wechat_context` ( + `id` int(10) NOT NULL AUTO_INCREMENT, + `openid` varchar(64) NOT NULL DEFAULT '', + `type` varchar(30) NOT NULL DEFAULT '' COMMENT '类型', + `eventkey` varchar(64) NOT NULL DEFAULT '', + `command` varchar(64) NOT NULL DEFAULT '', + `message` varchar(255) NOT NULL DEFAULT '' COMMENT '内容', + `refreshtime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '最后刷新时间', + `createtime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间', + `updatetime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间', + PRIMARY KEY (`id`), + KEY `openid` (`openid`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='微信上下文表'; + +-- ---------------------------- +-- Table structure for `fa_wechat_response` +-- ---------------------------- +DROP TABLE IF EXISTS `fa_wechat_response`; +CREATE TABLE `fa_wechat_response` ( + `id` int(10) NOT NULL AUTO_INCREMENT, + `title` varchar(100) NOT NULL DEFAULT '' COMMENT '资源名', + `eventkey` varchar(128) NOT NULL DEFAULT '' COMMENT '事件', + `type` enum('text','image','news','voice','video','music','link','app') NOT NULL DEFAULT 'text' COMMENT '类型', + `content` text NOT NULL COMMENT '内容', + `remark` varchar(255) NOT NULL DEFAULT '' COMMENT '备注', + `createtime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间', + `updatetime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间', + `status` varchar(30) NOT NULL DEFAULT '' COMMENT '状态', + PRIMARY KEY (`id`), + UNIQUE KEY `event` (`eventkey`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='微信资源表'; + +-- ---------------------------- +-- Records of `fa_wechat_response` +-- ---------------------------- +BEGIN; +INSERT INTO `fa_wechat_response` VALUES ('1', '签到送积分', '58adaf7876aab', 'app', '{\"app\":\"signin\"}', '', '1487777656', '0', 'normal'), ('2', '关于我们', '58bf944aa0777', 'app', '{\"app\":\"article\",\"id\":\"1\"}', '', '1488950346', '0', 'normal'), ('3', '测试我们', '58c7d908c4570', 'text', '{\"content\":\"\\u8fd4\\u56de\\u6210\\u529f\\u5566\\uff01\"}', '测试我们', '1489492232', '0', 'normal'), ('4', '联系客服', '58cb852984970', 'app', '{\"app\":\"service\"}', '', '1489732905', '0', 'normal'); +COMMIT; + +SET FOREIGN_KEY_CHECKS = 1; diff --git a/application/admin/command/Install/install.lock b/application/admin/command/Install/install.lock new file mode 100644 index 00000000..56a6051c --- /dev/null +++ b/application/admin/command/Install/install.lock @@ -0,0 +1 @@ +1 \ No newline at end of file diff --git a/application/admin/command/Menu.php b/application/admin/command/Menu.php index 53f12558..d50609e5 100644 --- a/application/admin/command/Menu.php +++ b/application/admin/command/Menu.php @@ -11,6 +11,7 @@ use think\console\Command; use think\console\Input; use think\console\input\Option; use think\console\Output; +use think\Exception; class Menu extends Command { @@ -33,8 +34,7 @@ class Menu extends Command $controller = $input->getOption('controller') ? : ''; if (!$controller) { - $output->error("please input controller name"); - return; + throw new Exception("please input controller name"); } if ($controller != 'all-controller') diff --git a/application/admin/controller/Ajax.php b/application/admin/controller/Ajax.php index f0333395..92f52791 100644 --- a/application/admin/controller/Ajax.php +++ b/application/admin/controller/Ajax.php @@ -146,7 +146,8 @@ class Ajax extends Backend $admin_rule_ids = $this->auth->getRuleIds(); $superadmin = $this->auth->isSuperAdmin(); $current_rule_ids = $id ? explode(',', $currentgroupmodel->rules) : []; - if (!$id || !array_key_exists($pid, Tree::instance()->init($model->all(['status' => 'normal']))->getChildrenIds($id, TRUE))) + + if (!$id || !in_array($pid, Tree::instance()->init($model->all(['status' => 'normal']))->getChildrenIds($id, TRUE))) { //构造jstree所需的数据 $nodelist = []; diff --git a/application/admin/controller/Dashboard.php b/application/admin/controller/Dashboard.php index 842c89e9..914482d4 100644 --- a/application/admin/controller/Dashboard.php +++ b/application/admin/controller/Dashboard.php @@ -13,6 +13,9 @@ use app\common\controller\Backend; class Dashboard extends Backend { + /** + * 查看 + */ public function index() { $seventtime = \fast\Date::unixtime('day', -7); diff --git a/application/admin/controller/auth/Admin.php b/application/admin/controller/auth/Admin.php index 79049354..ac1133b5 100644 --- a/application/admin/controller/auth/Admin.php +++ b/application/admin/controller/auth/Admin.php @@ -2,6 +2,7 @@ namespace app\admin\controller\auth; +use app\admin\model\AdminLog; use app\common\controller\Backend; use fast\Random; use fast\Tree; @@ -56,10 +57,11 @@ class Admin extends Backend $params = $this->request->post("row/a"); if ($params) { - $params['salt'] = Random::basic(4); + $params['salt'] = Random::alnum(); $params['password'] = md5(md5($params['password']) . $params['salt']); $admin = $this->model->create($params); + AdminLog::record(__('Add'), $this->model->getLastInsID()); $group = $this->request->post("group/a"); //过滤不允许的组别,避免越权 @@ -98,6 +100,7 @@ class Admin extends Backend $params['password'] = md5(md5($params['password']) . $params['salt']); } $row->save($params); + AdminLog::record(__('Edit'), $ids); // 先移除所有权限 model('AuthGroupAccess')->where('uid', $row->id)->delete(); @@ -137,15 +140,41 @@ class Admin extends Backend $this->code = -1; if ($ids) { - $count = $this->model->where('id', 'in', $ids)->delete(); - if ($count) + // 避免越权删除管理员 + $childrenGroupIds = $this->childrenIds; + $adminList = $this->model->where('id', 'in', $ids)->where('id', 'in', function($query) use($childrenGroupIds) + { + $query->name('auth_group_access')->where('group_id', 'in', $childrenGroupIds)->field('uid'); + })->select(); + if ($adminList) { - model('AuthGroupAccess')->where('uid', 'in', $ids)->delete(); - $this->code = 1; + $deleteIds = []; + foreach ($adminList as $k => $v) + { + $deleteIds[] = $v->id; + } + $deleteIds = array_diff($deleteIds, [$this->auth->id]); + if ($deleteIds) + { + AdminLog::record(__('Del'), $deleteIds); + $this->model->destroy($deleteIds); + model('AuthGroupAccess')->where('uid', 'in', $deleteIds)->delete(); + $this->code = 1; + } } } return; } + /** + * 批量更新 + * @internal + */ + public function multi($ids = "") + { + // 管理员禁止批量操作 + $this->code = -1; + } + } diff --git a/application/admin/controller/auth/Group.php b/application/admin/controller/auth/Group.php index 0108ba24..8aebd666 100644 --- a/application/admin/controller/auth/Group.php +++ b/application/admin/controller/auth/Group.php @@ -2,6 +2,7 @@ namespace app\admin\controller\auth; +use app\admin\model\AdminLog; use app\common\controller\Backend; use fast\Tree; @@ -104,6 +105,7 @@ class Group extends Backend if ($params) { $this->model->create($params); + AdminLog::record(__('Add'), $this->model->getLastInsID()); $this->code = 1; } @@ -151,6 +153,7 @@ class Group extends Backend if ($params) { $row->save($params); + AdminLog::record(__('Edit'), $ids); $this->code = 1; } @@ -200,6 +203,7 @@ class Group extends Backend $count = $this->model->where('id', 'in', $ids)->delete(); if ($count) { + AdminLog::record(__('Del'), $ids); $this->code = 1; } } @@ -208,6 +212,7 @@ class Group extends Backend /** * 批量更新 + * @internal */ public function multi($ids = "") { diff --git a/application/admin/controller/auth/Rule.php b/application/admin/controller/auth/Rule.php index 2ab99290..170902e6 100644 --- a/application/admin/controller/auth/Rule.php +++ b/application/admin/controller/auth/Rule.php @@ -2,8 +2,10 @@ namespace app\admin\controller\auth; +use app\admin\model\AdminLog; use app\common\controller\Backend; use fast\Tree; +use think\Cache; /** * 规则管理 @@ -24,7 +26,7 @@ class Rule extends Backend // 必须将结果集转换为数组 Tree::instance()->init(collection($this->model->order('weigh', 'desc')->select())->toArray()); $this->rulelist = Tree::instance()->getTreeList(Tree::instance()->getTreeArray(0), 'title'); - $ruledata = []; + $ruledata = [0 => __('None')]; foreach ($this->rulelist as $k => $v) { $ruledata[$v['id']] = $v['title']; @@ -61,6 +63,8 @@ class Rule extends Backend if ($params) { $this->model->create($params); + AdminLog::record(__('Add'), $this->model->getLastInsID()); + Cache::rm('__menu__'); $this->code = 1; } @@ -84,6 +88,8 @@ class Rule extends Backend if ($params) { $row->save($params); + AdminLog::record(__('Edit'), $ids); + Cache::rm('__menu__'); $this->code = 1; } @@ -104,6 +110,8 @@ class Rule extends Backend $count = $this->model->where('id', 'in', $ids)->delete(); if ($count) { + AdminLog::record(__('Del'), $ids); + Cache::rm('__menu__'); $this->code = 1; } } @@ -111,4 +119,14 @@ class Rule extends Backend return; } + /** + * 批量更新 + * @internal + */ + public function multi($ids = "") + { + // 节点禁止批量操作 + $this->code = -1; + } + } diff --git a/application/admin/controller/general/Configvalue.php b/application/admin/controller/general/Configvalue.php index b25c51ea..a9d85aea 100644 --- a/application/admin/controller/general/Configvalue.php +++ b/application/admin/controller/general/Configvalue.php @@ -2,6 +2,7 @@ namespace app\admin\controller\general; +use app\admin\model\AdminLog; use app\common\controller\Backend; /** @@ -75,6 +76,7 @@ class Configvalue extends Backend $params['content'] = array_combine($fieldarr, $valuearr); } $this->model->save($params); + AdminLog::record(__('Add'), $this->model->getLastInsID()); $this->code = 1; } @@ -114,6 +116,7 @@ class Configvalue extends Backend $params['content'] = array_combine($fieldarr, $valuearr); } $row->save($params); + AdminLog::record(__('Edit'), $ids); $this->code = 1; } @@ -123,53 +126,4 @@ class Configvalue extends Backend return $this->view->fetch(); } - /** - * 删除 - */ - public function del($ids = "") - { - $this->code = -1; - if ($ids) - { - $count = $this->model->where('id', 'in', $ids)->delete(); - if ($count) - { - $this->code = 1; - } - } - - return; - } - - /** - * 批量更新 - */ - public function multi($ids = "") - { - $this->code = -1; - $ids = $ids ? $ids : $this->request->param("ids"); - if ($ids) - { - if ($this->request->has('params')) - { - parse_str($this->request->post("params"), $values); - $values = array_intersect_key($values, array_flip(array('status'))); - if ($values) - { - $count = $this->model->where('id', 'in', $ids)->update($values); - if ($count) - { - $this->code = 1; - } - } - } - else - { - $this->code = 1; - } - } - - return; - } - } diff --git a/application/admin/controller/general/Crontab.php b/application/admin/controller/general/Crontab.php index 3badf376..4120fcf1 100644 --- a/application/admin/controller/general/Crontab.php +++ b/application/admin/controller/general/Crontab.php @@ -51,97 +51,4 @@ class Crontab extends Backend return $this->view->fetch(); } - /** - * 添加 - */ - public function add() - { - if ($this->request->isPost()) - { - $this->code = -1; - $params = $this->request->post("row/a"); - if ($params) - { - $this->model->create($params); - $this->code = 1; - } - - return; - } - return $this->view->fetch(); - } - - /** - * 编辑 - */ - public function edit($ids = NULL) - { - $row = $this->model->get(['id' => $ids]); - if (!$row) - $this->error(__('No Results were found')); - if ($this->request->isPost()) - { - $this->code = -1; - $params = $this->request->post("row/a"); - if ($params) - { - $row->save($params); - $this->code = 1; - } - - return; - } - $this->view->assign("row", $row); - return $this->view->fetch(); - } - - /** - * 删除 - */ - public function del($ids = "") - { - $this->code = -1; - if ($ids) - { - $count = $this->model->where('id', 'in', $ids)->delete(); - if ($count) - { - $this->code = 1; - } - } - - return; - } - - /** - * 批量更新 - */ - public function multi($ids = "") - { - $this->code = -1; - $ids = $ids ? $ids : $this->request->param("ids"); - if ($ids) - { - if ($this->request->has('params')) - { - parse_str($this->request->post("params"), $values); - $values = array_intersect_key($values, array_flip(array('status'))); - if ($values) - { - $count = $this->model->where('id', 'in', $ids)->update($values); - if ($count) - { - $this->code = 1; - } - } - } - else - { - $this->code = 1; - } - } - - return; - } - } diff --git a/application/admin/controller/general/Database.php b/application/admin/controller/general/Database.php index dcb31e22..aa6801da 100644 --- a/application/admin/controller/general/Database.php +++ b/application/admin/controller/general/Database.php @@ -2,6 +2,7 @@ namespace app\admin\controller\general; +use app\admin\model\AdminLog; use app\common\controller\Backend; use think\Db; use think\Debug; @@ -59,6 +60,7 @@ class Database extends Backend if (in_array($do_action, array('doquery', 'optimizeall', 'repairall'))) { + AdminLog::record(__('query'), ['table' => $tablename, 'action' => $do_action, 'sql' => $this->request->post('sqlquery')]); $this->$do_action(); } else if (count($tablename) == 0) @@ -67,6 +69,7 @@ class Database extends Backend } else { + AdminLog::record(__('query'), ['table' => $tablename, 'action' => $do_action]); foreach ($tablename as $table) { $this->$do_action($table); diff --git a/application/admin/controller/general/Profile.php b/application/admin/controller/general/Profile.php index 6b37145d..0379bddd 100644 --- a/application/admin/controller/general/Profile.php +++ b/application/admin/controller/general/Profile.php @@ -2,6 +2,7 @@ namespace app\admin\controller\general; +use app\admin\model\AdminLog; use app\common\controller\Backend; use fast\Random; @@ -60,6 +61,7 @@ class Profile extends Backend if ($params) { model('admin')->where('id', $this->auth->id)->update($params); + AdminLog::record(__('Update'), $params); $this->code = 1; } } diff --git a/application/admin/controller/wechat/Autoreply.php b/application/admin/controller/wechat/Autoreply.php index d8147c5b..f28ecd6d 100644 --- a/application/admin/controller/wechat/Autoreply.php +++ b/application/admin/controller/wechat/Autoreply.php @@ -2,6 +2,7 @@ namespace app\admin\controller\wechat; +use app\admin\model\AdminLog; use app\common\controller\Backend; use app\common\model\WechatResponse; use think\Db; @@ -37,9 +38,10 @@ class Autoreply extends Backend if ($params) { $row->save($params); + AdminLog::record(__('Edit'), $ids); $this->code = 1; } - return FALSE; + return; } $response = WechatResponse::get(['eventkey' => $row['eventkey']]); $this->view->assign("response", $response); diff --git a/application/admin/controller/wechat/Config.php b/application/admin/controller/wechat/Config.php index c7bb8952..f23edae5 100644 --- a/application/admin/controller/wechat/Config.php +++ b/application/admin/controller/wechat/Config.php @@ -2,6 +2,7 @@ namespace app\admin\controller\wechat; +use app\admin\model\AdminLog; use app\common\controller\Backend; use app\common\model\Configvalue; @@ -54,6 +55,7 @@ class Config extends Backend $this->obj['config'][] = $this->request->post('row/a'); $this->wechatcfg->content = $this->obj; $this->wechatcfg->save(); + AdminLog::record(__('Add'), $this->request->post('row/a')); $this->code = 1; return; } @@ -84,6 +86,7 @@ class Config extends Backend $this->wechatcfg->content = $this->obj; $this->wechatcfg->save(); $this->code = 1; + AdminLog::record(__('Edit'), $ids); return; } $this->view->assign("row", $row); @@ -108,6 +111,7 @@ class Config extends Backend } $this->wechatcfg->content = $this->obj; $this->wechatcfg->save(); + AdminLog::record(__('Del'), $ids); $this->code = 1; } diff --git a/application/admin/controller/wechat/Menu.php b/application/admin/controller/wechat/Menu.php index 23698765..957c82c6 100644 --- a/application/admin/controller/wechat/Menu.php +++ b/application/admin/controller/wechat/Menu.php @@ -2,10 +2,12 @@ namespace app\admin\controller\wechat; +use app\admin\model\AdminLog; use app\common\controller\Backend; use app\common\model\Configvalue; use app\common\model\WechatResponse; use EasyWeChat\Foundation\Application; +use think\Config; use think\Exception; /** @@ -51,6 +53,7 @@ class Menu extends Backend $content['menu'] = $menu; $this->wechatcfg->content = $content; $this->wechatcfg->save(); + AdminLog::record(__('Edit'), $ids); $this->code = 1; return; } @@ -68,6 +71,7 @@ class Menu extends Backend $ret = $app->menu->add($this->wechatcfg->content['menu']); if ($ret->errcode == 0) { + AdminLog::record(__('Sync'), $this->wechatcfg->content['menu']); $this->code = 1; } else diff --git a/application/admin/controller/wechat/Response.php b/application/admin/controller/wechat/Response.php index 295fe96b..f5026dad 100644 --- a/application/admin/controller/wechat/Response.php +++ b/application/admin/controller/wechat/Response.php @@ -2,6 +2,7 @@ namespace app\admin\controller\wechat; +use app\admin\model\AdminLog; use app\common\controller\Backend; use fast\service\Wechat; @@ -44,6 +45,7 @@ class Response extends Backend if ($params) { $this->model->save($params); + AdminLog::record(__('Add'), $this->model->getLastInsID()); $this->code = 1; $this->content = $params; } @@ -72,6 +74,7 @@ class Response extends Backend if ($params) { $row->save($params); + AdminLog::record(__('Edit'), $ids); $this->code = 1; } return; diff --git a/application/admin/lang/zh-cn/general/database.php b/application/admin/lang/zh-cn/general/database.php index d69195b3..a63b0cf4 100644 --- a/application/admin/lang/zh-cn/general/database.php +++ b/application/admin/lang/zh-cn/general/database.php @@ -3,8 +3,8 @@ return [ 'SQL Result' => '查询结果', 'Basic query' => '基础查询', - 'View structure' => '基础查询', - 'View data' => '基础查询', + 'View structure' => '查看表结构', + 'View data' => '查看表数据', 'Optimize' => '优化表', 'Repair' => '修复表', 'Optimize all' => '优化全部表', diff --git a/application/admin/library/traits/Backend.php b/application/admin/library/traits/Backend.php index 3a9b0237..bd9845a6 100644 --- a/application/admin/library/traits/Backend.php +++ b/application/admin/library/traits/Backend.php @@ -2,6 +2,8 @@ namespace app\admin\library\traits; +use app\admin\model\AdminLog; + trait Backend { @@ -42,6 +44,7 @@ trait Backend if ($params) { $this->model->create($params); + AdminLog::record(__('Add'), $this->model->getLastInsID()); $this->code = 1; } @@ -65,6 +68,7 @@ trait Backend if ($params) { $row->save($params); + AdminLog::record(__('Edit'), $ids); $this->code = 1; } @@ -85,6 +89,7 @@ trait Backend $count = $this->model->where('id', 'in', $ids)->delete(); if ($count) { + AdminLog::record(__('Del'), $ids); $this->code = 1; } } @@ -110,6 +115,7 @@ trait Backend $count = $this->model->where('id', 'in', $ids)->update($values); if ($count) { + AdminLog::record(__('Multi'), $ids); $this->code = 1; } } diff --git a/application/admin/model/AdminLog.php b/application/admin/model/AdminLog.php index a7a15631..16aa0ca1 100644 --- a/application/admin/model/AdminLog.php +++ b/application/admin/model/AdminLog.php @@ -17,6 +17,7 @@ class AdminLog extends Model { $admin = \think\Session::get('admin'); $admin_id = $admin ? $admin->id : 0; + $content = !is_scalar($content) ? json_encode($content) : $content . ''; $username = $username ? $username : ($admin ? $admin->username : __('')); self::create([ 'title' => $title, diff --git a/application/admin/view/general/configvalue/index.html b/application/admin/view/general/configvalue/index.html index 2f26a7f8..f9ca18d2 100644 --- a/application/admin/view/general/configvalue/index.html +++ b/application/admin/view/general/configvalue/index.html @@ -14,7 +14,6 @@
  • 设为隐藏
  • - {:__('Clear cache')}
    diff --git a/application/admin/view/index/login.html b/application/admin/view/index/login.html index 6b060d39..5ee66152 100644 --- a/application/admin/view/index/login.html +++ b/application/admin/view/index/login.html @@ -49,6 +49,15 @@ } +
    diff --git a/application/command.php b/application/command.php index ccd632e7..e5a0dadc 100755 --- a/application/command.php +++ b/application/command.php @@ -13,4 +13,5 @@ return [ 'app\admin\command\Crud', 'app\admin\command\Menu', + 'app\admin\command\Install', ]; diff --git a/public/assets/js/backend/index.js b/public/assets/js/backend/index.js index cd379487..1b77de0a 100755 --- a/public/assets/js/backend/index.js +++ b/public/assets/js/backend/index.js @@ -1,4 +1,4 @@ -define(['jquery', 'bootstrap', 'backend', 'addtabs', 'adminlte'], function ($, undefined, Backend, undefined, AdminLTE) { +define(['jquery', 'bootstrap', 'backend', 'addtabs', 'adminlte', 'validator'], function ($, undefined, Backend, undefined, AdminLTE, undefined) { var Controller = { index: function () { diff --git a/public/assets/js/backend/wechat/menu.js b/public/assets/js/backend/wechat/menu.js index 15d94c84..c732e0a1 100644 --- a/public/assets/js/backend/wechat/menu.js +++ b/public/assets/js/backend/wechat/menu.js @@ -132,7 +132,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'sortable'], function //更新菜单数据 var menuUpdate = function () { $.post("wechat/menu/edit", {menu: JSON.stringify(getMenuList())}, function (data) { - if (data['code'] == 0) { + if (data['code'] == 1) { } else { Backend.api.error(); } @@ -255,7 +255,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'sortable'], function }); $(document).on('click', "#menuSyn", function () { $.post("wechat/menu/sync", {}, function (data) { - if (data['code'] == 0) { + if (data['code'] == 1) { Backend.api.toastr.success('菜单同步更新成功,生效时间看微信官网说明,或者你重新关注微信号!'); } else { Backend.api.toastr.error(data['content']);