1. 程式人生 > >sky平臺介面呼叫

sky平臺介面呼叫

一、使用者註冊

POST請求

URL:http://localhost:9999/restApi/record/registerUser

Content-Type: application/json

Body:

{
  "username": "test",
  "password": "123456"
}

返回:

{
    "message": "success",
    "status": 200,
    "data": true
}

 

二、獲取Token

POST請求

URL:http://localhost:9999/auth/oauth/token

Content-Type: application/x-www-form-urlencoded
grant_type=passwordusername=testpassword=123456client_id=skyclient_secret=sky

返回:

{
    "data": {
        "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJsaWNlbnNlIjoibWFkZSBieSBza3kiLCJ1c2VyX25hbWUiOiJ0ZXN0MyIsInNjb3BlIjpbInNlcnZlciJdLCJleHAiOjE1NDA5NDIzOTQsInVzZXJJZCI6MzgsImF1dGhvcml0aWVzIjpbIlJFU1QiXSwianRpIjoiNjE3ZWE0ZTItY2E4ZC00NGZiLWEyNDUtNzI5ZTU0MTBlMzM3IiwiY2xpZW50X2lkIjoic2t5In0.m4EcLoeZmXi97aP2MR7KgWCLWYMS336Akkgd_Qc58s0",
        "refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJsaWNlbnNlIjoibWFkZSBieSBza3kiLCJ1c2VyX25hbWUiOiJ0ZXN0MyIsInNjb3BlIjpbInNlcnZlciJdLCJhdGkiOiI2MTdlYTRlMi1jYThkLTQ0ZmItYTI0NS03MjllNTQxMGUzMzciLCJleHAiOjE1NDA5NDIzOTQsInVzZXJJZCI6MzgsImF1dGhvcml0aWVzIjpbIlJFU1QiXSwianRpIjoiZTY4MzE5NGYtNzc2OC00YzdlLWFlMzktMTZhZDdhYmU4Y2EwIiwiY2xpZW50X2lkIjoic2t5In0.9IHqp3sj56VqXR9RXD7AJHlLYyGoVzdcXOH-XB9RDj4",
        "license": "made by sky",
        "scope": "server",
        "token_type": "bearer",
        "expires_in": 71999,
        "userId": 38,
        "jti": "617ea4e2-ca8d-44fb-a245-729e5410e337"
    },
    "message": "success",
    "status": 200
}

三、上傳記錄

POST請求

URL:http://localhost:9999/auth/oauth/token

Content-Type: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJsaWNlbnNlIjoibWFkZSBieSBpbmYiLCJ1c2VyX25hbWUiOiJhZG1pbiIsInNjb3BlIjpbInNlcnZlciJdLCJleHAiOjE1MzkxNzgyNzgsInVzZXJJZCI6MiwiYXV0aG9yaXRpZXMiOlsiUk9MRV9VU0VSIl0sImp0aSI6ImRhNzczNGZhLTY4OWItNDhlYy1iNGM5LTlmYzQ5YzMzOWFjMyIsImNsaWVudF9pZCI6InJlc3QifQ.Vr6aO-_euUwqP4DwHTf-Nxjd5D53xCzEPrr_CNAmkag

Body:

{
  "companyname": "汽修廠",
  "costlistcode": "BY001",
  "faultdescription": "保養",
  "repairdate": "20181010",
  "repairmileage": "7000",
  "repairprojectlist": [
    {
      "repairproject": "換機油",
      "workinghours": "2"
    }
  ],
  "settledate": "20181010",
  "vehiclepartslist": [
    {
      "partscode": "CC001",
      "partsname": "機油",
      "partsquantity": "2"
    }
  ],
  "vehicleplatenumber": "蘇B12345",
  "vin": "LS123344333"
}

返回:

{
    "message": "success",
    "status": 200,
    "data": true
}

 

三、分頁查詢

GET請求

