|
|
@@ -5,6 +5,8 @@ namespace App\Http\Controllers\api;
|
|
|
use App\Models\Cao;
|
|
|
use App\Models\Prediction;
|
|
|
use App\Services\IssueService;
|
|
|
+use Illuminate\Validation\ValidationException;
|
|
|
+use Exception;
|
|
|
|
|
|
class Issue extends BaseController
|
|
|
{
|
|
|
@@ -18,12 +20,25 @@ class Issue extends BaseController
|
|
|
* @apiSuccess {int} timestamp
|
|
|
* @apiSuccess {String} msg
|
|
|
* @apiSuccess {Object} data
|
|
|
+ *
|
|
|
+ * @apiParam {int} [page=1]
|
|
|
+ * @apiParam {int} [limit=10]
|
|
|
*/
|
|
|
function prediction()
|
|
|
{
|
|
|
- $page = request()->input('page', 1);
|
|
|
- $limit = request()->input('limit', 10);
|
|
|
- $list = Prediction::forPage($page, $limit) ->get();
|
|
|
+ try {
|
|
|
+ request()->validate([
|
|
|
+ 'page' => ['nullable', 'integer', 'min:1'],
|
|
|
+ 'limit' => ['nullable', 'integer', 'min:1']
|
|
|
+ ]);
|
|
|
+ $page = request()->input('page', 1);
|
|
|
+ $limit = request()->input('limit', 10);
|
|
|
+ $list = Prediction::forPage($page, $limit)->get();
|
|
|
+ } catch (ValidationException $e) {
|
|
|
+ return $this->error($e->validator->errors()->first());
|
|
|
+ } catch (Exception $e) {
|
|
|
+ return $this->error($e->getMessage());
|
|
|
+ }
|
|
|
return $this->success($list);
|
|
|
}
|
|
|
|
|
|
@@ -72,6 +87,9 @@ class Issue extends BaseController
|
|
|
* @apiGroup Issue
|
|
|
* @apiVersion 1.0.0
|
|
|
*
|
|
|
+ * @apiParam {int} [page=1]
|
|
|
+ * @apiParam {int} [limit=10]
|
|
|
+ *
|
|
|
* @apiSuccess {int} code
|
|
|
* @apiSuccess {int} timestamp
|
|
|
* @apiSuccess {String} msg
|
|
|
@@ -87,14 +105,20 @@ class Issue extends BaseController
|
|
|
*/
|
|
|
public function index()
|
|
|
{
|
|
|
- $page = request()->input('page', 1);
|
|
|
- $limit = request()->input('limit', 10);
|
|
|
- $params = [
|
|
|
- 'page' => $page,
|
|
|
- 'limit' => $limit
|
|
|
+ try {
|
|
|
+ $page = request()->input('page', 1);
|
|
|
+ $limit = request()->input('limit', 10);
|
|
|
+ $params = [
|
|
|
+ 'page' => $page,
|
|
|
+ 'limit' => $limit
|
|
|
// 'status'=>3
|
|
|
- ];
|
|
|
- $res = IssueService::paginate($params);
|
|
|
+ ];
|
|
|
+ $res = IssueService::paginate($params);
|
|
|
+ } catch (ValidationException $e) {
|
|
|
+ return $this->error($e->validator->errors()->first());
|
|
|
+ } catch (Exception $e) {
|
|
|
+ return $this->error($e->getMessage());
|
|
|
+ }
|
|
|
return $this->success($res);
|
|
|
}
|
|
|
|