Giter VIP home page Giter VIP logo

apiserver's Introduction

API Documents

中英混雜是因為我沒空懶得翻譯了,之後再改回中文


Account

/api/userfile/login/

click me
  • function
    • to get jwt token.
  • method
    • POST
  • Request body
{
    "account" : "your account",
    "password" : "your password"
}
  • Response body
#if login success
{
    "success": true,
    "message": "your jwt token",
    "account": "your account"
}
#if account doesn't exist
{
    "success": false,
    "message": "尚未註冊",
    "account": "your account"
}
#If the password is incorrect
{
    "success": false,
    "message": "登入失敗",
    "account": "your account"
}

/api/userfile/signup/

click me
  • function
    • to sign up.
  • method
    • POST
  • Request body
{
    "account":"your account",
    "password":"your password",
    "mail":"your email address",
    "phone":"your phone number"
}
  • Response body
#If the registration is successful.
{
    "success": true,
    "message": "註冊成功"
}
#If the account has already been registered.
{
    "success": false,
    "message": "帳號已經被註冊"
}
#If there is missing information in the requested body.
{
    "success": false,
    "message": "註冊失敗"
}

/api/userfile/verify_token/

click me
  • function
    • Verify the legality of the JWT token, with a validity period of 10 days. As the verification has been performed during acquisition, the existence of the account and password will not be verified here.
  • method
    • GET
  • Request header
Authorization:your jwt token
  • Response body
#If the JWT token is within its validity period of 10 days.
{
    "success": true,
}
#當jwt token過期或是不合法時.
{
    "success": false,
}

/api/userfile/search_by_account/

click me
  • function
    • This API is used to return specified parameters. The query format is "?account={your account name}". If no parameters are provided, it will return all accounts when directly GET "api/userfile/search_by_account". This is for testing purposes only. After formal deployment, access will be restricted to local GET requests only.
  • method
    • GET
  • Request header
None
  • Response body
#Return one or multiple user data in the form of an array depending on whether parameters are added.Format as follows.
{
    "id": your id(integer),
    "Account": "your account",
    "Password": "your password(SHA-256)",
    "Name": "your name",
    "Email": "your email",
    "Phonenumber": "your phone number",
    "StudentID": "your StudentID",
    "Introduction": "your Introduction",
    "Favorite": "your Favorite",
    "Profliephoto": "The file path of your personal profilephoto."
}

Commodity

/api/commodity/my_commodity/

click me
  • function
    • 取得這個帳號的所有商品,需使用jwt
  • method
    • GET
  • Request header
None
  • Response body
#Return one or multiple user data in the form of an array.
{
    "id": your id(integer),
    "Account": "who launched this commodity",
    "Launched": launch state(boolean),
    "Name": "commodity's name",
    "Description": "commodity's description",
    "Price": "commodity's price",
    "Amount": "commodity's amount",
    "Position": "where is the commodity",
    "Image": [
      "an array of picture name",
      "maxmium is 5 picture",
      "at least 1"
    ]
}

/api/commodity/launch/

click me
  • function
    • 更改商品上下架狀態,需使用jwt,並且在網址列加上目標商品的id,格式為"/api/commodity/launch/?id={商品id}"
  • method
    • POST
  • Request header
Authorization:your jwt token
  • Request body
{
  "launched": launch state
}
  • Response body
#成功
{
  "success": true,
  "message": "ok"
}
#找不到商品
{
  "success": false,
  "message": "can't find commodity with this id"
}
#非商品擁有者
{
  "success": false,
  "message": "this commodity is not yours"
}

/api/commodity/search_by_commodity/

click me
  • function
    • The usage of this API is the same as "api/userfile/search_by_account".The query format is "?commodity={your commodity name}"
  • method
    • GET
  • Request header
None
  • Response body
#Return one or multiple user data in the form of an array depending on whether parameters are added.Format as follows.
{
    "id": your id(integer),
    "Account": "who launched this commodity",
    "Launched": launch state(boolean),
    "Name": "commodity's name",
    "Description": "commodity's description",
    "Price": "commodity's price",
    "Amount": "commodity's amount",
    "Position": "where is the commodity",
    "Image": [
      "an array of picture name",
      "maxmium is 5 picture",
      "at least 1"
    ]
}

/api/commodity/commodity_CRUD/

click me
  • function
    • 這支api用來對商品做CRUD,header內必須加上jwt token.
    • 請注意,搜尋和主頁大量獲取商品資訊勿使用此api
    • RUD都需在網址列加上id的參數,格式為"/api/commodity/commodity_CRUD/?id="
  • method
    • GET,POST,PUT,DELETE

GET

  • Request header
Authorization:your jwt token
  • Response body
#正常情況.
{
    "id": your id(integer),
    "Account": "who launched this commodity",
    "Launched": launch state(boolean),
    "Name": "commodity's name",
    "Description": "commodity's description",
    "Price": "commodity's price",
    "Amount": "commodity's amount",
    "Position": "where is the commodity",
    "Image": [
      "an array of picture name",
      "maxmium is 5 picture",
      "at least 1"
    ]
}
#如果沒有在網址加上id.
{
  "success": false,
  "message": "Please add parameters to the URL."
}
#如果無法透過這個id找到商品.
{
  "success": false,
  "message": "can't find commodity with this id"
}
#如果這個商品不是你的.
{
  "success": false,
  "message": "this commodity is not yours"
}

POST

  • Request header
Authorization:your jwt token
  • Request body
{
    "name":"your commodity name",
    "launched":"launched state",
    "description":"description",
    "price":"your price",
    "amount":"commodity amount",
    "position":"where is your commodity",
    "image":["至少一張圖片","可選","可選","可選","最多五張圖片"]
}
  • Response body
#If there are no issues with the uploaded data.
{
    "success": true,
    "message": "成功上傳商品"
}
#如果POST的資料有缺漏.
{
    "success": false,
    "message": "缺少必要資料"
}

PUT

  • 網址列的id就是要變更的商品
  • Request header
Authorization:your jwt token
  • Request body
{
    "name":"your commodity name",
    "launched":"launched state",
    "description":"description",
    "price":"your price",
    "amount":"commodity amount",
    "position":"where is your commodity",
    "remain_image":["要留下的圖片名稱,請注意不要輸入不存在的檔名","image和remain_image最多總和只能五張圖片","多餘的會從remain_image的最後面開始刪掉"],
    "image":["至少一張圖片","可選","可選","可選","最多五張圖片"]
}
  • Response body
#If there are no issues with the uploaded data.
{
    "success": true,
    "message": "成功上傳商品"
}
#如果POST的資料有缺漏.
{
    "success": false,
    "message": "缺少必要資料"
}
#如果這個商品不是你的.
{
  "success": false,
  "message": "this commodity is not yours"
}

DELETE

  • 網址列的id就是要刪除的商品
  • Request header
Authorization:your jwt token
  • Request body
None
  • Response body
#If there are no issues
{
    "success": true
}
#如果無法根據id找到商品.
{
    "success": false,
    "message": "can't find commodity with this id"
}
#如果這個商品不是你的.
{
  "success": false,
  "message": "this commodity is not yours"
}

Picture

/image/get/

click me
  • function
    • This API is used to retrieve images.The query format is "?picture_name={your picture name}".
  • method
    • GET
  • Request header
None
  • HttpResponse
#If your image exists, it will return your image. Otherwise, it will report an error.

apiserver's People

Contributors

zong1203 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.