WIN-2308041133\Administrator пре 8 месеци
родитељ
комит
d58c8013f9
1 измењених фајлова са 32 додато и 38 уклоњено
  1. 32 38
      application/admin/controller/platform/Platform.php

+ 32 - 38
application/admin/controller/platform/Platform.php

@@ -4,72 +4,66 @@ namespace app\admin\controller\platform;
 
 use app\common\controller\Backend;
 
-/**
- * 第三方平台列表
- *
- * @icon fa fa-user
- */
 class Platform extends Backend
 {
-
-    protected $relationSearch = true;
-
-
-    /**
-     * @var \app\admin\model\User
-     */
+    // 模型对象
     protected $model = null;
 
     public function _initialize()
     {
         parent::_initialize();
-        $this->model = model('platform');
+        $this->model = new \app\admin\model\third\Platform;
     }
 
-    /**
-     * 查看
-     */
+    // 列表页
     public function index()
     {
-        //设置过滤方法
-        
-        $this->request->filter(['strip_tags']);
         if ($this->request->isAjax()) {
-            //如果发送的来源是Selectpage,则转发到Selectpage
-            if ($this->request->request('keyField')) {
-                return $this->selectpage();
-            }
             list($where, $sort, $order, $offset, $limit) = $this->buildparams();
             $total = $this->model
-//                ->with('user')
                 ->where($where)
                 ->order($sort, $order)
                 ->count();
             $list = $this->model
-//                ->with('user')
                 ->where($where)
                 ->order($sort, $order)
                 ->limit($offset, $limit)
                 ->select();
-            $result = array("total" => $total, "rows" => $list);
+            $result = [
+                "total" => $total,
+                "rows" => $list,
+            ];
             return json($result);
         }
         return $this->view->fetch();
     }
 
-    /**
-     * 编辑
-     */
-    public function edit($ids = NULL)
-    {
-        $row = $this->model->get($ids);
-        if (!$row)
-            $this->error(__('No Results were found'));
-        return parent::edit($ids);
-    }
+    // 添加/编辑
     public function add()
     {
-        return parent::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'));
+    }
+}