V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
Geebarwan
V2EX  ›  问与答

求网站 "喜欢" 的业务设计。

  •  
  •   Geebarwan · Mar 10, 2017 · 1787 views
    This topic created in 3336 days ago, the information mentioned may be changed or developed.
    对 "喜欢" 按钮进行点击,表示的是对 "文章" 的喜欢操作,如果再次点击,则表示对 "文章" 取消喜欢的操作,这 2 个操作放到 1 个 Api 接口好呢,还是写 2 个 Api 接口好呢?求大神解答一下,最好说一下其中的利与弊。
    7 replies    2017-03-10 17:46:54 +08:00
    zhuyao
        1
    zhuyao  
       Mar 10, 2017   ❤️ 1
    放到一个啊,给定“喜欢”为 1 ,取消喜欢“ 0 ”
    lcnr
        2
    lcnr  
       Mar 10, 2017   ❤️ 1
    如果是喜欢,那肯定是 1 个,如果你的意思是“支持” 和 “反对”,那就需要 2 个
    kindjeff
        3
    kindjeff  
       Mar 10, 2017   ❤️ 1
    phperstar
        4
    phperstar  
       Mar 10, 2017   ❤️ 1
    放到一个里面,请求的得时候,有个 action 参数 1 表示喜欢 非 1 表示取消喜欢 难道做操作之前,不用判断当前得状态是否已经是喜欢 或者 取消状态了。。来个友情提醒啥的。。
    ivvei
        5
    ivvei  
       Mar 10, 2017   ❤️ 1
    @phperstar 不用提醒吧。本身就是很直观的变化,而且也不是非常重要的事情,发现点错了再点一次也没什么代价。
    xylitolLin
        6
    xylitolLin  
       Mar 10, 2017   ❤️ 1
    一个接口, 用 post 方法调用:喜欢,用 del 方法调用:取消喜欢
    learnshare
        7
    learnshare  
       Mar 10, 2017   ❤️ 1
    PATCH|PUT [API]/item/[itemId]
    {
    like: true|false
    }
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3600 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 38ms · UTC 11:07 · PVG 19:07 · LAX 04:07 · JFK 07:07
    ♥ Do have faith in what you're doing.