47 lines
1.1 KiB
Ruby
47 lines
1.1 KiB
Ruby
#coding=utf-8
|
|
module Mobile
|
|
module Apis
|
|
class Watches < Grape::API
|
|
resource :watches do
|
|
|
|
desc "获取所有关注"
|
|
params do
|
|
requires :token, type: String
|
|
end
|
|
get do
|
|
authenticate!
|
|
us = UsersService.new
|
|
ws = us.user_watcher(id: current_user.id)
|
|
{status: 0, data: ws }
|
|
end
|
|
|
|
|
|
desc "关注某人"
|
|
params do
|
|
requires :token, type: String
|
|
requires :object_id, type: Integer, desc: '关注的用户的id'
|
|
end
|
|
post do
|
|
authenticate!
|
|
ws = WatchesService.new
|
|
o = ws.watch(params.merge({current_user_id:current_user.id, object_type:'user' }) )
|
|
{status:0, data: o}
|
|
end
|
|
|
|
|
|
desc "取消关注"
|
|
params do
|
|
requires :token, type: String
|
|
requires :object_id, type: Integer, desc: '取消关注的用户的id'
|
|
end
|
|
delete do
|
|
authenticate!
|
|
ws = WatchesService.new
|
|
ws.unwatch(params.merge({current_user_id:current_user.id, object_type:'user' }) )
|
|
{status: 0}
|
|
end
|
|
|
|
end
|
|
end
|
|
end
|
|
end |