💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
>[info] 由于时间原因,只做了视图的自动生成,模型和控制器需要手动创建 ###数据库 前往mysql管理工具使用命令或可视化功能创建一个test表,结构如下 ![](https://box.kancloud.cn/740bd25095c67c5eb9979bbbbbdd9615_504x223.png) * * * * * * * * ##模型 创建模型 ~~~ // 关闭自动写入update_time字段 protected $updateTime = false; public function getTest($keyword = '', $start = 0, $limit = 10){ $data = $this->where(['title'=>['like','%'.$keyword.'%']])->limit($start, $limit)->order('orders ASC')->select(); return $data; } public function getPage($limit = 10){ $page = $this->count(); $page = floor($page / $limit); return $page; } ~~~ 此处代码作用为控制器可以获取数据和分页做准备。 ![](https://box.kancloud.cn/07d1405871a032fac6b29aefe106bbfe_1411x563.png) * * * * * * * * ##控制器 继承base目录下的system类,添加一个gettest方法以及save方法 ~~~ public function gettest($p = 1, $keyword = '') { $test = new Test(); $p = ($p*10) - 10; $list = $test->getTest($keyword, $p); $msg['status'] =200; $msg['data']['list'] = $list; $msg['pages'] = $test->getPage(); return $msg; } public function save() { if($this->request->isAjax()){ $post_data = $this->request->param(); if(empty($post_data)){return getMsg("数据不能为空");} $test = new Test(); $state = $test->allowField(true)->save($post_data,$post_data['id']); if(false == $state){ return getMsg("操作失败"); } return getMsg("操作成功"); } } ~~~ ![](https://box.kancloud.cn/1e25bf72b0cb36c6196d21c63f5844d9_860x598.png) * * * * * * * * ##视图 点击后台的系统-快捷方式-生成列表 1.选择hello mini的目录 test/index/index 2.表格字段按之前数据表中的字段来填,不需要输入id和排序和状态 ~~~ 我是标题|title|300 作者|author|200 创建时间|create_time|200 ~~~ 3.json地址:填上面控制器中的gettest()方法的路径,如: test/index/gettest 4.传递数据:留空 5:模型名:Test 6:列表名:测试数据 填完后点击立即生成(此处需要在模块目录创建文件的权限) ![](https://box.kancloud.cn/5b91ef9f3b2d374e65dfeb4ab1bc00dc_1003x613.png) 回到hello mini ,右键tab选择刷新 ![](https://box.kancloud.cn/b3977ef9b6ba868bb46673223dfcf8d2_749x333.png) 列表已经成功生成 ![](https://box.kancloud.cn/aedb989e62c16953b928263faade4bd9_1323x392.png)