• 请不要在回答技术问题时复制粘贴 AI 生成的内容
zivyou
V2EX  ›  程序员

请教一个 REST api 设计的问题

  •  
  •   zivyou · May 13, 2020 · 2899 views
    This topic created in 2368 days ago, the information mentioned may be changed or developed.
    各位老哥,我们有一个「预约申请审批」系统,里面有一个管理员角色,他可以审批「预约」,同时,管理员也可以发起「预约」。所以,现在要设计两个接口:
    1. 用来展示「我」发起的「预约」;
    2. 用来展示和我相关的已经完成了的预约,「和我相关」指的是「我发起的」或者「由我审批」的

    目前,1 我用的是 'GET /application/my', 2 我用的是'GET /application/myRelated',感觉设计的不好。
    望各位老哥不吝赐教。
    3 replies  •  2020-05-14 10:09:17 +08:00
    cutiechi
    cutiechi
    May 13, 2020 via iPhone❤️1
    1
    用 fliter 就好了 1: /applications?我申请的=true 2: /applications?我参与的=true
    jerray
    jerray
    May 13, 2020❤️1
    2
    1. /applications?issuer=uid
    2. /applications?related=uid

    不论是我的还是谁的,都是在按照条件做筛选。
    ChanKc
    ChanKc
    May 14, 2020❤️1
    3
    无所谓

    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].
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1526 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 00:36 · PVG 08:36 · LAX 16:36 · JFK 19:36
    ♥ Do have faith in what you're doing.