Commit e5ea5042 authored by hujun's avatar hujun

商学院标签名

parent ea5e8e11
<?php
/**
* Created by PhpStorm.
* User: fuju
* User: hu jun
* Date: 2018/6/12
* Time: 17:21
*/
......@@ -79,16 +79,16 @@ class News extends Basic
return $this->response(101, "Id is null.");
}
$comment = new SNewsComment();
$field_news = 'id,title,s_label_id,cover_plan,content,create_time';
$where_news['status'] = 0;
$where_news['id'] = $this->params['id'];
$data['news'] = $this->m_news->getNewsInfo($field_news, $where_news);
$field = 'a.id,a.comment_content,a.create_time,b.name,b.img';
$where['a.s_news_id'] = $this->params['id'];
$where['a.status'] = 0;
$data['comment'] = $comment->getListAgent(1, 3, 'a.id DESC', $field, $where);
$comment = new SNewsComment();
$field_news = 'id,title,s_label_id,cover_plan,content,create_time';
$where_news['status'] = 0;
$where_news['id'] = $this->params['id'];
$data['news'] = $this->m_news->getNewsInfo($field_news, $where_news);
$data['news']['label_name'] = $this->m_news->getNewsLable($data['news']['s_label_id']);
$field = 'a.id,a.comment_content,a.create_time,b.name,b.img';
$where['a.s_news_id'] = $this->params['id'];
$where['a.status'] = 0;
$data['comment'] = $comment->getListAgent(1, 3, 'a.id DESC', $field, $where);
return $this->response(200, "", $data);
}
......
......@@ -91,4 +91,16 @@ class SNews extends BaseModel
$comment_number += 1;
return $this->where('id', $id)->setField('comment_number', $comment_number);
}
/**
* 根据s_label_id获取标签id名
*
* @param $id
* @param string $field
* @return mixed
*/
public function getNewsLable($id, $field = 'label_name') {
$m_label = new SLabel();
return $m_label->where('id',$id)->value($field);
}
}
\ 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