Ver código fonte

新增自定义字段接口

chenxiqiang 6 anos atrás
pai
commit
7326714716

+ 6
- 6
manage-server/app/Http/Controllers/ClassifyController.php Ver arquivo

@@ -42,7 +42,7 @@ class ClassifyController extends Controller
42 42
     public function home(Request $request)
43 43
     {
44 44
         $top = Classify::where("location", "top")->orderBy("updated_at", "desc")->limit(3)->get()->toArray();
45
-        $bottom = Classify::where("location", "bottom")->orderBy("updated_at", "desc")->first();
45
+        //$bottom = Classify::where("location", "bottom")->orderBy("updated_at", "desc")->first();
46 46
         $homePage = HomePage::find(1);
47 47
         $tops = array_map(function ($t) {
48 48
             return [
@@ -58,11 +58,11 @@ class ClassifyController extends Controller
58 58
             "top" => $tops,
59 59
             "introduce" => $homePage->introduce,
60 60
             "bottom" => [
61
-                "id" => $bottom["id"],
62
-                "server" => $bottom["server"],
63
-                "content" => $bottom["content"],
64
-                "photo" => $bottom["photo"],
65
-                "location" => $bottom["location"]
61
+                "id" => $homePage->id,
62
+                "server" => "",
63
+                "content" => $homePage->content,
64
+                "photo" => $homePage->photo,
65
+                "location" => "bottom"
66 66
             ]
67 67
         ]);
68 68
     }

+ 3
- 2
manage-server/app/Http/Controllers/CommonController.php Ver arquivo

@@ -123,6 +123,7 @@ class CommonController extends Controller
123 123
 
124 124
             $record = $this->getRecord($order_type, $order_id);
125 125
             $record->comment_id = $comment->id;
126
+            $record->comment = $content;
126 127
             $record->status = 4;
127 128
             $record->save();
128 129
 
@@ -380,13 +381,13 @@ class CommonController extends Controller
380 381
         $order_type = $request->route("order_type");
381 382
         if ($id && $order_type) {
382 383
             $record = $this->getRecord($order_type, $id);
383
-            $comment = Comment::where("order_type", $order_type)->where("order_id", $id)->first();
384
+            //$comment = Comment::where("order_type", $order_type)->where("order_id", $id)->first();
384 385
             if ($record) {
385 386
                 $ret = [
386 387
                     "status" => 0,
387 388
                     "data" => $record
388 389
                 ];
389
-                $ret["data"]["comment"] = $comment->content;
390
+                //$ret["data"]["comment"] = $comment->content;
390 391
                 return Response()->json($ret);
391 392
             }
392 393
             return Response()->json([

+ 42
- 0
manage-server/app/Http/Controllers/HomePageController.php Ver arquivo

@@ -42,4 +42,46 @@ class HomePageController extends Controller
42 42
             ]
43 43
         ]);
44 44
     }
45
+
46
+
47
+    public function getBottom(Request $request) {
48
+
49
+        $homePage = HomePage::find(1);
50
+        return Response()->json([
51
+            "status" => 0,
52
+            "data" => [
53
+                "content" => $homePage->content,
54
+                "photo" => $homePage->photo,
55
+            ]
56
+        ]);
57
+    }
58
+
59
+
60
+
61
+    public function bottom(Request $request) {
62
+        $content = $request->input("content");
63
+        $photo = $request->input("photo");
64
+        if($content) {
65
+            $homePage = HomePage::find(1);
66
+            if($homePage) {
67
+                $homePage->content = $content;
68
+                $homePage->photo = $photo;
69
+                $homePage->save();
70
+                return Response()->json([
71
+                    "status" => 0,
72
+                    "message" => "修改成功"
73
+                ]);
74
+            } else {
75
+                return Response()->json([
76
+                    "status" => -1,
77
+                    "message" => "记录不存在"
78
+                ]);
79
+            }
80
+        } else {
81
+            return Response()->json([
82
+                "status" => -1,
83
+                "message" => "introduce不能为空!"
84
+            ]);
85
+        }
86
+    }
45 87
 }

+ 2
- 0
manage-server/app/Models/HomePage.php Ver arquivo

@@ -10,5 +10,7 @@ class HomePage extends Model
10 10
 
11 11
     protected $fillable = [
12 12
         'introduce',
13
+        'content',
14
+        'photo'
13 15
     ];
14 16
 }

+ 1
- 0
manage-server/app/Models/Order.php Ver arquivo

@@ -21,6 +21,7 @@ class Order extends Model
21 21
         'price', // 订单价格
22 22
         'photo', // 显示的图片
23 23
         'comment_id', // 评论id
24
+        'comment', // 评论
24 25
         'paid_at',  // 支付时间,
25 26
         'classify', //订单类型,分类
26 27
         'classify1', //分类1

+ 2
- 0
manage-server/routes/web.php Ver arquivo

@@ -74,6 +74,8 @@ Route::middleware(['manage.token'])->group(function () {
74 74
 
75 75
     Route::get('/introduce', 'HomePageController@introduce');
76 76
     Route::post('/introduce/store', 'HomePageController@store');
77
+    Route::post('/bottom/store', 'HomePageController@bottom');
78
+    Route::get('/bottom', 'HomePageController@getBottom');
77 79
 
78 80
 
79 81
 });

Carregando…
Cancelar
Salvar