浏览代码

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	app/api/controller/GoodsController.php
#	app/api/logic/GoodsLogic.php
林海涛 1 年之前
父节点
当前提交
6ab168ae91

+ 19 - 0
app/api/controller/GoodsCategoryController.php

@@ -0,0 +1,19 @@
+<?php
+namespace app\api\controller;
+
+use app\api\lists\GoodsCategoryLists;
+
+/**
+ * 用户控制器
+ * Class GoodsCategoryController
+ * @package app\api\controller
+ */
+class GoodsCategoryController extends BaseApiController
+{
+    public array $notNeedLogin = ['lists'];
+
+    public function lists()
+    {
+        return $this->dataLists(new GoodsCategoryLists());
+    }
+}

+ 7 - 1
app/api/controller/GoodsController.php

@@ -18,7 +18,6 @@ namespace app\api\controller;
 
 
 use app\api\lists\GoodsLists;
-use app\api\logic\GoodsLogic;
 
 /**
  * 用户控制器
@@ -39,4 +38,11 @@ class GoodsController extends BaseApiController
         $result = GoodsLogic::getHotData();
         return $this->data($result);
     }
+
+    public function detail()
+    {
+        $id = $this->request->get('id/d');
+        $result = GoodsLogic::detail($id, $this->userId);
+        return $this->data($result);
+    }
 }

+ 63 - 0
app/api/lists/GoodsCategoryLists.php

@@ -0,0 +1,63 @@
+<?php
+namespace app\api\lists;
+
+use app\common\model\goods_category\GoodsCategory;
+use app\common\lists\ListsSearchInterface;
+
+/**
+ * GoodsCategory列表
+ * Class GoodsCategoryLists
+ * @package app\api\lists\goods_category
+ */
+class GoodsCategoryLists extends BaseApiDataLists implements ListsSearchInterface
+{
+
+
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @author likeadmin
+     * @date 2024/07/07 18:23
+     */
+    public function setSearch(): array
+    {
+        return [
+            '=' => ['category_type', 'name', 'is_goods', 'status'],
+
+        ];
+    }
+
+
+    /**
+     * @notes 获取列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author whitef
+     * @date 2024/07/07 18:23
+     */
+    public function lists(): array
+    {
+        $lists = GoodsCategory::where($this->searchWhere)
+            ->field(['id', 'pid' ,'picture', 'name'])
+            ->order(['weigh' => 'desc'])
+            ->select()
+            ->toArray();
+
+        return linear_to_tree($lists, 'children', 'id', 'pid');
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author whitef
+     * @date 2024/07/07 18:23
+     */
+    public function count(): int
+    {
+        return GoodsCategory::where($this->searchWhere)->count();
+    }
+
+}

+ 14 - 15
app/api/logic/GoodsLogic.php

@@ -1,30 +1,29 @@
 <?php
-// +----------------------------------------------------------------------
-// | likeadmin快速开发前后端分离管理后台(PHP版)
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | 开源版本可自由商用,可去除界面版权logo
-// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
-// | github下载:https://github.com/likeshop-github/likeadmin
-// | 访问官网:https://www.likeadmin.cn
-// | likeadmin团队 版权所有 拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeadminTeam
-// +----------------------------------------------------------------------
-
 namespace app\api\logic;
 
 use app\common\logic\BaseLogic;
 use app\common\model\goods\Goods;
 
+
 /**
- * 文章逻辑
- * Class ArticleLogic
+ * 服务商品逻辑处理
+ * Class GoodsLogic
  * @package app\api\logic
  */
 class GoodsLogic extends BaseLogic
 {
 
+    /**
+     * @notes 文章详情
+     * @param $goods_id
+     * @param $userId
+     * @return array
+     * @author whitef
+     * @date 2022/9/20 17:09
+     */
+    public static function detail($goods_id, $userId){
+        return Goods::findOrEmpty($goods_id)->visible(['id'])->toArray();
+    }
 
     public static function getHotData()
     {