From cf8e1ba1f3377a8ebeadf57548ef01abae971a22 Mon Sep 17 00:00:00 2001 From: xb205 <62425964+devxb@users.noreply.github.com> Date: Fri, 12 Apr 2024 22:34:52 +0900 Subject: [PATCH 01/12] =?UTF-8?q?docs:=20line=20mode=EB=A5=BC=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=ED=95=9C=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index d5c30e1..070349c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,10 @@ + + + + ##
@@ -26,7 +30,15 @@ ## 빠르게 사용하기 -아래의 MARKDOWN 혹은 HTML 방식중 하나를 붙여넣기 하는것으로 쉽게 적용할 수 있어요. +아래의 MARKDOWN 혹은 HTML 중 하나를 깃허브 Readme 에 붙여넣기 하는것으로 쉽게 적용할 수 있어요. + +> [!IMPORTANT] +> {username} 은 자신의 깃허브 닉네임 (ex. devxb) 으로 변경해주세요. +> 이때, {username} 은 반드시 자신의 깃허브 이름이 들어가야 합니다. + +### farm mode + +farm mode는 갖고있는 모든 동물과 추가적인 정보를 보여줘요. ```markdown [![gitanimals](https://render.gitanimals.org/farms/{username})](https://github.com/devxb/gitanimals) @@ -37,12 +49,21 @@ ``` - -> [!IMPORTANT] -> {username} 은 자신의 깃허브 닉네임 (ex. devxb) 으로 변경해주세요. -> 이때, {username} 은 반드시 자신의 깃허브 이름이 들어가야 합니다. +### line mode + +line mode는 자신이 갖고있는 펫중 하나를 지정해서, 길게 움직이게 해요. +Readme에서 펫을 돌아다니게 하는데 사용할 수 있어요. + +```markdown +[![gitanimals](https://render.gitanimals.org/farms/{username}?mode=line)](https://github.com/devxb/gitanimals) +``` +```html + + + +``` ## TIPS From d574e8f04e760706499b20142f2b4bdd03cfacd4 Mon Sep 17 00:00:00 2001 From: xb205 <62425964+devxb@users.noreply.github.com> Date: Fri, 12 Apr 2024 22:35:52 +0900 Subject: [PATCH 02/12] =?UTF-8?q?docs:=20=ED=8E=AB=EC=9D=98=20=EC=9C=84?= =?UTF-8?q?=EC=B9=98=EB=A5=BC=20=EB=B3=80=EA=B2=BD=ED=95=9C=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 070349c..54e5b3a 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,11 @@ +## -## -
⭐스타를 눌러주세요 개발에 큰 도움이 됩니다!⭐️

Press star

From f5890707e10d64098ecc91b37f6f391d7c904eee Mon Sep 17 00:00:00 2001 From: xb205 <62425964+devxb@users.noreply.github.com> Date: Fri, 12 Apr 2024 22:41:15 +0900 Subject: [PATCH 03/12] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 54e5b3a..bc6d1b7 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,7 @@ farm mode는 갖고있는 모든 동물과 추가적인 정보를 보여줘요. ### line mode line mode는 자신이 갖고있는 펫중 하나를 지정해서, 길게 움직이게 해요. +이때, img의 width와 height를 조절해서 펫의 이동영역을 조절할 수 있어요. Readme에서 펫을 돌아다니게 하는데 사용할 수 있어요. ```markdown @@ -60,7 +61,7 @@ Readme에서 펫을 돌아다니게 하는데 사용할 수 있어요. ```html - + ``` From 6f12a276e44ecb8535809b1be050d96231ebea34 Mon Sep 17 00:00:00 2001 From: xb205 <62425964+devxb@users.noreply.github.com> Date: Fri, 12 Apr 2024 22:44:42 +0900 Subject: [PATCH 04/12] =?UTF-8?q?docs:=20line=20mode=EC=9D=98=20=EC=84=A4?= =?UTF-8?q?=EB=AA=85=EC=9D=84=20=EC=9E=90=EC=84=B8=ED=95=98=EA=B2=8C=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=ED=95=9C=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index bc6d1b7..e4d3b97 100644 --- a/README.md +++ b/README.md @@ -51,9 +51,12 @@ farm mode는 갖고있는 모든 동물과 추가적인 정보를 보여줘요. ### line mode -line mode는 자신이 갖고있는 펫중 하나를 지정해서, 길게 움직이게 해요. -이때, img의 width와 height를 조절해서 펫의 이동영역을 조절할 수 있어요. -Readme에서 펫을 돌아다니게 하는데 사용할 수 있어요. +line mode는 자신이 갖고있는 펫중 하나를 지정해서, 지정한 width, height범위에서 움직이게 해요. +펫이 Readme에서 자유롭게 움직이는모습을 표현할 수 있어요. +> [!TIP] +> **Img의 width와 height를 조절해서 펫의 이동영역을 조절할 수 있어요.** +> width를 길게 height를 작게하면 (width = 1000, height = 60) 가로로 길게 움직이게 할 수 있어요. +> 반대로, width를 작게 height를 길게하면 (width = 60, height = 1000) 세로로 길게 움직이게 할 수 있어요. ```markdown [![gitanimals](https://render.gitanimals.org/farms/{username}?mode=line)](https://github.com/devxb/gitanimals) From 4b9cc0ffb1a597c1a5d2300c916d9220c541aaff Mon Sep 17 00:00:00 2001 From: xb205 <62425964+devxb@users.noreply.github.com> Date: Fri, 12 Apr 2024 22:34:52 +0900 Subject: [PATCH 05/12] =?UTF-8?q?docs:=20line=20mode=EB=A5=BC=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=ED=95=9C=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index d5c30e1..070349c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,10 @@ + + + + ##
@@ -26,7 +30,15 @@ ## 빠르게 사용하기 -아래의 MARKDOWN 혹은 HTML 방식중 하나를 붙여넣기 하는것으로 쉽게 적용할 수 있어요. +아래의 MARKDOWN 혹은 HTML 중 하나를 깃허브 Readme 에 붙여넣기 하는것으로 쉽게 적용할 수 있어요. + +> [!IMPORTANT] +> {username} 은 자신의 깃허브 닉네임 (ex. devxb) 으로 변경해주세요. +> 이때, {username} 은 반드시 자신의 깃허브 이름이 들어가야 합니다. + +### farm mode + +farm mode는 갖고있는 모든 동물과 추가적인 정보를 보여줘요. ```markdown [![gitanimals](https://render.gitanimals.org/farms/{username})](https://github.com/devxb/gitanimals) @@ -37,12 +49,21 @@ ``` - -> [!IMPORTANT] -> {username} 은 자신의 깃허브 닉네임 (ex. devxb) 으로 변경해주세요. -> 이때, {username} 은 반드시 자신의 깃허브 이름이 들어가야 합니다. +### line mode + +line mode는 자신이 갖고있는 펫중 하나를 지정해서, 길게 움직이게 해요. +Readme에서 펫을 돌아다니게 하는데 사용할 수 있어요. + +```markdown +[![gitanimals](https://render.gitanimals.org/farms/{username}?mode=line)](https://github.com/devxb/gitanimals) +``` +```html + + + +``` ## TIPS From acc7fcc19cc1fc31000ac43e04c586ef5bafb21f Mon Sep 17 00:00:00 2001 From: xb205 <62425964+devxb@users.noreply.github.com> Date: Fri, 12 Apr 2024 22:35:52 +0900 Subject: [PATCH 06/12] =?UTF-8?q?docs:=20=ED=8E=AB=EC=9D=98=20=EC=9C=84?= =?UTF-8?q?=EC=B9=98=EB=A5=BC=20=EB=B3=80=EA=B2=BD=ED=95=9C=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 070349c..54e5b3a 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,11 @@ +## -## -
⭐스타를 눌러주세요 개발에 큰 도움이 됩니다!⭐️

Press star

