Ver código fonte

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

LiuJ 3 meses atrás
pai
commit
534a87877e

+ 30 - 3
app/JsonRpc/PublicRpcService.php

@@ -48,6 +48,7 @@ use App\Model\ComponentImg;
 use App\Model\TemplateRule;
 use App\Model\SectorType;
 use App\Model\Level;
+use App\Model\StyleCode;
 
 #[RpcService(name: "PublicRpcService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
 class PublicRpcService implements PublicRpcServiceInterface
@@ -2123,11 +2124,13 @@ class PublicRpcService implements PublicRpcServiceInterface
         Db::beginTransaction();
         try {
             if (empty($website_template_info)) {
-                $result['template_info'] = WebsiteTemplateInfo::create([
+                $result['template_info'] = WebsiteTemplateInfo::insertGetId([
                     'website_id' => $data['website_id'],
                     'page_type' => $page_type,
-                    'user_id' => $data['user_id']
-                ])->id;
+                    'user_id' => $data['user_id'],
+                    'status' => 0,
+                    'action_id' => 1,
+                ]);
             } else {
                 if ($website_template_info['status'] == 2) {
                     Db::rollBack();
@@ -3794,4 +3797,28 @@ class PublicRpcService implements PublicRpcServiceInterface
             return Result::success($result);
         }
     }
+    /**
+     * 自助建站-添加样式代码
+     */
+    public function addStyleCode(array $data): array
+    {
+        unset($data['status']);
+        $style_code = StyleCode::insertGetId($data);
+        if (empty($style_code)) {
+            return Result::error('添加失败!');
+        }
+        return Result::success($style_code);
+    }
+    /**
+     * 自助建站-获取样式代码
+     */
+    public function getStyleCode(array $data): array
+    {
+        unset($data['status']);
+        $style_code = StyleCode::get()->all();
+        if (empty($style_code)) {
+            return Result::error('样式代码不存在!');
+        }
+        return Result::success($style_code);
+    }
 }

+ 33 - 5
app/JsonRpc/WebsiteService.php

@@ -2295,9 +2295,9 @@ class WebsiteService implements WebsiteServiceInterface
         // if (!in_array(1, $foot_type) ) {
         //     $missingTypes[] = "列表型底部导航";
         // }
-        if (!in_array(0, $foot_type)) {
-            $missingTypes[] = "单页(详情)";
-        }
+        if (!in_array(0, $foot_type) ) {
+            $missingTypes = "单页(详情)";
+        } 
         if (!empty($missingTypes)) {
             $errorMessage = "请先添加" . $missingTypes . "!";
             return Result::error($errorMessage, 0);
@@ -2778,7 +2778,11 @@ class WebsiteService implements WebsiteServiceInterface
      */
     public function getWebsiteFootAll(array $data): array
     {
-        $website = Website::where('id', $data['website_id'])->where('status', 1)->first();
+        if(!isset($data['is_diyweb']) || empty($data['is_diyweb'])){
+            $website = Website::where('id',$data['website_id'])->where('status',1)->first();
+        }else{
+            $website = Website::where('id',$data['website_id'])->first();
+        }
         if (empty($website)) {
             return Result::error("暂无该网站", 0);
         }
@@ -3047,11 +3051,35 @@ class WebsiteService implements WebsiteServiceInterface
         if (isset($data['category_id']) && !empty($data['category_id'])) {
             array_push($where, ['category_id', '=', $data['category_id']]);
         }
-        $list = WebsiteCategory::query()->where($where)
+        if($data['article_id'] != 0){
+            $list = Article::where('article.id', $data['article_id'])
+            ->leftJoin('website_category', 'article.catid', '=', 'website_category.category_id')
+            // WebsiteCategory::query()->where($where)
+            ->leftJoin('website', 'website.id', '=', 'website_category.website_id')
+            ->leftJoin('article_ignore', 'website_category.website_id', '=', 'article_ignore.website_id') // 左连接 article_ignore 表
+            ->when(isset($data['article_id']), function ($query) use ($data) {
+                return $query->where(function ($query) use ($data) {
+                    $query->where('article_ignore.article_id', $data['article_id'])
+                          ->orWhereNull('article_ignore.article_id');
+                });
+            })
+            ->select('website_category.*', 'website.website_name', 'article_ignore.c_show_time') // 选择需要的字段,不存在记录时 c_show_time 为 null
+            ->distinct()
+            ->get()
+            // ->array_map(function ($item) {
+            //     $item['c_show_time'] = json_decode($item['category_arr_id'], true);
+            //     return $item;
+            // })
+            ;
+        }else{
+             $list = WebsiteCategory::query()->where($where)
             ->leftJoin('website', 'website.id', '=', 'website_category.website_id')
             ->select('website_category.*', 'website.website_name')
             ->distinct()
             ->get();
+        }
+        
+        
         if (empty($list)) {
             return Result::error("获取失败", 0);
         } else {

+ 31 - 0
app/Model/Level.php

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

+ 27 - 0
app/Model/StyleCode.php

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

+ 1 - 1
config/autoload/databases.php

@@ -31,7 +31,7 @@ return [
             'max_idle_time' => (float) env('DB_MAX_IDLE_TIME', 60),
         ],
         'variables' => [
-            'time_zone' => '+08:00', // 设置MySQL连接的时区
+            'time_zone' => '+08:00', // 设置MySQL连接的时区 
         ],
         'commands' => [
             'gen:model' => [