瀏覽代碼

自助建站添加搭建基础信息

15313670163 4 月之前
父節點
當前提交
7ffd250019

+ 205 - 1
app/JsonRpc/WebsiteService.php

@@ -2,6 +2,8 @@
 namespace App\JsonRpc;
 use App\Model\Article;
 use App\Model\Category;
+use App\Model\FooterCategory;
+use App\Model\FooterContent;
 use App\Model\LetterOfComplaint;
 use App\Model\TemplateClass;
 use App\Model\Template;
@@ -14,8 +16,10 @@ use Hyperf\DbConnection\Db;
 use Hyperf\RpcServer\Annotation\RpcService;
 use App\Tools\Result;
 use App\Model\WebsiteCategory;
+use App\Model\WebsiteTemplate;
+use App\Model\WebsiteTemplateInfo;
 use function PHPUnit\Framework\isNull;
-
+// use Illuminate\Support\Facades\DB;
 #[RpcService(name: "WebsiteService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
 class WebsiteService implements WebsiteServiceInterface
 {
@@ -1077,5 +1081,205 @@ class WebsiteService implements WebsiteServiceInterface
         }
         return Result::success($websiteInfo->toArray());
     }
+     /**
+     * 获取并搜索 网站模板信息
+     * @param array $data
+     * @return array
+     */
+    public function getWebsiteTemplateinfo(array $data): array
+    {
+        $where = []; // 初始化 $where 数组
+        //若存在条件;则在$rep的基础上进行筛选
+        if(isset($data['website_name'])){
+            array_push($where, ['website.website_name','like','%'.$data['website_name'].'%']);
+        }
+        if(isset($data['status'])){
+            if($data['status'] == 0){
+                array_push($where, ['website_template_info.status','=',null]);
+            }else{
+                array_push($where, ['website_template_info.status','=',$data['status']]);
+            }
+        }
+        //查询所有网站模板信息
+        if(empty($where)){
+            $rep = Website::where('website.status', 1)
+            ->leftJoin("website_template_info", "website_template_info.website_id", "website.id")
+            ->leftJoin("template", "template.id", "website_template_info.template_id")
+            ->select(
+                "website.website_name",
+                "website.website_url",
+                "website_template_info.id as tid",
+                "website_template_info.created_at",
+                "website_template_info.updated_at",
+                "website_template_info.page_type",                
+                DB::raw("COALESCE(website_template_info.status, 0) as template_status"),
+                "template.template_name"
+            )
+            ->limit($data['pageSize'])
+            ->offset(($data['page'] - 1) * $data['pageSize'])
+            ->orderBy("website_template_info.updated_at", "asc")
+            ->get();
+        }else{
+            $rep = Website::where($where)
+            ->where('website.status', 1)
+            ->leftJoin("website_template_info", "website_template_info.website_id", "website.id")
+            ->leftJoin("template", "template.id", "website_template_info.template_id")
+            ->select(
+                "website.website_name",
+                "website.website_url",
+                "website_template_info.id as tid",
+                "website_template_info.created_at",
+                "website_template_info.updated_at",
+                "website_template_info.page_type", 
+                DB::raw("COALESCE(website_template_info.status, 0) as template_status"),
+                "template.template_name"
+            )
+            ->limit($data['pageSize'])
+            ->offset(($data['page'] - 1) * $data['pageSize'])
+            ->orderBy("website_template_info.updated_at", "asc")
+            ->get();
 
+        }
+        $result = [
+            "rows" => $rep->toArray(),
+            "count" => $rep->count()
+        ];
+        if($rep->count()==0){
+            return Result::error("没有查找到相关数据",0);
+        } else {
+            return Result::success($result); // 返回结果应该是 $result,而不是 $where
+        }
+        // return Result::success($result);
+    }
+    /**
+     * 添加网站模板信息
+     * @param array $data
+     * @return array
+     */
+    public function addWebsiteTemplateinfo(array $data): array
+    {
+        $website = Website::where('website.id',$data['website_id'])->first();
+        if(empty($website)){
+            $message = "请输入正确的网站id!";
+        }else{
+            if(empty($website['website_column_id'])){
+                $message = "请先关联导航池!";
+            }
+            if(isset($data['page_type'])){
+                if (in_array(1, $data['page_type']) && in_array(7, $data['page_type'])) {
+                    // 数组中同时包含值为 1(首页) 和值为 7 (底部导航详情页)的元素
+                    $result = 'yes';
+                    $data['page_type'] = json_encode($data['page_type'])??''; // 将数组转换为 JSON 字符串
+                    $result = WebsiteTemplateInfo::insertGetId($data);
+                } else {
+                    $message = "请先选择首页和底部导航详情页!";
+                }
+            }else{
+                $footer = FooterCategory::where('website_id',$data['website_id'])->select('type')->get();
+                if(empty($footer)){
+                    $types = '2';
+                }else{
+                    $types = 2;
+                    foreach ($footer as $v) {
+                        if ($v['type'] == 1) {
+                            $types = 1;
+                        } else {
+                            $types = 0;
+                        }
+                    }
+                }
+                $result['type'] = $types;
+            }
+        }
+        if(empty($result)){
+            return Result::error($message,0);
+        }else{
+            return Result::success($result);
+        }
+    }
+     /**
+     * 添加网站模板信息
+     * @param array $data
+     * @return array
+     */
+    public function addWebsiteTemplate(array $data): array
+    {
+        $website = Website::where('website.id',$data['website_id'])->first();
+        if(empty($website)){
+            $message = "请输入正确的网站id!";
+        }else{
+            //若存在模板id 则直接添加
+            if(isset($data['template_id'])){
+                $template = Template::where('id',$data['template_id'])->first();
+                if(empty($template)){
+                    $message = "请输入正确的模板id!";
+                }else{
+                    $result = WebsiteTemplateInfo::where('website_id',$data['website_id'])
+                    ->update(['template_id'=>$data['template_id']]);
+                    return Result::success($result);
+                }
+            }else{
+                $where = $data["page_type"];
+                if(isset($data['template_class_id'])){
+                    $template_class = TemplateClass::where('id',$data['template_class_id'])->first();
+                    if(empty($template_class)){
+                        $message = "请输入正确的模板风格id!";
+                    }else{
+                        // 获取指定风格下的模板
+                        $rep = Template::where('template_class_id', $data['template_class_id'])
+                            ->where(function ($query) use ($where) {
+                                foreach ($where as $value) {
+                                    $query->whereJsonContains('template_img', ['value' => $value]);
+                                }
+                            })
+                            ->leftJoin('template_class','template_class.id','template.template_class_id')
+                            ->select('template.*','template_class.name')
+                            ->limit($data['pageSize'])
+                            ->offset(($data['page'] - 1) * $data['pageSize'])
+                            ->orderBy("template.updated_at", "desc")
+                            ->get();
+                    }
+                }else{
+                    //获取所有模板
+                    $rep = Template::where(function ($query) use ($where) {
+                            foreach ($where as $value) {
+                                $query->whereJsonContains('template_img', ['value' => $value]);
+                            }
+                        })
+                        ->offset(($data['page'] - 1) * $data['pageSize'])
+                        ->limit($data['pageSize'])
+                        ->orderBy("template.updated_at", "desc")
+                        ->get();
+                }
+                if(empty($rep->toArray())){
+                    $message = "没有查找到相关数据!";
+                }else{
+                    $result = [
+                        "rows" => $rep->toArray(),
+                        "count" => $rep->count()
+                    ];
+                }
+            }
+        }
+        
+        if(empty($rep->toArray())){
+            return Result::error($message,0);
+        }else{
+            return Result::success($result);
+        }
+    }
+     /**
+     * 获取所有网站模板信息
+     *
+     * @return array
+     */
+    public function getAllTemplateClass(array $data): array
+    {
+        $result = TemplateClass::all();
+        if(empty($result)){
+            return Result::error("没有查找到相关数据!",0);
+        }else{
+            return Result::success($result);
+        }
+    }
 }

