Job Api Example - NoBodyKnowsWhatsGoingOn/prototype1 GitHub Wiki

Job api example

Model

  • id: auto generate, don't need to provide
  • title: required, string, title of job, will delete space in it
  • description: required, text, detail of job
  • create time: auto, datetime, will insert when create, cannot edit
  • update time: auto, datetime, will update when modify, cannot edit
  • active: default is false, boolean, if the job is active or not

url

  • host_address/sowork_job/update: show all jobs in database with json format, also can add new job here.
  • host_address/sowork_job/update/[id]: show one job detail with json format, can modify or delete job here.
  • host_address/sowork_job: client should only see this page, it will display all jobs in html page.

example json when create new job

{
    "title": "TestJob1",
    "description": "basin is basin",
    "active": true
}

example to update a job

json in database:

{
    "id": 1,
    "title": "TestJob1",
    "description": "basin is basin",
    "createTime": "2016-12-28T18:36:58.044165Z",
    "lastUpdateTime": "2016-12-28T18:36:58.044171Z",
    "active": true
}

update json:

{
    "id": 1,
    "title": "TestJob1",
    "description": "basin is basin!!!!!!",
    "active": false
}

result:

{
    "id": 1,
    "title": "TestJob1",
    "description": "basin is basin!!!!",
    "createTime": "2016-12-28T18:36:58.044165Z",
    "lastUpdateTime": "2016-12-28T20:15:41.044621",
    "active": false
}