From 41f3409bf150ae68315cd9b46dbee2fa699a2503 Mon Sep 17 00:00:00 2001 From: wangxiaowei Date: Sat, 21 Sep 2024 11:36:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=95=86=E5=AD=A6=E9=99=A2?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/BusinessSchool.php | 2 +- app/api/logic/BusinessSchoolLogic.php | 47 +++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) 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