修改news api

This commit is contained in:
lizanle 2015-06-26 17:16:03 +08:00
parent c9a614d520
commit 09b6f1d787
2 changed files with 5 additions and 3 deletions

View File

@ -26,13 +26,15 @@ module Mobile
news_expose :title news_expose :title
expose :author,using: Mobile::Entities::User do |f, opt| expose :author,using: Mobile::Entities::User do |f, opt|
n = f[:news] n = f[:author]
n.author if n.respond_to?(:author) #n.author if n.respond_to?(:author)
end end
#作者id #作者id
news_expose :author_id news_expose :author_id
#作者名 #作者名
news_expose :author_name news_expose :author_name
#作者头像url
news_expose :author_img_url
#新闻内容 #新闻内容
news_expose :description news_expose :description
#发布时间 #发布时间

View File

@ -123,7 +123,7 @@ class CoursesService
scope = @course ? @course.news.course_visible(current_user) : News.course_visible(current_user) scope = @course ? @course.news.course_visible(current_user) : News.course_visible(current_user)
news = [] news = []
scope.each do |n| scope.each do |n|
news << {:id => n.id,:title => n.title,:author_name => n.author.name,:author_id => n.author.id, :description => n.description,:created_on => format_time(n.created_on),:comments_count => n.comments_count} news << {:id => n.id,:title => n.title,:author_name => n.author.name,:author_id => n.author.id, :author=>n.author, :description => n.description,:created_on => format_time(n.created_on),:comments_count => n.comments_count}
end end
news news
end end