|
@@ -4,6 +4,8 @@ namespace App\Helpers;
|
|
|
|
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
use App\Models\DistAdminDistributor;
|
|
|
+use App\Models\DistAppearance;
|
|
|
+use App\Models\DistAppearancePublishList;
|
|
|
|
|
|
class SiteCache
|
|
|
{
|
|
@@ -14,20 +16,26 @@ class SiteCache
|
|
|
* @param int $seconds 缓存时间(秒)
|
|
|
* @return Dist|null
|
|
|
*/
|
|
|
- public static function getDist(?string $domain = null, int $seconds = 600): ?string
|
|
|
+ public static function getDist(?string $domain = null, int $seconds = 300): ?string
|
|
|
{
|
|
|
if (is_null($domain)) {
|
|
|
return null; // 如果未传入域名,返回 null
|
|
|
}
|
|
|
|
|
|
return Cache::tags([$domain, 'dist'])->remember("dist_{$domain}", $seconds, function () use ($domain) {
|
|
|
- $dist= DistAdminDistributor::where('custom_domain', $domain)
|
|
|
- ->orWhere('secondary_domain', $domain)
|
|
|
- ->first();
|
|
|
- //dd($dist); // 调试缓存的数据
|
|
|
+ $dist= DistAdminDistributor::findByDomain($domain);
|
|
|
+
|
|
|
+ if($dist['appearance_id'])
|
|
|
+ {
|
|
|
+ $dist['appearance'] = DistAppearance::getTemplateById($dist['appearance_id']);
|
|
|
+ $dist['publishList'] = DistAppearancePublishList::findByDistAndAppearance($dist['id'], $dist['appearance_id']);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
// 序列化存储
|
|
|
return serialize($dist);
|
|
|
-
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -54,7 +62,7 @@ class SiteCache
|
|
|
* @param int $seconds 缓存时间(秒)
|
|
|
* @return Product|null
|
|
|
*/
|
|
|
- public static function getProduct(?string $domain = null, ?int $productId = null, int $seconds = 600): ?Product
|
|
|
+ public static function getProduct(?string $domain = null, ?int $productId = null, int $seconds = 300): ?Product
|
|
|
{
|
|
|
if (is_null($domain) || is_null($productId)) {
|
|
|
return null; // 如果未传入 domain 或 productId,返回 null
|
|
@@ -89,7 +97,7 @@ class SiteCache
|
|
|
* @param int $seconds 缓存时间(秒)
|
|
|
* @return Article|null
|
|
|
*/
|
|
|
- public static function getArticle(?string $domain = null, ?int $articleId = null, int $seconds = 600): ?Article
|
|
|
+ public static function getArticle(?string $domain = null, ?int $articleId = null, int $seconds = 300): ?Article
|
|
|
{
|
|
|
if (is_null($domain) || is_null($articleId)) {
|
|
|
return null; // 如果未传入 domain 或 articleId,返回 null
|