From dda5a1b65e698a1e9c5bc8c5b4e0d81c36884ae3 Mon Sep 17 00:00:00 2001 From: panliang <1163816051@qq.com> Date: Tue, 13 Sep 2022 14:52:56 +0800 Subject: [PATCH] api goods --- README.md | 2 ++ lang/zh_CN/goods.php | 1 + src/Http/Admin/GoodsController.php | 2 ++ src/Http/Api/GoodsController.php | 2 +- src/Http/Resources/GoodsResource.php | 8 -------- src/Http/Resources/GoodsSkuResource.php | 4 ---- src/Http/Resources/GoodsTinyResource.php | 1 - 7 files changed, 6 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 9a9abbf..8dacf3d 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,8 @@ $menus = [ ## API接口 +- [在线预览](https://www.apifox.cn/apidoc/shared-86eb60cb-ba8f-46c6-b718-f33f99de5e7d) + ## 数据表 ### 商品分类: goods_category diff --git a/lang/zh_CN/goods.php b/lang/zh_CN/goods.php index d75ea2f..d124dd8 100644 --- a/lang/zh_CN/goods.php +++ b/lang/zh_CN/goods.php @@ -44,5 +44,6 @@ return [ 'created_at' => '创建时间', 'updated_at' => '更新时间', 'is_recommend' => '推荐', + 'description' => '描述', ], ]; diff --git a/src/Http/Admin/GoodsController.php b/src/Http/Admin/GoodsController.php index 2c539bc..bbc6280 100644 --- a/src/Http/Admin/GoodsController.php +++ b/src/Http/Admin/GoodsController.php @@ -176,6 +176,7 @@ class GoodsController extends AdminController $info = Goods::with(['category', 'brand', 'type'])->findOrFail($id); $show = Show::make($info); $show->field('name'); + $show->field('description'); $show->field('category_id')->as(function () { if (!$this->category) { return $this->category_id; @@ -236,6 +237,7 @@ class GoodsController extends AdminController $form->select('category_id')->options(GoodsCategory::selectOptions(null, false))->required(); $form->select('brand_id')->options(GoodsBrand::pluck('name', 'id')); $form->text('name')->required(); + $form->text('description'); $form->text('goods_sn')->rules([$unique], [ 'unique' => '商品编号已经存在', ]); diff --git a/src/Http/Api/GoodsController.php b/src/Http/Api/GoodsController.php index 55e25f5..dc3af12 100644 --- a/src/Http/Api/GoodsController.php +++ b/src/Http/Api/GoodsController.php @@ -22,7 +22,7 @@ class GoodsController extends Controller public function show($id) { - $info = Goods::with(['merchant', 'skus'])->show()->findOrFail($id); + $info = Goods::with(['skus'])->show()->findOrFail($id); return $this->json(GoodsResource::make($info)); } diff --git a/src/Http/Resources/GoodsResource.php b/src/Http/Resources/GoodsResource.php index 9c7b91a..f0bcd2a 100644 --- a/src/Http/Resources/GoodsResource.php +++ b/src/Http/Resources/GoodsResource.php @@ -10,18 +10,10 @@ class GoodsResource extends GoodsTinyResource return array_merge($data, [ 'content' => $this->content, - 'weight' => $this->weight, - 'volume' => $this->volume, - 'shipping_tmp_id' => $this->shipping_tmp_id, 'attr' => $this->attr, 'part' => $this->part, 'spec' => $this->spec, 'created_at' => $this->created_at->timestamp, - 'check_user_id' => $this->check_user_id, - 'check_at' => $this->check_at?->timestamp, - 'check_remarks' => $this->check_remarks, - 'check_status' => $this->check_status, - 'check_status_text' => $this->check_status->text(), 'skus' => GoodsSkuResource::collection($this->whenLoaded('skus')), ]); diff --git a/src/Http/Resources/GoodsSkuResource.php b/src/Http/Resources/GoodsSkuResource.php index 4ecf204..cd25417 100644 --- a/src/Http/Resources/GoodsSkuResource.php +++ b/src/Http/Resources/GoodsSkuResource.php @@ -14,12 +14,8 @@ class GoodsSkuResource extends JsonResource 'goods_id' => $this->goods_id, 'name' => $this->name, 'price' => $this->price, - 'vip_price' => $this->vip_price, 'stock' => $this->stock, 'spec' => $this->spec, - 'weight' => $this->weight, - 'volume' => $this->volume, - 'shipping_tmp_id' => $this->shipping_tmp_id, ]; } } diff --git a/src/Http/Resources/GoodsTinyResource.php b/src/Http/Resources/GoodsTinyResource.php index f54957d..406ed6c 100644 --- a/src/Http/Resources/GoodsTinyResource.php +++ b/src/Http/Resources/GoodsTinyResource.php @@ -3,7 +3,6 @@ namespace Peidikeji\Goods\Http\Resources; use Illuminate\Http\Resources\Json\JsonResource; -use Peidikeji\Merchant\Http\Resources\MerchantTinyResource; class GoodsTinyResource extends JsonResource {