-
Notifications
You must be signed in to change notification settings - Fork 0
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
10 changed files
with
94 additions
and
87 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
22 changes: 22 additions & 0 deletions
22
...server/src/main/kotlin/com/sphereon/oid/fed/server/admin/controllers/AccountController.kt
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,22 @@ | ||
package com.sphereon.oid.fed.server.admin.controllers | ||
import org.springframework.web.bind.annotation.* | ||
|
||
import com.sphereon.oid.fed.openapi.models.AccountDTO | ||
import com.sphereon.oid.fed.openapi.models.CreateAccountDTO | ||
import com.sphereon.oid.fed.server.admin.services.* | ||
|
||
@RestController | ||
@RequestMapping("/account") | ||
class AccountController { | ||
private val accountService = AccountService() | ||
|
||
@GetMapping | ||
fun getAccounts(): List<AccountDTO> { | ||
return accountService.findAll() | ||
} | ||
|
||
@PostMapping | ||
fun createAccount(@RequestBody account: CreateAccountDTO) { | ||
return accountService.create(account) | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...admin-server/src/main/kotlin/com/sphereon/oid/fed/server/admin/services/AccountService.kt
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,18 @@ | ||
package com.sphereon.oid.fed.server.admin.services | ||
|
||
import com.sphereon.oid.fed.openapi.models.AccountDTO | ||
import com.sphereon.oid.fed.openapi.models.CreateAccountDTO | ||
import com.sphereon.oid.fed.persistence.Persistence | ||
import com.sphereon.oid.fed.persistence.extensions.toDTO | ||
|
||
class AccountService { | ||
private val accountRepository = Persistence.accountRepository | ||
|
||
fun create(account: CreateAccountDTO) { | ||
return accountRepository.create(account) | ||
} | ||
|
||
fun findAll(): List<AccountDTO> { | ||
return accountRepository.findAll().map { it.toDTO() } | ||
} | ||
} |
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
12 changes: 3 additions & 9 deletions
12
modules/persistence/src/commonMain/kotlin/com.sphereon.oid.fed.persistence/Persistence.kt
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 |
---|---|---|
@@ -1,13 +1,7 @@ | ||
import com.sphereon.oid.fed.persistence.Database | ||
package com.sphereon.oid.fed.persistence | ||
|
||
import com.sphereon.oid.fed.persistence.repositories.AccountRepository | ||
|
||
class Persistence(databaseFactory: DatabaseFactory, config: DatabaseConfig) { | ||
val database: Database | ||
expect object Persistence { | ||
val accountRepository: AccountRepository | ||
|
||
init { | ||
val driver = databaseFactory.createDriver(config) | ||
database = Database(driver) | ||
accountRepository = AccountRepository(database) | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...ce/src/commonMain/kotlin/com/sphereon/oid/fed/persistence/extensions/AccountExtensions.kt
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,10 @@ | ||
package com.sphereon.oid.fed.persistence.extensions | ||
|
||
import com.sphereon.oid.fed.openapi.models.AccountDTO | ||
import entities.Account as SqlDelightAccount | ||
|
||
fun SqlDelightAccount.toDTO(): AccountDTO { | ||
return AccountDTO( | ||
username = this.username | ||
) | ||
} |
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
13 changes: 13 additions & 0 deletions
13
modules/persistence/src/jvmMain/kotlin/com.sphereon.oid.fed.persistence/Persistence.jvm.kt
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,13 @@ | ||
package com.sphereon.oid.fed.persistence | ||
import PlatformSqlDriver | ||
import com.sphereon.oid.fed.persistence.repositories.AccountRepository | ||
|
||
actual object Persistence { | ||
actual val accountRepository: AccountRepository | ||
|
||
init { | ||
val driver = PlatformSqlDriver().createPostgresDriver(System.getenv("DB_URL"), System.getenv("DB_USER"), System.getenv("DB_PASSWORD")) | ||
val database = Database(driver) | ||
accountRepository = AccountRepository(database) | ||
} | ||
} |
23 changes: 0 additions & 23 deletions
23
...persistence/src/jvmMain/kotlin/com.sphereon.oid.fed.persistence/PersistenceInitializer.kt
This file was deleted.
Oops, something went wrong.