diff --git a/app/api/controller/BusinessSchool.php b/app/api/controller/BusinessSchool.php index d5fdb75c..9bf5693e 100755 --- a/app/api/controller/BusinessSchool.php +++ b/app/api/controller/BusinessSchool.php @@ -24,7 +24,7 @@ class BusinessSchool extends Api $get = $this->request->get(); $get['page_no'] = $this->page_no; $get['page_size'] = $this->page_size; - $lists = ArticleLogic::lists($get); + $lists = BusinessSchoolLogic::lists($get); return JsonServer::success('获取成功', $lists); } diff --git a/app/api/logic/BusinessSchoolLogic.php b/app/api/logic/BusinessSchoolLogic.php index d3dbe2df..2d80fd8e 100644 --- a/app/api/logic/BusinessSchoolLogic.php +++ b/app/api/logic/BusinessSchoolLogic.php @@ -20,4 +20,51 @@ class BusinessSchoolLogic extends Logic return ['error'=>$e->getMessage()]; } } + + public static function lists($get) + { + try { + $where = [ + ['a.del', '=', 0], + ['a.is_show', '=', 1], + ['c.del', '=', 0], + ['c.is_show', '=', 1], + ]; + if(isset($get['cid']) && !empty($get['cid'])) { + $where[] = ['cid', '=', $get['cid']]; + } + + $order = [ + 'sort' => 'asc', + 'id' => 'desc' + ]; + + $model = new BusinessSchool(); + + $count = $model->alias('a')->join('article_category c', 'c.id = a.cid')->where($where)->count(); + + $list = $model->alias('a') + ->join('article_category c', 'c.id = a.cid') + ->field(['a.id', 'a.title', 'a.image', 'a.visit', 'a.likes','a.intro', 'a.content', 'a.create_time']) + ->where($where) + ->order($order) + ->page($get['page_no'], $get['page_size']) + ->select() + ->toArray(); + + $more = is_more($count, $get['page_no'], $get['page_size']); + + $data = [ + 'list' => $list, + 'page_no' => $get['page_no'], + 'page_size' => $get['page_size'], + 'count' => $count, + 'more' => $more + ]; + return $data; + + } catch (\Exception $e) { + return ['error'=>$e->getMessage()]; + } + } } \ No newline at end of file