diff --git a/app/api/mobile/apis/blog_comments.rb b/app/api/mobile/apis/blog_comments.rb index 3334b2bf8..adb1799b1 100644 --- a/app/api/mobile/apis/blog_comments.rb +++ b/app/api/mobile/apis/blog_comments.rb @@ -8,7 +8,7 @@ module Mobile desc "get special topic" get ':id' do blog = BlogComment.find params[:id] - present :blog, message, with: Mobile::Entities::BlogComment + present :data, blog, with: Mobile::Entities::BlogComment present :status, 0 end end diff --git a/app/api/mobile/entities/blog_comment.rb b/app/api/mobile/entities/blog_comment.rb index 8f387eafa..ac3fc3d9e 100644 --- a/app/api/mobile/entities/blog_comment.rb +++ b/app/api/mobile/entities/blog_comment.rb @@ -15,10 +15,12 @@ module Mobile u.send(f) end else - # case f - # when :xx - # # - # end + case f + when :blog_praise_count + get_activity_praise_num(u) + when :lasted_comment + time_from_now(u.created_at) + end end end @@ -35,7 +37,9 @@ module Mobile blog_comment_expose :content blog_comment_expose :comments_count blog_comment_expose :created_at + blog_comment_expose :lasted_comment blog_comment_expose :id + blog_comment_expose :blog_praise_count expose :blog_comment_children, using:Mobile::Entities::BlogComment do |c,opt| if c.is_a? (::BlogComment) c.children diff --git a/app/api/mobile/entities/jours.rb b/app/api/mobile/entities/jours.rb index 97eabd21f..257721d3e 100644 --- a/app/api/mobile/entities/jours.rb +++ b/app/api/mobile/entities/jours.rb @@ -15,9 +15,9 @@ module Mobile f.send(field) end else - case f - when :course_name - f[:jour_type] == "Course" ? f.course.name : "" + case field + when :lasted_comment + time_from_now f.created_on end end end @@ -29,6 +29,7 @@ module Mobile f.user end jours_expose :created_on + jours_expose :lasted_comment jours_expose :notes jours_expose :m_reply_id jours_expose :m_parent_id diff --git a/app/api/mobile/entities/message.rb b/app/api/mobile/entities/message.rb index 6a2ca1fb0..3d7fb7bbe 100644 --- a/app/api/mobile/entities/message.rb +++ b/app/api/mobile/entities/message.rb @@ -15,10 +15,16 @@ module Mobile u.send(f) end else - # case f - # when :xx - # # - # end + case f + when :course_project_name + if u.board.project_id == -1 + u.course.name + else + u.project.name + end + when :lasted_comment + time_from_now u.created_on + end end end @@ -30,12 +36,14 @@ module Mobile c.author end end + message_expose :course_project_name message_expose :board_id message_expose :subject message_expose :content message_expose :replies_count message_expose :created_on message_expose :id + message_expose :lasted_comment expose :message_children,using:Mobile::Entities::Message do |c,opt| if c.is_a? (::Message) c.children diff --git a/app/api/mobile/entities/news.rb b/app/api/mobile/entities/news.rb index 36893d16f..bf084c2f4 100644 --- a/app/api/mobile/entities/news.rb +++ b/app/api/mobile/entities/news.rb @@ -7,10 +7,17 @@ module Mobile if f.is_a?(Hash) && f.key?(field) f[field] elsif f.is_a?(::News) - if field == :created_on - format_time(f.send(field)) if f.respond_to?(field) + if f.respond_to?(field) + if field == :created_on + format_time(f.send(field)) + else + f.send(field) + end else - f.send(field) if f.respond_to?(field) + case field + when :course_name + Course.find(f.course_id).name unless f.course_id == nil + end end elsif f.is_a?(Hash) && !f.key?(field) n = f[:news] @@ -52,6 +59,8 @@ module Mobile news_expose :created_on #评论数量 news_expose :comments_count + #课程名字 + news_expose :course_name #评论 expose :comments, using: Mobile::Entities::Comment do |f, opt| if f.is_a?(Hash) && f.key?(:comments) diff --git a/app/api/mobile/entities/student_work.rb b/app/api/mobile/entities/student_work.rb index 6cf68c875..9dafdd240 100644 --- a/app/api/mobile/entities/student_work.rb +++ b/app/api/mobile/entities/student_work.rb @@ -32,14 +32,14 @@ module Mobile end end student_work_expose :student_id - student_work_expose :id + student_work_expose :id student_work_expose :name - student_work_expose :description - student_work_expose :final_score - student_work_expose :teacher_score - student_work_expose :student_score - student_work_expose :teacher_asistant_score - student_work_expose :created_at + student_work_expose :description + student_work_expose :final_score + student_work_expose :teacher_score + student_work_expose :student_score + student_work_expose :teacher_asistant_score + student_work_expose :created_at end end end \ No newline at end of file diff --git a/app/api/mobile/entities/whomework.rb b/app/api/mobile/entities/whomework.rb index db3b49a6b..562e3a1a7 100644 --- a/app/api/mobile/entities/whomework.rb +++ b/app/api/mobile/entities/whomework.rb @@ -8,14 +8,14 @@ module Mobile def self.whomework_expose(f) expose f do |wh, opt| if wh.is_a?(Hash) && wh.key?(f) - if f == :created_at - format_time(wh[f]) - else - wh[f] - end + wh[f] elsif wh.is_a?(::HomeworkCommon) if wh.respond_to?(f) - wh.send(f) + if f == :created_at + format_time(wh.send(f)) + else + wh.send(f) + end else case f when :absence_penalty @@ -28,6 +28,8 @@ module Mobile get_activity_praise_num(wh) when :whomework_journal_count wh.journals_for_messages.count + when :course_name + wh.course.name end end end @@ -49,6 +51,7 @@ module Mobile expose :anonymous_comment expose :quotes expose :is_open + whomework_expose :course_name whomework_expose :created_at whomework_expose :absence_penalty whomework_expose :evaluation_start