+ 5 - 0
app/JsonRpc/WebsiteServiceInterface.php

@@ -68,4 +68,9 @@ interface WebsiteServiceInterface
     public function upWebsiteCategoryones(array $data): array;
     public function getWebsiteAllCategory(array $data): array;
 
+
+    public function getWebsiteTemplateinfo(array $data): array;
+    public function addWebsiteTemplateinfo(array $data): array;
+    public function addWebsiteTemplate(array $data): array;
+    public function getAllTemplateClass(array $data): array;
 }

File diff suppressed because it is too large
+ 0 - 0
runtime/container/classes.cache


File diff suppressed because it is too large
+ 0 - 0
runtime/container/scan.cache


+ 1 - 1
runtime/hyperf.pid

@@ -1 +1 @@
-35017
+594

+ 4 - 0
vendor/composer/autoload_classmap.php

@@ -24,6 +24,7 @@ return array(
     'App\\Model\\Article' => $baseDir . '/app/Model/Article.php',
     'App\\Model\\ArticleData' => $baseDir . '/app/Model/ArticleData.php',
     'App\\Model\\Category' => $baseDir . '/app/Model/Category.php',
+    'App\\Model\\Component' => $baseDir . '/app/Model/Component.php',
     'App\\Model\\Department' => $baseDir . '/app/Model/Department.php',
     'App\\Model\\District' => $baseDir . '/app/Model/District.php',
     'App\\Model\\FooterCategory' => $baseDir . '/app/Model/FooterCategory.php',
@@ -32,6 +33,7 @@ return array(
     'App\\Model\\LetterType' => $baseDir . '/app/Model/LetterType.php',
     'App\\Model\\Link' => $baseDir . '/app/Model/Link.php',
     'App\\Model\\Model' => $baseDir . '/app/Model/Model.php',
+    'App\\Model\\Sector' => $baseDir . '/app/Model/Sector.php',
     'App\\Model\\Template' => $baseDir . '/app/Model/Template.php',
     'App\\Model\\TemplateClass' => $baseDir . '/app/Model/TemplateClass.php',
     'App\\Model\\User' => $baseDir . '/app/Model/User.php',
@@ -41,6 +43,8 @@ return array(
     'App\\Model\\WebsiteColumn' => $baseDir . '/app/Model/WebsiteColumn.php',
     'App\\Model\\WebsiteRole' => $baseDir . '/app/Model/WebsiteRole.php',
     'App\\Model\\WebsiteRoleUser' => $baseDir . '/app/Model/WebsiteRoleUser.php',
+    'App\\Model\\WebsiteTemplate' => $baseDir . '/app/Model/WebsiteTemplate.php',
+    'App\\Model\\WebsiteTemplateInfo' => $baseDir . '/app/Model/WebsiteTemplateInfo.php',
     'App\\Tools\\Result' => $baseDir . '/app/Tools/Result.php',
     'Attribute' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/Attribute.php',
     'CURLStringFile' => $vendorDir . '/symfony/polyfill-php81/Resources/stubs/CURLStringFile.php',

+ 4 - 0
vendor/composer/autoload_static.php

@@ -713,6 +713,7 @@ class ComposerStaticInit88f2a4d4a4e81dc7d415bcdf39930654
         'App\\Model\\Article' => __DIR__ . '/../..' . '/app/Model/Article.php',
         'App\\Model\\ArticleData' => __DIR__ . '/../..' . '/app/Model/ArticleData.php',
         'App\\Model\\Category' => __DIR__ . '/../..' . '/app/Model/Category.php',
+        'App\\Model\\Component' => __DIR__ . '/../..' . '/app/Model/Component.php',
         'App\\Model\\Department' => __DIR__ . '/../..' . '/app/Model/Department.php',
         'App\\Model\\District' => __DIR__ . '/../..' . '/app/Model/District.php',
         'App\\Model\\FooterCategory' => __DIR__ . '/../..' . '/app/Model/FooterCategory.php',
@@ -721,6 +722,7 @@ class ComposerStaticInit88f2a4d4a4e81dc7d415bcdf39930654
         'App\\Model\\LetterType' => __DIR__ . '/../..' . '/app/Model/LetterType.php',
         'App\\Model\\Link' => __DIR__ . '/../..' . '/app/Model/Link.php',
         'App\\Model\\Model' => __DIR__ . '/../..' . '/app/Model/Model.php',
+        'App\\Model\\Sector' => __DIR__ . '/../..' . '/app/Model/Sector.php',
         'App\\Model\\Template' => __DIR__ . '/../..' . '/app/Model/Template.php',
         'App\\Model\\TemplateClass' => __DIR__ . '/../..' . '/app/Model/TemplateClass.php',
         'App\\Model\\User' => __DIR__ . '/../..' . '/app/Model/User.php',
@@ -730,6 +732,8 @@ class ComposerStaticInit88f2a4d4a4e81dc7d415bcdf39930654
         'App\\Model\\WebsiteColumn' => __DIR__ . '/../..' . '/app/Model/WebsiteColumn.php',
         'App\\Model\\WebsiteRole' => __DIR__ . '/../..' . '/app/Model/WebsiteRole.php',
         'App\\Model\\WebsiteRoleUser' => __DIR__ . '/../..' . '/app/Model/WebsiteRoleUser.php',
+        'App\\Model\\WebsiteTemplate' => __DIR__ . '/../..' . '/app/Model/WebsiteTemplate.php',
+        'App\\Model\\WebsiteTemplateInfo' => __DIR__ . '/../..' . '/app/Model/WebsiteTemplateInfo.php',
         'App\\Tools\\Result' => __DIR__ . '/../..' . '/app/Tools/Result.php',
         'Attribute' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/Attribute.php',
         'CURLStringFile' => __DIR__ . '/..' . '/symfony/polyfill-php81/Resources/stubs/CURLStringFile.php',

Some files were not shown because too many files changed in this diff