diff --git a/src/main/kotlin/org/gitanimals/core/FieldType.kt b/src/main/kotlin/org/gitanimals/core/FieldType.kt index 0e23651..b3735ca 100644 --- a/src/main/kotlin/org/gitanimals/core/FieldType.kt +++ b/src/main/kotlin/org/gitanimals/core/FieldType.kt @@ -355,7 +355,52 @@ enum class FieldType { override fun drawBorder(): String = "" - } + }, + FOLDER { + override fun loadComponent(name: String, commit: Long): String { + return whiteFieldSvg.replace(NAME_FIX, name.toSvg(0.0, 3.0)) + .replace(COMMIT_FIX, commit.toSvg("commit", 260.0, 4.0)) + } + + override fun fillBackground(): String = + """ + + $folderFieldSvg + """ + + override fun drawBorder(): String = + "" + }, + RED_COMPUTER { + override fun loadComponent(name: String, commit: Long): String { + return whiteFieldSvg.replace(NAME_FIX, name.toSvg(0.0, 3.0)) + .replace(COMMIT_FIX, commit.toSvg("commit", 260.0, 4.0)) + } + + override fun fillBackground(): String = + """ + + $redComputerFieldSvg + """ + + override fun drawBorder(): String = + "" + }, + RED_SOFA { + override fun loadComponent(name: String, commit: Long): String { + return whiteFieldSvg.replace(NAME_FIX, name.toSvg(0.0, 3.0)) + .replace(COMMIT_FIX, commit.toSvg("commit", 260.0, 4.0)) + } + + override fun fillBackground(): String = + """ + + $redSofaFieldSvg + """ + + override fun drawBorder(): String = + "" + }, ; abstract fun loadComponent(name: String, commit: Long): String diff --git a/src/main/kotlin/org/gitanimals/core/Svgs.kt b/src/main/kotlin/org/gitanimals/core/Svgs.kt index 5614f3f..3914f7f 100644 --- a/src/main/kotlin/org/gitanimals/core/Svgs.kt +++ b/src/main/kotlin/org/gitanimals/core/Svgs.kt @@ -44,6 +44,15 @@ val dummyGuildFieldSvg: String = ClassPathResource("persona/field/white-field.sv val logoShowingFieldSvg: String = ClassPathResource("persona/field/logo-showing.svg") .getContentAsString(Charset.defaultCharset()) +val redSofaFieldSvg: String = ClassPathResource("persona/field/red-sofa.svg") + .getContentAsString(Charset.defaultCharset()) + +val redComputerFieldSvg: String = ClassPathResource("persona/field/red-computer.svg") + .getContentAsString(Charset.defaultCharset()) + +val folderFieldSvg: String = ClassPathResource("persona/field/folder.svg") + .getContentAsString(Charset.defaultCharset()) + val gooseSvg: String = ClassPathResource("persona/animal/goose.svg") .getContentAsString(Charset.defaultCharset()) diff --git a/src/main/kotlin/org/gitanimals/guild/app/CreateGuildFacade.kt b/src/main/kotlin/org/gitanimals/guild/app/CreateGuildFacade.kt index d29d831..a15b25e 100644 --- a/src/main/kotlin/org/gitanimals/guild/app/CreateGuildFacade.kt +++ b/src/main/kotlin/org/gitanimals/guild/app/CreateGuildFacade.kt @@ -1,6 +1,7 @@ package org.gitanimals.guild.app import org.gitanimals.guild.app.request.CreateGuildRequest +import org.gitanimals.guild.domain.Guild import org.gitanimals.guild.domain.GuildService import org.gitanimals.guild.domain.request.CreateLeaderRequest import org.rooftop.netx.api.Orchestrator @@ -19,17 +20,17 @@ class CreateGuildFacade( orchestratorFactory: OrchestratorFactory, ) { - private lateinit var createGuildOrchestrator: Orchestrator + private lateinit var createGuildOrchestrator: Orchestrator fun createGuild( token: String, createGuildRequest: CreateGuildRequest, - ) { - createGuildOrchestrator.sagaSync( + ): Guild { + return createGuildOrchestrator.sagaSync( request = createGuildRequest, context = mapOf("token" to token, IDEMPOTENCY_KEY to UUID.randomUUID().toString()), timeoutMillis = 1.minutes.inWholeMilliseconds, - ).decodeResultOrThrow(Unit::class) + ).decodeResultOrThrow(Guild::class) } init { diff --git a/src/main/kotlin/org/gitanimals/guild/controller/GuildController.kt b/src/main/kotlin/org/gitanimals/guild/controller/GuildController.kt index 54575e3..fb0e0ec 100644 --- a/src/main/kotlin/org/gitanimals/guild/controller/GuildController.kt +++ b/src/main/kotlin/org/gitanimals/guild/controller/GuildController.kt @@ -36,7 +36,7 @@ class GuildController( fun createGuild( @RequestHeader(HttpHeaders.AUTHORIZATION) token: String, @RequestBody createGuildRequest: CreateGuildRequest, - ) = createGuildFacade.createGuild(token, createGuildRequest) + ) = GuildResponse.from(createGuildFacade.createGuild(token, createGuildRequest)) @ResponseStatus(HttpStatus.OK) @PostMapping("/guilds/{guildId}") diff --git a/src/main/kotlin/org/gitanimals/guild/domain/GuildService.kt b/src/main/kotlin/org/gitanimals/guild/domain/GuildService.kt index cfb83e0..de66357 100644 --- a/src/main/kotlin/org/gitanimals/guild/domain/GuildService.kt +++ b/src/main/kotlin/org/gitanimals/guild/domain/GuildService.kt @@ -27,7 +27,7 @@ class GuildService( farmType: FieldType, autoJoin: Boolean, createLeaderRequest: CreateLeaderRequest, - ) { + ): Guild { require(guildRepository.existsByTitle(title).not()) { "Cannot create guild cause duplicated guild already exists." } @@ -43,7 +43,7 @@ class GuildService( autoJoin = autoJoin, ) - guildRepository.save(newGuild) + return guildRepository.save(newGuild) } @Transactional diff --git a/src/main/kotlin/org/gitanimals/guild/domain/extension/GuildFieldTypeExtension.kt b/src/main/kotlin/org/gitanimals/guild/domain/extension/GuildFieldTypeExtension.kt index 95e43e0..260fc6e 100644 --- a/src/main/kotlin/org/gitanimals/guild/domain/extension/GuildFieldTypeExtension.kt +++ b/src/main/kotlin/org/gitanimals/guild/domain/extension/GuildFieldTypeExtension.kt @@ -8,5 +8,9 @@ object GuildFieldTypeExtension { return this in guildFields } - private val guildFields = listOf(FieldType.LOGO_SHOWING) + private val guildFields = setOf( + FieldType.FOLDER, + FieldType.RED_COMPUTER, + FieldType.RED_SOFA, + ) } diff --git a/src/main/kotlin/org/gitanimals/render/domain/extension/RenderFieldTypeExtension.kt b/src/main/kotlin/org/gitanimals/render/domain/extension/RenderFieldTypeExtension.kt index e2ff864..dbe2632 100644 --- a/src/main/kotlin/org/gitanimals/render/domain/extension/RenderFieldTypeExtension.kt +++ b/src/main/kotlin/org/gitanimals/render/domain/extension/RenderFieldTypeExtension.kt @@ -8,5 +8,9 @@ object RenderFieldTypeExtension { return this in renderFields } - private val renderFields = FieldType.entries.filter { it != FieldType.LOGO_SHOWING } + private val renderFields = FieldType.entries.asSequence() + .filter { it != FieldType.LOGO_SHOWING } + .filter { it != FieldType.FOLDER } + .filter { it != FieldType.RED_SOFA } + .filter { it != FieldType.RED_COMPUTER } } diff --git a/src/main/resources/persona/field/folder.svg b/src/main/resources/persona/field/folder.svg new file mode 100644 index 0000000..aa7c43e --- /dev/null +++ b/src/main/resources/persona/field/folder.svg @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/persona/field/red-computer.svg b/src/main/resources/persona/field/red-computer.svg new file mode 100644 index 0000000..191b9e5 --- /dev/null +++ b/src/main/resources/persona/field/red-computer.svg @@ -0,0 +1,119 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/persona/field/red-sofa.svg b/src/main/resources/persona/field/red-sofa.svg new file mode 100644 index 0000000..1e39b7d --- /dev/null +++ b/src/main/resources/persona/field/red-sofa.svg @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +