Prechádzať zdrojové kódy

wesmiler 报恩寺项目提交

wesmiler 4 rokov pred
rodič
commit
8e6673945a

+ 7 - 1
app/Http/Controllers/Api/v1/ArticleController.php

@@ -46,8 +46,14 @@ class ArticleController extends BaseController
      * @return array|mixed
      * @return array|mixed
      */
      */
     public function info(){
     public function info(){
+        $id = request()->get('id',0);
+        if($id<=0){
+            return message(1006, false);
+        }
+
         $this->service->updateVisit($this->userId);
         $this->service->updateVisit($this->userId);
-        return $this->service->getDetail();
+        $info = $this->service->getDetail($id);
+        return message(1005, true, $info);
     }
     }
 
 
     /**
     /**

+ 0 - 25
app/Services/ArticleService.php

@@ -117,31 +117,6 @@ class ArticleService extends BaseService
     }
     }
 
 
     /**
     /**
-     * 获取详情
-     * @param $id
-     * @return array
-     */
-    public function getDetail(){
-        $id = request()->get('id', 0);
-        if($id<=0){
-            return message(1006, false);
-        }
-
-        $info = $this->model::from('article as a')
-            ->leftJoin('article_cates as c','c.id','=','a.cate_id')
-            ->where(['id'=> $id,'mark'=> 1,'status'=> 1])
-            ->select(['a.*','c.name as cate_name'])
-            ->first();
-        $info = $info? $info->toArray() :[];
-        if($info){
-            $info['thumb'] = $info['thumb']? get_image_url($info['thumb']) : '';
-            $info['create_time'] = $info['create_time']? datetime($info['create_time'], 'Y-m-d H:i:s') : '';
-        }
-
-        return message(1005, true, $info);
-    }
-
-    /**
      * 访问量
      * 访问量
      * @return mixed
      * @return mixed
      */
      */