From 313d415a15be3b5c1d1711c9b1021be5f966b71a Mon Sep 17 00:00:00 2001 From: Yiang Gan Date: Wed, 30 Mar 2016 17:49:05 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=AF=A6=E6=83=85api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/blog_comments.rb | 2 +- app/api/mobile/entities/blog_comment.rb | 12 ++++++++---- app/api/mobile/entities/jours.rb | 7 ++++--- app/api/mobile/entities/message.rb | 16 ++++++++++++---- app/api/mobile/entities/news.rb | 15 ++++++++++++--- app/api/mobile/entities/student_work.rb | 14 +++++++------- app/api/mobile/entities/whomework.rb | 15 +++++++++------ 7 files changed, 53 insertions(+), 28 deletions(-) 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 From b30fad723de648294c528d7cf362498532c56a95 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 30 Mar 2016 17:56:45 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=8F=9C=E5=8D=95=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/menu.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/menu.yml b/config/menu.yml index 4072f5793..afb2ef0f7 100644 --- a/config/menu.yml +++ b/config/menu.yml @@ -2,7 +2,7 @@ button: - type: "view" name: "最新动态" - url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=http://wechat.trustie.net/assets/wechat/issue.html&response_type=code&scope=snsapi_base&state=123#wechat_redirect" + url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=http://wechat.trustie.net/assets/wechat/activities.html&response_type=code&scope=snsapi_base&state=123#wechat_redirect" - type: "click" name: "意见返馈"