Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix | #81 | @YongsHub | v1.0.1 출시 위해 Query Transform 리팩토링 #88

Merged
merged 10 commits into from
Feb 29, 2024
Prev Previous commit
Next Next commit
refactor: 쿼리 변경으로 인한 로직 리팩토링
YongsHub committed Feb 28, 2024
commit 5f7a4f283fc77ab78adbd57923680fc5dce0d9e6
Original file line number Diff line number Diff line change
@@ -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<DiarySimpleListResponse> {
): ApiResponse<DiaryListResponse> {
return ApiResponse.success(diaryService.findAllByMemoryDate(request, user))
}

@GetMapping
fun findAll(
@AuthorizedUser user: User
): ApiResponse<DiarySimpleListResponse> {
): ApiResponse<DiaryListResponse> {
return ApiResponse.success(diaryService.findAll(user))
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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<DiarySimpleResponseParam> = diaryReader.findAll(user.id!!, partner?.id)

val diaries: List<DiaryResponseParam> = 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<DiarySimpleResponseParam> = diaryReader.findAllByMemoryDate(request.toParam(user.id!!, partner?.id))
val diaries: List<DiaryResponseParam> = diaryReader.findAllByMemoryDate(request.toParam(user.id!!, partner?.id))

decryptDiariesOfSimple(diaries)

return DiarySimpleListResponse.of(diaries)
return DiaryListResponse.of(diaries)
}

@Transactional(readOnly = true)
Original file line number Diff line number Diff line change
@@ -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<DiarySimpleResponseParam>) {
fun decryptDiariesOfSimple(diaries: List<DiaryResponseParam>) {
diaries.forEach {
it.title = decryptString(it.title)
it.place = it.place?.let { place -> decryptString(place) }

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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<DiarySimpleResponseParam> {
fun findAllByMemoryDate(param: DiarySimpleRequestParam): List<DiaryResponseParam> {
return diaryQueryRepository.findAllByMemoryDate(param)
}

fun findAll(userId: Long, partnerId: Long?): List<DiarySimpleResponseParam> {
fun findAll(userId: Long, partnerId: Long?): List<DiaryResponseParam> {
return diaryQueryRepository.findAll(userId, partnerId)
}
}