diff --git a/doc/acl-layer.png b/doc/acl-layer.png deleted file mode 100644 index f0f9b9c..0000000 Binary files a/doc/acl-layer.png and /dev/null differ diff --git a/doc/employee.png b/doc/employee.png deleted file mode 100644 index 9f29dee..0000000 Binary files a/doc/employee.png and /dev/null differ diff --git a/doc/employees.md b/doc/employees.md index 28e4769..e5be7d1 100644 --- a/doc/employees.md +++ b/doc/employees.md @@ -1,10 +1,10 @@ # Employees Module -Module | Description +Module | HTTP Method | URL | Description --- | --- | --- | --- -[Add](#add) | POST | Add New Data Employee -[View](#view) | GET | View Data Employee -[Edit](#edit) | PUT | Edit Data Employee -[Delete](#delete) | DELETE | Delete Data Employee +[Add](#add) | POST | /employees | Add New Data Employee +[View](#view) | GET | /employees/:id | View Data Employee +[Edit](#edit) | PUT | /employees/:id | Edit Data Employee +[Delete](#delete) | DELETE | /employees/:id | Delete Data Employee ## Add @@ -14,12 +14,12 @@ POST /employees ### Database ![](./employees.png) -for add, you need login with company_id from companies tables and branch_id from branches tables +for add, you need login with company_id from companies tables and branch_code from branches tables ### Headers Key | Value --- | --- -Content-Type | * +Content-Type | application/json Accept | application/json Email | alamat@emailcdc.com @@ -29,18 +29,21 @@ Name | Type | Example Value employee_kode | string | 20201201 employee_nama | string | ferry stall_code | string | Heavy Repair +jabatan_kode | string | 1 ``` { "employee_kode": "20200301", "employee_nama": "ferry", - "stall_code": "Heavy Repair" + "stall_code": "Heavy Repair", + "jabatan_kode": "1" } ``` ### Response Payloads HTTP Code | Status | Description --- | --- | --- -400 | Bad Request | Bad request payload +400 | Bad Request | Bad request payload +404 | Not Found | branch_code not found in database 500 | Internal Server Error | some un-handle error in server 201 | Created | Created ``` @@ -60,8 +63,11 @@ HTTP Code | Status | Description "employee_kode": "20200301", "employee_nama": "ferry", "stall_code": "Heavy Repair", - "jabatan_id": "5d2c04c9-fffc-4175-ac06-148dcf944ef7", + "jabatan_kode": "1", + "branch_id": "5d2c04c9-fffc-4175-ac06-148dcf944ef7", + "branch_code": "cdc-011", "company_id": "5e1befd2-ab04-49c2-addd-5b25c0a8141e", + "company_code": "cdc-01", "created" : "2020-12-03 09:44:02", "modified" : "2020-12-03 09:44:02" } @@ -74,6 +80,8 @@ HTTP Code | Status | Description - employee_kode : required and not empty - employee_nama : required and not empty - stall_code : required and not empty +- jabatan_kode : required, not empty and exist in jabatans table +- branch_code : required, not empty and owned by user login as main dealer ### Scenario Test @@ -214,6 +222,123 @@ Response Payload: } ``` +#### Case : Negative Case 8 + +Request Payload +``` +{ + "employee_kode": "20200301", + "employee_nama": "ferry", + "stall_code": "Heavy Repair", + "jabatan_kode": "" +} +``` + +Response HTTP Status Code : 400 + +Response Payload +``` +{ + "status_code": "cdc-400", + "status_message": "jabatan_kode is required", + "data": null +} +``` + +#### Case : Negative Case 9 + +Request Payload : +``` +{ + "employee_kode": "20200301", + "employee_nama": "ferry", + "stall_code": "Heavy Repair", + "jabatan_kode": "" +} +``` + +Response HTTP Status Code : 400 + +Response Payload: +``` +{ + "status_code": "cdc-400", + "status_message": "jabatan_kode is empty", + "data": null +} +``` + +#### Case : Negative Case 10 + +Request Payload : +``` +{ + "employee_kode": "20200301", + "employee_nama": "ferry", + "stall_code": "Heavy Repair", + "jabatan_kode": "1" +} +``` + +Response HTTP Status Code : 400 + +Response Payload: +``` +{ + "status_code": "cdc-400", + "status_message": "branch_code is required", + "data": null +} +``` + +#### Case : Negative Case 11 + +Request Payload : +``` +{ + "employee_kode": "20200301", + "employee_nama": "ferry", + "stall_code": "Heavy Repair", + "jabatan_kode": "1", + "branch_code" : "" +} +``` + +Response HTTP Status Code : 400 + +Response Payload: +``` +{ + "status_code": "cdc-400", + "status_message": "branch_code is empty", + "data": null +} +``` + +#### Case : Negative Case 12 + +Request Payload : +``` +{ + "employee_kode": "20200301", + "employee_nama": "ferry", + "stall_code": "Heavy Repair", + "jabatan_kode": "1", + "branch_code" : "cdc-011" +} +``` + +Response HTTP Status Code : 403 + +Response Payload: +``` +{ + "status_code": "cdc-403", + "status_message": "branch_code not owned by user login", + "data": null +} +``` + #### Case : Positive Case Request Payload : @@ -221,23 +346,25 @@ Request Payload : { "employee_kode": "20200301", "employee_nama": "ferry", - "stall_code": "Heavy Repair" + "stall_code": "Heavy Repair", + "jabatan_kode": "1" } ``` -Response HTTP Status Code : 200 +Response HTTP Status Code : 201 Response Payload : ``` { - "status_code": "CDC-200", - "status_message": "OK", + "status_code": "CDC-201", + "status_message": "Created", "data": { "id":"5fbf4995-b4ac-4a2e-9cad-4021cf944ef7", "employee_kode": "20200301", "employee_nama": "ferry", "stall_code": "Heavy Repair", - "jabatan_id": "5d2c04c9-fffc-4175-ac06-148dcf944ef7", + "jabatan_kode": "1", + "branch_id": "5d2c04c9-fffc-4175-ac06-148dcf944ef7", "company_id": "5e1befd2-ab04-49c2-addd-5b25c0a8141e", "company_code": "cdc-01", "created" : "2020-12-03 09:44:02", @@ -254,14 +381,15 @@ GET /employees/:id ### Headers Key | Value --- | --- -Content-Type | * +Content-Type | application/json Accept | application/json Email | alamat@emailcdc.com ### Response Payloads HTTP Code | Status | Description --- | --- | --- -404 | Not Found | User not found in database +403 | Forbidden | id is not owned by user login +404 | Not Found | Employee not found in database 500 | Internal Server Error | some un-handle error in server 200 | OK | OK @@ -274,7 +402,9 @@ HTTP Code | Status | Description "employee_kode": "20200301", "employee_nama": "ferry", "stall_code": "Heavy Repair", - "jabatan_id": "5d2c04c9-fffc-4175-ac06-148dcf944ef7", + "jabatan_kode": "1", + "branch_id": "5d2c04c9-fffc-4175-ac06-148dcf944ef7", + "branch_code": "cdc-011", "company_id": "5e1befd2-ab04-49c2-addd-5b25c0a8141e", "company_code": "cdc-01", "created" : "2020-12-03 09:44:02", @@ -283,8 +413,40 @@ HTTP Code | Status | Description } ``` +### Logic + +#### Validation +- id : not found +- id : is owned by user login + ### Scenario Test +#### Case : Negative Case 1 + +Response HTTP Status Code : 404 + +Response Payload : +``` +{ + "status_code": "cdc-404", + "status_message": "id not found", + "data": null +} +``` + +#### Case : Negative Case 2 + +Response HTTP Status Code : 403 + +Response Payload : +``` +{ + "status_code": "cdc-403", + "status_message": "id not owned by user login", + "data": null +} +``` + #### Case : Positive Case Response HTTP Status Code : 200 @@ -299,7 +461,9 @@ Response Payload : "employee_kode": "20200301", "employee_nama": "ferry", "stall_code": "Heavy Repair", - "jabatan_id": "5d2c04c9-fffc-4175-ac06-148dcf944ef7", + "jabatan_kode": "1", + "branch_id": "5d2c04c9-fffc-4175-ac06-148dcf944ef7", + "branch_code": "cdc-011", "company_id": "5e1befd2-ab04-49c2-addd-5b25c0a8141e", "company_code": "cdc-01", "created" : "2020-12-03 09:44:02", @@ -316,7 +480,7 @@ PUT /employees/:id ### Headers Key | Value --- | --- -Content-Type | * +Content-Type | application/json Accept | application/json Email | alamat@emailcdc.com @@ -326,11 +490,13 @@ Name | Type | Example Value employee_kode | string | 200301 employee_nama | string | ferry setiawan stall_code | string | Reguler +jabatan_kode | string | 1 ``` { "employee_kode": "200301", "employee_nama": "ferry setiawan", - "stall_code": "Reguler" + "stall_code": "Reguler", + "jabatan_kode": "1" } ``` @@ -338,13 +504,14 @@ stall_code | string | Reguler HTTP Code | Status | Description --- | --- | --- 400 | Bad Request | Bad request payload -404 | Not Found | User not found in database +403 | Forbidden | id is not owned by user login +404 | Not Found | Employee not found in database 500 | Internal Server Error | some un-handle error in server 200 | OK | OK ``` { - "status_code": "CDC-200", - "status_message": "OK", + "status_code": "CDC-400", + "status_message": "Bad Request", "data": null } ``` @@ -358,7 +525,9 @@ HTTP Code | Status | Description "employee_kode": "200301", "employee_nama": "ferry setiawan", "stall_code": "Reguler", - "jabatan_id": "5d2c04c9-fffc-4175-ac06-148dcf944ef7", + "jabatan_kode": "2", + "branch_id": "5d2c04c9-fffc-4175-ac06-148dcf944ef7", + "branch_code": "cdc-011", "company_id": "5e1befd2-ab04-49c2-addd-5b25c0a8141e", "company_code": "cdc-01", "created" : "2020-12-03 09:44:02", @@ -373,6 +542,7 @@ HTTP Code | Status | Description - employee_kode : not empty and must be unique - employee_nama : not empty - stall_code : not empty +- jabatan_kode : not empty ### Scenario Test @@ -393,9 +563,11 @@ Response Payload : #### Case : Negative Case 2 -Request Payload : +Request payload : ``` -{} +{ + "employee_kode": "" +} ``` Response HTTP Status Code : 400 @@ -404,27 +576,27 @@ Response Payload : ``` { "status_code": "cdc-400", - "status_message": "employee_kode is required", + "status_message": "employee_kode is empty", "data": null } ``` #### Case : Negative Case 3 -Request payload : +Request Payload ``` { - "employee_kode": "" + "employee_nama": "" } ``` Response HTTP Status Code : 400 -Response Payload : +Response Payload ``` { "status_code": "cdc-400", - "status_message": "employee_kode is empty", + "status_message": "employee_nama is empty", "data": null } ``` @@ -434,7 +606,7 @@ Response Payload : Request Payload ``` { - "employee_nama": "" + "stall_code": "" } ``` @@ -444,7 +616,7 @@ Response Payload ``` { "status_code": "cdc-400", - "status_message": "employee_nama is empty", + "status_message": "stall_code is empty", "data": null } ``` @@ -454,7 +626,7 @@ Response Payload Request Payload ``` { - "stall_code": "" + "jabatan_kode": "" } ``` @@ -464,7 +636,7 @@ Response Payload ``` { "status_code": "cdc-400", - "status_message": "stall_code is empty", + "status_message": "jabatan_kode is empty", "data": null } ``` @@ -510,7 +682,9 @@ Response Payload : "employee_kode": "200301", "employee_nama": "ferry", "stall_code": "Heavy Repair", - "jabatan_id": "5d2c04c9-fffc-4175-ac06-148dcf944ef7", + "jabatan_kode": "1", + "branch_id": "5d2c04c9-fffc-4175-ac06-148dcf944ef7", + "branch_code": "cdc-011", "company_id": "5e1befd2-ab04-49c2-addd-5b25c0a8141e", "company_code": "cdc-01", "created" : "2020-12-03 09:44:02", @@ -540,7 +714,9 @@ Response Payload : "employee_kode": "200301", "employee_nama": "ferry setiawan", "stall_code": "Heavy Repair", - "jabatan_id": "5d2c04c9-fffc-4175-ac06-148dcf944ef7", + "jabatan_kode": "1", + "branch_id": "5d2c04c9-fffc-4175-ac06-148dcf944ef7", + "branch_code": "cdc-011", "company_id": "5e1befd2-ab04-49c2-addd-5b25c0a8141e", "company_code": "cdc-01", "created" : "2020-12-03 09:44:02", @@ -570,7 +746,41 @@ Response Payload : "employee_kode": "20200301", "employee_nama": "ferry", "stall_code": "Regular", - "jabatan_id": "5d2c04c9-fffc-4175-ac06-148dcf944ef7", + "jabatan_kode": "1", + "branch_id": "5d2c04c9-fffc-4175-ac06-148dcf944ef7", + "branch_code": "cdc-011", + "company_id": "5e1befd2-ab04-49c2-addd-5b25c0a8141e", + "company_code": "cdc-01", + "created" : "2020-12-03 09:44:02", + "modified" : "2020-12-04 10:40:02" + } +} +``` + +#### Case : Positive Case 4 + +Request Payload : +``` +{ + "stall_code": "Regular" +} +``` + +Response HTTP Status Code : 200 + +Response Payload : +``` +{ + "status_code": "CDC-200", + "status_message": "OK", + "data": { + "id":"5fbf4995-b4ac-4a2e-9cad-4021cf944ef7", + "employee_kode": "20200301", + "employee_nama": "ferry", + "stall_code": "Heavy Repair", + "jabatan_kode": "2", + "branch_id": "5d2c04c9-fffc-4175-ac06-148dcf944ef7", + "branch_code": "cdc-011", "company_id": "5e1befd2-ab04-49c2-addd-5b25c0a8141e", "company_code": "cdc-01", "created" : "2020-12-03 09:44:02", @@ -594,7 +804,8 @@ Email | alamat@emailcdc.com ### Response Payloads HTTP Code | Status | Description --- | --- | --- -404 | Not Found | User not found in database +403 | Forbidden | id is not owned by user login +404 | Not Found | id not found in database 500 | Internal Server Error | some un-handle error in server 204 | No content | No content diff --git a/doc/employees.png b/doc/employees.png index 2d76b18..3c654bc 100644 Binary files a/doc/employees.png and b/doc/employees.png differ