2016-07-27 14:30:19 +08:00
|
|
|
module Mobile
|
|
|
|
module Entities
|
|
|
|
class ProjectMember < Grape::Entity
|
|
|
|
include Redmine::I18n
|
|
|
|
include ApplicationHelper
|
|
|
|
include ApiHelper
|
|
|
|
def self.member_expose(f)
|
|
|
|
expose f do |u,opt|
|
|
|
|
if u.is_a?(Hash) && u.key?(f)
|
|
|
|
u[f]
|
|
|
|
elsif u.is_a?(::Member)
|
|
|
|
if u.respond_to?(f)
|
|
|
|
u.send(f)
|
|
|
|
else
|
|
|
|
case f
|
|
|
|
when :roles_id
|
2016-08-02 15:50:15 +08:00
|
|
|
# u.roles[0].id
|
|
|
|
u.roles.map {|r| r.id}
|
2016-07-27 14:30:19 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
expose :user, using: Mobile::Entities::User do |c, opt|
|
|
|
|
if c.is_a?(::Member)
|
|
|
|
c.user
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
member_expose :roles_id
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|