Created
October 31, 2017 07:15
-
-
Save syossan27/98edc13b6b4c466da6e086cdbc306ba0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // テーブルに指定したIDのレコードがあれば、Contentsを返す | |
| // 無かった場合、新たなレコードをInsertし、結果のContentsを返す | |
| def hoge(id: Int): String = { | |
| Await.result(database.findById(id), Duration.Inf) match { | |
| case Some(result) => { | |
| // idに合致するレコードがあればcontentsを返す | |
| return result.contents | |
| } | |
| case None => { | |
| val table_entity = TableEntity(id, "コンテンツ") | |
| Await.result(database.save(table_entity), Duration.Inf) match { | |
| case result => { | |
| if (result) { | |
| // insertが成功した場合 | |
| Await.result(database.findById(id), Duration.Inf) match { | |
| case Some(result) => { | |
| // 発見すればproduct_tokenを返す | |
| return result.contents | |
| } | |
| case None => { | |
| // エラー処理 | |
| } | |
| } | |
| } else { | |
| // insertが失敗した場合 | |
| // エラー処理 | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment