CollectController.php
1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
/**
* Created by PhpStorm.
* User: yhbr
* Date: 2018/9/12
* Time: 15:17
*/
namespace app\collect\controller;
use cmf\controller\HomeBaseController;
use Think\Db;
/**
* @title 收藏模块
*/
class CollectController extends HomeBaseController
{
/**
* @title 我的收藏列表
* @description 接口说明
* @author sᴏᴜʟ ᴏғ ᴄɪɴᴅᴇʀ
* @url /collect/Collect/index
* @method POST
*/
public function index()
{
//收藏的活动
$activity = Db::name('collect')->alias('c')
->field('a.name,a.thumb')
->join('activity a', 'a.id=c.activity_id')
->where(['c.user_id' => session('user.id')])
->select();
$news = Db::name('collect_news')->alias('c')
->field('p.post_title,p.more')
->join('portal_post p', 'p.id=c.post_id')
->where(['c.user_id' => session('user.id')])
->select();
foreach ($news as $k => $v) {
$temp = json_decode($v['more'], true);
$v['thumb'] = cmf_get_image_url($temp['thumbnail']);
unset($v['more']);
$news[$k] = $v;
}
$data = [
'activity' => $activity,
'news' => $news
];
echo json_encode(['data' => $data]);
exit();
}
}