|
@@ -2,6 +2,8 @@ package inn.ocsf.bee.freigeld.serve.rest
|
|
|
|
|
|
import inn.ocsf.bee.freigeld.core.model.CentralBank
|
|
|
import inn.ocsf.bee.freigeld.core.model.GlobalWorld
|
|
|
+import inn.ocsf.bee.freigeld.core.model.PersonIdentityPrivateMember
|
|
|
+import inn.ocsf.bee.freigeld.core.model.PersonMemberPosition
|
|
|
import inn.ocsf.bee.freigeld.core.model.data.PersonData
|
|
|
import inn.ocsf.bee.freigeld.core.service.WorldService
|
|
|
import org.springframework.http.ResponseEntity
|
|
@@ -24,19 +26,24 @@ class OrgController {
|
|
|
@RequestMapping("api/new/private", method = [RequestMethod.POST])
|
|
|
fun new(@RequestBody newReq: NewPrivatePersonReq): ResponseEntity<Map<String, Any?>> {
|
|
|
val orgId = world.addPerson(PersonData.PrivatePersonImpl(newReq.ownerId))
|
|
|
+ val org = world.getPerson(orgId) ?: throw RuntimeException("org not created")
|
|
|
+ world.setPersonIdentity(org, PersonIdentityPrivateMember(newReq.ownerId, PersonMemberPosition.owner))
|
|
|
val orgAccount = bank.addAccount(orgId)
|
|
|
return ResponseEntity.ok(mapOf("id" to orgId, "accountId" to orgAccount.id))
|
|
|
}
|
|
|
|
|
|
@RequestMapping("api/old/private/{ownerId}/list", method = [RequestMethod.GET])
|
|
|
fun list(@PathVariable("ownerId") ownerId: UUID): ResponseEntity<List<PrivatePersonInfo>> {
|
|
|
- return ResponseEntity.ok(worldService.findAllByOwnerId(ownerId).map {
|
|
|
- val org = world.getPerson(it)
|
|
|
- PrivatePersonInfo(it)
|
|
|
- })
|
|
|
+ val ret = (worldService.findAllByOwnerId(ownerId).map {
|
|
|
+ //val org = world.getPerson(it)
|
|
|
+ PrivatePersonInfo(it, PersonMemberPosition.owner)
|
|
|
+ } + worldService.findAllByMemberId(ownerId).map {
|
|
|
+ PrivatePersonInfo(it._1, it._2)
|
|
|
+ }).distinctBy { it.id }
|
|
|
+ return ResponseEntity.ok(ret)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-data class PrivatePersonInfo(val id: UUID)
|
|
|
+data class PrivatePersonInfo(val id: UUID, val position: PersonMemberPosition)
|
|
|
|
|
|
data class NewPrivatePersonReq(val ownerId: UUID)
|