36 lines
1.1 KiB
Ruby
36 lines
1.1 KiB
Ruby
module Mobile
|
|
module Entities
|
|
#匿评作品页面相关参数
|
|
class AnonymousWorksParams < Grape::Entity
|
|
def self.anonymous_works_params_expose(field)
|
|
expose field do |f,opt|
|
|
if f.is_a?(Hash) && f.key?(field)
|
|
f[field]
|
|
elsif f.is_a?(Hash) && !f.key?(field)
|
|
|
|
end
|
|
end
|
|
end
|
|
anonymous_works_params_expose :is_teacher
|
|
anonymous_works_params_expose :m_score
|
|
anonymous_works_params_expose :is_anonymous_comments
|
|
anonymous_works_params_expose :cur_type
|
|
anonymous_works_params_expose :cur_page
|
|
expose :jours ,using: Mobile::Entities::Jours do |f, opt|
|
|
if f.is_a?(Hash) && f.key?(:jours)
|
|
f[:jours]
|
|
end
|
|
end
|
|
expose :teacher_stars,using: Mobile::Entities::HomeworkJours do |f, opt|
|
|
if f.is_a?(Hash) && f.key?(:teacher_stars)
|
|
f[:teacher_stars]
|
|
end
|
|
end
|
|
expose :student_stars , using: Mobile::Entities::HomeworkJours do |f, opt|
|
|
if f.is_a?(Hash) && f.key?(:student_stars)
|
|
f[:student_stars]
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end |