| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- <?php
- // +----------------------------------------------------------------------
- // | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
- // +----------------------------------------------------------------------
- // | 版权所有 2017~2021 LARAVEL研发中心
- // +----------------------------------------------------------------------
- // | 官方网站: http://www.laravel.cn
- // +----------------------------------------------------------------------
- // | Author: laravel开发员 <laravel.qq.com>
- // +----------------------------------------------------------------------
- namespace App\Services\Api;
- use App\Models\NoticeModel;
- use App\Models\SocialCircleModel;
- use App\Services\BaseService;
- use App\Services\ConfigService;
- use App\Services\RedisService;
- /**
- * 生活圈-服务类
- * @author laravel开发员
- * @since 2020/11/11
- * @package App\Services\Api
- */
- class SocialCircleService extends BaseService
- {
- // 静态对象
- protected static $instance = null;
- /**
- * 构造函数
- * @author laravel开发员
- * @since 2020/11/11
- */
- public function __construct()
- {
- $this->model = new SocialCircleModel();
- }
- /**
- * 静态入口
- */
- public static function make()
- {
- if (!self::$instance) {
- self::$instance = new static();
- }
- return self::$instance;
- }
- /**
- * 主页列表
- * @param int $num
- * @return array|mixed
- */
- public function getIndexList($num = 0)
- {
- $num = ConfigService::make()->getConfigByCode('show_social_num', 12);
- $cacheKey = "caches:socials:list_{$num}";
- $datas = RedisService::get($cacheKey);
- if($datas){
- return $datas;
- }
- $datas = $this->model->where(['status'=>1,'mark'=>1])
- ->select(['id','name','logo','link_type','app_id','sort','status'])
- ->orderBy('sort','desc')
- ->orderBy('id','asc')
- ->limit($num)
- ->get();
- $datas = $datas? $datas->toArray() : [];
- if($datas){
- $datas = $datas?array_chunk($datas,8) : [];
- RedisService::set($cacheKey, $datas, rand(300, 600));
- }
- return $datas;
- }
- }
|