From cebc72c2b7857b577f72406b7c7a91023d69f072 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=ED=83=9C=EC=9A=A9?= Date: Thu, 29 Feb 2024 02:42:14 +0900 Subject: [PATCH 01/10] =?UTF-8?q?fix:=20QueryDSL=20Config=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/kotlin/com/lovebird/domain/config/QuerydslConfig.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lovebird-domain/src/main/kotlin/com/lovebird/domain/config/QuerydslConfig.kt b/lovebird-domain/src/main/kotlin/com/lovebird/domain/config/QuerydslConfig.kt index 8a8fb64..bac057c 100644 --- a/lovebird-domain/src/main/kotlin/com/lovebird/domain/config/QuerydslConfig.kt +++ b/lovebird-domain/src/main/kotlin/com/lovebird/domain/config/QuerydslConfig.kt @@ -1,5 +1,6 @@ package com.lovebird.domain.config +import com.querydsl.jpa.JPQLTemplates import com.querydsl.jpa.impl.JPAQueryFactory import jakarta.persistence.EntityManager import jakarta.persistence.PersistenceContext @@ -13,6 +14,6 @@ class QuerydslConfig { @Bean fun queryFactory(): JPAQueryFactory { - return JPAQueryFactory(entityManager) + return JPAQueryFactory(JPQLTemplates.DEFAULT, entityManager) } } From b89619abe10db3574366de2a28ac4a7734f9045f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=ED=83=9C=EC=9A=A9?= Date: Thu, 29 Feb 2024 02:45:07 +0900 Subject: [PATCH 02/10] =?UTF-8?q?refactor:=20Diary=20=EC=BF=BC=EB=A6=AC=20?= =?UTF-8?q?transform=20=EB=B3=80=EA=B2=BD=20=EB=B0=8F=20DTO=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20=EB=B0=A9=EB=B2=95=20=EB=A6=AC=ED=8C=A9=ED=86=A0?= =?UTF-8?q?=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/dto/query/DiaryResponseParam.kt | 21 +++- .../repository/query/DiaryQueryRepository.kt | 108 +++++------------- 2 files changed, 45 insertions(+), 84 deletions(-) diff --git a/lovebird-domain/src/main/kotlin/com/lovebird/domain/dto/query/DiaryResponseParam.kt b/lovebird-domain/src/main/kotlin/com/lovebird/domain/dto/query/DiaryResponseParam.kt index 4bc8a8d..f8b735b 100644 --- a/lovebird-domain/src/main/kotlin/com/lovebird/domain/dto/query/DiaryResponseParam.kt +++ b/lovebird-domain/src/main/kotlin/com/lovebird/domain/dto/query/DiaryResponseParam.kt @@ -1,5 +1,6 @@ package com.lovebird.domain.dto.query +import com.lovebird.domain.entity.Diary import java.time.LocalDate data class DiaryResponseParam( @@ -9,5 +10,21 @@ data class DiaryResponseParam( val memoryDate: LocalDate, var place: String?, var content: String?, - val imageUrls: List -) + val imageUrls: List? +) { + + companion object { + fun of(transform: Map>): List { + return transform.entries.stream() + .map { entry -> DiaryResponseParam( + diaryId = entry.key.id!!, + userId = entry.key.user.id!!, + title = entry.key.title, + memoryDate = entry.key.memoryDate, + place = entry.key.place, + content = entry.key.content, + imageUrls = entry.value + ) }.toList() + } + } +} diff --git a/lovebird-domain/src/main/kotlin/com/lovebird/domain/repository/query/DiaryQueryRepository.kt b/lovebird-domain/src/main/kotlin/com/lovebird/domain/repository/query/DiaryQueryRepository.kt index e669439..7b44000 100644 --- a/lovebird-domain/src/main/kotlin/com/lovebird/domain/repository/query/DiaryQueryRepository.kt +++ b/lovebird-domain/src/main/kotlin/com/lovebird/domain/repository/query/DiaryQueryRepository.kt @@ -3,16 +3,12 @@ package com.lovebird.domain.repository.query import com.lovebird.domain.dto.query.DiaryListRequestParam import com.lovebird.domain.dto.query.DiaryResponseParam import com.lovebird.domain.dto.query.DiarySimpleRequestParam -import com.lovebird.domain.dto.query.DiarySimpleResponseParam -import com.lovebird.domain.dto.query.QDiarySimpleResponseParam +import com.lovebird.domain.entity.Diary import com.lovebird.domain.entity.QDiary -import com.lovebird.domain.entity.QDiary.diary -import com.lovebird.domain.entity.QDiaryImage.diaryImage -import com.lovebird.domain.entity.QUser.user -import com.querydsl.core.group.GroupBy.groupBy -import com.querydsl.core.group.GroupBy.list +import com.lovebird.domain.entity.QDiary.* +import com.lovebird.domain.entity.QDiaryImage.* +import com.querydsl.core.group.GroupBy.* import com.querydsl.core.types.OrderSpecifier -import com.querydsl.core.types.Projections import com.querydsl.core.types.dsl.BooleanExpression import com.querydsl.core.types.dsl.NumberPath import com.querydsl.jpa.impl.JPAQueryFactory @@ -25,9 +21,9 @@ class DiaryQueryRepository( ) { fun findBeforeNowUsingCursor(param: DiaryListRequestParam): List { - return queryFactory + val transform: Map> = queryFactory .from(diary) - .innerJoin(diary.user) + .leftJoin(diary.diaryImages, diaryImage) .where( eqCouple(param.userId, param.partnerId), eqMemoryDateAndGtDiaryId(param.memoryDate, param.diaryId), @@ -35,32 +31,15 @@ class DiaryQueryRepository( ) .orderBy(descMemoryDate(), ascDiaryId()) .limit(param.pageSize) - .transform( - groupBy(diary.id) - .list( - Projections.constructor( - DiaryResponseParam::class.java, - diary.id, - user.id, - diary.title, - diary.memoryDate, - diary.place, - diary.content, - list( - Projections.constructor( - String::class.java, - diaryImage.imageUrl - ) - ) - ) - ) - ) + .transform(groupBy(diary).`as`(list(diaryImage.imageUrl))) + + return DiaryResponseParam.of(transform) } fun findAfterNowUsingCursor(param: DiaryListRequestParam): List { - return queryFactory + val transform: Map> = queryFactory .from(diary) - .innerJoin(diary.user) + .leftJoin(diary.diaryImages, diaryImage) .where( eqCouple(param.userId, param.partnerId), eqMemoryDateAndGtDiaryId(param.memoryDate, param.diaryId), @@ -68,66 +47,31 @@ class DiaryQueryRepository( ) .orderBy(ascMemoryDate(), ascDiaryId()) .limit(param.pageSize) - .transform( - groupBy(diary.id) - .list( - Projections.constructor( - DiaryResponseParam::class.java, - diary.id, - user.id, - diary.title, - diary.memoryDate, - diary.place, - diary.content, - list( - Projections.constructor( - String::class.java, - diaryImage.imageUrl - ) - ) - ) - ) - ) + .transform(groupBy(diary).`as`(list(diaryImage.imageUrl))) + + return DiaryResponseParam.of(transform) } - fun findAllByMemoryDate(param: DiarySimpleRequestParam): List { - return queryFactory - .select( - QDiarySimpleResponseParam( - diary.id, - diary.user.id, - diary.title, - diary.memoryDate, - diary.place, - diary.content, - diary.diaryImages.get(0).imageUrl - ) - ) + fun findAllByMemoryDate(param: DiarySimpleRequestParam): List { + val transform: Map> = queryFactory .from(diary) - .innerJoin(diary.user) + .leftJoin(diary.diaryImages, diaryImage) .where(eqCouple(param.userId, param.partnerId), eqMemoryDate(param.memoryDate)) .orderBy(ascDiaryId()) - .fetch() + .transform(groupBy(diary).`as`(list(diaryImage.imageUrl))) + + return DiaryResponseParam.of(transform) } - fun findAll(userId: Long, partnerId: Long?): List { - return queryFactory - .select( - QDiarySimpleResponseParam( - diary.id, - diary.user.id, - diary.title, - diary.memoryDate, - diary.place, - diary.content, - diary.diaryImages.get(0).imageUrl - ) - ) + fun findAll(userId: Long, partnerId: Long?): List { + val transform: Map> = queryFactory .from(diary) - .innerJoin(diary.user) + .leftJoin(diary.diaryImages, diaryImage) .where(eqCouple(userId, partnerId)) .orderBy(ascDiaryId()) - .fetch() + .transform(groupBy(diary).`as`(list(diaryImage.imageUrl))) + + return DiaryResponseParam.of(transform) } private fun eqDiary(diary: QDiary): BooleanExpression = diary.eq(diary) From 5f7a4f283fc77ab78adbd57923680fc5dce0d9e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=ED=83=9C=EC=9A=A9?= Date: Thu, 29 Feb 2024 02:47:57 +0900 Subject: [PATCH 03/10] =?UTF-8?q?refactor:=20=EC=BF=BC=EB=A6=AC=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=EC=9C=BC=EB=A1=9C=20=EC=9D=B8=ED=95=9C=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EB=A6=AC=ED=8C=A9=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/controller/diary/DiaryController.kt | 5 ++--- .../dto/response/diary/DiarySimpleListResponse.kt | 14 -------------- .../lovebird/api/service/diary/DiaryService.kt | 15 +++++++-------- .../kotlin/com/lovebird/api/util/DiaryUtils.kt | 3 +-- .../domain/dto/query/DiarySimpleResponseParam.kt | 14 -------------- .../domain/repository/reader/DiaryReader.kt | 5 ++--- 6 files changed, 12 insertions(+), 44 deletions(-) delete mode 100644 lovebird-api/src/main/kotlin/com/lovebird/api/dto/response/diary/DiarySimpleListResponse.kt delete mode 100644 lovebird-domain/src/main/kotlin/com/lovebird/domain/dto/query/DiarySimpleResponseParam.kt diff --git a/lovebird-api/src/main/kotlin/com/lovebird/api/controller/diary/DiaryController.kt b/lovebird-api/src/main/kotlin/com/lovebird/api/controller/diary/DiaryController.kt index 15ac91f..d315d89 100644 --- a/lovebird-api/src/main/kotlin/com/lovebird/api/controller/diary/DiaryController.kt +++ b/lovebird-api/src/main/kotlin/com/lovebird/api/controller/diary/DiaryController.kt @@ -6,7 +6,6 @@ import com.lovebird.api.dto.request.diary.DiaryListRequest import com.lovebird.api.dto.request.diary.DiaryUpdateRequest import com.lovebird.api.dto.response.diary.DiaryDetailResponse import com.lovebird.api.dto.response.diary.DiaryListResponse -import com.lovebird.api.dto.response.diary.DiarySimpleListResponse import com.lovebird.api.service.diary.DiaryService import com.lovebird.common.response.ApiResponse import com.lovebird.domain.entity.User @@ -39,14 +38,14 @@ class DiaryController( fun findAllByMemoryDate( @AuthorizedUser user: User, @ModelAttribute request: DiaryListRequest.SearchByMemoryDateRequest - ): ApiResponse { + ): ApiResponse { return ApiResponse.success(diaryService.findAllByMemoryDate(request, user)) } @GetMapping fun findAll( @AuthorizedUser user: User - ): ApiResponse { + ): ApiResponse { return ApiResponse.success(diaryService.findAll(user)) } diff --git a/lovebird-api/src/main/kotlin/com/lovebird/api/dto/response/diary/DiarySimpleListResponse.kt b/lovebird-api/src/main/kotlin/com/lovebird/api/dto/response/diary/DiarySimpleListResponse.kt deleted file mode 100644 index f40d309..0000000 --- a/lovebird-api/src/main/kotlin/com/lovebird/api/dto/response/diary/DiarySimpleListResponse.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.lovebird.api.dto.response.diary - -import com.lovebird.domain.dto.query.DiarySimpleResponseParam - -data class DiarySimpleListResponse( - val diaries: List, - val totalCount: Int = diaries.size -) { - companion object { - fun of(diaries: List): DiarySimpleListResponse { - return DiarySimpleListResponse(diaries) - } - } -} diff --git a/lovebird-api/src/main/kotlin/com/lovebird/api/service/diary/DiaryService.kt b/lovebird-api/src/main/kotlin/com/lovebird/api/service/diary/DiaryService.kt index 2b354b1..c9fbd15 100644 --- a/lovebird-api/src/main/kotlin/com/lovebird/api/service/diary/DiaryService.kt +++ b/lovebird-api/src/main/kotlin/com/lovebird/api/service/diary/DiaryService.kt @@ -5,7 +5,6 @@ import com.lovebird.api.dto.param.diary.DiaryUpdateParam import com.lovebird.api.dto.request.diary.DiaryListRequest import com.lovebird.api.dto.response.diary.DiaryDetailResponse import com.lovebird.api.dto.response.diary.DiaryListResponse -import com.lovebird.api.dto.response.diary.DiarySimpleListResponse import com.lovebird.api.util.DiaryUtils.decryptDiaries import com.lovebird.api.util.DiaryUtils.decryptDiariesOfSimple import com.lovebird.api.util.DiaryUtils.decryptDiary @@ -14,7 +13,6 @@ import com.lovebird.api.util.DiaryUtils.encryptDiaryUpdateParam import com.lovebird.common.enums.DiarySearchType import com.lovebird.domain.dto.query.DiaryListRequestParam import com.lovebird.domain.dto.query.DiaryResponseParam -import com.lovebird.domain.dto.query.DiarySimpleResponseParam import com.lovebird.domain.entity.CoupleEntry import com.lovebird.domain.entity.Diary import com.lovebird.domain.entity.User @@ -78,25 +76,26 @@ class DiaryService( } @Transactional(readOnly = true) - fun findAll(user: User): DiarySimpleListResponse { + fun findAll(user: User): DiaryListResponse { val coupleEntry: CoupleEntry? = coupleEntryReader.findByUser(user) val partner: User? = coupleEntry?.partner - val diaries: List = diaryReader.findAll(user.id!!, partner?.id) + + val diaries: List = diaryReader.findAll(user.id!!, partner?.id) decryptDiariesOfSimple(diaries) - return DiarySimpleListResponse.of(diaries) + return DiaryListResponse.of(diaries) } @Transactional(readOnly = true) - fun findAllByMemoryDate(request: DiaryListRequest.SearchByMemoryDateRequest, user: User): DiarySimpleListResponse { + fun findAllByMemoryDate(request: DiaryListRequest.SearchByMemoryDateRequest, user: User): DiaryListResponse { val coupleEntry: CoupleEntry? = coupleEntryReader.findByUser(user) val partner: User? = coupleEntry?.partner - val diaries: List = diaryReader.findAllByMemoryDate(request.toParam(user.id!!, partner?.id)) + val diaries: List = diaryReader.findAllByMemoryDate(request.toParam(user.id!!, partner?.id)) decryptDiariesOfSimple(diaries) - return DiarySimpleListResponse.of(diaries) + return DiaryListResponse.of(diaries) } @Transactional(readOnly = true) diff --git a/lovebird-api/src/main/kotlin/com/lovebird/api/util/DiaryUtils.kt b/lovebird-api/src/main/kotlin/com/lovebird/api/util/DiaryUtils.kt index cc68ac0..2e70522 100644 --- a/lovebird-api/src/main/kotlin/com/lovebird/api/util/DiaryUtils.kt +++ b/lovebird-api/src/main/kotlin/com/lovebird/api/util/DiaryUtils.kt @@ -5,7 +5,6 @@ import com.lovebird.api.dto.param.diary.DiaryUpdateParam import com.lovebird.api.provider.AesEncryptProvider.decryptString import com.lovebird.api.provider.AesEncryptProvider.encryptString import com.lovebird.domain.dto.query.DiaryResponseParam -import com.lovebird.domain.dto.query.DiarySimpleResponseParam import com.lovebird.domain.entity.Diary object DiaryUtils { @@ -18,7 +17,7 @@ object DiaryUtils { } } - fun decryptDiariesOfSimple(diaries: List) { + fun decryptDiariesOfSimple(diaries: List) { diaries.forEach { it.title = decryptString(it.title) it.place = it.place?.let { place -> decryptString(place) } diff --git a/lovebird-domain/src/main/kotlin/com/lovebird/domain/dto/query/DiarySimpleResponseParam.kt b/lovebird-domain/src/main/kotlin/com/lovebird/domain/dto/query/DiarySimpleResponseParam.kt deleted file mode 100644 index 3f846ad..0000000 --- a/lovebird-domain/src/main/kotlin/com/lovebird/domain/dto/query/DiarySimpleResponseParam.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.lovebird.domain.dto.query - -import com.querydsl.core.annotations.QueryProjection -import java.time.LocalDate - -data class DiarySimpleResponseParam @QueryProjection constructor( - val diaryId: Long, - val userId: Long, - var title: String, - val memoryDate: LocalDate, - var place: String?, - var content: String?, - val imageUrl: String? -) diff --git a/lovebird-domain/src/main/kotlin/com/lovebird/domain/repository/reader/DiaryReader.kt b/lovebird-domain/src/main/kotlin/com/lovebird/domain/repository/reader/DiaryReader.kt index b184f7c..d136893 100644 --- a/lovebird-domain/src/main/kotlin/com/lovebird/domain/repository/reader/DiaryReader.kt +++ b/lovebird-domain/src/main/kotlin/com/lovebird/domain/repository/reader/DiaryReader.kt @@ -6,7 +6,6 @@ import com.lovebird.domain.annotation.Reader import com.lovebird.domain.dto.query.DiaryListRequestParam import com.lovebird.domain.dto.query.DiaryResponseParam import com.lovebird.domain.dto.query.DiarySimpleRequestParam -import com.lovebird.domain.dto.query.DiarySimpleResponseParam import com.lovebird.domain.entity.Diary import com.lovebird.domain.repository.jpa.DiaryJpaRepository import com.lovebird.domain.repository.query.DiaryQueryRepository @@ -29,11 +28,11 @@ class DiaryReader( return diaryQueryRepository.findAfterNowUsingCursor(param) } - fun findAllByMemoryDate(param: DiarySimpleRequestParam): List { + fun findAllByMemoryDate(param: DiarySimpleRequestParam): List { return diaryQueryRepository.findAllByMemoryDate(param) } - fun findAll(userId: Long, partnerId: Long?): List { + fun findAll(userId: Long, partnerId: Long?): List { return diaryQueryRepository.findAll(userId, partnerId) } } From 51a901adc076f7a7be9f735d52687c6c3de1139e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=ED=83=9C=EC=9A=A9?= Date: Thu, 29 Feb 2024 03:00:17 +0900 Subject: [PATCH 04/10] =?UTF-8?q?test:=20DTO=20=EB=B3=80=EA=B2=BD=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20=EC=9D=B8=ED=95=9C=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lovebird/api/controller/diary/DiaryControllerTest.kt | 9 ++++----- .../com/lovebird/api/service/diary/DiaryServiceTest.kt | 9 ++++----- .../kotlin/com/lovebird/api/utils/DiaryTestFixture.kt | 9 ++++----- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/lovebird-api/src/test/kotlin/com/lovebird/api/controller/diary/DiaryControllerTest.kt b/lovebird-api/src/test/kotlin/com/lovebird/api/controller/diary/DiaryControllerTest.kt index dd63930..9fed8c3 100644 --- a/lovebird-api/src/test/kotlin/com/lovebird/api/controller/diary/DiaryControllerTest.kt +++ b/lovebird-api/src/test/kotlin/com/lovebird/api/controller/diary/DiaryControllerTest.kt @@ -3,7 +3,6 @@ package com.lovebird.api.controller.diary import com.lovebird.api.common.base.ControllerDescribeSpec import com.lovebird.api.dto.response.diary.DiaryDetailResponse import com.lovebird.api.dto.response.diary.DiaryListResponse -import com.lovebird.api.dto.response.diary.DiarySimpleListResponse import com.lovebird.api.service.diary.DiaryService import com.lovebird.api.utils.CommonTestFixture import com.lovebird.api.utils.DiaryTestFixture @@ -59,8 +58,8 @@ class DiaryControllerTest( .header(HttpHeaders.AUTHORIZATION, "Bearer access-token") val user = CommonTestFixture.getUser(1L, "providerUniqueId") - val diaries = DiaryTestFixture.getDiarySimpleResponseList(user, null, 5) - val response = DiarySimpleListResponse.of(diaries) + val diaries = DiaryTestFixture.getDiaryResponseList(user, null, 5) + val response = DiaryListResponse.of(diaries) it("1000 SUCCESS") { every { diaryService.findAllByMemoryDate(any(), any()) } returns response @@ -131,8 +130,8 @@ class DiaryControllerTest( context("다이어리 전체 조회 요청한다면") { val request = request(HttpMethod.GET, url) .header(HttpHeaders.AUTHORIZATION, "Bearer access-token") - val diaries = DiaryTestFixture.getDiarySimpleResponseList(user, null, 5) - val response = DiarySimpleListResponse.of(diaries) + val diaries = DiaryTestFixture.getDiaryResponseList(user, null, 5) + val response = DiaryListResponse.of(diaries) it("1000 SUCCESS") { every { diaryService.findAll(any()) } returns response diff --git a/lovebird-api/src/test/kotlin/com/lovebird/api/service/diary/DiaryServiceTest.kt b/lovebird-api/src/test/kotlin/com/lovebird/api/service/diary/DiaryServiceTest.kt index bdee319..190b679 100644 --- a/lovebird-api/src/test/kotlin/com/lovebird/api/service/diary/DiaryServiceTest.kt +++ b/lovebird-api/src/test/kotlin/com/lovebird/api/service/diary/DiaryServiceTest.kt @@ -3,7 +3,6 @@ package com.lovebird.api.service.diary import com.lovebird.api.common.base.ServiceDescribeSpec import com.lovebird.api.dto.response.diary.DiaryDetailResponse import com.lovebird.api.dto.response.diary.DiaryListResponse -import com.lovebird.api.dto.response.diary.DiarySimpleListResponse import com.lovebird.api.util.DiaryUtils import com.lovebird.api.utils.CoupleTestFixture.getCoupleEntry import com.lovebird.api.utils.DiaryTestFixture @@ -248,7 +247,7 @@ class DiaryServiceTest : ServiceDescribeSpec({ val size = 5 context("파트너가 존재하지 않아도") { - val diaries = DiaryTestFixture.getDiarySimpleResponseList(user = user, partner = null, size = size) + val diaries = DiaryTestFixture.getDiaryResponseList(user = user, partner = null, size = size) every { coupleEntryReader.findByUser(user) } returns getCoupleEntry(user = user, partner = user) every { diaryReader.findAllByMemoryDate(any()) } returns diaries every { DiaryUtils.decryptDiariesOfSimple(any()) } just Runs @@ -257,7 +256,7 @@ class DiaryServiceTest : ServiceDescribeSpec({ // 상태 검증 diaryService.findAllByMemoryDate(request, user) - .shouldBeEqualToComparingFields(DiarySimpleListResponse.of(diaries)) + .shouldBeEqualToComparingFields(DiaryListResponse.of(diaries)) // 행위 검증 verify(exactly = 1) { @@ -269,7 +268,7 @@ class DiaryServiceTest : ServiceDescribeSpec({ } context("파트너가 존재한다면") { - val diaries = DiaryTestFixture.getDiarySimpleResponseList(user = user, partner = partner, size = size) + val diaries = DiaryTestFixture.getDiaryResponseList(user = user, partner = partner, size = size) every { coupleEntryReader.findByUser(user) } returns getCoupleEntry(user = user, partner = partner) every { diaryReader.findAllByMemoryDate(any()) } returns diaries every { DiaryUtils.decryptDiariesOfSimple(any()) } just Runs @@ -278,7 +277,7 @@ class DiaryServiceTest : ServiceDescribeSpec({ // 상태 검증 diaryService.findAllByMemoryDate(request, user) - .shouldBeEqualToComparingFields(DiarySimpleListResponse.of(diaries)) + .shouldBeEqualToComparingFields(DiaryListResponse.of(diaries)) // 행위 검증 verify(exactly = 1) { diff --git a/lovebird-api/src/test/kotlin/com/lovebird/api/utils/DiaryTestFixture.kt b/lovebird-api/src/test/kotlin/com/lovebird/api/utils/DiaryTestFixture.kt index 4efc36a..815e05f 100644 --- a/lovebird-api/src/test/kotlin/com/lovebird/api/utils/DiaryTestFixture.kt +++ b/lovebird-api/src/test/kotlin/com/lovebird/api/utils/DiaryTestFixture.kt @@ -7,7 +7,6 @@ import com.lovebird.api.dto.request.diary.DiaryListRequest import com.lovebird.api.dto.request.diary.DiaryUpdateRequest import com.lovebird.common.enums.DiarySearchType import com.lovebird.domain.dto.query.DiaryResponseParam -import com.lovebird.domain.dto.query.DiarySimpleResponseParam import com.lovebird.domain.entity.Diary import com.lovebird.domain.entity.User import org.springframework.test.util.ReflectionTestUtils @@ -125,19 +124,19 @@ object DiaryTestFixture { ) } - fun getDiarySimpleResponseList(user: User, partner: User?, size: Int): List { - val diaries = arrayListOf() + fun getDiaryResponseList(user: User, partner: User?, size: Int): List { + val diaries = arrayListOf() for (i in 1..size) { diaries.add( - DiarySimpleResponseParam( + DiaryResponseParam( diaryId = i.toLong(), userId = getRandomUserId(user, partner), title = "제목$i", memoryDate = LocalDate.now(), place = "장소$i", content = "내용$i", - imageUrl = "imageURL$i" + imageUrls = arrayListOf("imageURL$i") ) ) } From e7fb0cee1f4ad0f546e3b2875774c13c07d19553 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=ED=83=9C=EC=9A=A9?= Date: Thu, 29 Feb 2024 03:00:37 +0900 Subject: [PATCH 05/10] =?UTF-8?q?refactor:=20ktlint=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/dto/query/DiaryResponseParam.kt | 20 ++++++++++--------- .../repository/query/DiaryQueryRepository.kt | 10 ++++++---- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/lovebird-domain/src/main/kotlin/com/lovebird/domain/dto/query/DiaryResponseParam.kt b/lovebird-domain/src/main/kotlin/com/lovebird/domain/dto/query/DiaryResponseParam.kt index f8b735b..9c4a969 100644 --- a/lovebird-domain/src/main/kotlin/com/lovebird/domain/dto/query/DiaryResponseParam.kt +++ b/lovebird-domain/src/main/kotlin/com/lovebird/domain/dto/query/DiaryResponseParam.kt @@ -16,15 +16,17 @@ data class DiaryResponseParam( companion object { fun of(transform: Map>): List { return transform.entries.stream() - .map { entry -> DiaryResponseParam( - diaryId = entry.key.id!!, - userId = entry.key.user.id!!, - title = entry.key.title, - memoryDate = entry.key.memoryDate, - place = entry.key.place, - content = entry.key.content, - imageUrls = entry.value - ) }.toList() + .map { entry -> + DiaryResponseParam( + diaryId = entry.key.id!!, + userId = entry.key.user.id!!, + title = entry.key.title, + memoryDate = entry.key.memoryDate, + place = entry.key.place, + content = entry.key.content, + imageUrls = entry.value + ) + }.toList() } } } diff --git a/lovebird-domain/src/main/kotlin/com/lovebird/domain/repository/query/DiaryQueryRepository.kt b/lovebird-domain/src/main/kotlin/com/lovebird/domain/repository/query/DiaryQueryRepository.kt index 7b44000..1038126 100644 --- a/lovebird-domain/src/main/kotlin/com/lovebird/domain/repository/query/DiaryQueryRepository.kt +++ b/lovebird-domain/src/main/kotlin/com/lovebird/domain/repository/query/DiaryQueryRepository.kt @@ -1,19 +1,21 @@ package com.lovebird.domain.repository.query + +import java.time.LocalDate import com.lovebird.domain.dto.query.DiaryListRequestParam import com.lovebird.domain.dto.query.DiaryResponseParam import com.lovebird.domain.dto.query.DiarySimpleRequestParam import com.lovebird.domain.entity.Diary import com.lovebird.domain.entity.QDiary -import com.lovebird.domain.entity.QDiary.* -import com.lovebird.domain.entity.QDiaryImage.* -import com.querydsl.core.group.GroupBy.* +import com.lovebird.domain.entity.QDiary.diary +import com.lovebird.domain.entity.QDiaryImage.diaryImage +import com.querydsl.core.group.GroupBy.list +import com.querydsl.core.group.GroupBy.groupBy import com.querydsl.core.types.OrderSpecifier import com.querydsl.core.types.dsl.BooleanExpression import com.querydsl.core.types.dsl.NumberPath import com.querydsl.jpa.impl.JPAQueryFactory import org.springframework.stereotype.Repository -import java.time.LocalDate @Repository class DiaryQueryRepository( From 139df877c403afc2387f93461bc405a68598aef5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=ED=83=9C=EC=9A=A9?= Date: Thu, 29 Feb 2024 03:48:20 +0900 Subject: [PATCH 06/10] =?UTF-8?q?refactor:=20DiarySimpleResponse=EB=A1=9C?= =?UTF-8?q?=20=EB=A6=AC=ED=8C=A9=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/controller/diary/DiaryController.kt | 5 +++-- .../api/dto/response/diary/DiarySimpleResponse.kt | 14 ++++++++++++++ .../com/lovebird/api/service/diary/DiaryService.kt | 9 +++++---- .../repository/query/DiaryQueryRepository.kt | 2 -- 4 files changed, 22 insertions(+), 8 deletions(-) create mode 100644 lovebird-api/src/main/kotlin/com/lovebird/api/dto/response/diary/DiarySimpleResponse.kt diff --git a/lovebird-api/src/main/kotlin/com/lovebird/api/controller/diary/DiaryController.kt b/lovebird-api/src/main/kotlin/com/lovebird/api/controller/diary/DiaryController.kt index d315d89..b423dd1 100644 --- a/lovebird-api/src/main/kotlin/com/lovebird/api/controller/diary/DiaryController.kt +++ b/lovebird-api/src/main/kotlin/com/lovebird/api/controller/diary/DiaryController.kt @@ -6,6 +6,7 @@ import com.lovebird.api.dto.request.diary.DiaryListRequest import com.lovebird.api.dto.request.diary.DiaryUpdateRequest import com.lovebird.api.dto.response.diary.DiaryDetailResponse import com.lovebird.api.dto.response.diary.DiaryListResponse +import com.lovebird.api.dto.response.diary.DiarySimpleResponse import com.lovebird.api.service.diary.DiaryService import com.lovebird.common.response.ApiResponse import com.lovebird.domain.entity.User @@ -38,14 +39,14 @@ class DiaryController( fun findAllByMemoryDate( @AuthorizedUser user: User, @ModelAttribute request: DiaryListRequest.SearchByMemoryDateRequest - ): ApiResponse { + ): ApiResponse { return ApiResponse.success(diaryService.findAllByMemoryDate(request, user)) } @GetMapping fun findAll( @AuthorizedUser user: User - ): ApiResponse { + ): ApiResponse { return ApiResponse.success(diaryService.findAll(user)) } diff --git a/lovebird-api/src/main/kotlin/com/lovebird/api/dto/response/diary/DiarySimpleResponse.kt b/lovebird-api/src/main/kotlin/com/lovebird/api/dto/response/diary/DiarySimpleResponse.kt new file mode 100644 index 0000000..43406f6 --- /dev/null +++ b/lovebird-api/src/main/kotlin/com/lovebird/api/dto/response/diary/DiarySimpleResponse.kt @@ -0,0 +1,14 @@ +package com.lovebird.api.dto.response.diary + +import com.lovebird.domain.dto.query.DiaryResponseParam + +data class DiarySimpleResponse( + val diaries: List, + val totalCount: Int = diaries.size +) { + companion object { + fun of(diaries: List): DiarySimpleResponse { + return DiarySimpleResponse(diaries) + } + } +} diff --git a/lovebird-api/src/main/kotlin/com/lovebird/api/service/diary/DiaryService.kt b/lovebird-api/src/main/kotlin/com/lovebird/api/service/diary/DiaryService.kt index c9fbd15..d5a9725 100644 --- a/lovebird-api/src/main/kotlin/com/lovebird/api/service/diary/DiaryService.kt +++ b/lovebird-api/src/main/kotlin/com/lovebird/api/service/diary/DiaryService.kt @@ -5,6 +5,7 @@ import com.lovebird.api.dto.param.diary.DiaryUpdateParam import com.lovebird.api.dto.request.diary.DiaryListRequest import com.lovebird.api.dto.response.diary.DiaryDetailResponse import com.lovebird.api.dto.response.diary.DiaryListResponse +import com.lovebird.api.dto.response.diary.DiarySimpleResponse import com.lovebird.api.util.DiaryUtils.decryptDiaries import com.lovebird.api.util.DiaryUtils.decryptDiariesOfSimple import com.lovebird.api.util.DiaryUtils.decryptDiary @@ -76,7 +77,7 @@ class DiaryService( } @Transactional(readOnly = true) - fun findAll(user: User): DiaryListResponse { + fun findAll(user: User): DiarySimpleResponse { val coupleEntry: CoupleEntry? = coupleEntryReader.findByUser(user) val partner: User? = coupleEntry?.partner @@ -84,18 +85,18 @@ class DiaryService( decryptDiariesOfSimple(diaries) - return DiaryListResponse.of(diaries) + return DiarySimpleResponse.of(diaries) } @Transactional(readOnly = true) - fun findAllByMemoryDate(request: DiaryListRequest.SearchByMemoryDateRequest, user: User): DiaryListResponse { + fun findAllByMemoryDate(request: DiaryListRequest.SearchByMemoryDateRequest, user: User): DiarySimpleResponse { val coupleEntry: CoupleEntry? = coupleEntryReader.findByUser(user) val partner: User? = coupleEntry?.partner val diaries: List = diaryReader.findAllByMemoryDate(request.toParam(user.id!!, partner?.id)) decryptDiariesOfSimple(diaries) - return DiaryListResponse.of(diaries) + return DiarySimpleResponse.of(diaries) } @Transactional(readOnly = true) diff --git a/lovebird-domain/src/main/kotlin/com/lovebird/domain/repository/query/DiaryQueryRepository.kt b/lovebird-domain/src/main/kotlin/com/lovebird/domain/repository/query/DiaryQueryRepository.kt index 1038126..e15d3a6 100644 --- a/lovebird-domain/src/main/kotlin/com/lovebird/domain/repository/query/DiaryQueryRepository.kt +++ b/lovebird-domain/src/main/kotlin/com/lovebird/domain/repository/query/DiaryQueryRepository.kt @@ -1,6 +1,4 @@ package com.lovebird.domain.repository.query - - import java.time.LocalDate import com.lovebird.domain.dto.query.DiaryListRequestParam import com.lovebird.domain.dto.query.DiaryResponseParam From 7741533e072a27e6d06c3348629768efbaf57c04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=ED=83=9C=EC=9A=A9?= Date: Thu, 29 Feb 2024 03:49:16 +0900 Subject: [PATCH 07/10] =?UTF-8?q?test:=20=EC=9C=A0=EC=A0=80=EC=9D=98=20?= =?UTF-8?q?=EB=8B=A4=EC=9D=B4=EC=96=B4=EB=A6=AC=20=EC=A0=84=EC=B2=B4=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20=EB=B0=8F=20=EB=82=A0=EC=A7=9C=EB=B3=84=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20=EB=A6=AC=ED=8C=A9=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/diary/DiaryControllerTest.kt | 25 ++++++------------- .../api/service/diary/DiaryServiceTest.kt | 5 ++-- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/lovebird-api/src/test/kotlin/com/lovebird/api/controller/diary/DiaryControllerTest.kt b/lovebird-api/src/test/kotlin/com/lovebird/api/controller/diary/DiaryControllerTest.kt index 9fed8c3..c87652c 100644 --- a/lovebird-api/src/test/kotlin/com/lovebird/api/controller/diary/DiaryControllerTest.kt +++ b/lovebird-api/src/test/kotlin/com/lovebird/api/controller/diary/DiaryControllerTest.kt @@ -3,6 +3,7 @@ package com.lovebird.api.controller.diary import com.lovebird.api.common.base.ControllerDescribeSpec import com.lovebird.api.dto.response.diary.DiaryDetailResponse import com.lovebird.api.dto.response.diary.DiaryListResponse +import com.lovebird.api.dto.response.diary.DiarySimpleResponse import com.lovebird.api.service.diary.DiaryService import com.lovebird.api.utils.CommonTestFixture import com.lovebird.api.utils.DiaryTestFixture @@ -27,9 +28,9 @@ import org.springframework.http.HttpHeaders import org.springframework.http.HttpMethod import org.springframework.http.MediaType import org.springframework.restdocs.ManualRestDocumentation -import org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.request +import org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.* import org.springframework.restdocs.payload.FieldDescriptor -import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status +import org.springframework.test.web.servlet.result.MockMvcResultMatchers.* import org.springframework.web.context.WebApplicationContext import java.time.LocalDate import java.time.format.DateTimeFormatter @@ -59,7 +60,7 @@ class DiaryControllerTest( val user = CommonTestFixture.getUser(1L, "providerUniqueId") val diaries = DiaryTestFixture.getDiaryResponseList(user, null, 5) - val response = DiaryListResponse.of(diaries) + val response = DiarySimpleResponse.of(diaries) it("1000 SUCCESS") { every { diaryService.findAllByMemoryDate(any(), any()) } returns response @@ -79,7 +80,7 @@ class DiaryControllerTest( "data.diaries" type ARRAY means "다이어리 목록", "data.totalCount" type NUMBER means "캘린더 개수" ) - .andWithPrefix("data.diaries[].", getSimpleDiaryDetailResponseSnippet()) + .andWithPrefix("data.diaries[].", getDiaryDetailResponseSnippet()) ) } } @@ -131,7 +132,7 @@ class DiaryControllerTest( val request = request(HttpMethod.GET, url) .header(HttpHeaders.AUTHORIZATION, "Bearer access-token") val diaries = DiaryTestFixture.getDiaryResponseList(user, null, 5) - val response = DiaryListResponse.of(diaries) + val response = DiarySimpleResponse.of(diaries) it("1000 SUCCESS") { every { diaryService.findAll(any()) } returns response @@ -148,7 +149,7 @@ class DiaryControllerTest( "data.diaries" type ARRAY means "다이어리 목록", "data.totalCount" type NUMBER means "캘린더 개수" ) - .andWithPrefix("data.diaries[].", getSimpleDiaryDetailResponseSnippet()) + .andWithPrefix("data.diaries[].", getDiaryDetailResponseSnippet()) ) } } @@ -267,18 +268,6 @@ class DiaryControllerTest( } }) { companion object { - fun getSimpleDiaryDetailResponseSnippet(): List { - return responseDiaryDetailResponse( - "diaryId" type NUMBER means "다이어리 아이디", - "userId" type NUMBER means "유저 아이디", - "title" type STRING means "제목", - "memoryDate" type DATE means "데이트 날짜", - "place" type STRING means "장소", - "content" type STRING means "내용", - "imageUrl" type STRING means "이미지 URL" - ) - } - fun getDiaryDetailResponseSnippet(): List { return responseDiaryDetailResponse( "diaryId" type NUMBER means "다이어리 아이디", diff --git a/lovebird-api/src/test/kotlin/com/lovebird/api/service/diary/DiaryServiceTest.kt b/lovebird-api/src/test/kotlin/com/lovebird/api/service/diary/DiaryServiceTest.kt index 190b679..df88594 100644 --- a/lovebird-api/src/test/kotlin/com/lovebird/api/service/diary/DiaryServiceTest.kt +++ b/lovebird-api/src/test/kotlin/com/lovebird/api/service/diary/DiaryServiceTest.kt @@ -3,6 +3,7 @@ package com.lovebird.api.service.diary import com.lovebird.api.common.base.ServiceDescribeSpec import com.lovebird.api.dto.response.diary.DiaryDetailResponse import com.lovebird.api.dto.response.diary.DiaryListResponse +import com.lovebird.api.dto.response.diary.DiarySimpleResponse import com.lovebird.api.util.DiaryUtils import com.lovebird.api.utils.CoupleTestFixture.getCoupleEntry import com.lovebird.api.utils.DiaryTestFixture @@ -256,7 +257,7 @@ class DiaryServiceTest : ServiceDescribeSpec({ // 상태 검증 diaryService.findAllByMemoryDate(request, user) - .shouldBeEqualToComparingFields(DiaryListResponse.of(diaries)) + .shouldBeEqualToComparingFields(DiarySimpleResponse.of(diaries)) // 행위 검증 verify(exactly = 1) { @@ -277,7 +278,7 @@ class DiaryServiceTest : ServiceDescribeSpec({ // 상태 검증 diaryService.findAllByMemoryDate(request, user) - .shouldBeEqualToComparingFields(DiaryListResponse.of(diaries)) + .shouldBeEqualToComparingFields(DiarySimpleResponse.of(diaries)) // 행위 검증 verify(exactly = 1) { From 38aaf10a64b684f379f59d794fbdb04d04aefa43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=ED=83=9C=EC=9A=A9?= Date: Thu, 29 Feb 2024 11:09:11 +0900 Subject: [PATCH 08/10] =?UTF-8?q?refactor:=20ktlint=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/lovebird/api/controller/diary/DiaryControllerTest.kt | 4 ++-- .../lovebird/domain/repository/query/DiaryQueryRepository.kt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lovebird-api/src/test/kotlin/com/lovebird/api/controller/diary/DiaryControllerTest.kt b/lovebird-api/src/test/kotlin/com/lovebird/api/controller/diary/DiaryControllerTest.kt index c87652c..915d0e7 100644 --- a/lovebird-api/src/test/kotlin/com/lovebird/api/controller/diary/DiaryControllerTest.kt +++ b/lovebird-api/src/test/kotlin/com/lovebird/api/controller/diary/DiaryControllerTest.kt @@ -28,9 +28,9 @@ import org.springframework.http.HttpHeaders import org.springframework.http.HttpMethod import org.springframework.http.MediaType import org.springframework.restdocs.ManualRestDocumentation -import org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.* +import org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.request import org.springframework.restdocs.payload.FieldDescriptor -import org.springframework.test.web.servlet.result.MockMvcResultMatchers.* +import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status import org.springframework.web.context.WebApplicationContext import java.time.LocalDate import java.time.format.DateTimeFormatter diff --git a/lovebird-domain/src/main/kotlin/com/lovebird/domain/repository/query/DiaryQueryRepository.kt b/lovebird-domain/src/main/kotlin/com/lovebird/domain/repository/query/DiaryQueryRepository.kt index e15d3a6..a2e1fb8 100644 --- a/lovebird-domain/src/main/kotlin/com/lovebird/domain/repository/query/DiaryQueryRepository.kt +++ b/lovebird-domain/src/main/kotlin/com/lovebird/domain/repository/query/DiaryQueryRepository.kt @@ -1,5 +1,6 @@ package com.lovebird.domain.repository.query import java.time.LocalDate +import org.springframework.stereotype.Repository import com.lovebird.domain.dto.query.DiaryListRequestParam import com.lovebird.domain.dto.query.DiaryResponseParam import com.lovebird.domain.dto.query.DiarySimpleRequestParam @@ -13,7 +14,6 @@ import com.querydsl.core.types.OrderSpecifier import com.querydsl.core.types.dsl.BooleanExpression import com.querydsl.core.types.dsl.NumberPath import com.querydsl.jpa.impl.JPAQueryFactory -import org.springframework.stereotype.Repository @Repository class DiaryQueryRepository( From c62fa25f73ba52faed5e5ec89a2732e44849f444 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=ED=83=9C=EC=9A=A9?= Date: Thu, 29 Feb 2024 11:16:17 +0900 Subject: [PATCH 09/10] =?UTF-8?q?feat:=20Business=20Exception=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 --- .../lovebird/api/controller/GlobalControllerAdvice.kt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lovebird-api/src/main/kotlin/com/lovebird/api/controller/GlobalControllerAdvice.kt b/lovebird-api/src/main/kotlin/com/lovebird/api/controller/GlobalControllerAdvice.kt index 4900b41..fa88762 100644 --- a/lovebird-api/src/main/kotlin/com/lovebird/api/controller/GlobalControllerAdvice.kt +++ b/lovebird-api/src/main/kotlin/com/lovebird/api/controller/GlobalControllerAdvice.kt @@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.ExceptionHandler import org.springframework.web.bind.annotation.RestControllerAdvice import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException import java.sql.SQLException +import kotlin.RuntimeException @RestControllerAdvice class GlobalControllerAdvice { @@ -59,4 +60,13 @@ class GlobalControllerAdvice { .status(HttpStatus.INTERNAL_SERVER_ERROR) .body(ApiResponse.error(ReturnCode.INTERNAL_SERVER_ERROR)) } + + @ExceptionHandler( + value = [RuntimeException::class] + ) + fun handleBusinessException(e: RuntimeException): ResponseEntity> { + return ResponseEntity + .status(HttpStatus.INTERNAL_SERVER_ERROR) + .body(ApiResponse.error(ReturnCode.INTERNAL_SERVER_ERROR)) + } } From 251ac82ca1a571b94afd021764f5847f1b6a32a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=ED=83=9C=EC=9A=A9?= Date: Thu, 29 Feb 2024 11:48:41 +0900 Subject: [PATCH 10/10] =?UTF-8?q?refactor:=20ktlint=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/static/docs/index.html | 74 +++++++++---------- .../repository/query/DiaryQueryRepository.kt | 10 +-- 2 files changed, 41 insertions(+), 43 deletions(-) diff --git a/lovebird-api/src/main/resources/static/docs/index.html b/lovebird-api/src/main/resources/static/docs/index.html index 1f4414d..8a91e55 100644 --- a/lovebird-api/src/main/resources/static/docs/index.html +++ b/lovebird-api/src/main/resources/static/docs/index.html @@ -2112,8 +2112,8 @@
6.2.1 "imageUrl" : "test-image-url", "email" : "test-email", "nickname" : "test-nickname", - "birthday" : "2024-02-26", - "firstDate" : "2024-02-26", + "birthday" : "2024-02-29", + "firstDate" : "2024-02-29", "gender" : "UNKNOWN" } @@ -3674,7 +3674,7 @@

9.2.1. HTTP request

-
GET /api/v1/diaries/memory-date?memoryDate=2024-02-26 HTTP/1.1
+
GET /api/v1/diaries/memory-date?memoryDate=2024-02-29 HTTP/1.1
 Authorization: Bearer access-token
 Host: localhost:8080
@@ -3728,7 +3728,7 @@

HTTP/1.1 200 OK
 Content-Type: application/json;charset=UTF-8
-Content-Length: 1125
+Content-Length: 1150
 
 {
   "code" : "1000",
@@ -3738,42 +3738,42 @@ 

내용

-

data.diaries[].imageUrl

-

String

-

이미지 URL

+

data.diaries[].imageUrls

+

Array

+

이미지 URL 목록

@@ -3867,7 +3867,7 @@

9.3.1. HTTP request

-
GET /api/v1/diaries/cursor?memoryDate=2024-02-26&searchType=BEFORE&diaryId=-1&pageSize=10 HTTP/1.1
+
GET /api/v1/diaries/cursor?memoryDate=2024-02-29&searchType=BEFORE&diaryId=-1&pageSize=10 HTTP/1.1
 Authorization: Bearer access-token
 Host: localhost:8080
@@ -3943,7 +3943,7 @@

@@ -4144,7 +4144,7 @@

{
   "title" : "다이어리 제목",
-  "memoryDate" : "2024-02-26",
+  "memoryDate" : "2024-02-29",
   "place" : "장소",
   "content" : "내용",
   "imageUrls" : [ "imageUrl1", "imageUrl2" ]
@@ -4388,7 +4388,7 @@ 

{
   "title" : "다이어리 제목 수정",
-  "memoryDate" : "2024-02-26",
+  "memoryDate" : "2024-02-29",
   "place" : "장소",
   "content" : "내용 수정",
   "imageUrls" : [ "imageUrl1", "imageUrl2" ]
@@ -4585,7 +4585,7 @@ 

diff --git a/lovebird-domain/src/main/kotlin/com/lovebird/domain/repository/query/DiaryQueryRepository.kt b/lovebird-domain/src/main/kotlin/com/lovebird/domain/repository/query/DiaryQueryRepository.kt index a2e1fb8..dacdc39 100644 --- a/lovebird-domain/src/main/kotlin/com/lovebird/domain/repository/query/DiaryQueryRepository.kt +++ b/lovebird-domain/src/main/kotlin/com/lovebird/domain/repository/query/DiaryQueryRepository.kt @@ -1,19 +1,19 @@ package com.lovebird.domain.repository.query -import java.time.LocalDate -import org.springframework.stereotype.Repository + import com.lovebird.domain.dto.query.DiaryListRequestParam import com.lovebird.domain.dto.query.DiaryResponseParam import com.lovebird.domain.dto.query.DiarySimpleRequestParam import com.lovebird.domain.entity.Diary -import com.lovebird.domain.entity.QDiary import com.lovebird.domain.entity.QDiary.diary import com.lovebird.domain.entity.QDiaryImage.diaryImage -import com.querydsl.core.group.GroupBy.list import com.querydsl.core.group.GroupBy.groupBy +import com.querydsl.core.group.GroupBy.list import com.querydsl.core.types.OrderSpecifier import com.querydsl.core.types.dsl.BooleanExpression import com.querydsl.core.types.dsl.NumberPath import com.querydsl.jpa.impl.JPAQueryFactory +import org.springframework.stereotype.Repository +import java.time.LocalDate @Repository class DiaryQueryRepository( @@ -74,8 +74,6 @@ class DiaryQueryRepository( return DiaryResponseParam.of(transform) } - private fun eqDiary(diary: QDiary): BooleanExpression = diary.eq(diary) - private fun eqCouple(userId: Long, partnerId: Long?): BooleanExpression { val expression: BooleanExpression = eqUserId(userId)