Skip to content

Commit

Permalink
release: 1.0.9 (#232)
Browse files Browse the repository at this point in the history
  • Loading branch information
devxb authored Jan 6, 2025
2 parents ab3b345 + a8e4801 commit 90276b6
Show file tree
Hide file tree
Showing 10 changed files with 341 additions and 10 deletions.
47 changes: 46 additions & 1 deletion src/main/kotlin/org/gitanimals/core/FieldType.kt
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,52 @@ enum class FieldType {

override fun drawBorder(): String =
"<rect x=\"0.5\" y=\"0.5\" width=\"599\" height=\"299\" rx=\"4.5\" stroke=\"#D9D9D9\" fill=\"none\"/>"
}
},
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 =
"""
<rect x="0.5" y="0.5" width="599" height="299" rx="4.5" fill="#F5EDFD"/>
$folderFieldSvg
"""

override fun drawBorder(): String =
"<rect x=\"0.5\" y=\"0.5\" width=\"599\" height=\"299\" rx=\"4.5\" stroke=\"#F5EDFD\" fill=\"none\"/>"
},
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 =
"""
<rect x="0.5" y="0.5" width="599" height="299" rx="4.5" fill="#DAFDEC"/>
$redComputerFieldSvg
"""

override fun drawBorder(): String =
"<rect x=\"0.5\" y=\"0.5\" width=\"599\" height=\"299\" rx=\"4.5\" stroke=\"#DAFDEC\" fill=\"none\"/>"
},
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 =
"""
<rect x="0.5" y="0.5" width="599" height="299" rx="4.5" fill="#C4F2F7"/>
$redSofaFieldSvg
"""

override fun drawBorder(): String =
"<rect x=\"0.5\" y=\"0.5\" width=\"599\" height=\"299\" rx=\"4.5\" stroke=\"#C4F2F7\" fill=\"none\"/>"
},
;

abstract fun loadComponent(name: String, commit: Long): String
Expand Down
9 changes: 9 additions & 0 deletions src/main/kotlin/org/gitanimals/core/Svgs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand Down
9 changes: 5 additions & 4 deletions src/main/kotlin/org/gitanimals/guild/app/CreateGuildFacade.kt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -19,17 +20,17 @@ class CreateGuildFacade(
orchestratorFactory: OrchestratorFactory,
) {

private lateinit var createGuildOrchestrator: Orchestrator<CreateGuildRequest, Unit>
private lateinit var createGuildOrchestrator: Orchestrator<CreateGuildRequest, Guild>

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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/org/gitanimals/guild/domain/GuildService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}
Expand All @@ -43,7 +43,7 @@ class GuildService(
autoJoin = autoJoin,
)

guildRepository.save(newGuild)
return guildRepository.save(newGuild)
}

@Transactional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
86 changes: 86 additions & 0 deletions src/main/resources/persona/field/folder.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 90276b6

Please sign in to comment.