socialforge/app/api/mobile/entities/jours.rb

38 lines
1.0 KiB
Ruby

module Mobile
module Entities
#普通留言
class Jours < Grape::Entity
include Redmine::I18n
include WordsHelper
def self.jours_expose(field)
expose field do |f,opt|
if f.is_a?(Hash) && f.key?(field)
f[field]
elsif f.is_a?(::JournalsForMessage) && f.respond_to?(field)
if field == :created_on
format_time(f.send(field))
else
f.send(field)
end
end
end
end
jours_expose :id
expose :user,using: Mobile::Entities::User do |f, opt|
f.user
end
jours_expose :created_on
jours_expose :notes
jours_expose :m_reply_id
expose :reply_user,using: Mobile::Entities::User do |f, opt|
f.at_user
end
expose :child_reply,using: Mobile::Entities::Jours do |f, opt|
if f.is_a?(::JournalsForMessage)
fetch_user_leaveWord_reply(f)
end
end
end
end
end