|
|
@@ -0,0 +1,69 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace app\admin\controller\third;
|
|
|
+
|
|
|
+use app\common\controller\Backend;
|
|
|
+
|
|
|
+class Platform extends Backend
|
|
|
+{
|
|
|
+ // 模型对象
|
|
|
+ protected $model = null;
|
|
|
+
|
|
|
+ public function _initialize()
|
|
|
+ {
|
|
|
+ parent::_initialize();
|
|
|
+ $this->model = new \app\admin\model\third\Platform;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 列表页
|
|
|
+ public function index()
|
|
|
+ {
|
|
|
+ if ($this->request->isAjax()) {
|
|
|
+ list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
|
|
+ $total = $this->model
|
|
|
+ ->where($where)
|
|
|
+ ->order($sort, $order)
|
|
|
+ ->count();
|
|
|
+ $list = $this->model
|
|
|
+ ->where($where)
|
|
|
+ ->order($sort, $order)
|
|
|
+ ->limit($offset, $limit)
|
|
|
+ ->select();
|
|
|
+ $result = [
|
|
|
+ "total" => $total,
|
|
|
+ "rows" => $list,
|
|
|
+ ];
|
|
|
+ return json($result);
|
|
|
+ }
|
|
|
+ return $this->view->fetch();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 添加/编辑
|
|
|
+ public function add()
|
|
|
+ {
|
|
|
+ if ($this->request->isPost()) {
|
|
|
+ $params = $this->request->post("row/a");
|
|
|
+ if ($params) {
|
|
|
+ $params['createtime'] = time(); // 自动填充时间戳
|
|
|
+ $result = $this->model->save($params);
|
|
|
+ if ($result) {
|
|
|
+ $this->success();
|
|
|
+ } else {
|
|
|
+ $this->error(__('Operation failed'));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $this->error(__('Parameter %s can not be empty', ''));
|
|
|
+ }
|
|
|
+ return $this->view->fetch();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 删除
|
|
|
+ public function del($ids = "")
|
|
|
+ {
|
|
|
+ if ($ids) {
|
|
|
+ $this->model->destroy($ids);
|
|
|
+ $this->success();
|
|
|
+ }
|
|
|
+ $this->error(__('Parameter %s can not be empty', 'ids'));
|
|
|
+ }
|
|
|
+}
|