Skip to content

매일위키 객관식 문제 출제 기능을 구현한다.#265

Merged
le2sky merged 29 commits intomainfrom
261
Mar 31, 2025
Merged

매일위키 객관식 문제 출제 기능을 구현한다.#265
le2sky merged 29 commits intomainfrom
261

Conversation

@le2sky
Copy link
Member

@le2sky le2sky commented Mar 31, 2025

[연관 관계]

객관식 문제 출제 기능을 구현했어요. workbook -n-> question -n-> option 관계를 데이터베이스 구조에 맞춰서 ManyToOne으로 관계를 설정했습니다. 양방향을 고려하거나, 도메인 객체를 JPA로부터 분리하는 선택지가 있었지만, 얻는 이점에 비해서 현재처럼 단순하게 가져가는 것이 낫다고 생각했어요.

[저장]
workbookRepository에서 questions를 받아서 저장하는데, questionRepository로 분리할지 고민됩니다. 또한, 저장과 관련해서 persist를 고려했으나, 카톡에서 논의한 것처럼 성능상 문제로 batch insert를 사용하도록 구현했습니다.

insert into multiple_choice_option (content, is_correct_answer, created_at, updated_at, question_id) values
('1-1. 모든 예외에서 롤백된다.', 0, '2025-03-31 15:20:16.117105', '2025-03-31 15:20:16.117105', 28),
('1-2. 체크 예외(Checked Exception)에서도 롤백된다.', 0, '2025-03-31 15:20:16.117112', '2025-03-31 15:20:16.117112', 28),
('1-3. 런타임 예외(RuntimeException) 발생 시 롤백된다.', 1, '2025-03-31 15:20:16.117114', '2025-03-31 15:20:16.117114', 28),('1-4. 예외가 발생해도 롤백되지 않는다.', 0, '2025-03-31 15:20:16.117116', '2025-03-31 15:20:16.117116', 28),
('2-1. server.xml 파일을 수정한다.', 0, '2025-03-31 15:20:16.117121', '2025-03-31 15:20:16.117121', 29),
('2-2. application.properties에서 server.port를 변경한다.', 1, '2025-03-31 15:20:16.117123', '2025-03-31 15:20:16.117123', 29),
('2-3. JVM 옵션으로 --server.port=9090을 설정한다.', 0, '2025-03-31 15:20:16.117125', '2025-03-31 15:20:16.117125', 29),('2-4. 코드에서 직접 System.setProperty를 호출한다.', 0, '2025-03-31 15:20:16.117127', '2025-03-31 15:20:16.117127', 29),('3-1. @Autowired를 사용한 필드 주입', 0, '2025-03-31 15:20:16.11713', '2025-03-31 15:20:16.11713', 30),
('3-2. 생성자 주입', 0, '2025-03-31 15:20:16.117132', '2025-03-31 15:20:16.117132', 30),
('3-3. Setter 주입', 0, '2025-03-31 15:20:16.117134', '2025-03-31 15:20:16.117134', 30),
('3-4. main 메서드에서 직접 인스턴스 생성', 1, '2025-03-31 15:20:16.117136', '2025-03-31 15:20:16.117136', 30)

image

@github-actions
Copy link

github-actions bot commented Mar 31, 2025

Test Results

151 tests   150 ✅  6s ⏱️
 46 suites    1 💤
 46 files      0 ❌

Results for commit 9a1c01a.

♻️ This comment has been updated with latest results.

Copy link
Member

@GIVEN53 GIVEN53 left a comment

Choose a reason for hiding this comment

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

고생 많으셨습니다 👍🏻 구현 깔끔해서 사소한 코멘트정도만 남겼습니다
시간되실 때 천천히 확인해주세요 :)

import maeilwiki.mutiplechoice.domain.Option;
import maeilwiki.mutiplechoice.domain.WorkbookQuestion;

public record OptionRequest(String content, boolean isCorrectAnswer) {
Copy link
Member

Choose a reason for hiding this comment

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

order 빼주셨네요 👍🏻 API 명세도 수정이 필요할 것 같습니다

Copy link
Member Author

Choose a reason for hiding this comment

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

API 명세 변경했습니다! 추후에 데이터베이스에 order를 저장할 수도 있으니(옵션 순서 변경) ERD는 따로 수정하지 않을게요.

ddl.sql Outdated
solved_count int not null,
member_id bigint not null,
created_at datetime(6) not null,
updated_at datetime(6) not null,
Copy link
Member

Choose a reason for hiding this comment

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

새로운 테이블들의 시간관련 컬럼은 datetime인 이유가 있을까요?? (단순 궁금증)

Copy link
Member Author

Choose a reason for hiding this comment

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

놓치고 있던 부분이네요. timestamp로 변경했습니다!

@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class TimeLimit {

private static final List<Integer> TIME_TABLE = List.of(5, 10, 15, 20, 25, 30, 40, 50, 60);
Copy link
Member

Choose a reason for hiding this comment

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

사소하지만 Set을 써도 괜찮을 듯 하네요

@sonarqubecloud
Copy link

@le2sky le2sky merged commit ef48603 into main Mar 31, 2025
3 checks passed
@le2sky le2sky deleted the 261 branch March 31, 2025 09:37
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.

매일위키 객관식 문제 출제 기능을 구현한다.

2 participants