Browse Source

Merge branch 'master' of http://git.bjzxtw.org.cn:3000/zxt/public_producer

LiuJ 20 hours ago
parent
commit
59f96254dc

+ 73 - 0
app/JsonRpc/PublicRpcService.php

@@ -42,6 +42,8 @@ use App\Model\WebsiteCategory;
 use App\Model\AdPlace;
 use App\Model\WebsiteImg;
 use App\Model\SectorComponent;
+use App\Model\ComponentImg;
+
 #[RpcService(name: "PublicRpcService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
 class PublicRpcService implements PublicRpcServiceInterface
 {
@@ -2567,4 +2569,75 @@ class PublicRpcService implements PublicRpcServiceInterface
         }
         return Result::success($sector);
     }
+    /**
+     * 自助建站-组件管理-获取组件预览图列表
+     */
+    public function getComponentImgList(array $data): array
+    {
+        
+        $where['component_img.component_id'] = $data['component_id'];
+        if(isset($data['template_id']) && !empty($data['template_id'])){
+            $where['component_img.template_id'] = $data['template_id'];
+        }
+        $component_img = ComponentImg::where($where)
+        ->leftJoin('template','component_img.template_id','=','template.template_id')
+        ->leftJoin('component','component_img.component_id','=','component.component_type')
+        ->select('component_img.*','template.template_name','component.component_name')
+        ->paginate($data['page_size'], ['*'], 'page', $data['page']);
+        if(empty($component_img)){
+            return Result::error('组件预览图不存在!');
+        }
+        return Result::success($component_img);
+    }
+    /**
+     * 自助建站-组件管理-添加组件预览图
+     */
+    public function addComponentImg(array $data): array
+    {
+        unset($data['user_id']);
+        $img = ComponentImg::where('component_id',$data['component_id'])->where('template_id',$data['template_id'])->get()->all();
+        if(!empty($img)){
+            return Result::error('该组件已存在此皮肤的预览图!');
+        }
+        $component_img = ComponentImg::insertGetId($data);
+        if(empty($component_img)){
+            return Result::error('添加失败!');
+        }
+        return Result::success($component_img);
+    }
+    /**
+     * 自助建站-组件管理-删除组件预览图
+     */
+    public function delComponentImg(array $data): array
+    {
+        $component_img = ComponentImg::where('id',$data['id'])->delete();
+        if(empty($component_img)){
+            return Result::error('删除失败!');
+        }
+        return Result::success($component_img);
+    }
+    /**
+     * 自助建站-组件管理-更新组件预览图
+     */
+    public function updateComponentImg(array $data): array
+    {
+        $img = ComponentImg::where('id','!=',$data['id'])->where('component_id',$data['component_id'])->where('template_id',$data['template_id'])->get()->all();
+        if(!empty($img)){
+            return Result::error('该组件已存在此皮肤的预览图!');
+        }
+        unset($data['user_id']);
+        // unset($data['updated_at']);
+        $id = $data['id'];
+        unset($data['id']);
+        // return Result::success($data);
+
+        $component_img = ComponentImg::where('id',$id)->update($data);
+        if(empty($component_img)){
+            return Result::error('更新失败!');
+        }
+        return Result::success($component_img);
+    }
+
+
+
 }

+ 11 - 0
app/JsonRpc/PublicRpcServiceInterface.php

@@ -201,5 +201,16 @@ interface PublicRpcServiceInterface
     public function getAllSector(array $data): array;
     //组件管理-获取所有组件
     public function getAllComponent(array $data): array;
+    //组件管理-获取组件预览图列表
+    public function getComponentImgList(array $data): array;
+    //组件管理-添加组件预览图
+    public function addComponentImg(array $data): array;
+    //组件管理-删除组件预览图
+    public function delComponentImg(array $data): array;
+    //组件管理-更新组件预览图
+    public function updateComponentImg(array $data): array;
+
+
+
 
 }

+ 16 - 10
app/JsonRpc/WebsiteService.php

@@ -167,15 +167,15 @@ class WebsiteService implements WebsiteServiceInterface
             'suffix' => $data['suffix'] ?? "",
             'ad_key' => $data['ad_key'] ?? "",
         ];
-        $web_templsate = WebsiteTemplateInfo::where('website_id', $data['id'])->first();
+        // $web_templsate = WebsiteTemplateInfo::where('website_id', $data['id'])->first();
         // `status` tinyint(1) DEFAULT '0' COMMENT '0:未构建 1:未应用 2:已应用',
-        if (!empty($web_templsate) && $web_templsate['status'] == 2) {
-            return Result::error("此网站已应用,不可修改基本信息", 0);
-        }
-
-        Db::beginTransaction();
-        try {
-            if ($data['ad_key'] !=  $website['ad_key']) {
+        // if (!empty($web_templsate) && $web_templsate['status'] == 2) {
+        //     return Result::error("此网站已应用,不可修改基本信息", 0);
+        // }
+       
+       Db::beginTransaction();
+       try{
+            if($data['ad_key'] !=  $website['ad_key']){
                 $web = Website::where(function ($query) use ($data) {
                     $query->where('id', '!=', $data['id'])
                         ->where('ad_key', $data['ad_key']);
@@ -2126,8 +2126,7 @@ class WebsiteService implements WebsiteServiceInterface
     public function getWebsiteintel(array $data): array
     {
         //查询所有网站模板信息
-        $query = Website::where('website.status', 1)
-            ->leftJoin("website_template_info", "website_template_info.website_id", "website.id")
+        $query = Website::leftJoin("website_template_info", "website_template_info.website_id", "website.id")
             ->leftJoin("template", "template.template_id", "website_template_info.template_id")
             ->leftJoin("template_class", "template_class.class_id", "template.template_class_id")
             ->leftJoin('website_column', 'website_column.id', 'website.website_column_id')
@@ -2244,6 +2243,11 @@ class WebsiteService implements WebsiteServiceInterface
         if (empty($result)) {
             return Result::error("请输入正确的网站id!", 0);
         }
+        // 0:未构建 1:未应用 2:已应用
+        if($result['status'] == 2){
+            return Result::error("此网站的模板正在应用中,暂不可编辑!", 0);
+        }
+
         // 订单状态:1:通过;2:驳回;3:撤回;4:修改;5:过期;6:待审核;7:结束
         $order = Order::where('website_id', $data['website_id'])->where('status', 1)->first();
         if (!empty($order)) {
@@ -3526,6 +3530,8 @@ class WebsiteService implements WebsiteServiceInterface
             //克隆网站基础信息  website_template_info website_category
             $resultWebsiteTemplateInfo = WebsiteTemplateInfo::where(['website_id' => $data['website_id']])->first();
             $clone_website_template_info = $resultWebsiteTemplateInfo->replicate();
+            $clone_website_template_info->status = 0;
+            $clone_website_template_info->action_id = 0;
             $clone_website_template_info->website_id = $clone_website->id;
             $clone_website_template_info->save();
             //克隆网站导航 获取原始 website_id 对应的所有 WebsiteCategory 记录

+ 29 - 0
app/Model/ComponentImg.php

@@ -0,0 +1,29 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+/**
+ */
+class ComponentImg extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $table = 'component_img';
+
+    /**
+     * The attributes that are mass assignable.
+     */
+    // protected array $fillable = [];
+
+    /**
+     * The attributes that should be cast to native types.
+     */
+    protected array $casts = [];
+
+    protected array $guarded = [];
+}