Commit 70e2d038 authored by hujun's avatar hujun

修改公告

parent 01e207c7
......@@ -116,7 +116,7 @@ class Feed extends Basic
header('Access-Control-Allow-Origin:*');
$push = new PushFeed();
$field = 'id,create_time,house_title,click_num,content,type';
$field = 'id,create_time,house_title,click_num,content,type,title';
if (empty($this->params['id'])) {
return $this->response(101, "Id is null!");
......
......@@ -33,7 +33,7 @@ class Notice extends Basic
*/
public function index() {
if (!$this->request->isAjax()) {
return view('index');
// return view('index');
}
$pageNo = empty($this->params['pageNo']) ? 1 : $this->params['pageNo'];
......@@ -55,12 +55,12 @@ class Notice extends Basic
$where['title'] = ['LIKE', '%' . $this->params['title'] . '%'];
}
$field = 'id,title,content,create_time';
$where['status'] = 0;
$where['type'] = 1;
$field = 'a.id,a.title,a.content,a.create_time,b.name';
$where['a.status'] = 0;
$where['a.type'] = 1;
$data['list'] = $this->m_push->getList($pageNo, $pageSize, 'id DESC', $field, $where);
$data['total'] = $this->m_push->getTotal($where);
$data['list'] = $this->m_push->getListAgent($pageNo, $pageSize, 'id DESC', $field, $where);
$data['total'] = $this->m_push->getListAgentTotal($where);
return $this->response(200, "", $data);
}
......@@ -70,11 +70,11 @@ class Notice extends Basic
* @return \think\Response
*/
public function addNotice() {
if (!empty($this->params['title'])) {
if (empty($this->params['title'])) {
return $this->response(101, '标题为空!');
}
if (!empty($this->params['content'])) {
if (empty($this->params['content'])) {
return $this->response(101, '内容为空!');
}
......
......@@ -49,4 +49,37 @@ class PushFeed extends BaseModel
->order($order)
->find();
}
/**
* @param int $pageNo
* @param int $pageSize
* @param string $order_
* @param string $field
* @param string $params
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getListAgent($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field = '', $params = '') {
return $this->field($field)
->alias('a')
->join('a_agents b', 'a.user_id = b.id', 'left')
->where($params)
->order($order_)
->limit($pageSize)
->page($pageNo)
->select();
}
/**
* @param $params
* @return int|string
*/
public function getListAgentTotal($params) {
return $this->alias('a')
->join('a_agents b', 'a.user_id = b.id', 'left')
->where($params)
->count();
}
}
\ No newline at end of file
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