diff --git a/app/api/mobile/entities/activity.rb b/app/api/mobile/entities/activity.rb index 59127dedd..91e7d220b 100644 --- a/app/api/mobile/entities/activity.rb +++ b/app/api/mobile/entities/activity.rb @@ -49,7 +49,7 @@ module Mobile end when :latest_update time_from_now ac.updated_at unless ac.nil? - when :activity_praise_count + when :praise_count if ac.act_type == "HomeworkCommon" || ac.act_type == "News" || ac.act_type == "Message" || ac.act_type == "BlogComment" || ac.act_type == "JournalsForMessage" || ac.act_type == "Issue" ac.nil? || ac.act.nil? ? 0 : get_activity_praise_num(ac.act) end @@ -123,7 +123,7 @@ module Mobile end end act_expose :reply_count #回复数 - act_expose :activity_praise_count #点赞数 + act_expose :praise_count #点赞数 #act_expose :user_act #某个动态 act_expose :subject #标题 act_expose :description #描述 diff --git a/app/api/mobile/entities/blog_comment.rb b/app/api/mobile/entities/blog_comment.rb index dad3f7a93..655050fdd 100644 --- a/app/api/mobile/entities/blog_comment.rb +++ b/app/api/mobile/entities/blog_comment.rb @@ -16,10 +16,14 @@ module Mobile end else case f - when :blog_praise_count + when :praise_count get_activity_praise_num(u) when :lasted_comment time_from_now(u.created_at) + when :act_type + 'BlogComment' + when :act_id + u.id end end end @@ -32,6 +36,8 @@ module Mobile c.author end end + blog_comment_expose :act_type + blog_comment_expose :act_id blog_comment_expose :blog_id blog_comment_expose :title blog_comment_expose :content @@ -39,13 +45,13 @@ module Mobile blog_comment_expose :created_at blog_comment_expose :lasted_comment blog_comment_expose :id - blog_comment_expose :blog_praise_count + blog_comment_expose :praise_count expose :blog_comment_children, using:Mobile::Entities::BlogComment do |c,opt| if c.is_a? (::BlogComment) c.children.reverse end end - expose :has_praise , if: lambda { |instance, options| options[:user] } do |instance, options| + expose :has_praise, if: lambda { |instance, options| options[:user] } do |instance, options| has_praise = false current_user = options[:user] obj = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",instance.id,instance.class.to_s,current_user.id) diff --git a/app/api/mobile/entities/issue.rb b/app/api/mobile/entities/issue.rb index 41b9003d6..ef3d09450 100644 --- a/app/api/mobile/entities/issue.rb +++ b/app/api/mobile/entities/issue.rb @@ -26,8 +26,12 @@ module Mobile issue.journals.where("notes is not null and notes != ''").count when :project_name issue.project.name - when :issue_praise_count + when :praise_count get_activity_praise_num(issue) + when :act_type + 'Issue' + when :act_id + issue.id end end end @@ -37,13 +41,15 @@ module Mobile expose :description expose :author, using: Mobile::Entities::User expose :done_ratio + issue_expose :act_type + issue_expose :act_id issue_expose :created_on issue_expose :issue_priority issue_expose :issue_assigned_to issue_expose :issue_status issue_expose :journals_count issue_expose :project_name - issue_expose :issue_praise_count + issue_expose :praise_count expose :issue_journals, using: Mobile::Entities::Journal do |f, opt| if f.is_a?(::Issue) f.journals.where("notes is not null and notes != ''").reverse diff --git a/app/api/mobile/entities/jours.rb b/app/api/mobile/entities/jours.rb index 3d3e76e7c..15e22174c 100644 --- a/app/api/mobile/entities/jours.rb +++ b/app/api/mobile/entities/jours.rb @@ -19,12 +19,19 @@ module Mobile time_from_now f.created_on when :reply_count f.children.count - when :message_praise_count + when :praise_count get_activity_praise_num(f) + when :act_type + 'JournalsForMessage' + when :act_id + f.id end end end end + + jours_expose :act_type + jours_expose :act_id jours_expose :id jours_expose :jour_type jours_expose :jour_id @@ -37,7 +44,7 @@ module Mobile jours_expose :m_reply_id jours_expose :m_parent_id jours_expose :reply_count - jours_expose :message_praise_count + jours_expose :praise_count expose :course,using:Mobile::Entities::Course do |f,opt| if f.is_a?(::JournalsForMessage) && f[:jour_type] == "Course" f.course diff --git a/app/api/mobile/entities/message.rb b/app/api/mobile/entities/message.rb index fe55bc090..912b07e62 100644 --- a/app/api/mobile/entities/message.rb +++ b/app/api/mobile/entities/message.rb @@ -24,8 +24,12 @@ module Mobile end when :lasted_comment time_from_now u.created_on - when :message_praise_count + when :praise_count get_activity_praise_num(u) + when :act_type + 'Message' + when :act_id + u.id end end end @@ -38,12 +42,14 @@ module Mobile c.author end end + message_expose :act_type + message_expose :act_id message_expose :course_project_name message_expose :board_id message_expose :subject message_expose :content message_expose :replies_count - message_expose :message_praise_count + message_expose :praise_count message_expose :created_on message_expose :id message_expose :lasted_comment diff --git a/app/api/mobile/entities/news.rb b/app/api/mobile/entities/news.rb index aab9a93b0..4f973d82e 100644 --- a/app/api/mobile/entities/news.rb +++ b/app/api/mobile/entities/news.rb @@ -18,8 +18,12 @@ module Mobile case field when :course_name get_course(f.course_id).name unless f.course_id == nil - when :news_praise_count + when :praise_count get_activity_praise_num(f) + when :act_type + 'News' + when :act_id + f.id end end elsif f.is_a?(Hash) && !f.key?(field) @@ -50,6 +54,8 @@ module Mobile end obj end + news_expose :act_type + news_expose :act_id #作者id news_expose :author_id #作者名 @@ -62,7 +68,7 @@ module Mobile news_expose :created_on #评论数量 news_expose :comments_count - news_expose :news_praise_count + news_expose :praise_count #课程名字 news_expose :course_name #评论 diff --git a/app/api/mobile/entities/whomework.rb b/app/api/mobile/entities/whomework.rb index 4c4dd2403..5101d68eb 100644 --- a/app/api/mobile/entities/whomework.rb +++ b/app/api/mobile/entities/whomework.rb @@ -24,12 +24,16 @@ module Mobile wh.nil? || wh.homework_detail_manual.nil? ? nil : convert_to_time(wh.homework_detail_manual.evaluation_start, 0) when :evaluation_end wh.nil? || wh.homework_detail_manual.nil? ? nil : convert_to_time(wh.homework_detail_manual.evaluation_end, 1) - when :whomework_praise_count + when :praise_count get_activity_praise_num(wh) when :whomework_journal_count wh.journals_for_messages.count when :course_name wh.course.name + when :act_type + 'Homework' + when :act_id + wh.id end end end @@ -54,12 +58,14 @@ module Mobile expose :anonymous_comment expose :quotes expose :is_open + whomework_expose :act_type + whomework_expose :act_id whomework_expose :course_name whomework_expose :created_at whomework_expose :absence_penalty whomework_expose :evaluation_start whomework_expose :evaluation_end - whomework_expose :whomework_praise_count + whomework_expose :praise_count whomework_expose :whomework_journal_count expose :journals_for_messages, using: Mobile::Entities::Jours do |f, opt| #f[:journals_for_messages] if f.is_a?(Hash) && f.key?(:journals_for_messages)