Преглед на файлове

新增自定义字段接口

chenxiqiang преди 6 години
родител
ревизия
7326714716

+ 6
- 6
manage-server/app/Http/Controllers/ClassifyController.php Целия файл

42
     public function home(Request $request)
42
     public function home(Request $request)
43
     {
43
     {
44
         $top = Classify::where("location", "top")->orderBy("updated_at", "desc")->limit(3)->get()->toArray();
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
         $homePage = HomePage::find(1);
46
         $homePage = HomePage::find(1);
47
         $tops = array_map(function ($t) {
47
         $tops = array_map(function ($t) {
48
             return [
48
             return [
58
             "top" => $tops,
58
             "top" => $tops,
59
             "introduce" => $homePage->introduce,
59
             "introduce" => $homePage->introduce,
60
             "bottom" => [
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 Целия файл

123
 
123
 
124
             $record = $this->getRecord($order_type, $order_id);
124
             $record = $this->getRecord($order_type, $order_id);
125
             $record->comment_id = $comment->id;
125
             $record->comment_id = $comment->id;
126
+            $record->comment = $content;
126
             $record->status = 4;
127
             $record->status = 4;
127
             $record->save();
128
             $record->save();
128
 
129
 
380
         $order_type = $request->route("order_type");
381
         $order_type = $request->route("order_type");
381
         if ($id && $order_type) {
382
         if ($id && $order_type) {
382
             $record = $this->getRecord($order_type, $id);
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
             if ($record) {
385
             if ($record) {
385
                 $ret = [
386
                 $ret = [
386
                     "status" => 0,
387
                     "status" => 0,
387
                     "data" => $record
388
                     "data" => $record
388
                 ];
389
                 ];
389
-                $ret["data"]["comment"] = $comment->content;
390
+                //$ret["data"]["comment"] = $comment->content;
390
                 return Response()->json($ret);
391
                 return Response()->json($ret);
391
             }
392
             }
392
             return Response()->json([
393
             return Response()->json([

+ 42
- 0
manage-server/app/Http/Controllers/HomePageController.php Целия файл

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 Целия файл

10
 
10
 
11
     protected $fillable = [
11
     protected $fillable = [
12
         'introduce',
12
         'introduce',
13
+        'content',
14
+        'photo'
13
     ];
15
     ];
14
 }
16
 }

+ 1
- 0
manage-server/app/Models/Order.php Целия файл

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

+ 2
- 0
manage-server/routes/web.php Целия файл

74
 
74
 
75
     Route::get('/introduce', 'HomePageController@introduce');
75
     Route::get('/introduce', 'HomePageController@introduce');
76
     Route::post('/introduce/store', 'HomePageController@store');
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
 });

Loading…
Отказ
Запис