From 9d8b19a826a5e9b12b377665ee0d5a25fd8cf472 Mon Sep 17 00:00:00 2001 From: ardhi Date: Sun, 12 Feb 2023 15:12:20 +0700 Subject: [PATCH] WIP: map-monitoring API --- .../Controllers/MapMonitoringController.php | 47 ++++++++++++++ app/Models/MapMonitoring.php | 33 ++++++++++ rest-client.http | 63 +++++++++++++++---- routes/web.php | 2 + 4 files changed, 134 insertions(+), 11 deletions(-) create mode 100644 app/Http/Controllers/MapMonitoringController.php create mode 100644 app/Models/MapMonitoring.php diff --git a/app/Http/Controllers/MapMonitoringController.php b/app/Http/Controllers/MapMonitoringController.php new file mode 100644 index 0000000..3614c2f --- /dev/null +++ b/app/Http/Controllers/MapMonitoringController.php @@ -0,0 +1,47 @@ +all(); + // $dataBuilder = $this->setUpPayload($payload, 't_clock_in_out'); + // $builder = $dataBuilder['builder']; + // $countBuilder = $dataBuilder['count']; + // $dataGet = $builder->get(); + // $totalRecord = $countBuilder->count(); + // return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); + + $monitoringData = MapMonitoring::getUsers($request->all()); + var_dump($monitoringData); + + } + + public function list() + { + $data = Presence::all(); + $countData = $data->count(); + + if($data){ + return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); + }else{ + return response()->json(['status'=>'failed','message'=>'failed get list presence, please try again later!','code'=>400], 400); + } + } + + +} diff --git a/app/Models/MapMonitoring.php b/app/Models/MapMonitoring.php new file mode 100644 index 0000000..a5e5fba --- /dev/null +++ b/app/Models/MapMonitoring.php @@ -0,0 +1,33 @@ +table) + ->select('id', 'user_id', 'clock_in', 'clock_out', 'clock_in_lat', 'clock_in_lng', 'clock_out_lat', 'clock_out_lng', 'clock_in_loc', 'clock_out_loc', 'clock_in_boundary', 'clock_out_boundary') + ->whereBetween('created_at', [$payload->timeFrom, $payload->timeTo]) + ->orderBy('created_at', 'desc') + ->get(); + + return $users; + } +} diff --git a/rest-client.http b/rest-client.http index a7a710b..453e2e5 100644 --- a/rest-client.http +++ b/rest-client.http @@ -1,12 +1,12 @@ -@token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9sb2NhbGhvc3Q6ODQ0NFwvYXBpXC9sb2dpbiIsImlhdCI6MTY3NTgzNTM3NSwiZXhwIjoxNjc2NDQwMTc1LCJuYmYiOjE2NzU4MzUzNzUsImp0aSI6IlhyVjlkTW55TXpOazlrTUIiLCJzdWIiOjEsInBydiI6IjIzYmQ1Yzg5NDlmNjAwYWRiMzllNzAxYzQwMDg3MmRiN2E1OTc2ZjcifQ.41uAX7bnRwftkC_daRiVwwKcFIN7EDV0Ly_zDuq4_MY +@token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9sb2NhbGhvc3Q6ODA3NFwvYWR3LWJhY2tlbmRcL2FwaVwvbG9naW4iLCJpYXQiOjE2NzYxODQ5ODgsImV4cCI6MTY3Njc4OTc4OCwibmJmIjoxNjc2MTg0OTg4LCJqdGkiOiJSMkk1R3FLdXM3bWhMUWwzIiwic3ViIjoxMjQ3LCJwcnYiOiIyM2JkNWM4OTQ5ZjYwMGFkYjM5ZTcwMWM0MDA4NzJkYjdhNTk3NmY3In0.GlxG-DaiY1Slc0dR8sRK6CvU-F7MTjT47989MImubJ0 # @hostname = https://adw-api.ospro.id/api # @hostname = https://ospro-api.ospro.id/api # @hostname = https://api-iu.ospro.id/api # @hostname = https://api-staging-adw.ospro.id/api -@hostname = http://localhost:8444/api +# @hostname = http://localhost:8444/api # @hostname = http://103.73.125.81:8444/api -# @hostname = http://172.20.10.2:8074/adw-backend/api +@hostname = http://localhost:8074/adw-backend/api ###### login POST {{hostname}}/login @@ -15,8 +15,8 @@ POST {{hostname}}/login content-type: application/json { - "username": "admin", - "password": "1nt3gr4s14" + "username": "demo", + "password": "demo123" } ###### Tools Req @@ -805,11 +805,11 @@ Authorization: Bearer {{token}} content-type: application/json { - "clock_out_lat": -6.2622811, - "clock_out_lng": 106.7881746, - "clock_time": "2023-02-06T16:40:17+07:00", - "type": "out", - "user_id": 1 + "clock_out_lat": -6.16678379060529, + "clock_out_lng": 106.9175039866567, + "clock_time": "2023-02-10T14:48:17+07:00", + "type": "in", + "user_id": 1247 } @@ -913,4 +913,45 @@ content-type: application/json "datesend": "2023-02-07T10:44:17+07:00" } ] -} \ No newline at end of file +} + +##### +POST {{hostname}}/map-monitoring/search +Authorization: Bearer {{token}} +content-type: application/json + +{ + "time_from": "2023-02-10 00:00:00", + "time_to": "2023-02-10 23:59:00", +} + +# { +# "columns": [ +# { +# "logic_operator": "range", +# "name": "created_at", +# "operator": "AND", +# "value": "2023-02-10 00:00:00", +# "value1": "2023-02-10 23:59:00" +# } +# ], +# "joins": [ +# { +# "column_join": "user_id", +# "column_results": [ +# "username", "name" +# ], +# "name": "m_users" +# } +# ], +# "orders": { +# "ascending": false, +# "columns": [ +# "created_at" +# ] +# }, +# "paging": { +# "length": 25, +# "start": 0 +# } +# } \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index 46b30a2..57e03bc 100644 --- a/routes/web.php +++ b/routes/web.php @@ -432,6 +432,8 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout $router->post('/project-comment/add', 'ProjectCommentController@add'); $router->put('/project-comment/update/{id}', 'ProjectCommentController@update'); $router->post('/project-comment/search', 'ProjectCommentController@search'); + + $router->post('/map-monitoring/search', 'MapMonitoringController@search'); }); });