15669368801 4 years ago
parent
commit
a1ade2ed43
1 changed files with 32 additions and 5 deletions
  1. 32 5
      app/adminapi/controller/v1/company/Company.php

+ 32 - 5
app/adminapi/controller/v1/company/Company.php

@@ -86,13 +86,40 @@ class Company extends AuthController
      */
     public function read($id)
     {
-        // if ($id) {
-        //     $info = ArticleModel::where('n.id', $id)->alias('n')->field('n.*,c.content')->join('ArticleContent c', 'c.nid=n.id', 'left')->find();
-        //     if (!$info) return $this->fail('数据不存在!');
-        //     $info['cid'] = intval($info['cid']);
-        // }
         $info = CompanyModel::getOne($id);
         return $this->success(compact('info'));
     }
 
+    /**
+     * 删除指定资源
+     *
+     * @param int $id
+     * @return \think\Response
+     */
+    public function delete($id)
+    {
+        if (!$id) return $this->fail('数据不存在');
+        $res = CompanyModel::get($id);
+        if (!$res) return $this->fail('数据不存在!');
+        if ($res['is_del']) return $this->fail('已删除!');
+        $data['is_del'] = 1;
+        if (!CompanyModel::edit($data, $id))
+            return $this->fail(CompanyModel::getErrorInfo('删除失败,请稍候再试!'));
+        else
+            return $this->success('删除成功!');
+    }
+
+    /**
+     * 修改状态
+     * @param $id
+     * @param $status
+     * @return mixed
+     */
+    public function set_status($id, $status)
+    {
+        if ($status == '' || $id == 0) return $this->fail('参数错误');
+        CompanyModel::where(['id' => $id])->update(['status' => $status]);
+        return $this->success($status == 0 ? '关闭成功' : '开启成功');
+    }
+
 }