From 32a955dd8e3f479fd993548d8e327fbe6beb11ac Mon Sep 17 00:00:00 2001 From: uuuuuuuk Date: Thu, 12 Oct 2023 11:56:02 +0900 Subject: [PATCH 1/7] =?UTF-8?q?:memo:=20PointResponseDto=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/data/response/PointResponseDto.kt | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 src/main/kotlin/andreas311/miso/domain/user/presentation/data/response/PointResponseDto.kt diff --git a/src/main/kotlin/andreas311/miso/domain/user/presentation/data/response/PointResponseDto.kt b/src/main/kotlin/andreas311/miso/domain/user/presentation/data/response/PointResponseDto.kt new file mode 100644 index 00000000..e1f2b21c --- /dev/null +++ b/src/main/kotlin/andreas311/miso/domain/user/presentation/data/response/PointResponseDto.kt @@ -0,0 +1,11 @@ +package andreas311.miso.domain.user.presentation.data.response + +import andreas311.miso.domain.user.entity.User + +data class PointResponseDto( + val point: Int +) { + constructor(user: User) : this( + point = user.point + ) +} From bd718266f3bd5c637e64f4155dac99e4664fc413 Mon Sep 17 00:00:00 2001 From: uuuuuuuk Date: Thu, 12 Oct 2023 11:56:24 +0900 Subject: [PATCH 2/7] =?UTF-8?q?:memo:=20ReadOnlyService=20=EC=BB=A4?= =?UTF-8?q?=EC=8A=A4=ED=85=80=20=EC=96=B4=EB=85=B8=ED=85=8C=EC=9D=B4?= =?UTF-8?q?=EC=85=98=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../andreas311/miso/global/annotation/ReadOnlyService.kt | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 src/main/kotlin/andreas311/miso/global/annotation/ReadOnlyService.kt diff --git a/src/main/kotlin/andreas311/miso/global/annotation/ReadOnlyService.kt b/src/main/kotlin/andreas311/miso/global/annotation/ReadOnlyService.kt new file mode 100644 index 00000000..b2a99eac --- /dev/null +++ b/src/main/kotlin/andreas311/miso/global/annotation/ReadOnlyService.kt @@ -0,0 +1,8 @@ +package andreas311.miso.global.annotation + +import org.springframework.stereotype.Service +import org.springframework.transaction.annotation.Transactional + +@Service +@Transactional(readOnly = true) +annotation class ReadOnlyService() From e5827c2f2635f3e15cdd2c6079d5443705fa7068 Mon Sep 17 00:00:00 2001 From: uuuuuuuk Date: Thu, 12 Oct 2023 11:58:53 +0900 Subject: [PATCH 3/7] =?UTF-8?q?:memo:=20Item=20=EC=97=94=ED=8B=B0=ED=8B=B0?= =?UTF-8?q?=EC=97=90=20User=20=EB=A7=A4=ED=95=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/kotlin/andreas311/miso/domain/item/entity/Item.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/andreas311/miso/domain/item/entity/Item.kt b/src/main/kotlin/andreas311/miso/domain/item/entity/Item.kt index a07a236c..dfa2b6c6 100644 --- a/src/main/kotlin/andreas311/miso/domain/item/entity/Item.kt +++ b/src/main/kotlin/andreas311/miso/domain/item/entity/Item.kt @@ -1,5 +1,6 @@ package andreas311.miso.domain.item.entity +import andreas311.miso.domain.user.entity.User import org.hibernate.annotations.DynamicUpdate import javax.persistence.* @@ -22,5 +23,9 @@ class Item( val content: String, @Column(name = "image_url") - val imageUrl: String + val imageUrl: String, + + @ManyToOne + @JoinColumn(name = "user_id") + val user: User ) \ No newline at end of file From 0760eb8c9d6425dd33c8c6f4d1ef87055e602288 Mon Sep 17 00:00:00 2001 From: uuuuuuuk Date: Thu, 12 Oct 2023 12:00:03 +0900 Subject: [PATCH 4/7] =?UTF-8?q?:sparkles:=20=EB=82=B4=20=ED=8F=AC=EC=9D=B8?= =?UTF-8?q?=ED=8A=B8=20=ED=98=84=ED=99=A9=20api=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/user/service/GetPointService.kt | 8 ++++++++ .../user/service/impl/GetPointServiceImpl.kt | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 src/main/kotlin/andreas311/miso/domain/user/service/GetPointService.kt create mode 100644 src/main/kotlin/andreas311/miso/domain/user/service/impl/GetPointServiceImpl.kt diff --git a/src/main/kotlin/andreas311/miso/domain/user/service/GetPointService.kt b/src/main/kotlin/andreas311/miso/domain/user/service/GetPointService.kt new file mode 100644 index 00000000..01857cab --- /dev/null +++ b/src/main/kotlin/andreas311/miso/domain/user/service/GetPointService.kt @@ -0,0 +1,8 @@ +package andreas311.miso.domain.user.service + +import andreas311.miso.domain.user.presentation.data.response.PointResponseDto + +interface GetPointService { + + fun execute(): PointResponseDto +} \ No newline at end of file diff --git a/src/main/kotlin/andreas311/miso/domain/user/service/impl/GetPointServiceImpl.kt b/src/main/kotlin/andreas311/miso/domain/user/service/impl/GetPointServiceImpl.kt new file mode 100644 index 00000000..e6db8f4d --- /dev/null +++ b/src/main/kotlin/andreas311/miso/domain/user/service/impl/GetPointServiceImpl.kt @@ -0,0 +1,19 @@ +package andreas311.miso.domain.user.service.impl + +import andreas311.miso.domain.user.presentation.data.response.PointResponseDto +import andreas311.miso.domain.user.service.GetPointService +import andreas311.miso.global.annotation.ReadOnlyService +import andreas311.miso.global.util.UserUtil + +@ReadOnlyService +class GetPointServiceImpl( + private val userUtil: UserUtil +) : GetPointService { + + override fun execute(): PointResponseDto { + + val user = userUtil.currentUser() + + return PointResponseDto(user) + } +} \ No newline at end of file From 885eaf344eb9f79b70de1399059b74230348e229 Mon Sep 17 00:00:00 2001 From: uuuuuuuk Date: Thu, 12 Oct 2023 12:00:16 +0900 Subject: [PATCH 5/7] =?UTF-8?q?:sparkles:=20UserController=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1=20=EB=B0=8F=20=EB=82=B4=20=ED=8F=AC=EC=9D=B8=ED=8A=B8?= =?UTF-8?q?=20=ED=98=84=ED=99=A9=20api=20=EB=93=B1=EB=A1=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../user/presentation/UserController.kt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/main/kotlin/andreas311/miso/domain/user/presentation/UserController.kt diff --git a/src/main/kotlin/andreas311/miso/domain/user/presentation/UserController.kt b/src/main/kotlin/andreas311/miso/domain/user/presentation/UserController.kt new file mode 100644 index 00000000..851c37e9 --- /dev/null +++ b/src/main/kotlin/andreas311/miso/domain/user/presentation/UserController.kt @@ -0,0 +1,19 @@ +package andreas311.miso.domain.user.presentation + +import andreas311.miso.domain.user.presentation.data.response.PointResponseDto +import andreas311.miso.domain.user.service.GetPointService +import andreas311.miso.global.annotation.RequestController +import org.springframework.http.HttpStatus +import org.springframework.http.ResponseEntity +import org.springframework.web.bind.annotation.GetMapping + +@RequestController("/user") +class UserController( + private val getPointService: GetPointService +) { + + @GetMapping + fun point(): ResponseEntity = + getPointService.execute() + .let { ResponseEntity.status(HttpStatus.OK).body(it) } +} \ No newline at end of file From a09281c5713a2370abbc72e162c587b2737cf0fa Mon Sep 17 00:00:00 2001 From: uuuuuuuk Date: Thu, 12 Oct 2023 12:00:45 +0900 Subject: [PATCH 6/7] =?UTF-8?q?:memo:=20DetailItemServiceImpl=20=EC=9D=98?= =?UTF-8?q?=20=EC=96=B4=EB=85=B8=ED=85=8C=EC=9D=B4=EC=85=98=20=EB=B0=8F=20?= =?UTF-8?q?=EC=A4=84=20=EB=9D=84=EC=9B=80=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../miso/domain/item/service/impl/DetailItemServiceImpl.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/andreas311/miso/domain/item/service/impl/DetailItemServiceImpl.kt b/src/main/kotlin/andreas311/miso/domain/item/service/impl/DetailItemServiceImpl.kt index 05455715..4f3aaf66 100644 --- a/src/main/kotlin/andreas311/miso/domain/item/service/impl/DetailItemServiceImpl.kt +++ b/src/main/kotlin/andreas311/miso/domain/item/service/impl/DetailItemServiceImpl.kt @@ -4,13 +4,14 @@ import andreas311.miso.domain.item.exception.ItemNotFoundException import andreas311.miso.domain.item.presentation.data.response.DetailItemResponseDto import andreas311.miso.domain.item.repository.ItemRepository import andreas311.miso.domain.item.service.DetailItemService -import andreas311.miso.global.annotation.RollbackService +import andreas311.miso.global.annotation.ReadOnlyService import org.springframework.data.repository.findByIdOrNull -@RollbackService +@ReadOnlyService class DetailItemServiceImpl( private val itemRepository: ItemRepository ) : DetailItemService { + override fun execute(id: Long): DetailItemResponseDto { val item = itemRepository.findByIdOrNull(id) From 7956330bf2a222abd8433e092c7b2c607f31a072 Mon Sep 17 00:00:00 2001 From: uuuuuuuk Date: Thu, 12 Oct 2023 12:01:12 +0900 Subject: [PATCH 7/7] =?UTF-8?q?:sparkles:=20SecurityConfig=20=EC=97=90=20?= =?UTF-8?q?=EB=82=B4=20=ED=8F=AC=EC=9D=B8=ED=8A=B8=20=ED=98=84=ED=99=A9=20?= =?UTF-8?q?api=20=EA=B6=8C=ED=95=9C=20=EC=84=A4=EC=A0=95=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/andreas311/miso/global/security/SecurityConfig.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/kotlin/andreas311/miso/global/security/SecurityConfig.kt b/src/main/kotlin/andreas311/miso/global/security/SecurityConfig.kt index cb43c0be..eb862620 100644 --- a/src/main/kotlin/andreas311/miso/global/security/SecurityConfig.kt +++ b/src/main/kotlin/andreas311/miso/global/security/SecurityConfig.kt @@ -47,6 +47,8 @@ class SecurityConfig( .antMatchers(HttpMethod.GET, "/item/{id}").authenticated() + .antMatchers(HttpMethod.GET, "/user").authenticated() + .anyRequest().denyAll() .and() .exceptionHandling()