Skip to content

Commit

Permalink
refactor : 북마크 조회시 시간 데이터 어플리케이션 레벨에서 변환하도록 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
JunHwan Kim committed Feb 14, 2024
1 parent 17cf30a commit 81b9f97
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import java.util.List;

import static com.querydsl.core.types.dsl.Expressions.stringTemplate;
import static dnd.project.domain.bookmark.entity.QBookmark.bookmark;
import static dnd.project.domain.lecture.entity.QLecture.lecture;
import static dnd.project.domain.user.entity.QUsers.users;
Expand All @@ -30,7 +29,7 @@ public List<BookmarkResponse.Detail> findByMyBookmark(Long userId) {
bookmark.lecture.source.as("source"),
bookmark.lecture.title.as("title"),
bookmark.lecture.price.as("price"),
stringTemplate("TO_CHAR({0}, 'yyyy-MM-dd')", bookmark.createdDate).as("addedDate")))
bookmark.createdDate.as("addedDate")))
.from(bookmark)
.innerJoin(bookmark.lecture, lecture)
.innerJoin(bookmark.user, users)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package dnd.project.domain.bookmark.response;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

public class BookmarkResponse {

@AllArgsConstructor
Expand All @@ -19,6 +22,7 @@ public static class Detail {
private String source;
private String title;
private String price;
private String addedDate;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "Asia/Seoul")
private LocalDateTime addedDate;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class EmbeddedRedisConfig {

@PostConstruct
public void redisServer() throws IOException {
redisServer = new RedisServer(isRedisRunning()? findAvailablePort() : port);
redisServer = new RedisServer(isRedisRunning() ? findAvailablePort() : port);
try {
redisServer.start();
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders;
import org.springframework.restdocs.payload.JsonFieldType;

import java.time.LocalDateTime;
import java.util.List;

import static com.epages.restdocs.apispec.MockMvcRestDocumentationWrapper.document;
Expand Down Expand Up @@ -117,7 +118,7 @@ void readMyBookmark() throws Exception {
.source("fastcampus")
.title("100가지 시나리오로 학습하는 프론트엔드 : 5년 이상 경험을 초압축한 실전 문제 해결 패키지")
.price("211000")
.addedDate("2023-08-02")
.addedDate(LocalDateTime.of(2023, 8, 2, 0, 0, 0))
.build();

BookmarkResponse.Detail response2 = BookmarkResponse.Detail.builder()
Expand All @@ -128,7 +129,7 @@ void readMyBookmark() throws Exception {
.source("fastcampus")
.title("시그니처 백엔드 Path 초격차 패키지 Online.")
.price("216500")
.addedDate("2023-08-07")
.addedDate(LocalDateTime.of(2023, 8, 7, 0, 0, 0))
.build();

BookmarkResponse.Detail response3 = BookmarkResponse.Detail.builder()
Expand All @@ -139,7 +140,7 @@ void readMyBookmark() throws Exception {
.source("coloso")
.title("영국 왕실에서만 사용하는 비밀 디저트 레시피 오픈")
.price("725000")
.addedDate("2023-08-14")
.addedDate(LocalDateTime.of(2023, 8, 14, 0, 0, 0))
.build();

given(bookmarkService.readMyBookmark(any()))
Expand Down

0 comments on commit 81b9f97

Please sign in to comment.