From 301d4576521e95f06f321217d03bb576e57bcdfc Mon Sep 17 00:00:00 2001 From: xb205 <62425964+devxb@users.noreply.github.com> Date: Fri, 12 Apr 2024 22:41:15 +0900 Subject: [PATCH 07/12] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 54e5b3a..bc6d1b7 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,7 @@ farm mode는 갖고있는 모든 동물과 추가적인 정보를 보여줘요. ### line mode line mode는 자신이 갖고있는 펫중 하나를 지정해서, 길게 움직이게 해요. +이때, img의 width와 height를 조절해서 펫의 이동영역을 조절할 수 있어요. Readme에서 펫을 돌아다니게 하는데 사용할 수 있어요. ```markdown @@ -60,7 +61,7 @@ Readme에서 펫을 돌아다니게 하는데 사용할 수 있어요. ```html - + ``` From 2d78151ec0a6bb57f10b5b8b29db60f384df1d15 Mon Sep 17 00:00:00 2001 From: xb205 <62425964+devxb@users.noreply.github.com> Date: Fri, 12 Apr 2024 22:44:42 +0900 Subject: [PATCH 08/12] =?UTF-8?q?docs:=20line=20mode=EC=9D=98=20=EC=84=A4?= =?UTF-8?q?=EB=AA=85=EC=9D=84=20=EC=9E=90=EC=84=B8=ED=95=98=EA=B2=8C=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=ED=95=9C=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index bc6d1b7..e4d3b97 100644 --- a/README.md +++ b/README.md @@ -51,9 +51,12 @@ farm mode는 갖고있는 모든 동물과 추가적인 정보를 보여줘요. ### line mode -line mode는 자신이 갖고있는 펫중 하나를 지정해서, 길게 움직이게 해요. -이때, img의 width와 height를 조절해서 펫의 이동영역을 조절할 수 있어요. -Readme에서 펫을 돌아다니게 하는데 사용할 수 있어요. +line mode는 자신이 갖고있는 펫중 하나를 지정해서, 지정한 width, height범위에서 움직이게 해요. +펫이 Readme에서 자유롭게 움직이는모습을 표현할 수 있어요. +> [!TIP] +> **Img의 width와 height를 조절해서 펫의 이동영역을 조절할 수 있어요.** +> width를 길게 height를 작게하면 (width = 1000, height = 60) 가로로 길게 움직이게 할 수 있어요. +> 반대로, width를 작게 height를 길게하면 (width = 60, height = 1000) 세로로 길게 움직이게 할 수 있어요. ```markdown [![gitanimals](https://render.gitanimals.org/farms/{username}?mode=line)](https://github.com/devxb/gitanimals) From 4805471c3816aeb5bc875b6e622072a89a934816 Mon Sep 17 00:00:00 2001 From: devxb Date: Fri, 12 Apr 2024 23:00:30 +0900 Subject: [PATCH 09/12] =?UTF-8?q?refactor:=20line=20mode=EC=9D=98=20url=20?= =?UTF-8?q?path=EB=A5=BC=20=EB=B3=80=EA=B2=BD=ED=95=9C=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gitanimals/render/app/AnimationFacade.kt | 24 +++++++++++++++---- .../render/controller/AnimationController.kt | 19 ++++++++++----- .../gitanimals/render/domain/AnimationMode.kt | 11 --------- .../org/gitanimals/render/domain/User.kt | 5 ++-- .../gitanimals/render/domain/UserService.kt | 9 ++++--- 5 files changed, 41 insertions(+), 27 deletions(-) delete mode 100644 src/main/kotlin/org/gitanimals/render/domain/AnimationMode.kt diff --git a/src/main/kotlin/org/gitanimals/render/app/AnimationFacade.kt b/src/main/kotlin/org/gitanimals/render/app/AnimationFacade.kt index 2945b41..41c737f 100644 --- a/src/main/kotlin/org/gitanimals/render/app/AnimationFacade.kt +++ b/src/main/kotlin/org/gitanimals/render/app/AnimationFacade.kt @@ -1,7 +1,6 @@ package org.gitanimals.render.app import jakarta.annotation.PostConstruct -import org.gitanimals.render.domain.AnimationMode import org.gitanimals.render.domain.User import org.gitanimals.render.domain.UserService import org.gitanimals.render.domain.event.Visited @@ -18,11 +17,10 @@ class AnimationFacade( private lateinit var registerNewUserOrchestrator: Orchestrator - fun getSvgAnimation(username: String, mode: String): String { - val animationMode = AnimationMode.valueOf(mode.uppercase()) + fun getFarmAnimation(username: String): String { return when (userService.existsByName(username)) { true -> { - val svgAnimation = userService.getSvgAnimationByUsername(username, animationMode) + val svgAnimation = userService.getFarmAnimationByUsername(username) sagaManager.startSync(Visited(username)) svgAnimation } @@ -30,7 +28,23 @@ class AnimationFacade( false -> { registerNewUserOrchestrator.sagaSync(10000, username) - userService.getSvgAnimationByUsername(username, animationMode) + userService.getFarmAnimationByUsername(username) + } + } + } + + fun getLineAnimation(username: String, personaId: Long): String { + return when(userService.existsByName(username)) { + true -> { + val svgAnimation = userService.getLineAnimationByUsername(username, personaId) + sagaManager.startSync(Visited(username)) + svgAnimation + } + + false -> { + registerNewUserOrchestrator.sagaSync(10000, username) + + userService.getLineAnimationByUsername(username ,personaId) } } } diff --git a/src/main/kotlin/org/gitanimals/render/controller/AnimationController.kt b/src/main/kotlin/org/gitanimals/render/controller/AnimationController.kt index 72665bc..f407adf 100644 --- a/src/main/kotlin/org/gitanimals/render/controller/AnimationController.kt +++ b/src/main/kotlin/org/gitanimals/render/controller/AnimationController.kt @@ -4,24 +4,31 @@ import jakarta.servlet.http.HttpServletResponse import org.gitanimals.render.app.AnimationFacade import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.PathVariable -import org.springframework.web.bind.annotation.RequestMapping import org.springframework.web.bind.annotation.RequestParam import org.springframework.web.bind.annotation.RestController @RestController -@RequestMapping("/farms") class AnimationController( private val animationFacade: AnimationFacade, ) { - @GetMapping(value = ["/{username}"], produces = ["image/svg+xml"]) - fun getSvgAnimation( + @GetMapping(value = ["/farms/{username}"], produces = ["image/svg+xml"]) + fun getFarmSvgAnimation( @PathVariable("username") username: String, - @RequestParam(name = "mode", defaultValue = "FARM") mode: String, response: HttpServletResponse ): String { response.noCache() - return animationFacade.getSvgAnimation(username, mode) + return animationFacade.getFarmAnimation(username) + } + + @GetMapping(value = ["/lines/{username}"], produces = ["image/svg+xml"]) + fun getLineSvgAnimation( + @PathVariable("username") username: String, + @RequestParam(name = "pet-id", defaultValue = "0") personaId: Long, + response: HttpServletResponse, + ): String { + response.noCache() + return animationFacade.getLineAnimation(username, personaId) } fun HttpServletResponse.noCache(): HttpServletResponse { diff --git a/src/main/kotlin/org/gitanimals/render/domain/AnimationMode.kt b/src/main/kotlin/org/gitanimals/render/domain/AnimationMode.kt deleted file mode 100644 index c2367e5..0000000 --- a/src/main/kotlin/org/gitanimals/render/domain/AnimationMode.kt +++ /dev/null @@ -1,11 +0,0 @@ -package org.gitanimals.render.domain - -enum class AnimationMode( - private val func: (User) -> String, -) { - - FARM({ it.createFarmAnimation() }), - LINE({ it.createLineAnimation() }), - ; - fun createAnimation(user: User): String = func.invoke(user) -} diff --git a/src/main/kotlin/org/gitanimals/render/domain/User.kt b/src/main/kotlin/org/gitanimals/render/domain/User.kt index 95500be..8eae70e 100644 --- a/src/main/kotlin/org/gitanimals/render/domain/User.kt +++ b/src/main/kotlin/org/gitanimals/render/domain/User.kt @@ -101,10 +101,11 @@ class User( visit += 1 } - fun createLineAnimation(): String { + fun createLineAnimation(personaId: Long): String { val builder = StringBuilder().openLine() - val persona = personas.first() + val persona = personas.find { it.id!! >= personaId } + ?: throw IllegalArgumentException("Cannot find persona by id \"$personaId\"") builder.append(persona.toSvg()) return builder.closeSvg() diff --git a/src/main/kotlin/org/gitanimals/render/domain/UserService.kt b/src/main/kotlin/org/gitanimals/render/domain/UserService.kt index 3a10793..9955a90 100644 --- a/src/main/kotlin/org/gitanimals/render/domain/UserService.kt +++ b/src/main/kotlin/org/gitanimals/render/domain/UserService.kt @@ -13,9 +13,12 @@ class UserService( fun existsByName(name: String): Boolean = userRepository.existsByName(name) - fun getSvgAnimationByUsername(username: String, mode: AnimationMode): String { - val user = getUserByName(username) - return mode.createAnimation(user) + fun getFarmAnimationByUsername(username: String): String { + return getUserByName(username).createFarmAnimation() + } + + fun getLineAnimationByUsername(username: String, personaId: Long): String { + return getUserByName(username).createLineAnimation(personaId) } @Retryable(retryFor = [OptimisticLockingFailureException::class], maxAttempts = 10) From 6dce1062907d3f0183114114c4d14a29b813d290 Mon Sep 17 00:00:00 2001 From: devxb Date: Fri, 12 Apr 2024 23:01:37 +0900 Subject: [PATCH 10/12] =?UTF-8?q?refactor:=20=EC=9B=80=EC=A7=81=EC=9D=B4?= =?UTF-8?q?=EB=8A=94=20y=EB=B2=94=EC=9C=84=EB=A5=BC=2070=20->=2090=20?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EB=B3=80=EA=B2=BD=ED=95=9C=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/kotlin/org/gitanimals/render/domain/PersonaType.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/org/gitanimals/render/domain/PersonaType.kt b/src/main/kotlin/org/gitanimals/render/domain/PersonaType.kt index f7d55bd..f4f42f5 100644 --- a/src/main/kotlin/org/gitanimals/render/domain/PersonaType.kt +++ b/src/main/kotlin/org/gitanimals/render/domain/PersonaType.kt @@ -953,7 +953,7 @@ enum class PersonaType(private val weight: Double) { duration: String, personaWidth: Long, ): StringBuilder { - var currentY = Random.nextInt(10, 70) + var currentY = Random.nextInt(10, 90) var currentX = Random.nextInt(10, 90) var currentAngle = (Random.nextDouble() * 10).toInt() var currentScale = Random.nextInt(0, 2) - 1 @@ -973,7 +973,7 @@ enum class PersonaType(private val weight: Double) { val beforeAnimationPercentage = animationPercentage animationPercentage += Random.nextInt(2, 6) val nextY = - Random.nextInt(max(0, min(79, currentY - speed)), min(70, currentY + speed)) + Random.nextInt(max(10, min(79, currentY - speed)), min(80, currentY + speed)) val nextX = Random.nextInt(max(10, min(79, currentX - speed)), min(80, currentX + speed)) val nextAngle = (atan2( From 061e96b704c86af80ebac870b17ae763a54f8344 Mon Sep 17 00:00:00 2001 From: devxb Date: Fri, 12 Apr 2024 23:13:07 +0900 Subject: [PATCH 11/12] =?UTF-8?q?feat:=20user=EC=9D=98=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=EB=A5=BC=20=EC=A1=B0=ED=9A=8C=ED=95=A0=20=EC=88=98=20?= =?UTF-8?q?=EC=9E=88=EB=8A=94=20api=20endpoint=EB=A5=BC=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=ED=95=9C=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../render/controller/PersonaController.kt | 18 +++++++++++++++ .../controller/response/PersonaResponse.kt | 9 ++++++++ .../controller/response/UserResponse.kt | 22 +++++++++++++++++++ .../org/gitanimals/render/domain/Persona.kt | 2 ++ .../org/gitanimals/render/domain/User.kt | 2 +- 5 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 src/main/kotlin/org/gitanimals/render/controller/PersonaController.kt create mode 100644 src/main/kotlin/org/gitanimals/render/controller/response/PersonaResponse.kt create mode 100644 src/main/kotlin/org/gitanimals/render/controller/response/UserResponse.kt diff --git a/src/main/kotlin/org/gitanimals/render/controller/PersonaController.kt b/src/main/kotlin/org/gitanimals/render/controller/PersonaController.kt new file mode 100644 index 0000000..2439788 --- /dev/null +++ b/src/main/kotlin/org/gitanimals/render/controller/PersonaController.kt @@ -0,0 +1,18 @@ +package org.gitanimals.render.controller + +import org.gitanimals.render.controller.response.UserResponse +import org.gitanimals.render.domain.UserService +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.PathVariable +import org.springframework.web.bind.annotation.RestController + +@RestController +class PersonaController( + private val userService: UserService +) { + + @GetMapping("/users/{username}") + fun getUserByName(@PathVariable("username") username: String): UserResponse { + return UserResponse.from(userService.getUserByName(username)) + } +} diff --git a/src/main/kotlin/org/gitanimals/render/controller/response/PersonaResponse.kt b/src/main/kotlin/org/gitanimals/render/controller/response/PersonaResponse.kt new file mode 100644 index 0000000..9c66209 --- /dev/null +++ b/src/main/kotlin/org/gitanimals/render/controller/response/PersonaResponse.kt @@ -0,0 +1,9 @@ +package org.gitanimals.render.controller.response + +import org.gitanimals.render.domain.PersonaType + +data class PersonaResponse( + val id: String, + val type: PersonaType, + val level: String, +) diff --git a/src/main/kotlin/org/gitanimals/render/controller/response/UserResponse.kt b/src/main/kotlin/org/gitanimals/render/controller/response/UserResponse.kt new file mode 100644 index 0000000..a6eac7e --- /dev/null +++ b/src/main/kotlin/org/gitanimals/render/controller/response/UserResponse.kt @@ -0,0 +1,22 @@ +package org.gitanimals.render.controller.response + +import org.gitanimals.render.domain.User + +data class UserResponse( + val id: String, + val name: String, + private val personas: List, +) { + + companion object { + fun from(user: User): UserResponse { + return UserResponse( + user.id.toString(), + user.name, + user.personas.map { + PersonaResponse(it.id.toString(), it.type, it.level().toString()) + }.toList() + ) + } + } +} diff --git a/src/main/kotlin/org/gitanimals/render/domain/Persona.kt b/src/main/kotlin/org/gitanimals/render/domain/Persona.kt index f8f84e3..149ae13 100644 --- a/src/main/kotlin/org/gitanimals/render/domain/Persona.kt +++ b/src/main/kotlin/org/gitanimals/render/domain/Persona.kt @@ -32,4 +32,6 @@ class Persona( fun toSvg(): String = type.load(this) + + fun level(): Long = level.value } diff --git a/src/main/kotlin/org/gitanimals/render/domain/User.kt b/src/main/kotlin/org/gitanimals/render/domain/User.kt index 8eae70e..32eafb2 100644 --- a/src/main/kotlin/org/gitanimals/render/domain/User.kt +++ b/src/main/kotlin/org/gitanimals/render/domain/User.kt @@ -25,7 +25,7 @@ class User( val name: String, @OneToMany(mappedBy = "user", fetch = FetchType.LAZY, cascade = [CascadeType.ALL]) - private val personas: MutableList = mutableListOf(), + val personas: MutableList = mutableListOf(), @BatchSize(size = 20) @ElementCollection(fetch = FetchType.LAZY) From 16a7e2ec8efafaf95cab29ee4e4073ab1ceb64d3 Mon Sep 17 00:00:00 2001 From: devxb Date: Fri, 12 Apr 2024 23:18:55 +0900 Subject: [PATCH 12/12] =?UTF-8?q?docs:=20Readme.md=EC=9D=98=20line-mode?= =?UTF-8?q?=EC=9D=98=20=EC=84=A4=EB=AA=85=EC=9D=84=20=EC=B6=94=EA=B0=80?= =?UTF-8?q?=ED=95=9C=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e4d3b97..b33ebc6 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ ## - +
@@ -52,7 +52,8 @@ farm mode는 갖고있는 모든 동물과 추가적인 정보를 보여줘요. ### line mode line mode는 자신이 갖고있는 펫중 하나를 지정해서, 지정한 width, height범위에서 움직이게 해요. -펫이 Readme에서 자유롭게 움직이는모습을 표현할 수 있어요. +펫이 Readme에서 자유롭게 움직이는모습을 표현할 수 있어요. +pet-id에 아무값도 입력하지 않으면, 첫번째 펫이 가져와져요. > [!TIP] > **Img의 width와 height를 조절해서 펫의 이동영역을 조절할 수 있어요.** > width를 길게 height를 작게하면 (width = 1000, height = 60) 가로로 길게 움직이게 할 수 있어요. @@ -64,7 +65,17 @@ line mode는 자신이 갖고있는 펫중 하나를 지정해서, 지정한 wid ```html - + + +``` + +펫은 다음 url을 웹에 요청 후, `$.personas.[].id` 에 해당하는 값을 url의 pet-id param에 입력하면서 변경할 수 있어요. +사용 가능한 펫을 확인하려면, `https://render.gitanimals.org/users/{username}` 을 url에 붙여넣으세요. +```html +예시) + + + ```