ActivityNews.php 972 字节
<?php
/**
 * Created by PhpStorm.
 * auther: sgj
 * Date: 2020/9/26
 * Time: 17:40
 */

namespace api\common\model;


use think\Model;

class ActivityNews extends Model
{
    protected $name = 'activity_news';

    /**
     * 通过类型获取新闻
     * @param $type
     * @return mixed
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function getNewsByType($type){
        $map['activity_type']=$type;
        $list=$this->where($map)->select()->order('weight desc')->toArray();
        return $list;
    }


    public function getInfo($id){
        $info=$this::find($id);
        $info['content']=cmf_replace_content_file_url(htmlspecialchars_decode($info['content']));
        $info['create_time']=date('Y-m-d',$info['create_time']);
        $info['thumbnail']=cmf_get_image_url($info['thumbnail']);
        return $info;
    }


}