Skip to content

Commit

Permalink
Merge pull request #259 from tipi-tapi/feature/254
Browse files Browse the repository at this point in the history
[관리자 일기 목록 API] 이미지 평가, 이미지 생성 시간 필드 추가
  • Loading branch information
choihuk authored Oct 9, 2023
2 parents 970231f + 3abc347 commit c1e0063
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,26 @@ public class GetDiaryAdminResponse {
@Schema(description = "일기 작성 시간", requiredMode = RequiredMode.REQUIRED)
private final LocalDateTime createdAt;

@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS")
@JsonSerialize(using = LocalDateTimeSerializer.class)
@Schema(description = "이미지 생성 시간", requiredMode = RequiredMode.REQUIRED)
private final LocalDateTime imageCreatedAt;

@Schema(description = "일기 이미지 URL", requiredMode = RequiredMode.NOT_REQUIRED)
private String imageURL;

@Schema(description = "평가 점수 (1~5 사이의 숫자)")
private final String review;

@QueryProjection
public GetDiaryAdminResponse(Long id, String imageURL, String prompt,
LocalDateTime createdAt) {
LocalDateTime createdAt, LocalDateTime imageCreatedAt, String review) {
this.id = id;
this.imageURL = imageURL;
this.prompt = prompt;
this.createdAt = createdAt;
this.imageCreatedAt = imageCreatedAt;
this.review = review;
}

public void updateImageUrl(String imageUrl) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ public Page<GetDiaryAdminResponse> getDiariesForMonitorAsPage(Pageable pageable,

List<GetDiaryAdminResponse> content = queryFactory.select(
new QGetDiaryAdminResponse(diary.diaryId, image.imageUrl, prompt.promptText,
diary.createdAt))
diary.createdAt, image.createdAt, image.review))
.from(diary)
.leftJoin(image).on(diary.diaryId.eq(image.diary.diaryId))
.leftJoin(prompt).on(diary.diaryId.eq(prompt.diary.diaryId))
.where(withoutTest, withEmotion)
.orderBy(direction.isAscending() ? diary.createdAt.asc() : diary.createdAt.desc())
.orderBy(direction.isAscending() ? image.createdAt.asc() : image.createdAt.desc())
.offset(pageable.getOffset())
.limit(pageable.getPageSize())
.fetch();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ void return_diaries_as_pagination() throws Exception {
diaries.add(new GetDiaryAdminResponse(1L,
"https://drawmytoday.s3.ap-northeast-2.amazonaws.com/2021-08-16/1.png",
"happy , pink , canvas-textured, Oil Pastel, a crowded subway",
LocalDateTime.now().minusDays(5)));
LocalDateTime.now().minusDays(5), LocalDateTime.now(), null));
diaries.add(new GetDiaryAdminResponse(2L,
"https://drawmytoday.s3.ap-northeast-2.amazonaws.com/2021-08-16/2.png",
"angry , blue , glass-textured, crayon, school",
LocalDateTime.now().minusDays(1)));
LocalDateTime.now().minusDays(1), LocalDateTime.now(), "3"));
given(adminService.getDiaries(anyLong(), anyInt(), anyInt(), any(Direction.class),
anyLong()))
.willReturn(new PageImpl<>(diaries, pageable, 2));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ void it_returns_diaries_with_pagination() {
diaries.add(new GetDiaryAdminResponse(1L,
"https://drawmytoday.s3.ap-northeast-2.amazonaws.com/2021-08-16/1.png",
"joyful , pink , canvas-textured, Oil Pastel, a crowded subway",
LocalDateTime.of(2023, 6, 16, 15, 0, 0)));
LocalDateTime.of(2023, 6, 16, 15, 0, 0), LocalDateTime.now(), "4"));
diaries.add(new GetDiaryAdminResponse(2L,
"https://drawmytoday.s3.ap-northeast-2.amazonaws.com/2021-08-16/2.png",
"angry , purple , canvas-textured, Oil Pastel, school",
LocalDateTime.of(2023, 6, 17, 15, 0, 0)));
LocalDateTime.of(2023, 6, 17, 15, 0, 0), LocalDateTime.now(), "3"));
given(adminDiaryService.getDiaries(any(Integer.class), any(Integer.class),
any(Direction.class), anyLong())).willReturn(new PageImpl<>(diaries));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ void it_returns_diaries_with_pagination() {
diaries.add(new GetDiaryAdminResponse(1L,
"https://drawmytoday.s3.ap-northeast-2.amazonaws.com/2021-08-16/1.png",
"joyful , pink , canvas-textured, Oil Pastel, a crowded subway",
LocalDateTime.of(2023, 6, 16, 15, 0, 0)));
LocalDateTime.of(2023, 6, 16, 15, 0, 0), LocalDateTime.now(), "4"));
diaries.add(new GetDiaryAdminResponse(2L,
"https://drawmytoday.s3.ap-northeast-2.amazonaws.com/2021-08-16/2.png",
"angry , purple , canvas-textured, Oil Pastel, school",
LocalDateTime.of(2023, 6, 17, 15, 0, 0)));
LocalDateTime.of(2023, 6, 17, 15, 0, 0), LocalDateTime.now(), null));
given(
diaryRepository.getDiariesForMonitorAsPage(any(Pageable.class),
any(Direction.class), eq(1L)))
Expand Down

0 comments on commit c1e0063

Please sign in to comment.