修改时间格式解析
This commit is contained in:
parent
103a411b40
commit
3018ee206c
|
@ -1,6 +1,7 @@
|
|||
module Mobile
|
||||
module Entities
|
||||
class Course < Grape::Entity
|
||||
include Redmine::I18n
|
||||
def self.course_expose(field)
|
||||
expose field do |f,opt|
|
||||
c = nil
|
||||
|
@ -12,6 +13,8 @@ module Mobile
|
|||
if field == :img_url
|
||||
f[field] if f.is_a?(Hash) && f.key?(field)
|
||||
#f.img_url if f.respond_to?(:img_url)
|
||||
elsif field == :created_at || field == :updated_at
|
||||
(format_time(c[field]) if (c.is_a?(Hash) && c.key?(field))) || (format_time(c.send(field)) if c.respond_to?(field))
|
||||
else
|
||||
(c[field] if (c.is_a?(Hash) && c.key?(field))) || (c.send(field) if c.respond_to?(field))
|
||||
end
|
||||
|
|
|
@ -6,7 +6,11 @@ module Mobile
|
|||
def self.homework_jours_expose(field)
|
||||
expose field do |f,opt|
|
||||
if f.is_a?(Hash) && f.key?(field)
|
||||
f[field]
|
||||
if field == :created_at
|
||||
format_time(f[field])
|
||||
else
|
||||
f[field]
|
||||
end
|
||||
elsif f.is_a?(::SeemsRateableRates)
|
||||
|
||||
end
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
module Mobile
|
||||
module Entities
|
||||
class News < Grape::Entity
|
||||
include Redmine::I18n
|
||||
def self.news_expose(field)
|
||||
expose field do |f,opt|
|
||||
if f.is_a?(Hash) && f.key?(field)
|
||||
|
@ -9,13 +10,18 @@ module Mobile
|
|||
n = f[:news]
|
||||
comments = f[:comments]
|
||||
if n.is_a?(::News)
|
||||
n.send(field) if n.respond_to?(field)
|
||||
if field == :created_on
|
||||
format_time(n.send(field)) if n.respond_to?(field)
|
||||
else
|
||||
n.send(field) if n.respond_to?(field)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
news_expose :id
|
||||
#新闻标题
|
||||
news_expose :title
|
||||
|
||||
|
|
|
@ -117,7 +117,7 @@ class CoursesService
|
|||
scope = @course ? @course.news.course_visible(current_user) : News.course_visible(current_user)
|
||||
news = []
|
||||
scope.each do |n|
|
||||
news << {: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, :description => n.description,:created_on => format_time(n.created_on),:comments_count => n.comments_count}
|
||||
end
|
||||
news
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue