Commit 5d1b903b authored by hujun's avatar hujun

app 商学院接口

parent 6b5e5817
<?php
/**
* Created by PhpStorm.
* User: fuju
* Date: 2018/6/12
* Time: 17:21
*/
namespace app\api_broker\controller;
use app\index\extend\Basic;
use app\model\SLabel;
use app\model\SNews;
use think\Request;
class News extends Basic
{
protected $m_news;
public function __construct(Request $request = null)
{
parent::__construct($request);
$this->m_news = new SNews();
}
/**
* 商学院列表
*
* @return \think\Response|\think\response\View
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function index()
{
if (!$this->request->isAjax()) {
return view('index');
}
$pageNo = empty($this->params['pageNo']) ? 1 : $this->params['pageNo'];
$pageSize = empty($this->params['pageSize']) ? 10 : $this->params['pageSize'];
if (!empty($this->params['start_time']) && empty($this->params['end_time'])) {
$where['a.create_time'] = [ '> time', $this->params['start_time'] . ' 00:00:00' ];
}
if (!empty($this->params['end_time']) && empty($this->params['start_time'])) {
$where['a.create_time'] = [ '< time', $this->params['end_time'] . ' 23:59:59' ];
}
if (!empty($this->params['end_time']) && !empty($this->params['start_time'])) {
$where['a.create_time'] = [ 'between time', [ $this->params['start_time'] . ' 00:00:00', $this->params['end_time'] . ' 23:59:59' ] ];
}
if (!empty($this->params['title'])) {
$where['a.title'] = [ 'LIKE', '%' . $this->params['title'] . '%' ];
}
if (!empty($this->params['label_id'])) {
$where['a.s_label_id'] = $this->params['label_id'];
}
$field = 'a.id,a.title,a.content,a.create_time,b.name,c.label_name';
$where['a.status'] = 0;
$data['list'] = $this->m_news->getListAgent($pageNo, $pageSize, 'id DESC', $field, $where);
$data['total'] = $this->m_news->getListAgentTotal($where);
return $this->response(200, "", $data);
}
/**
* 商学院资讯详情
*
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getNewsInfo()
{
if (empty($this->params['id'])) {
return $this->response(101, "Id is null.");
}
$data = $this->m_news->getNewsInfo('id,title,s_label_id,cover_plan,content');
return $this->response(200, "", $data);
}
/**
* 商学院标签
*
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getNewsLabel() {
$label = new SLabel();
$data = $label->getList(1, 200, '', 'id,label_name', ['status'=>0]);
return $this->response(200, '', $data);
}
}
\ No newline at end of file
...@@ -488,10 +488,10 @@ Route::group('broker', [ ...@@ -488,10 +488,10 @@ Route::group('broker', [
'superviseListNew' => [ 'api_broker/Supervise/superviseList', [ 'method' => 'POST|GET' ] ], //监督执行列表 朱伟 2018-06-15 'superviseListNew' => [ 'api_broker/Supervise/superviseList', [ 'method' => 'POST|GET' ] ], //监督执行列表 朱伟 2018-06-15
'addSupervise' => [ 'api_broker/Supervise/addSupervise', [ 'method' => 'POST|GET' ] ], //新增-监督执行 朱伟 2018-06-20 'addSupervise' => [ 'api_broker/Supervise/addSupervise', [ 'method' => 'POST|GET' ] ], //新增-监督执行 朱伟 2018-06-20
'superviseUploadImg' => [ 'api_broker/Supervise/superviseUploadImg', [ 'method' => 'POST|GET' ] ], //监督执行-上传图片 朱伟 2018-06-20 'superviseUploadImg' => [ 'api_broker/Supervise/superviseUploadImg', [ 'method' => 'POST|GET' ] ], //监督执行-上传图片 朱伟 2018-06-20
'uploadImg' => [ 'api_broker/UploadImg/uploadImg', [ 'method' => 'POST|GET' ] ], //图片上传 'uploadImg' => [ 'api_broker/UploadImg/uploadImg', [ 'method' => 'POST|GET' ] ], //图片上传
'business_school' => [ 'api_broker/news/index', [ 'method' => 'GET' ] ], //商学院资讯列表
'getNewsInfo' => [ 'api_broker/news/getNewsInfo', [ 'method' => 'GET' ] ], //商学院资讯详情
'getNewsLabel' => [ 'api_broker/news/getNewsLabel', [ 'method' => 'GET' ] ], //商学院资标签
]); ]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment