Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get the specified expose #323

Open
dccmmtop opened this issue Sep 26, 2019 · 0 comments
Open

How to get the specified expose #323

dccmmtop opened this issue Sep 26, 2019 · 0 comments

Comments

@dccmmtop
Copy link

User Entity

  class User < EEntity
    expose :id, :name, :pinyin, :account_id, :hidden, :dept_id, :actived
    expose :initialism, as: :short_pinyin
    expose :role_code
    expose :login_name
    expose(:email, if: lambda { |u, op| op[:included_user_email] == true }) do |u, options|
      u.email
    end
    expose :cellvoice1, if: lambda { |u, op| !op[:no_privacy] } do |u, options|
      if u.get_user_info
        u.get_user_info.cellvoice1
      else
        nil
      end
    end
    expose :nickname do |u, options|
      if u.get_user_info
        u.get_user_info.nickname
      else
        nil
      end
    end
    expose :workvoice do |u, options|
      if u.get_user_info
        u.get_user_info.workvoice
      else
        nil
      end
    end
    expose :dept_name do |u, options|
      uinfo = u.get_user_info
      if uinfo
        uinfo.get_dept_display_name
      else
        nil
      end
    end
end

How to get some of these exposes?
example:

::Entity::User.represent_only([:name.:pinyin, :account_id, :hidden, :dept_id ],{}).as_json

Result:

{
  name: 'xxx',
  pinyin: 'xxx',
  account_id: 1,
  hidden: true,
  dept_id: 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant