##开始使用
1. 填写好控制器名称
2. 填写好表单元素
3. 点同步字段,会将表单元素自动同步到表字段,如果不想建表,也要点一下同步,不然前端校验通过不了,包含 `id`、`status`、`isdelete`、`create_time`、`update_time` 的数据类型随便填写,模型会根据选项自动生成,不按此处选择的数据类型生成
4. 勾选需要生成的首页菜单
5. 勾选是否创建模型和验证器
6. 点击生成


>[info] 以下代码、日志全部是自动生成,没有做任何修改,包括缩进,严格的缩进非常方便二次编辑和查阅
##生成文件
###controller/one/two/three/Forth.php
```
// +----------------------------------------------------------------------
// | tpadmin [a web admin based ThinkPHP5]
// +----------------------------------------------------------------------
// | Copyright (c) 2016 tianpian All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: tianpian
// +----------------------------------------------------------------------
//------------------------
// 四级控制器控制器
//-------------------------
namespace appadmincontrolleronetwothree;
use appadminController;
class Forth extends Controller
{
use appadmintraitscontrollerController;
protected function filter(&$map)
{
if ($this->request->param("account")) $map['account'] = ["like", "%" . $this->request->param("account") . "%"];
}
}
```
###view/one/two/three/forth/index.html
```
{extend name="template/base" /}
{block name="content"}
{include file='form' /}
{include file="template/table_menu" menu="add,delete,recycleBin" /}
共有数据 :{$count} 条
{include file="th" /}
操作 |
|---|
{volist name="list" id="vo"}
{include file="td" /}
{$vo.status|show_status=$vo.id} {tp:access action='edit'} $vo['id']])}')" style="text-decoration:none"> {/tp:access} {tp:access action='delete'} {/tp:access} |
{/volist}
{$page}
{/block}
```
###view/one/two/three/forth/th.html
```
|
帐号 |
密码 |
城市 |
{:sort_by('年龄','age')} |
爱好 |
```
###view/one/two/three/forth/td.html
```
|
{$vo.account|high_light=\think\Request::instance()->param('account')} |
{$vo.password} |
{$vo.city} |
{$vo.age} |
{$vo.hobby} |
```
###view/one/two/three/forth/form.html
```
```
###view/one/two/three/forth/recyclebin.html
```
{extend name="template/recyclebin" /}
```
###view/one/two/three/forth/edit.html
```
{extend name="template/base" /}
{block name="content"}
{/block}
{block name="script"}
{/block}
```
###model/one/two/three/Forth.php
```
// +----------------------------------------------------------------------
// | tpadmin [a web admin based ThinkPHP5]
// +----------------------------------------------------------------------
// | Copyright (c) 2016 tianpian All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: tianpian
// +----------------------------------------------------------------------
//------------------------
// 四级控制器模型
//-------------------------
namespace appadminmodelonetwothree;
use thinkModel;
class Forth extends Model
{
// 指定表名,不含前缀
protected $name = 'one_two_three_forth';
// 开启自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
}
```
###validate/one/two/three/Forth.php
```
// +----------------------------------------------------------------------
// | tpadmin [a web admin based ThinkPHP5]
// +----------------------------------------------------------------------
// | Copyright (c) 2016 tianpian All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: tianpian
// +----------------------------------------------------------------------
//------------------------
// 四级控制器验证器
//-------------------------
namespace appadminvalidateonetwothree;
use thinkValidate;
class Forth extends Validate
{
protected $rule = [
"account|帐号" => "require",
"password|密码" => "require",
"age|年龄" => "require",
];
}
```
##生成数据表
下面是 Linux 版 Navicat 截图

下面是从 Linux 版 Navicat 中拷贝出的建表语句
```
CREATE TABLE `tp_one_two_three_forth` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '四级控制器主键',
`account` char(30) DEFAULT NULL COMMENT '帐号',
`password` char(32) DEFAULT NULL COMMENT '密码',
`city` varchar(255) DEFAULT NULL COMMENT '城市',
`age` tinyint(3) DEFAULT NULL COMMENT '年龄',
`hobby` varchar(255) DEFAULT NULL COMMENT '爱好',
`isdelete` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '删除状态,1-删除 | 0-正常',
`create_time` int(11) unsigned NOT NULL COMMENT '创建时间',
`update_time` int(11) unsigned NOT NULL COMMENT '更新时间',
PRIMARY KEY (`id`),
KEY `account` (`account`),
KEY `age` (`age`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='四级控制器';
```
##生成日志
runtime/log 目录下的日志原文:
>[info] 在当天的日志中搜索 build_sql 即可搜索到,日志原文中的标记是 BUILD_SQL
```
---------------------------------------------------------------
[ 2016-10-26T15:39:02+08:00 ] 127.0.0.1 127.0.0.1 POST /admin/generate/generate.html
[ log ] tpadmin.dev/admin/generate/generate.html [运行时间:0.037991s][吞吐率:26.32req/s] [内存消耗:2,767.79kb] [文件加载:58]
[ sql ] BUILD_SQL:
DROP TABLE IF EXISTS `tp_one_two_three_forth`;
CREATE TABLE `tp_one_two_three_forth` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '四级控制器主键',
`account` char(30) COMMENT '帐号',
`password` char(32) COMMENT '密码',
`city` varchar(255) COMMENT '城市',
`age` tinyint(3) COMMENT '年龄',
`hobby` varchar(255) COMMENT '爱好',
`isdelete` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '删除状态,1-删除 | 0-正常',
`create_time` int(11) unsigned NOT NULL COMMENT '创建时间',
`update_time` int(11) unsigned NOT NULL COMMENT '更新时间',
PRIMARY KEY (`id`),
KEY `account` (`account`),
KEY `age` (`age`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT '四级控制器';
```