Current section
Files
Jump to
Current section
Files
lib/user.ex
defmodule SsoLogin.User do
@moduledoc """
默认的用户模型
"""
defstruct [:id, :name, :email, :mobile, :roles]
def from_data(data) do
roles = Enum.map(data["roleList"] || [], &transform_role/1)
%SsoLogin.User{
id: data["id"],
name: data["name"],
email: data["email"],
mobile: data["mobile"],
roles: roles
}
end
defp transform_role(role) do
%{
id: role["id"],
name: role["enname"],
title: role["name"]
}
end
end