zhaojs
2023-08-02 21512703df5ddf962893003a460e75af10d4757f
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
 
namespace app\api\logic;
 
use app\common\logic\Basic as BasicLogic;
use app\common\model\TalentInfo as ModelTalentInfo;
use app\api\logic\taoke\device\Haodanku as LogicHaodanku;
 
 
class TalentInfo extends BasicLogic
{
 
    protected $model = null;
 
    public function __construct()
    {
        parent::__construct();
 
        $this->model = new ModelTalentInfo();
    }
 
    /**
     * 获取列表数据
     *
     * @return void
     */
    public function getList($talentcat = 0)
    {
        $where = ['status' => 1,'is_delete'=>0];
        if($talentcat != 0) $where['talentcat'] = $talentcat;
        $list = $this->model->field('tid,type,tk_item_id,t_class,talentcat,name,talent_name,talent_id,short_title,label,item_num,image,high_quality,head_img,follow_times,compose_image,article_banner,article,app_image')->where($where)->select();
        $return_data = [
            'clickdata' => [],
            'newdata' => [],
            'topdata' => []
        ];
        if(empty($list)) return $return_data;
        foreach($list as $item){
            if($item['t_class'] == 1)array_push($return_data['topdata'],$item);
            if($item['t_class'] == 2)array_push($return_data['newdata'],$item);
            array_push($return_data['clickdata'],$item);
        }
        return $return_data;
    }
 
 
 
    /**
     * 获取详情
     *
     * @return void
     */
    public function getDetail($id)
    {
        $LogicHaodanku = new LogicHaodanku();
        $detail = $LogicHaodanku->getTalentArticle($id);
        if(isset($detail['addtime'])) $detail['addtime'] = date('Y-m-d',$detail['addtime']);
        if(isset($detail['article'])) $detail['article'] = htmlspecialchars_decode($detail['article']);
        $invalidList = [];
        $itemIds = explode(',',$detail['itemid_str']);
        $effectiveIds = empty($detail['items']) ? [] : array_column($detail['items'], 'itemid');
        $detail['invalidList'] = array_values(array_diff($itemIds,$effectiveIds));
        return $detail;
    }
 
}