Ken преди 2 дни
родител
ревизия
7325531f3c
променени са 2 файла, в които са добавени 43 реда и са изтрити 0 реда
  1. 42 0
      app/Http/Controllers/api/NewPc.php
  2. 1 0
      routes/api.php

+ 42 - 0
app/Http/Controllers/api/NewPc.php

@@ -189,4 +189,46 @@ class NewPc extends BaseController
         $data['winnings'] = $arr;
         return $this->success($data);
     }
+
+    /**
+     * @api {get} /newPc 结果,走势
+     * @apiGroup newPc
+     * @apiVersion 1.0.0
+     *
+     * @apiParam {int} [page=1]
+     * @apiParam {int} [limit=10]
+     *
+     * @apiSuccess {int} code
+     * @apiSuccess {int} timestamp
+     * @apiSuccess {String} msg
+     * @apiSuccess {Object[]} data
+     * @apiSuccess {int} data.id
+     * @apiSuccess {String} data.issue_no 期号
+     * @apiSuccess {String} data.start_time 开始时间
+     * @apiSuccess {String} data.end_time 结束时间
+     * @apiSuccess {String[]} data.award 开奖结果
+     * @apiSuccess {String[]} data.winning_array 开奖结果
+     * @apiSuccess {int} data.end_timestamp 结束时间 时间戳
+     *
+     */
+    public function index()
+    {
+        try {
+            $page = request()->input('page', 1);
+            $limit = request()->input('limit', 10);
+
+
+            $res['total'] = PcIssue::count();
+            $res['data'] = PcIssue::forPage($page, $limit)
+                ->orderByDesc('id')->get();
+            foreach ($res['data'] as &$item) {
+                $item['day'] = date("m-d H:i", strtotime($item['end_time']));
+            }
+        } catch (ValidationException $e) {
+            return $this->error($e->validator->errors()->first());
+        } catch (Exception $e) {
+            return $this->error($e->getMessage());
+        }
+        return $this->success($res);
+    }
 }

+ 1 - 0
routes/api.php

@@ -21,6 +21,7 @@ Route::prefix('/newPc')->group(function () {
     Route::get("/history", [NewPc::class, 'history']);
     Route::get("/prediction", [NewPc::class, 'prediction']);
     Route::get("/countdown", [NewPc::class, 'countdown']);
+    Route::get("/", [NewPc::class, 'index']);
 });
 
 Route::prefix('/issue')->group(function () {