添加商学院分类获取

This commit is contained in:
wangxiaowei 2024-09-21 10:39:17 +08:00
parent 9f52af49ee
commit d809be4dbd
2 changed files with 66 additions and 0 deletions

@ -0,0 +1,41 @@
<?php
namespace app\api\controller;
use app\api\logic\BusinessSchoolLogic;
use app\common\basics\Api;
use app\common\server\JsonServer;
class BusinessSchool extends Api
{
// 文章分类
public function category()
{
$lists = BusinessSchoolLogic::category();
return JsonServer::success('获取成功', $lists);
}
/**
* @Notes: 文章列表
* @Author: 张无忌
*/
public function lists()
{
$get = $this->request->get();
$get['page_no'] = $this->page_no;
$get['page_size'] = $this->page_size;
$lists = ArticleLogic::lists($get);
return JsonServer::success('获取成功', $lists);
}
/**
* @Notes: 文章详细
* @Author: 张无忌
*/
public function detail()
{
$id = $this->request->get('id');
$detail = ArticleLogic::detail($id);
return JsonServer::success('获取成功', $detail);
}
}

@ -0,0 +1,25 @@
<?php
namespace app\api\logic;
use app\common\basics\Logic;
use app\common\model\BusinessSchool;
use app\common\model\BusinessSchoolCategory;
class BusinessSchoolLogic extends Logic
{
public static function category()
{
try {
$model = new BusinessSchoolCategory();
return $model->field(['id', 'name'])
->where([
['del', '=', 0],
['is_show', '=', 1]
])->order('order asc')->select()->toArray();
} catch (\Exception $e) {
return ['error'=>$e->getMessage()];
}
}
}