فهرست منبع

首页视频轮播

whitefang 1 سال پیش
والد
کامیت
57027c041d

+ 9 - 1
app/api/controller/HomeServiceController.php

@@ -5,11 +5,12 @@ namespace app\api\controller;
 use app\api\lists\HomeServiceLists;
 use app\api\lists\HomeSpecialLists;
 use app\api\logic\HomeSpecialLogic;
+use app\api\validate\HomeSpecialValidate;
 use app\common\model\home_service\HomeSpecial;
 
 class HomeServiceController extends BaseApiController
 {
-    public array $notNeedLogin = ['lists','specialHot','specialLists'];
+    public array $notNeedLogin = ['lists','specialHot','specialLists','specialDetail'];
     public function lists()
     {
         return $this->dataLists(new HomeServiceLists());
@@ -47,4 +48,11 @@ class HomeServiceController extends BaseApiController
     {
         return $this->dataLists(new HomeSpecialLists());
     }
+
+    public function specialDetail()
+    {
+        $params = (new HomeSpecialValidate())->goCheck('detail');
+        $result = HomeSpecialLogic::detail($params);
+        return $this->data($result);
+    }
 }

+ 7 - 1
app/api/lists/HomeSpecialLists.php

@@ -2,6 +2,7 @@
 namespace app\api\lists;
 
 use app\adminapi\lists\BaseAdminDataLists;
+use app\common\model\goods\Goods;
 use app\common\model\home_service\HomeSpecial;
 use app\common\lists\ListsSearchInterface;
 
@@ -42,10 +43,15 @@ class HomeSpecialLists  extends BaseApiDataLists implements ListsSearchInterface
     {
         return HomeSpecial::where($this->searchWhere)
             ->where('status',1)
-            ->field(['id', 'special_type','special_way', 'title', 'cover_type', 'cover', 'user_head', 'user_nickname', 'vue_web', 'vue_param', 'view_num', 'tags', 'status', 'original_price' ,'present_price'])
+            ->field(['id', 'special_type','special_way', 'title', 'cover_type', 'cover', 'user_head', 'user_nickname', 'vue_web', 'vue_param', 'view_num', 'tags', 'status', 'original_price' ,'present_price','goods_id'])
             ->limit($this->limitOffset, $this->limitLength)
             ->order(['id' => 'desc'])
             ->select()
+            ->each(function($item){
+                if($item->goods_id){
+                    $item->goods = Goods::where('id',$item->goods_id)->field('goods_banners,goods_name,service_total,service_fee')->findOrEmpty();
+                }
+           })
             ->toArray();
     }
 

+ 1 - 1
app/api/logic/HomeSpecialLogic.php

@@ -42,6 +42,6 @@ class HomeSpecialLogic extends BaseLogic
      */
     public static function detail($params): array
     {
-        return HomeSpecial::findOrEmpty($params['id'])->toArray();
+        return HomeSpecial::field('cover_type,cover,title,describe,content')->findOrEmpty($params['id'])->toArray();
     }
 }

+ 63 - 0
app/api/validate/HomeSpecialValidate.php

@@ -0,0 +1,63 @@
+<?php
+
+namespace app\api\validate;
+
+
+use app\common\validate\BaseValidate;
+
+
+/**
+ * HomeSpecial验证器
+ * Class HomeSpecialValidate
+ * @package app\api\validate\home_service
+ */
+class HomeSpecialValidate extends BaseValidate
+{
+
+     /**
+      * 设置校验规则
+      * @var string[]
+      */
+    protected $rule = [
+        'id' => 'require',
+        'special_type' => 'require',
+        'title' => 'require',
+        'cover_type' => 'require',
+        'cover' => 'require',
+        'vue_web' => 'require',
+        'vue_param' => 'require',
+        'weight' => 'require',
+        'view_num' => 'require',
+        'status' => 'require',
+    ];
+
+
+    /**
+     * 参数描述
+     * @var string[]
+     */
+    protected $field = [
+        'id' => 'id',
+        'special_type' => '专题页类别',
+        'title' => '专题页名称',
+        'cover_type' => '封面类型:0=图片,1=视频',
+        'cover' => '封面',
+        'vue_web' => '专题页地址',
+        'vue_param' => '专题页参数',
+        'weight' => '权重',
+        'view_num' => '浏览次数',
+        'status' => '状态',
+    ];
+
+    /**
+     * @notes 详情场景
+     * @return HomeSpecialValidate
+     * @author likeadmin
+     * @date 2024/11/18 10:05
+     */
+    public function sceneDetail()
+    {
+        return $this->only(['id']);
+    }
+
+}