kphcdr 1 年之前
父节点
当前提交
468b154fa5

+ 12 - 23
app/Modules/Admin/Controllers/Admin/CommonController.php

@@ -5,6 +5,8 @@ namespace App\Modules\Admin\Controllers\Admin;
 use App\Base\BaseController;
 use App\Models\Auth\AdminGroup;
 use App\Models\Auth\AdminPermission;
+use App\Models\Goods\Category;
+use App\Models\Goods\Spec;
 use App\Modules\Admin\Services\SettingService;
 
 class CommonController extends BaseController
@@ -56,35 +58,22 @@ class CommonController extends BaseController
     public function allSpec()
     {
         return $this->ok([
-            "list" => [
-                [
-                    "id" => 1,
-                    "name" => "名称",
-                    "attr_name" => ["红色", "白色"],
-                ],
-            ],
+            "list" => Spec::get()->map(function (Spec $s) {
+                return [
+                    "id" => $s->id,
+                    "name" => $s->name,
+                    "attr_name" => $s->attrs->pluck("name"),
+                ];
+            }),
         ]);
     }
 
     public function allCategory()
     {
         return $this->ok([
-            "list" => [
-                [
-                    "id" => 1,
-                    "name" => "分类名称",
-                    "level" => 1,
-                    "parent_id" => 0,
-                    "parent_name" => "",
-                ],
-                [
-                    "id" => 2,
-                    "name" => "二级分类名称",
-                    "level" => 2,
-                    "parent_id" => 1,
-                    "parent_name" => "上级分类",
-                ],
-            ],
+            "list" => Category::get()->map(function (Category $c) {
+                return $c->format();
+            }),
         ]);
     }
 }

+ 1 - 1
app/Modules/Admin/Controllers/Admin/GoodsController.php

@@ -53,7 +53,7 @@ class GoodsController extends BaseController
                 [
                     "id" => 0,
                     "sn" => "规格型号",
-                    "3d_url" => "",
+                    "url_3d" => "",
                     "spec_attr" => [
                         [
                             "id" => 1,