<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Core\Util; use Illuminate\Support\Facades\Cache; use ModStart\Core\Dao\ModelUtil; class CmsUtil { private static function _CmsCacheRegister($pDSQm, $m1RYi) { $kpTEi = "CmsKeys:{$pDSQm}"; if (DBLockUtil::acquire('CmsCache.' . $kpTEi)) { goto Jd50v; KbikR: $otVv3[$m1RYi] = true; goto da9Sa; Jd50v: $otVv3 = Cache::get($kpTEi); goto rDRpb; da9Sa: Cache::forever($kpTEi, $otVv3); goto ekQPK; ekQPK: DBLockUtil::release('CmsCache.' . $kpTEi); goto ElH0g; rDRpb: if (!is_array($otVv3)) { $otVv3 = array(); } goto KbikR; ElH0g: } } private static function _CmsCacheFlush($pDSQm) { goto Rq1Xf; Rq1Xf: $kpTEi = "CmsKeys:{$pDSQm}"; goto w3esc; wZTfC: if (!is_array($otVv3)) { return; } goto wDyF3; wDyF3: foreach ($otVv3 as $U9AsU => $wsDBG) { Cache::forget($U9AsU); } goto wIFei; w3esc: $otVv3 = Cache::get($kpTEi); goto wZTfC; wIFei: } private static function CmsCacheClear($pDSQm) { self::_CmsCacheFlush($pDSQm); } public static function CmsCategoryAll($I1hTb, $ArzOE = array(), $cCRbx = array('*'), $eYPY0 = array('sort', 'asc'), $Kxp9e = 3600) { $m1RYi = "CmsCategory:{$I1hTb}:All:" . md5(serialize(array($ArzOE, $cCRbx, $eYPY0))); return Cache::remember($m1RYi, $Kxp9e, function () use($I1hTb, $ArzOE, $cCRbx, $eYPY0, $m1RYi) { self::_CmsCacheRegister($I1hTb, $m1RYi); $nWxZB = ModelUtil::all($I1hTb, $ArzOE, $cCRbx, $eYPY0); return $nWxZB; }); } public static function CmsCategoryTree($I1hTb, $GwMAe = array('name'), $spZCh = 'id', $gy8KO = 'pid', $xQBbx = 'sort', $Kxp9e = 3600) { $m1RYi = "CmsCategory:{$I1hTb}:Tree:" . md5(serialize(array($GwMAe, $spZCh, $gy8KO, $xQBbx))); return Cache::remember($m1RYi, $Kxp9e, function () use($I1hTb, $GwMAe, $spZCh, $gy8KO, $xQBbx, $m1RYi) { self::_CmsCacheRegister($I1hTb, $m1RYi); $Heozd = \TechOnline\Laravel\Util\TreeUtil::model2Nodes($I1hTb, $GwMAe, $spZCh, $gy8KO, $xQBbx); return $Heozd; }); } public static function CmsCategoryChildrenIds($I1hTb, $UFOLC, $GwMAe = array('name'), $spZCh = 'id', $gy8KO = 'pid', $xQBbx = 'sort', $Kxp9e = 3600) { $m1RYi = "CmsCategory:{$I1hTb}:CIds:" . md5(serialize(array($UFOLC, $GwMAe, $spZCh, $gy8KO, $xQBbx))); return Cache::remember($m1RYi, $Kxp9e, function () use($I1hTb, $UFOLC, $GwMAe, $spZCh, $gy8KO, $xQBbx, $m1RYi) { self::_CmsCacheRegister($I1hTb, $m1RYi); $nWxZB = ModelUtil::all($I1hTb, array(), array('*'), array($xQBbx, 'asc')); $a3gf2 = \TechOnline\Laravel\Util\TreeUtil::allChildIds($nWxZB, $UFOLC, $spZCh, $gy8KO); return $a3gf2; }); } function CmsCategoryGet($I1hTb, $ArzOE = array(), $cCRbx = array('*'), $Kxp9e = 3600) { $m1RYi = "CmsCategory:{$I1hTb}:Get:" . md5(serialize(array($ArzOE, $cCRbx))); return Cache::remember($m1RYi, $Kxp9e, function () use($I1hTb, $ArzOE, $cCRbx, $m1RYi) { self::_CmsCacheRegister($I1hTb, $m1RYi); $BsYWq = ModelUtil::get($I1hTb, $ArzOE, $cCRbx); return $BsYWq; }); } function CmsBasicAll($I1hTb, $ArzOE = array(), $cCRbx = array('*'), $eYPY0 = null, $Kxp9e = 3600) { $m1RYi = "CmsBasic:{$I1hTb}:All:" . md5(serialize(array($ArzOE, $cCRbx, $eYPY0))); return Cache::remember($m1RYi, $Kxp9e, function () use($I1hTb, $ArzOE, $cCRbx, $eYPY0, $m1RYi) { self::_CmsCacheRegister($I1hTb, $m1RYi); $nWxZB = ModelUtil::all($I1hTb, $ArzOE, $cCRbx, $eYPY0); return $nWxZB; }); } function CmsBasicLimit($I1hTb, $ArzOE = array(), $cCRbx = array('*'), $eYPY0 = null, $c0fAD = 10, $Kxp9e = 3600, $DzdHs = array()) { $m1RYi = "CmsBasic:{$I1hTb}:Limit:" . md5(serialize(array($ArzOE, $cCRbx, $eYPY0, $c0fAD, $DzdHs))); return Cache::remember($m1RYi, $Kxp9e, function () use($I1hTb, $ArzOE, $cCRbx, $eYPY0, $c0fAD, $m1RYi, $DzdHs) { self::_CmsCacheRegister($I1hTb, $m1RYi); $ktBm1 = ModelUtil::model($I1hTb); $ktBm1 = $ktBm1->where($ArzOE)->limit($c0fAD); if ($eYPY0 !== null) { $ktBm1 = $ktBm1->orderBy($eYPY0[0], $eYPY0[1]); } if (!empty($DzdHs['whereIn'])) { $ktBm1 = $ktBm1->whereIn($DzdHs['whereIn'][0], $DzdHs['whereIn'][1]); } $Ft9yT = $ktBm1->get($cCRbx)->toArray(); return $Ft9yT; }); } function CmsBasicGet($I1hTb, $ArzOE = array(), $cCRbx = array('*'), $Kxp9e = 3600) { $m1RYi = "CmsBasic:{$I1hTb}:Get:" . md5(serialize(array($ArzOE, $cCRbx))); return Cache::remember($m1RYi, $Kxp9e, function () use($I1hTb, $ArzOE, $cCRbx, $m1RYi) { self::_CmsCacheRegister($I1hTb, $m1RYi); $BsYWq = ModelUtil::get($I1hTb, $ArzOE, $cCRbx); return $BsYWq; }); } function CmsBasicGetField($I1hTb, $Q2vn5, $ArzOE = array(), $cCRbx = array('*'), $Kxp9e = 3600) { goto sXedc; C5TDm: if (empty($BsYWq[$Q2vn5])) { return null; } goto SQzSi; sXedc: $BsYWq = CmsBasicGet($I1hTb, $ArzOE, $cCRbx, $Kxp9e); goto C5TDm; SQzSi: return $BsYWq[$Q2vn5]; goto t_cfK; t_cfK: } }