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

implement Question Domain #23

Merged
merged 2 commits into from
Apr 2, 2024
Merged

implement Question Domain #23

merged 2 commits into from
Apr 2, 2024

Conversation

daehwan2da
Copy link
Collaborator

✒️ 관련 이슈번호

🔑 Key Changes

📸 Screenshot

📢 To Reviewers

Comment on lines 27 to 47
@Column(name = "element_type", nullable = false, length = 30)
@Enumerated(EnumType.STRING)
var elementType: ElementType,
var elementType: ElementType = elementType
private set


@Column(name = "question_title", nullable = false, length = 100)
var title: String,
var title: String = title
private set

@Column(name = "question_content", nullable = false, length = 300)
var content: String,

@OneToMany(mappedBy = "question", fetch = FetchType.LAZY, cascade = [CascadeType.ALL], orphanRemoval = true)
var answers: List<Answer>
var content: String = content
private set

) : BaseEntity() {
@Column(name = "exposed_at", nullable = false, unique = true)
var exposedAt: LocalDateTime = exposedAt
private set
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저 이런식으로 선언하는건 처음보는데, 기존 방식이랑 어떤게 다른건가용?! 궁금합니당 ㅋㅋ
그리고 _id 이렇게 사용하는 부분은 다른 엔티티들에도 한번에 적용해놔도 좋을 것 같아요!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

생성자에 var 을 두면 setter 가 열려서 private 해지게하져고 필드에서 선언해주었어요~

Comment on lines 5 to 11
data class QuestionResult(
val questionId: Long,
val title: String,
val content: String,
val elementType: ElementType,
val exposedAt: LocalDateTime,
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저희 dto 들 네이밍 컨벤션도 맞추면 좋을 것 같아요!
저는 ~RequestDto, ~ResponseDto, ~Dto 이렇게 사용했는데
한번 통일하면 좋을 것 같습니당.

Comment on lines 10 to 27
@Component
class QuestionRetriever(
private val questionRepository: QuestionRepository,
) {
fun findQuestion(date: LocalDateTime): Question =
questionRepository.findByExposedAtOrNull(date) ?: throw InternalServerException(
ErrorCode.DATA_NOT_READY_EXCEPTION,
"($date) 날짜의 질문데이터가 준비되지 않았습니다. "
)

fun findMyQuestionsMonthly(memberId: Long, yearMonth: YearMonth): List<Question> =
questionRepository.findAllByExposedMonthIn(memberId, yearMonth)

fun findAnsweredYearMonth(memberId: Long): Set<YearMonth> =
questionRepository.findAllExposedAtIAnsweredMonth(memberId)
.map { YearMonth.of(it.year, it.monthValue) }
.toSet() // application 에서 중복 처리중, 500 넘는 warn log 발생시 월별 1건 조회하도록 쿼리 개선 필요!
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기도 컨벤션 맞추면 좋을 것 같아요! Member 쪽에는 MemberExplorer 라고 올려둬서..

Comment on lines 41 to 43
LocalDateTime.of(yearMonth.year, yearMonth.monthValue, 1, 0, 0),
// end (end day of month, 윤년 포함)
LocalDateTime.of(yearMonth.year, yearMonth.monthValue, yearMonth.month.maxLength(), 0, 0),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

달의 마지막 날의 경우 yyyyMMddHHmmss 를 20240301000000 일 경우에,
between 에 포함될까요? 안전하게 23시 59분 59초 정도로 세팅해줘도 좋을 것 같아요!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

더 안전하게 하기위해
gte(before), lt(later) 로 정의해둘게요

Comment on lines 52 to 59
override fun findAllExposedAtIAnsweredMonth(memberId: Long): List<LocalDateTime> {
return queryFactory
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo 한번 확인 부탁드립니다!

Comment on lines 21 to 26
@Auth
@Operation(summary = "오늘의 질문")
@GetMapping("/api/v1/questions/today")
fun getQuestionToday(): ApiResponse<QuestionTodayResponse> = questionService.getQuestionToday().let {
ApiResponse.success(toQuestionTodayResponse(it))
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오늘의 질문을 답변했을 때, 모두의 답변 보기가 활성화되어야 해서,
오늘의 질문 답변 여부 조회 api 도 필요할 것 같아요!

@daehwan2da daehwan2da force-pushed the feature/#22 branch 2 times, most recently from 465b507 to a76f8ed Compare March 6, 2024 13:52
private val questionService: QuestionService,
) {
@Auth
@Operation(summary = "오늘의 질문")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 파일의 Operation 부분 명세서와 동일하게 기재해주면 좋을 것 같아요
예를 들면, [인증] 오늘의 질문 조회 로요!

add exposed_at column as unique
get today question api
get question i answered api
get yearMonth i answered api
@daehwan2da daehwan2da merged commit f3ccb8a into develop Apr 2, 2024
1 of 2 checks passed
@daehwan2da daehwan2da deleted the feature/#22 branch April 2, 2024 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEAT] 오늘의 질문
3 participants