Browse Source

Merge branch 'master' of https://git.oslog.id/ordo/adw-backend

pull/3/head
farhan048 2 years ago
parent
commit
71ce568f4a
  1. 26
      app/Http/Controllers/WaypointController.php
  2. 89
      rest-client.http
  3. 1
      routes/web.php

26
app/Http/Controllers/WaypointController.php

@ -28,6 +28,32 @@ class WaypointController extends Controller
}
}
public function addBulk(Request $request)
{
$data = $request->all();
$now = date("Y-m-d H:i:s");
$data_send = array();
if (isset($data['wp_records']) && count($data['wp_records']) > 0) {
foreach($data['wp_records'] as $userLoc) {
$userLoc['created_at'] = $now;
$userLoc['created_by'] = $this->currentName;
$userLoc['updated_at'] = $now;
$userLoc['updated_by'] = $this->currentName;
$data_send[] = $userLoc;
}
$result = Waypoint::insert($data_send);
if($result){
return response()->json(['status'=>'success','message'=>'add waypoint successfully!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'add waypoint failed!','code'=>400], 400);
}
}
else {
return response()->json(['status'=>'failed','message'=>'add waypoint failed!','code'=>400], 400);
}
}
public function edit($id){
if(!$id || (int) $id < 0 || $id==""){
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);

89
rest-client.http

@ -1,12 +1,14 @@
@token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczpcL1wvYXBpLXN0YWdpbmctYWR3Lm9zcHJvLmlkXC9hcGlcL2xvZ2luIiwiaWF0IjoxNjU5NDc0MDY3LCJleHAiOjE2NjAwNzg4NjcsIm5iZiI6MTY1OTQ3NDA2NywianRpIjoia0ljaHBFOEpiaFI0TjN3UyIsInN1YiI6MSwicHJ2IjoiMjNiZDVjODk0OWY2MDBhZGIzOWU3MDFjNDAwODcyZGI3YTU5NzZmNyJ9.PxGL0NcRtxzhG2J21Ca-zgMbr1anY7vhNzEOpZHSNOk
@token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9sb2NhbGhvc3Q6ODA3NFwvYWR3LWJhY2tlbmRcL2FwaVwvbG9naW4iLCJpYXQiOjE2NzU3NjY2NzcsImV4cCI6MTY3NjM3MTQ3NywibmJmIjoxNjc1NzY2Njc3LCJqdGkiOiJwODNpWG1kU3pTV2ZVMGs3Iiwic3ViIjoxMjQ3LCJwcnYiOiIyM2JkNWM4OTQ5ZjYwMGFkYjM5ZTcwMWM0MDA4NzJkYjdhNTk3NmY3In0.I9Q6uI-IOHR8JKaMJfjfAizOM8KNPQsm8EyWM8f6Qbk
# @hostname = https://kit-api.ospro.id/api
# @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:8099/api
# @hostname = http://localhost:8099/api
# @hostname = http://103.73.125.81:8444/api
@hostname = http://localhost:8074/adw-backend/api
###### login
POST {{hostname}}/login
@ -15,8 +17,8 @@ POST {{hostname}}/login
content-type: application/json
{
"username": "admin",
"password": "admin123"
"username": "demo",
"password": "demo123"
}
###### Tools Req
@ -809,4 +811,81 @@ content-type: application/json
"clock_time": "2022-04-25T16:40:17+07:00",
"type": "out",
"user_id": 262
}
}
######
POST {{hostname}}/waypoint/add
Authorization: Bearer {{token}}
content-type: application/json
{
"user_id": 1247,
"lat": -6.2622811,
"lng": 106.7881746,
"wptime": "2023-02-07T10:40:17+07:00",
"speed": 0,
"angle": 0,
"satelite": 0
}
######
POST {{hostname}}/waypoint/add-bulk
Authorization: Bearer {{token}}
content-type: application/json
{
"wp_records": [
{
"user_id": 1247,
"lon": 106.88702067952579,
"lat": -6.193331793510694,
"wptime": "2023-02-07T10:40:17+07:00",
"speed": 0,
"angle": 0,
"satelite": 0,
"datesend": "2023-02-07T10:40:17+07:00"
},
{
"user_id": 1247,
"lon": 106.88731982052337,
"lat": -6.1933255977790225,
"wptime": "2023-02-07T10:41:17+07:00",
"speed": 0,
"angle": 0,
"satelite": 0,
"datesend": "2023-02-07T10:41:17+07:00"
},
{
"user_id": 1247,
"lon": 106.88765896352822,
"lat": -6.193328086924183,
"wptime": "2023-02-07T10:42:17+07:00",
"speed": 0,
"angle": 0,
"satelite": 0,
"datesend": "2023-02-07T10:42:17+07:00"
},
{
"user_id": 1247,
"lon": 106.88812637133634,
"lat": -6.1933373805197505,
"wptime": "2023-02-07T10:43:17+07:00",
"speed": 0,
"angle": 0,
"satelite": 0,
"datesend": "2023-02-07T10:43:17+07:00"
},
{
"user_id": 1247,
"lon": 106.88867721532353,
"lat": -6.1933448515770095,
"wptime": "2023-02-07T10:44:17+07:00",
"speed": 0,
"angle": 0,
"satelite": 0,
"datesend": "2023-02-07T10:44:17+07:00"
}
]
}

1
routes/web.php

@ -322,6 +322,7 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout
$router->post('/report-activity-material/update-status', 'ReportActivityMaterialController@updateStatusStartFinish');
$router->post('/waypoint/add', 'WaypointController@add');
$router->post('/waypoint/add-bulk', 'WaypointController@addBulk');
$router->get('/waypoint/edit/{id}', 'WaypointController@edit');
$router->put('/waypoint/update/{id}', 'WaypointController@update');
$router->post('/waypoint/search', 'WaypointController@search');

Loading…
Cancel
Save