...
|
...
|
@@ -20,15 +20,51 @@ class NewsController extends HomeBaseController |
|
|
* @author sᴏᴜʟ ᴏғ ᴄɪɴᴅᴇʀ
|
|
|
* @url /news/News/newsList
|
|
|
* @method POST
|
|
|
*
|
|
|
* @param name:t_id type:int require:1 default:11 other: desc:分类id
|
|
|
*/
|
|
|
public function newsList()
|
|
|
{
|
|
|
|
|
|
$news_type = Db::name('portal_category')->field('id as t_id,name,more')->where(['parent_id' => 10])->select();
|
|
|
foreach ($news_type as $k => $v) {
|
|
|
$arr = json_decode($v['more'], true);
|
|
|
$v['thumb'] = cmf_get_image_url($arr['thumbnail']);
|
|
|
unset($v['more']);
|
|
|
$news_type[$k] = $v;
|
|
|
}
|
|
|
$t_id = (request()->param('t_id') == null) ? $news_type[0]['t_id'] : request()->param('t_id');
|
|
|
$news_list = Db::name('portal_category_post')->alias('c')
|
|
|
->field('c.post_id as id,p.post_title,p.post_hits,more')
|
|
|
->join('portal_post p', 'p.id=c.post_id')
|
|
|
->where(['c.category_id' => $t_id])
|
|
|
->select();
|
|
|
$collect = Db::name('collect_news')->field('post_id')->where(['user_id' => session('user.id')])->select();
|
|
|
foreach ($collect as $k => $v) {
|
|
|
$temp[$k] = $v['post_id'];
|
|
|
}
|
|
|
foreach ($news_list as $k => $v) {
|
|
|
$arr = json_decode($v['more'], true);
|
|
|
$v['thumb'] = cmf_get_image_url($arr['thumbnail']);
|
|
|
unset($v['more']);
|
|
|
if (in_array($v['id'], $temp)) {
|
|
|
$v['is_collect'] = 1;
|
|
|
} else {
|
|
|
$v['is_collect'] = 0;
|
|
|
}
|
|
|
$news_list[$k] = $v;
|
|
|
}
|
|
|
$return = [
|
|
|
'news_type' => $news_type,
|
|
|
'type_name' => Db::name('portal_category')->where(['id' => $t_id])->value('name'),
|
|
|
'news_list' => $news_list
|
|
|
];
|
|
|
echo json_encode(['data' => $return, 'code' => 20000]);
|
|
|
exit();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @title 新闻详情
|
|
|
* @description 接口说明
|
|
|
* @description 接口说明(指定id为购买协议)
|
|
|
* @author sᴏᴜʟ ᴏғ ᴄɪɴᴅᴇʀ
|
|
|
* @url /news/News/detail
|
|
|
* @method GET
|
...
|
...
|
@@ -38,6 +74,8 @@ class NewsController extends HomeBaseController |
|
|
public function detail()
|
|
|
{
|
|
|
$id = request()->param('id');
|
|
|
//阅读量+1
|
|
|
Db::name('portal_post')->where(['id'=>$id])->setInc('post_hits', 1);
|
|
|
$news = Db::name('portal_post')->field('post_title,post_content,published_time')->where(['id' => $id])->find();
|
|
|
$news['published_time'] = date('Y/m/d', $news['published_time']);
|
|
|
$news['post_content'] = html_entity_decode($news['post_content']);
|
...
|
...
|
|