| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <?php
- // +----------------------------------------------------------------------
- // | 商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
- // +----------------------------------------------------------------------
- // | Copyright (c) 2017~2021 https://www.thinkphp.com All rights reserved.
- // +----------------------------------------------------------------------
- // | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
- // +----------------------------------------------------------------------
- // | Author: thinkphp <admin@yiovo.com>
- // +----------------------------------------------------------------------
- declare (strict_types=1);
- namespace app\common\model;
- use cores\BaseModel;
- /**
- * 学校图库模型类
- * Class SchoolAlbum
- * @package app\common\model
- */
- class SchoolAlbum extends BaseModel
- {
- protected $globalScope = [''];
- // 定义表名
- protected $name = 'school_album';
- // 定义主键
- protected $pk = 'album_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, $limitRow=0){
- if($list = \think\facade\Cache::get('caches:schools:albums:'.$schoolId)){
- return $list;
- }
- $query = self::where(['school_id'=>$schoolId]);
- if($limitRow){
- $query->limit($limitRow);
- }
- $list = $query->field('album_id,title,album_url')
- ->order('album_id desc')
- ->select();
- $list = $list? $list->toArray() :[];
- if($list){
- foreach ($list as &$item){
- $item['image'] = $item['album_url']? getPreview($item['album_url']) : '';
- }
- \think\facade\Cache::set('caches:schools:albums:'.$schoolId, $list, rand(5, 10));
- }
- return $list;
- }
- }
|