亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

java - REST API命名問題請教
怪我咯
怪我咯 2017-04-18 10:52:41
0
3
681

雇員類

public User{
    int id;//key
    int code;//員工編號 唯一
    String name;
    ...
}

api

  1. GET /employee/{id} 根據(jù)ID獲取人員

  2. GET /employee/{code}

如上:code也是唯一的,如果這么命名是會混淆,應(yīng)該如何命名?

怪我咯
怪我咯

走同樣的路,發(fā)現(xiàn)不同的人生

reply all(3)
阿神

/employee/code/{code}

洪濤

Getting the only user is /employee/{id}. What should be obtained through this URL is the user entity object.
For the properties inside the entity object: code . Should not be obtained by exposing the URL.

The first step when designing RESTURL is resource abstraction. It is necessary to clearly distinguish which resources can be extracted and design a unique URL. What can’t be done

Ty80

RESTful resources generally use plural numbers. I think code can also be used as a search condition: /employees/search?code=xxx. Of course, code can also be obtained and changed as a resource of employee, but when searching for employee through code, it should be Belongs to the search function.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template