zssn
1.0.0
데이터베이스 PostgreSQL 10을 사용하여 Laravel 6.5의 ZSSN 개발.
우선, 환경에서 작곡가 및 PHP (7.2 이상)를 구성해야합니다.
이제이 프로젝트를 PC에 복제해야합니다.
복제 후이 프로젝트는 작곡가를 실행하여 모든 종속성을 설치합니다.
composer install
자, 이제 데이터베이스를 구성합시다. 먼저, project의 루트에서 .env.example에 .env.example이 필요하다. Env.example은 환경을 구성하는 방법의 예입니다.
데이터베이스가 구성된 상태에서 마이그레이션을 만들고 채우 러 가자 ..
php artisan migrate
php artisan db:seed
그런 다음 php artisan serve 실행하면 http : // localhost : 8000/api에서 사용할 수 있습니다.
GET /survivors
Content-Type: "application/json"
200 Created
Content-Type: "application/json"
"data": [
{
"id": 2,
"name": "Gilberto Doyle",
"age": 47,
"gender": "Male",
"latitude": "18158.1727552",
"longitude": "261575.5293",
"infected": false,
"created_at": "2019-11-29 17:10:49",
"updated_at": "2019-11-29 17:10:49",
"reportsCount": 0
},
{
"id": 3,
"name": "Prof. Nico Yundt",
"age": 54,
"gender": "Female",
"latitude": "5.11093238",
"longitude": "48425886",
"infected": false,
"created_at": "2019-11-29 17:10:49",
"updated_at": "2019-11-29 17:10:49",
"reportsCount": 0
}
]
GET /:survivors/{id}
Content-Type: "application/json"
| 기인하다 | 설명 |
|---|---|
| ID | 생존자 ID |
200 Ok
Content-Type: "application/json"
{
"id": 1,
"name": "Miss Rhoda Abbott PhD",
"age": 55,
"gender": "Male",
"latitude": "116.4865271",
"longitude": "6211846.638",
"infected": false,
"created_at": "2019-11-29 17:10:49",
"updated_at": "2019-11-29 17:10:49",
"resources": [
{
"description": "Water",
"points": 4
},
{
"description": "Ammunition",
"points": 1
}
],
"reportsCount": 0
}
POST /survivors
Content-Type: "application/json"
{
"name": "Willardy Tyrone",
"age": 19,
"gender": "Male",
"latitude": "1522255.09052",
"longitude": "1336523.1439",
"infected": false
}
201 Created
Content-Type: "application/json"
{
"msg": "Survivor created at success"
}
| 기인하다 | 설명 |
|---|---|
| ID | 생존자 ID |
PUT /:survivors/{id}
Content-Type: "application/json"
201 Ok
Content-Type: "application/json"
{
"msg": "Survivor updated at success"
}
POST /:survivors/{survivorReport}/report_infection/{survivorReported}
Content-Type: "application/json"
| 기인하다 | 설명 |
|---|---|
| SurvivorReport | 생존자 ID |
| Survivorported | 생존자 ID |
200 Ok
Content-Type: "application/json"
{
"msg": "Unconfirmed infection!"
}
200 Ok
Content-Type: "application/json"
{
"msg": "Survivor infected!"
}
400 Ok
Content-Type: "application/json"
{
"msg": "Report already created"
}
200 Ok
Content-Type: "application/json"
GET /reports/percentInfected
Content-Type: "application/json"
200 Ok
Content-Type: "application/json"
{
"msg": "37% of survivors are infected"
}
200 Ok
Content-Type: "application/json"
GET /reports/percentNonInfected
Content-Type: "application/json"
{
"msg": "37% of survivors are not infected"
}
200 Ok
Content-Type: "application/json"
GET /reports/averageAmount
Content-Type: "application/json"
"data": {
"Water": 0.2857142857142857,
"Food": 0.2857142857142857,
"Medication": 0.14285714285714285,
"Ammunition": 1.5714285714285714
}
200 Ok
Content-Type: "application/json"
GET /reports/pointsLost/{id}
Content-Type: "application/json"
200 Ok
Content-Type: "application/json"
{
"message": "Survivor not infected, not yet"
}
200 Ok
Content-Type: "application/json"
{
"pointsLost": 4
}
200 Ok
Content-Type: "application/json"
PUT /traders/{survivorOften}/tradeItems/{survivorAceppt}
Content-Type: "application/json"
200 Ok
Content-Type: "application/json"
{
"erro": "Survivor are equals"
}
200 Ok
Content-Type: "application/json"
{
"msg": "Trade is done."
}
404 Ok
Content-Type: "application/json"
{
"erro": "Survivor not found"
}