| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <?php
- // +----------------------------------------------------------------------
- // | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
- // +----------------------------------------------------------------------
- // | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
- // +----------------------------------------------------------------------
- // | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
- // +----------------------------------------------------------------------
- // | Author: 萤火科技 <admin@yiovo.com>
- // +----------------------------------------------------------------------
- declare (strict_types=1);
- namespace app\common\model;
- use cores\BaseModel;
- /**
- * 学校图库模型类
- * Class SchoolNew
- * @package app\common\model
- */
- class SchoolNew extends BaseModel
- {
- protected $globalScope = [''];
- // 定义表名
- protected $name = 'school_news';
- // 定义主键
- protected $pk = 'news_id';
- /**
- * 获取学校新闻资讯列表
- * @param $schoolId
- * @param int $limitRow
- * @return array|mixed
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public static function getShowList($schoolId, $type = 1, $limitRow=0){
- $cacheKey = "caches:schools:news:{$schoolId}_{$type}_{$limitRow}";
- if($list = \think\facade\Cache::get($cacheKey)){
- return $list;
- }
- $query = self::where(['school_id'=>$schoolId, 'type'=> $type, 'status'=>1]);
- if($limitRow){
- $query->limit($limitRow);
- }
- $list = $query->order('addtime desc,news_id desc')->select();
- $list->hidden(['content','update_time','status']);
- $list = $list? $list->toArray() :[];
- if($list){
- foreach ($list as &$item){
- $item['logo_preview'] = $item['logo']? getPreview($item['logo']) : '';
- $item['publish_time'] = $item['addtime']? date('Y/m/d', strtotime($item['addtime'])) : '';
- }
- \think\facade\Cache::set($cacheKey, $list, rand(10, 30));
- }
- return $list;
- }
- public function getList($where, $limitRow= 15){
- }
- }
|