zhangguidong 2 年之前
父節點
當前提交
b491958f4f
共有 3 個文件被更改,包括 47 次插入1 次删除
  1. 30 0
      app/data/controller/api/Goods.php
  2. 10 0
      app/data/model/ShopGoodsCollection.php
  3. 7 1
      config/apidoc.php

+ 30 - 0
app/data/controller/api/Goods.php

@@ -5,6 +5,7 @@ namespace app\data\controller\api;
 use app\data\model\ShopGoods;
 use app\data\model\ShopGoodsCart;
 use app\data\model\ShopGoodsCate;
+use app\data\model\ShopGoodsCollection;
 use app\data\model\ShopGoodsMark;
 use app\data\service\ExpressService;
 use app\data\service\GoodsService;
@@ -61,6 +62,11 @@ class Goods extends Auth
     {
         $this->success('获取区域成功', ExpressService::region(3, 1));
     }
+
+    /**
+     * @Title ("购物车添加")
+     * @return void
+     */
     public function cart_add()
     {
         $user = $this->getUser();
@@ -128,4 +134,28 @@ class Goods extends Auth
         ShopGoodsCart::mk()->whereIn('id',$cart_id)->where('user_id',$user['id'])->delete();
         $this->success('购物车已删除');
     }
+    /**
+     * @Title ("添加我的收藏")
+     */
+    public function collection(){
+        $user =$this->getUser();
+        $goods_id = input('goods_id');
+        ShopGoodsCollection::mk()->insertGetId(['uuid'=>$user['id'],'goods_id'=>$goods_id,'create_at'=>date('Y-m-d H:i:s')]);
+        $this->success('商品收藏成功');
+    }
+    /**
+     * @Title ("删除我的收藏")
+     */
+    public function del_collection(){
+        $user = $this->getUser();
+        $coll_ids = input('coll_ids');
+        ShopGoodsCollection::mk()->whereIn('id',$coll_ids)->where('uuid',$user['id'])->delete();
+        $this->success('商品收藏已取消');
+    }
+    /**
+     * @Title ("我的收藏列表")
+     */
+    public function collection_list(){
+
+    }
 }

+ 10 - 0
app/data/model/ShopGoodsCollection.php

@@ -0,0 +1,10 @@
+<?php
+
+namespace app\data\model;
+
+use think\admin\Model;
+
+class ShopGoodsCollection extends Model
+{
+
+}

+ 7 - 1
config/apidoc.php

@@ -23,7 +23,13 @@ return [
                         \app\data\controller\api\Area::class,
                         \app\data\controller\api\Weather::class,
                         \app\data\controller\api\auth\Address::class,
-                    ]
+                        \app\data\controller\api\Goods::class,
+                        \app\data\controller\api\Order::class,
+                        \app\data\controller\api\User::class,
+
+
+
+                ]
                 ]
             ],
         ]