URL:http://localhost:9999/restApi/record/2/page?page=2&limit=1

Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJsaWNlbnNlIjoibWFkZSBieSBpbmYiLCJ1c2VyX25hbWUiOiJhZG1pbiIsInNjb3BlIjpbInNlcnZlciJdLCJleHAiOjE1MzkxNzgyNzgsInVzZXJJZCI6MiwiYXV0aG9yaXRpZXMiOlsiUk9MRV9VU0VSIl0sImp0aSI6ImRhNzczNGZhLTY4OWItNDhlYy1iNGM5LTlmYzQ5YzMzOWFjMyIsImNsaWVudF9pZCI6InJlc3QifQ.Vr6aO-_euUwqP4DwHTf-Nxjd5D53xCzEPrr_CNAmkag

返回:

{
    "total": 2,
    "size": 10,
    "pages": 1,
    "current": 1,
    "records": [
        {
            "vehicleplatenumber": "蘇B12345",
            "companyname": "汽修廠",
            "recordid": "506819704225005568",
            "companycode": null,
            "companyid": 38,
            "createdate": "2018-10-30 05:20:34",
            "vin": "LS123344333",
            "repairdate": "20181009",
            "repairmileage": 7000,
            "settledate": "20181010",
            "faultdescription": "保養",
            "costlistcode": "BY001",
            "repairprojectlist": [
                {
                    "repairproject": "換機油",
                    "workinghours": 2
                }
            ],
            "vehiclepartslist": [
                {
                    "partsname": "機油",
                    "partsquantity": 2,
                    "partscode": "CC001"
                }
            ]
        },
        {
            "vehicleplatenumber": "蘇B12345",
            "companyname": "汽修廠",
            "recordid": "506817987550904320",
            "companycode": null,
            "companyid": 38,
            "createdate": "2018-10-30 05:13:44",
            "vin": "LS123344333",
            "repairdate": "20181009",
            "repairmileage": 7000,
            "settledate": "20181010",
            "faultdescription": "保養",
            "costlistcode": "BY001",
            "repairprojectlist": [
                {
                    "repairproject": "換機油",
                    "workinghours": 2
                }
            ],
            "vehiclepartslist": [
                {
                    "partsname": "機油",
                    "partsquantity": 2,
                    "partscode": "CC001"
                }
            ]
        }
    ]
}

四、查詢詳情

GET請求

URL:http://localhost:9999/restApi/record/17/504700046139195392

Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJsaWNlbnNlIjoibWFkZSBieSBpbmYiLCJ1c2VyX25hbWUiOiJhZG1pbiIsInNjb3BlIjpbInNlcnZlciJdLCJleHAiOjE1MzkxNzgyNzgsInVzZXJJZCI6MiwiYXV0aG9yaXRpZXMiOlsiUk9MRV9VU0VSIl0sImp0aSI6ImRhNzczNGZhLTY4OWItNDhlYy1iNGM5LTlmYzQ5YzMzOWFjMyIsImNsaWVudF9pZCI6InJlc3QifQ.Vr6aO-_euUwqP4DwHTf-Nxjd5D53xCzEPrr_CNAmkag

返回:

{
    "message": "success",
    "status": 200,
    "data": {
        "vehicleplatenumber": "蘇B12345",
        "companyname": "汽修廠",
        "recordid": "506819704225005568",
        "companycode": null,
        "companyid": 38,
        "createdate": "2018-10-30 05:20:34",
        "vin": "LS123344333",
        "repairdate": "20181009",
        "repairmileage": 7000,
        "settledate": "20181010",
        "faultdescription": "保養",
        "costlistcode": "BY001",
        "repairprojectlist": [
            {
                "repairproject": "換機油",
                "workinghours": 2
            }
        ],
        "vehiclepartslist": [
            {
                "partsname": "機油",
                "partsquantity": 2,
                "partscode": "CC001"
            }
        ]
    }
}

 

sky平臺開源地址:https://gitee.com/haoxin963/sky

更多微服務的文章請關注我的微信公眾號: