Skip to content

Commit

Permalink
[SAMBAD-329] 질문 소제목 관련 정보 추가를 위한 QuestionTitleResponse 추가 (#159)
Browse files Browse the repository at this point in the history
* [SAMBAD-329] 질문 소제목 관련 정보 추가를 위한 QuestionTitleResponse 추가

* [SAMBAD-329] active dto 필수 여부 수정

* [SAMBAD-329] TimeZone 설정 추가
  • Loading branch information
kkjsw17 authored Sep 13, 2024
1 parent f8c9868 commit da5cd82
Show file tree
Hide file tree
Showing 20 changed files with 141 additions and 31 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
package org.depromeet.sambad.moring.api;

import java.util.TimeZone;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import jakarta.annotation.PostConstruct;

@SpringBootApplication
public class MoringApiApplication {

private static final String TIMEZONE_KST = "Asia/Seoul";

public static void main(String[] args) {
SpringApplication.run(MoringApiApplication.class, args);
}

@PostConstruct
public void init() {
TimeZone.setDefault(TimeZone.getTimeZone(TIMEZONE_KST));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,7 @@ public MeetingAnswerListResponse findAllByOtherMeetingMemberId(Long meetingMembe
.fetch();

List<MeetingAnswerResponseCustom> responseCustoms = meetingQuestions.stream()
.map(meetingQuestion -> new MeetingAnswerResponseCustom(meetingQuestion.getId(),
meetingQuestion.getTitle(),
.map(meetingQuestion -> new MeetingAnswerResponseCustom(meetingQuestion,
getMyAnswers(meetingMemberId, meetingQuestion),
getMyComment(meetingMemberId, meetingQuestion)))
.toList();
Expand All @@ -130,8 +129,8 @@ public MyMeetingAnswerListResponse findAllByMyMeetingMemberId(Long meetingMember
.fetch();

List<MyMeetingAnswerResponseCustom> responseCustoms = meetingQuestions.stream()
.map(meetingQuestion -> new MyMeetingAnswerResponseCustom(meetingQuestion.getId(),
meetingQuestion.getTitle(),
.map(meetingQuestion -> new MyMeetingAnswerResponseCustom(
meetingQuestion,
getMyAnswers(meetingMemberId, meetingQuestion),
getMyComment(meetingMemberId, meetingQuestion),
isHidden(meetingQuestion, meetingMemberId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
import java.util.List;

import org.depromeet.sambad.moring.domain.answer.domain.Answer;
import org.depromeet.sambad.moring.domain.meeting.question.domain.MeetingQuestion;

import com.querydsl.core.annotations.QueryProjection;

public record MeetingAnswerResponseCustom(
Long meetingQuestionId,
String meetingQuestionTitle,
MeetingQuestion meetingQuestion,
List<Answer> meetingAnswers,
String comment
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
import java.util.List;

import org.depromeet.sambad.moring.domain.answer.domain.Answer;
import org.depromeet.sambad.moring.domain.meeting.question.domain.MeetingQuestion;

import com.querydsl.core.annotations.QueryProjection;

public record MyMeetingAnswerResponseCustom(
Long meetingQuestionId,
String meetingQuestionTitle,
MeetingQuestion meetingQuestion,
List<Answer> meetingAnswers,
String comment,
Boolean isHidden
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import java.util.stream.IntStream;

import org.depromeet.sambad.moring.domain.meeting.answer.infrastructure.dto.MeetingAnswerResponseCustom;
import org.depromeet.sambad.moring.domain.meeting.question.domain.MeetingQuestion;
import org.depromeet.sambad.moring.domain.question.presentation.response.QuestionTitleResponse;

import io.swagger.v3.oas.annotations.media.Schema;

Expand All @@ -16,6 +18,9 @@ public record MeetingAnswerListResponseDetail(
@Schema(title = "질문 인덱스", example = "1", requiredMode = REQUIRED)
int idx,

@Schema(description = "질문 제목 정보", requiredMode = REQUIRED)
QuestionTitleResponse questionTitle,

@Schema(title = "릴레이 질문 제목", example = "갖고 싶은 초능력은?", requiredMode = REQUIRED)
String title,

Expand All @@ -31,10 +36,12 @@ public static List<MeetingAnswerListResponseDetail> from(List<MeetingAnswerRespo
return IntStream.range(0, responseCustoms.size())
.mapToObj(i -> {
MeetingAnswerResponseCustom response = responseCustoms.get(i);
MeetingQuestion meetingQuestion = response.meetingQuestion();
return new MeetingAnswerListResponseDetail(
response.meetingQuestionId(),
meetingQuestion.getId(),
i + 1,
response.meetingQuestionTitle(),
QuestionTitleResponse.from(meetingQuestion.getQuestion()),
meetingQuestion.getFullTitle(),
response.getMeetingAnswers(),
response.comment()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import java.util.stream.IntStream;

import org.depromeet.sambad.moring.domain.meeting.answer.infrastructure.dto.MyMeetingAnswerResponseCustom;
import org.depromeet.sambad.moring.domain.meeting.question.domain.MeetingQuestion;
import org.depromeet.sambad.moring.domain.question.presentation.response.QuestionTitleResponse;

import io.swagger.v3.oas.annotations.media.Schema;

Expand All @@ -16,6 +18,9 @@ public record MyMeetingAnswerListResponseDetail(
@Schema(title = "질문 인덱스", example = "1", requiredMode = REQUIRED)
int idx,

@Schema(description = "질문 제목 정보", requiredMode = REQUIRED)
QuestionTitleResponse questionTitle,

@Schema(title = "릴레이 질문 제목", example = "갖고 싶은 초능력은?", requiredMode = REQUIRED)
String title,

Expand All @@ -34,10 +39,12 @@ public static List<MyMeetingAnswerListResponseDetail> from(List<MyMeetingAnswerR
return IntStream.range(0, responseCustoms.size())
.mapToObj(i -> {
MyMeetingAnswerResponseCustom response = responseCustoms.get(i);
MeetingQuestion meetingQuestion = response.meetingQuestion();
return new MyMeetingAnswerListResponseDetail(
response.meetingQuestionId(),
meetingQuestion.getId(),
i + 1,
response.meetingQuestionTitle(),
QuestionTitleResponse.from(meetingQuestion.getQuestion()),
meetingQuestion.getFullTitle(),
response.getMeetingAnswers(),
response.comment(),
response.isHidden()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ public static MeetingMemberListResponse from(
) {
List<MeetingMember> sortedHandWavedMembers = handWavedMembers.stream()
.map(HandWavedMemberDto::handWavedMember)
.distinct()
.sorted()
.toList();

List<MeetingMember> sortedNotHandWavedMembers = notHandWavedMembers.stream()
.distinct()
.sorted()
.toList();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,4 +201,8 @@ private void validateTarget(MeetingMember targetMember) {
throw new InvalidMeetingMemberTargetException();
}
}

public String getFullTitle() {
return question.getFullTitle();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.depromeet.sambad.moring.domain.meeting.member.domain.MeetingMember;
import org.depromeet.sambad.moring.domain.meeting.member.presentation.response.MeetingMemberSummaryResponse;
import org.depromeet.sambad.moring.domain.meeting.question.domain.MeetingQuestion;
import org.depromeet.sambad.moring.domain.question.presentation.response.QuestionTitleResponse;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
Expand All @@ -18,10 +19,13 @@ public record CurrentMeetingQuestionResponse(

@FullFileUrl
@Schema(example = "https://avatars.githubusercontent.com/u/173370739?v=4", description = "모임 질문 이미지 URL",
requiredMode = REQUIRED)
requiredMode = NOT_REQUIRED)
String questionImageFileUrl,

@Schema(example = "갖고 싶은 초능력은?", description = "모임 질문 TITLE", requiredMode = REQUIRED)
@Schema(description = "질문 제목 정보", requiredMode = NOT_REQUIRED)
QuestionTitleResponse questionTitle,

@Schema(example = "갖고 싶은 초능력은?", description = "모임 질문 TITLE", requiredMode = NOT_REQUIRED)
String title,

@Schema(example = "18", description = "모임 내 질문 인덱스로 1 부터 시작합니다.", requiredMode = REQUIRED)
Expand Down Expand Up @@ -75,7 +79,8 @@ public static CurrentMeetingQuestionResponse questionRegisteredOf(MeetingQuestio
return CurrentMeetingQuestionResponse.builder()
.meetingQuestionId(meetingQuestion.getId())
.questionImageFileUrl(meetingQuestion.getQuestion().getQuestionImageUrl())
.title(meetingQuestion.getQuestion().getTitle())
.questionTitle(QuestionTitleResponse.from(meetingQuestion.getQuestion()))
.title(meetingQuestion.getFullTitle())
.questionNumber(meeting.getQuestionNumber(meetingQuestion))
.totalMeetingMemberCount(meeting.getTotalMemberCount())
.responseCount(meetingQuestion.getResponseCount())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.depromeet.sambad.moring.domain.meeting.meeting.domain.Meeting;
import org.depromeet.sambad.moring.domain.meeting.member.presentation.response.MeetingMemberSummaryResponse;
import org.depromeet.sambad.moring.domain.meeting.question.domain.MeetingQuestion;
import org.depromeet.sambad.moring.domain.question.presentation.response.QuestionTitleResponse;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
Expand All @@ -22,6 +23,9 @@ public record FullInactiveMeetingQuestionListResponseDetail(
requiredMode = REQUIRED)
String questionImageFileUrl,

@Schema(description = "질문 제목 정보", requiredMode = REQUIRED)
QuestionTitleResponse questionTitle,

@Schema(example = "갖고 싶은 초능력은?", description = "모임 질문 TITLE", requiredMode = REQUIRED)
String title,

Expand All @@ -42,6 +46,7 @@ public static FullInactiveMeetingQuestionListResponseDetail from(MeetingQuestion
return FullInactiveMeetingQuestionListResponseDetail.builder()
.meetingQuestionId(meetingQuestion.getId())
.questionImageFileUrl(meetingQuestion.getQuestionImageUrl())
.questionTitle(QuestionTitleResponse.from(meetingQuestion.getQuestion()))
.title(meetingQuestion.getTitle())
.questionNumber(questionNumber)
.startTime(meetingQuestion.getEpochMilliStartTime())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import org.depromeet.sambad.moring.domain.answer.domain.Answer;
import org.depromeet.sambad.moring.domain.meeting.question.domain.MeetingQuestion;
import org.depromeet.sambad.moring.domain.question.presentation.response.QuestionTitleResponse;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
Expand All @@ -15,6 +16,9 @@ public record MostInactiveMeetingQuestionListResponseDetail(
@Schema(example = "1", description = "모임 질문 식별자", requiredMode = REQUIRED)
Long meetingQuestionId,

@Schema(description = "질문 제목 정보", requiredMode = REQUIRED)
QuestionTitleResponse questionTitle,

@Schema(example = "갖고 싶은 초능력은?", description = "모임 질문 TITLE", requiredMode = REQUIRED)
String title,

Expand All @@ -32,7 +36,8 @@ public static MostInactiveMeetingQuestionListResponseDetail of(MeetingQuestion m
Optional<Answer> bestAnswer) {
return MostInactiveMeetingQuestionListResponseDetail.builder()
.meetingQuestionId(meetingQuestion.getId())
.title(meetingQuestion.getQuestion().getTitle())
.questionTitle(QuestionTitleResponse.from(meetingQuestion.getQuestion()))
.title(meetingQuestion.getFullTitle())
.content(bestAnswer.isPresent() ? bestAnswer.get().getContent() : null)
.engagementRate(meetingQuestion.calculateEngagementRate())
.startTime(meetingQuestion.getEpochMilliStartTime())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public void saveQuestion(QuestionRequest questionRequest) {
FileEntity image = fileService.uploadAndSave(questionRequest.questionImageUrl());
Question question = Question.builder()
.title(questionRequest.title())
.subtitle(questionRequest.subtitle())
.questionImageFile(image)
.questionType(questionRequest.questionType())
.answerContents(questionRequest.answerContents())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public class Question extends BaseTimeEntity {
@JoinColumn(name = "question_image_file_id")
private FileEntity questionImageFile;

private String subtitle;

private String title;

@Enumerated(EnumType.STRING)
Expand All @@ -52,10 +54,13 @@ public class Question extends BaseTimeEntity {
private List<Answer> answers = new ArrayList<>();

@Builder
public Question(String title, FileEntity questionImageFile, QuestionType questionType,
List<String> answerContents) {
public Question(
String subtitle, String title, FileEntity questionImageFile, QuestionType questionType,
List<String> answerContents
) {
QuestionType.validateAnswerCount(questionType, answerContents.size());
this.questionType = questionType;
this.subtitle = subtitle;
this.title = title;
this.questionImageFile = questionImageFile;

Expand All @@ -79,7 +84,7 @@ public String getQuestionImageUrl() {
.orElse(null);
}

public QuestionType getQuestionType() {
return questionType;
public String getFullTitle() {
return subtitle + " " + title;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.depromeet.sambad.moring.domain.question.domain;

import com.querydsl.core.annotations.QueryProjection;

public record QuestionSummaryDto(
Question question,
Long usedCount
) {

@QueryProjection
public QuestionSummaryDto {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import org.depromeet.sambad.moring.domain.common.response.PageableResponse;
import org.depromeet.sambad.moring.domain.question.application.QuestionRepository;
import org.depromeet.sambad.moring.domain.question.domain.Question;
import org.depromeet.sambad.moring.domain.question.domain.QuestionSummaryDto;
import org.depromeet.sambad.moring.domain.question.presentation.response.QuestionListResponse;
import org.depromeet.sambad.moring.domain.question.presentation.response.QuestionSummaryResponse;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Repository;

Expand Down Expand Up @@ -45,12 +45,10 @@ public QuestionListResponse findQuestionsByMeetingId(Long meetingId, Pageable pa
)
.fetch();

List<QuestionSummaryResponse> questionSummaryResponses = queryFactory
List<QuestionSummaryDto> questionSummaryResponses = queryFactory
.select(Projections.constructor(
QuestionSummaryResponse.class,
question.id.as("questionId"),
question.questionImageFile.physicalPath.as("questionImageFileUrl"),
question.title,
QuestionSummaryDto.class,
question,
as(select(meetingQuestion.count())
.from(meetingQuestion)
.where(questionEq()), "usedCount")
Expand All @@ -67,6 +65,7 @@ public QuestionListResponse findQuestionsByMeetingId(Long meetingId, Pageable pa
.from(question)
.where(question.id.notIn(usedQuestionIds))
.fetch();

return QuestionListResponse.of(questionSummaryResponses, PageableResponse.of(pageable, totalElementIds));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
import jakarta.validation.constraints.NotNull;

public record QuestionRequest(
@Schema(description = "질문 부제목", example = "다음 중", requiredMode = REQUIRED)
@NotBlank
String subtitle,

@Schema(description = "질문 제목", example = "오늘의 질문은?", requiredMode = REQUIRED)
@NotBlank
String title,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.List;

import org.depromeet.sambad.moring.domain.common.response.PageableResponse;
import org.depromeet.sambad.moring.domain.question.domain.QuestionSummaryDto;

import io.swagger.v3.oas.annotations.media.Schema;

Expand All @@ -19,8 +20,12 @@ public record QuestionListResponse<T>(
@Schema(description = "페이징 정보", requiredMode = REQUIRED)
PageableResponse<T> pageable
) {
public static <T> QuestionListResponse<T> of(List<QuestionSummaryResponse> content,
PageableResponse<T> pageableResponse) {
return new QuestionListResponse(content, pageableResponse);
public static <T> QuestionListResponse<T> of(
List<QuestionSummaryDto> dtoList, PageableResponse<T> pageableResponse
) {
List<QuestionSummaryResponse> contents = dtoList.stream()
.map(QuestionSummaryResponse::from)
.toList();
return new QuestionListResponse(contents, pageableResponse);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ public record QuestionResponse(
@Schema(description = "질문 이미지 URL", example = "https://example.com", requiredMode = REQUIRED)
String questionImageFileUrl,

@Schema(description = "질문 제목 정보", requiredMode = REQUIRED)
QuestionTitleResponse questionTitle,

@Schema(description = "질문 제목", example = "갖고 싶은 초능력은?", requiredMode = REQUIRED)
String title,

Expand All @@ -36,6 +39,7 @@ public static QuestionResponse from(final Question question) {
question.getId(),
question.getQuestionType(),
question.getQuestionImageUrl(),
QuestionTitleResponse.from(question),
question.getTitle(),
AnswerResponse.from(question.getAnswers())
);
Expand Down
Loading

0 comments on commit da5cd82

Please sign in to comment.