课程学生model
This commit is contained in:
parent
96aef6dbe2
commit
8929644ab1
|
@ -0,0 +1,33 @@
|
||||||
|
module Mobile
|
||||||
|
module Entities
|
||||||
|
class Member < Grape::Entity
|
||||||
|
include ApplicationHelper
|
||||||
|
include ApiHelper
|
||||||
|
def self.member_expose(f)
|
||||||
|
expose f do |u,opt|
|
||||||
|
if u.is_a?(Hash) && u.key?(f)
|
||||||
|
u[f]
|
||||||
|
elsif u.is_a?(::Member)
|
||||||
|
if u.respond_to?(f)
|
||||||
|
u.send(f)
|
||||||
|
else
|
||||||
|
case f
|
||||||
|
when :student_id
|
||||||
|
u.user.user_extensions.student_id
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
expose :user, using: Mobile::Entities::User do |c, opt|
|
||||||
|
if c.is_a?(::Member)
|
||||||
|
c.user
|
||||||
|
end
|
||||||
|
end
|
||||||
|
member_expose :student_id
|
||||||
|
member_expose :score
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue