-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Pengoose <[email protected]>
- Loading branch information
1 parent
051de19
commit 5d9cadd
Showing
64 changed files
with
1,280 additions
and
1,103 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
2 changes: 1 addition & 1 deletion
2
...rg/gitanimals/guild/core/AggregateRoot.kt → ...tlin/org/gitanimals/core/AggregateRoot.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
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
2 changes: 1 addition & 1 deletion
2
.../org/gitanimals/guild/core/IdGenerator.kt → ...kotlin/org/gitanimals/core/IdGenerator.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,4 +1,4 @@ | ||
package org.gitanimals.guild.core | ||
package org.gitanimals.core | ||
|
||
import com.github.f4b6a3.tsid.TsidFactory | ||
|
||
|
2 changes: 1 addition & 1 deletion
2
...tlin/org/gitanimals/render/domain/Mode.kt → src/main/kotlin/org/gitanimals/core/Mode.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,4 +1,4 @@ | ||
package org.gitanimals.render.domain | ||
package org.gitanimals.core | ||
|
||
enum class Mode { | ||
FARM, | ||
|
1,262 changes: 631 additions & 631 deletions
1,262
...g/gitanimals/render/domain/PersonaType.kt → ...kotlin/org/gitanimals/core/PersonaType.kt
Large diffs are not rendered by default.
Oops, something went wrong.
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
2 changes: 1 addition & 1 deletion
2
...kotlin/org/gitanimals/guild/core/clock.kt → src/main/kotlin/org/gitanimals/core/clock.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,4 +1,4 @@ | ||
package org.gitanimals.guild.core | ||
package org.gitanimals.core | ||
|
||
import java.time.Clock | ||
import java.time.Instant | ||
|
2 changes: 1 addition & 1 deletion
2
...ller/interceptor/InterceptorConfigurer.kt → ...core/interceptor/InterceptorConfigurer.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
2 changes: 1 addition & 1 deletion
2
...ler/interceptor/InternalApiInterceptor.kt → ...ore/interceptor/InternalApiInterceptor.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
70 changes: 70 additions & 0 deletions
70
src/main/kotlin/org/gitanimals/guild/app/DrawGuildFacade.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,70 @@ | ||
package org.gitanimals.guild.app | ||
|
||
import org.gitanimals.core.Mode | ||
import org.gitanimals.guild.domain.Guild | ||
import org.gitanimals.guild.domain.GuildService | ||
import org.gitanimals.guild.domain.GuildService.Companion.loadMembers | ||
import org.springframework.beans.factory.annotation.Value | ||
import org.springframework.stereotype.Service | ||
|
||
@Service | ||
class DrawGuildFacade( | ||
private val renderApi: RenderApi, | ||
private val guildService: GuildService, | ||
@Value("\${internal.secret}") private val internalSecret: String, | ||
) { | ||
|
||
fun drawGuild(id: Long): String { | ||
val guild = guildService.getGuildById(id, loadMembers) | ||
val renderUsers = getRenderUsers(guild) | ||
|
||
val svgBuilder = StringBuilder().openGuild() | ||
.append(guild.getGuildFarmType().fillBackground()) | ||
|
||
val personaSvgs = renderUsers.map { user -> | ||
val persona = user.personas.firstOrNull() | ||
?: throw IllegalArgumentException("Cannot draw guild cause user does not have any persona. user: \"$user\"") | ||
|
||
persona.type.load( | ||
name = user.name, | ||
contributionCount = user.totalContributions.toLong(), | ||
animationId = persona.id.toLong(), | ||
level = persona.level.toLong(), | ||
mode = Mode.NAME_WITH_LEVEL, | ||
) | ||
} | ||
|
||
personaSvgs.forEach { svgBuilder.append(it) } | ||
|
||
return svgBuilder.append( | ||
guild.getGuildFarmType().loadComponent(guild.getTitle(), guild.getTotalContributions()) | ||
).append(guild.getGuildFarmType().drawBorder()) | ||
.closeGuild() | ||
} | ||
|
||
private fun getRenderUsers(guild: Guild): List<RenderApi.UserResponse> { | ||
val userIdAndPersonaIdRequests = guild.getMembers().map { | ||
RenderApi.UserIdAndPersonaIdRequest( | ||
personaId = it.personaId, | ||
userId = it.userId, | ||
) | ||
} + RenderApi.UserIdAndPersonaIdRequest( | ||
personaId = guild.getLeaderPersonaId(), | ||
userId = guild.getLeaderUserId(), | ||
) | ||
|
||
return renderApi.getAllPersonasByUserIdsAndPersonaIds( | ||
internalSecret = internalSecret, | ||
userIdAndPersonaIdRequests = userIdAndPersonaIdRequests, | ||
) | ||
} | ||
|
||
|
||
private fun StringBuilder.openGuild(): StringBuilder = | ||
this.append("<svg width=\"600\" height=\"300\" viewBox=\"0 0 600 300\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">") | ||
|
||
private fun StringBuilder.closeGuild(): String = this | ||
.append("</svg>") | ||
.toString() | ||
|
||
} |
25 changes: 0 additions & 25 deletions
25
src/main/kotlin/org/gitanimals/guild/app/DrawGuildProxy.kt
This file was deleted.
Oops, something went wrong.
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
2 changes: 1 addition & 1 deletion
2
src/main/kotlin/org/gitanimals/guild/app/event/InboxInputEvent.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
4 changes: 2 additions & 2 deletions
4
src/main/kotlin/org/gitanimals/guild/app/request/CreateGuildRequest.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,12 +1,12 @@ | ||
package org.gitanimals.guild.app.request | ||
|
||
import org.gitanimals.guild.domain.GuildFarmType | ||
import org.gitanimals.core.FieldType | ||
|
||
data class CreateGuildRequest( | ||
val title: String, | ||
val body: String, | ||
val guildIcon: String, | ||
val autoJoin: Boolean, | ||
val farmType: GuildFarmType, | ||
val farmType: FieldType, | ||
val personaId: String, | ||
) |
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
4 changes: 2 additions & 2 deletions
4
src/main/kotlin/org/gitanimals/guild/controller/response/GuildBackgroundResponse.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,7 +1,7 @@ | ||
package org.gitanimals.guild.controller.response | ||
|
||
import org.gitanimals.guild.domain.GuildFarmType | ||
import org.gitanimals.core.FieldType | ||
|
||
data class GuildBackgroundResponse( | ||
val backgrounds: List<GuildFarmType> | ||
val backgrounds: List<FieldType> | ||
) |
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
Oops, something went wrong.