22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/monban/use_case/account/register.rb', line 22
def create(params)
Getto::Params.new.validate(params) do |v|
v.hash(
login_id: v.combine([v.string, v.not_empty]){|val| param_error!(login_id: val) },
)
end or param_error!(params: params)
repository.transaction do
if repository.login_id_exists?(login_id: params[:login_id])
error.conflict! "login_id already exists"
end
account_id = repository.insert_account(
now: time.now,
)
repository.update_login_id(
account_id: account_id,
login_id: params[:login_id],
now: time.now,
)
account_id
end
end
|