2015-01-22 17:21:15 +08:00
|
|
|
module Mobile
|
|
|
|
module Entities
|
2015-01-23 11:42:35 +08:00
|
|
|
#普通留言
|
2015-01-22 17:21:15 +08:00
|
|
|
class Jours < Grape::Entity
|
|
|
|
include Redmine::I18n
|
2015-01-23 11:42:35 +08:00
|
|
|
include WordsHelper
|
2015-01-22 17:21:15 +08:00
|
|
|
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
|
2015-05-28 17:51:50 +08:00
|
|
|
else
|
|
|
|
case f
|
|
|
|
when :course_name
|
|
|
|
f[:jour_type] == "Course" ? f.course.name : ""
|
|
|
|
end
|
2015-01-22 17:21:15 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2015-01-23 11:42:35 +08:00
|
|
|
jours_expose :id
|
2015-02-05 17:32:19 +08:00
|
|
|
jours_expose :jour_type
|
|
|
|
jours_expose :jour_id
|
2015-01-22 17:21:15 +08:00
|
|
|
expose :user,using: Mobile::Entities::User do |f, opt|
|
|
|
|
f.user
|
|
|
|
end
|
|
|
|
jours_expose :created_on
|
|
|
|
jours_expose :notes
|
2015-01-23 11:42:35 +08:00
|
|
|
jours_expose :m_reply_id
|
2015-02-05 17:32:19 +08:00
|
|
|
jours_expose :m_parent_id
|
2015-05-28 17:51:50 +08:00
|
|
|
expose :course,using:Mobile::Entities::Course do |f,opt|
|
|
|
|
if f.is_a?(::JournalsForMessage) && f[:jour_type] == "Course"
|
|
|
|
f.course
|
|
|
|
end
|
|
|
|
end
|
2015-01-23 11:42:35 +08:00
|
|
|
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
|
2015-01-22 17:21:15 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|