请教一个 REST api 设计的问题

2020-05-13 21:08:59 +08:00
 zivyou
各位老哥,我们有一个「预约申请审批」系统,里面有一个管理员角色,他可以审批「预约」,同时,管理员也可以发起「预约」。所以,现在要设计两个接口:
1. 用来展示「我」发起的「预约」;
2. 用来展示和我相关的已经完成了的预约,「和我相关」指的是「我发起的」或者「由我审批」的

目前,1 我用的是 'GET /application/my', 2 我用的是'GET /application/myRelated',感觉设计的不好。
望各位老哥不吝赐教。
1528 次点击
所在节点    程序员
3 条回复
superchijinpeng
2020-05-13 21:23:42 +08:00
用 fliter 就好了 1: /applications?我申请的=true 2: /applications?我参与的=true
jerray
2020-05-13 21:49:01 +08:00
1. /applications?issuer=uid
2. /applications?related=uid

不论是我的还是谁的,都是在按照条件做筛选。
ChanKc
2020-05-14 10:09:17 +08:00
无所谓

Roy T Fielding: A REST API must not define fixed resource names or hierarchies (an obvious coupling of client and server). Servers must have the freedom to control their own namespace. Instead, allow servers to instruct clients on how to construct appropriate URIs, such as is done in HTML forms and URI templates, by defining those instructions within media types and link relations. [Failure here implies that clients are assuming a resource structure due to out-of band information, such as a domain-specific standard, which is the data-oriented equivalent to RPC’s functional coupling].

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/671383

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX