-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
1,275 additions
and
257 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
defmodule Materia.Accounts.Account do | ||
use Ecto.Schema | ||
import Ecto.Changeset | ||
|
||
|
||
schema "accounts" do | ||
field :external_code, :string | ||
field :name, :string | ||
field :start_datetime, :utc_datetime | ||
field :frozen_datetime, :utc_datetime | ||
field :expired_datetime, :utc_datetime | ||
field :descriptions, :string | ||
field :status, :integer, default: 1 | ||
field :lock_version, :integer, default: 0 | ||
belongs_to :organization ,Materia.Organizations.Organization | ||
belongs_to :main_user ,Materia.Accounts.User, [foreign_key: :main_user_id] | ||
|
||
timestamps() | ||
end | ||
|
||
@doc false | ||
def create_changeset(account, attrs) do | ||
account | ||
|> cast(attrs, [:external_code, :name, :start_datetime, :descriptions, :frozen_datetime, :expired_datetime,:status, :organization_id, :main_user_id, :lock_version]) | ||
|> validate_required([:external_code, :start_datetime]) | ||
|> unique_constraint(:code) | ||
end | ||
|
||
@doc false | ||
def update_changeset(account, attrs) do | ||
account | ||
|> cast(attrs, [:external_code, :name, :start_datetime, :descriptions, :frozen_datetime, :expired_datetime, :status, :organization_id, :main_user_id, :lock_version]) | ||
|> validate_required([:lock_version]) | ||
|> unique_constraint(:code) | ||
|> optimistic_lock(:lock_version) | ||
end | ||
|
||
def status() do | ||
%{ | ||
activated: 1, # アカウント有効 | ||
frozen: 8, # アカウント凍結中 | ||
expired: 9, #アカウント無効 | ||
} | ||
end | ||
end |
Oops, something went wrong.