V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
zivyou
V2EX  ›  程序员

请教一个 REST api 设计的问题

  •  
  •   zivyou · 2020-05-13 21:08:59 +08:00 · 1517 次点击
    这是一个创建于 1433 天前的主题,其中的信息可能已经有所发展或是发生改变。
    各位老哥,我们有一个「预约申请审批」系统,里面有一个管理员角色,他可以审批「预约」,同时,管理员也可以发起「预约」。所以,现在要设计两个接口:
    1. 用来展示「我」发起的「预约」;
    2. 用来展示和我相关的已经完成了的预约,「和我相关」指的是「我发起的」或者「由我审批」的

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

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

    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].
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5679 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 38ms · UTC 06:36 · PVG 14:36 · LAX 23:36 · JFK 02:36
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.