-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from nunsongCookie/main
Feat: CI/CD 배포 테스트를 위한 머지 요청
- Loading branch information
Showing
51 changed files
with
1,208 additions
and
18 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
## 📌연관 이슈 | ||
<!-- #Issue_number --> | ||
|
||
## ✨작업 내용 | ||
<!-- 작업 코드 내용 --> | ||
|
||
## PR 유형 | ||
|
||
- [ ] 새로운 기능 추가 | ||
- [ ] 버그 수정 | ||
- [ ] CSS 등 사용자 UI 디자인 변경 | ||
- [ ] 코드에 영향을 주지 않는 변경사항(오타 수정, 탭 사이즈 변경, 변수명 변경) | ||
- [ ] 코드 리팩토링 | ||
- [ ] 주석 추가 및 수정 | ||
- [ ] 문서 수정 | ||
- [ ] 테스트 추가, 테스트 리팩토링 | ||
- [ ] 빌드 부분 혹은 패키지 매니저 수정 | ||
- [ ] 파일 혹은 폴더명 수정 | ||
- [ ] 파일 혹은 폴더 삭제 | ||
|
||
## 스크린샷 (선택) | ||
|
||
## 📑비고 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,3 +35,6 @@ out/ | |
|
||
### VS Code ### | ||
.vscode/ | ||
|
||
### ENV ### | ||
/src/main/resources/properties/env.properties |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/main/java/site/examready2025/quiz/config/EnvConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package site.examready2025.quiz.config; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.PropertySource; | ||
|
||
@Configuration | ||
@PropertySource("classpath:properties/env.properties") | ||
public class EnvConfig { | ||
} |
35 changes: 35 additions & 0 deletions
35
src/main/java/site/examready2025/quiz/domain/answer/controller/AnswerController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package site.examready2025.quiz.domain.answer.controller; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.CrossOrigin; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import site.examready2025.quiz.domain.answer.dto.AnswerBatchRequestDto; | ||
import site.examready2025.quiz.domain.answer.dto.AnswerRequestDto; | ||
import site.examready2025.quiz.domain.answer.service.AnswerService; | ||
|
||
import java.util.List; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@CrossOrigin(origins = "http://localhost:5173") | ||
public class AnswerController { | ||
|
||
private final AnswerService answerService; | ||
|
||
// @PostMapping("/api/answers") | ||
// public ResponseEntity<String> saveAnswers(@RequestBody AnswerBatchRequestDto requestDto){ | ||
// answerService.saveAnswers(requestDto.getResponseId(), requestDto.getAnswers()); | ||
// return ResponseEntity.status(HttpStatus.CREATED).body("답변 저장 완료"); | ||
// } | ||
|
||
@PostMapping("/api/answers") | ||
public ResponseEntity<String> saveAnswers(@RequestBody AnswerBatchRequestDto requestDto){ | ||
answerService.saveAnswers(requestDto.getResponseId(), requestDto.getQuizId(), requestDto.getAnswers()); | ||
|
||
return ResponseEntity.status(HttpStatus.CREATED).body("답변 저장 완료"); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/site/examready2025/quiz/domain/answer/dto/AnswerBatchRequestDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package site.examready2025.quiz.domain.answer.dto; | ||
|
||
import lombok.Getter; | ||
|
||
import java.util.List; | ||
|
||
@Getter | ||
public class AnswerBatchRequestDto { | ||
private Long responseId; | ||
private Long quizId; | ||
private List<AnswerRequestDto> answers; | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/site/examready2025/quiz/domain/answer/dto/AnswerRequestDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package site.examready2025.quiz.domain.answer.dto; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public class AnswerRequestDto { | ||
|
||
private Long questionId; | ||
private Long selectedChoiceId; | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/site/examready2025/quiz/domain/answer/entity/Answer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package site.examready2025.quiz.domain.answer.entity; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import site.examready2025.quiz.domain.choice.entity.Choice; | ||
import site.examready2025.quiz.domain.question.entity.Question; | ||
import site.examready2025.quiz.domain.response.entity.Response; | ||
|
||
@Entity | ||
@Getter | ||
@NoArgsConstructor | ||
@Table(name = "answer") | ||
public class Answer { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "response_id", nullable = false) | ||
private Response response; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "question_id", nullable = false) | ||
private Question question; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "selected_option_id", nullable = false) | ||
private Choice selectedChoice; | ||
|
||
@Builder | ||
public Answer(Response response, Question question, Choice selectedChoice) { | ||
this.response = response; | ||
this.question = question; | ||
this.selectedChoice = selectedChoice; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/site/examready2025/quiz/domain/answer/repository/AnswerRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package site.examready2025.quiz.domain.answer.repository; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import site.examready2025.quiz.domain.answer.entity.Answer; | ||
|
||
import java.util.List; | ||
|
||
public interface AnswerRepository extends JpaRepository<Answer, Long> { | ||
List<Answer> findByResponseId(Long responseId); | ||
} |
62 changes: 62 additions & 0 deletions
62
src/main/java/site/examready2025/quiz/domain/answer/service/AnswerService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package site.examready2025.quiz.domain.answer.service; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
import site.examready2025.quiz.domain.answer.dto.AnswerRequestDto; | ||
import site.examready2025.quiz.domain.answer.entity.Answer; | ||
import site.examready2025.quiz.domain.answer.repository.AnswerRepository; | ||
import site.examready2025.quiz.domain.choice.entity.Choice; | ||
import site.examready2025.quiz.domain.choice.repository.ChoiceRepository; | ||
import site.examready2025.quiz.domain.question.repository.QuestionRepository; | ||
import site.examready2025.quiz.domain.response.entity.Response; | ||
import site.examready2025.quiz.domain.response.repository.ResponseRepository; | ||
|
||
import java.util.List; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
@Transactional | ||
public class AnswerService { | ||
|
||
private final AnswerRepository answerRepository; | ||
private final ResponseRepository responseRepository; | ||
private final QuestionRepository questionRepository; | ||
private final ChoiceRepository choiceRepository; | ||
|
||
|
||
public void saveAnswers(Long responseId, Long quizId, List<AnswerRequestDto> answerRequestDtos){ | ||
Response response = responseRepository.findById(responseId).orElseThrow(()-> new IllegalArgumentException("해당 퀴즈 세션을 찾을 수 없습니다.")); | ||
|
||
for(AnswerRequestDto dto : answerRequestDtos){ | ||
// quizId, questionId, selectedChoiceId로 Choice를 검색 | ||
Choice choice= choiceRepository.findByQuizIdAndQuestionIdAndId(quizId, dto.getQuestionId(), dto.getSelectedChoiceId()) | ||
.orElseThrow(()-> new IllegalArgumentException("quizId로 Choice를 찾을 수 없습니다.")); | ||
|
||
Answer answer = Answer.builder() | ||
.response(response) | ||
.question(choice.getQuestion()) | ||
.selectedChoice(choice) | ||
.build(); | ||
answerRepository.save(answer); | ||
} | ||
} | ||
|
||
// public void saveAnswers(Long responseId, List<AnswerRequestDto> answerRequestDtos){ | ||
// | ||
// for(AnswerRequestDto dto : answerRequestDtos){ | ||
// Response response = responseRepository.findById(responseId).orElseThrow(()-> new IllegalArgumentException("해당 퀴즈 세션을 찾을 수 없습니다. response id : "+responseId)); | ||
// Question question = questionRepository.findById(dto.getQuestionId()) | ||
// .orElseThrow(()-> new IllegalArgumentException("해당 질문을 찾을 수 없습니다. 질문 id : "+ dto.getQuestionId())); | ||
// | ||
// Choice choice = choiceRepository.findById(dto.getSelectedChoiceId()).orElseThrow(()-> new IllegalArgumentException("해당 보기를 찾을 수 없습니다. 보기 id : "+dto.getSelectedChoiceId())); | ||
// | ||
// Answer answer = Answer.builder() | ||
// .response(response) | ||
// .question(question) | ||
// .selectedChoice(choice) | ||
// .build(); | ||
// answerRepository.save(answer); | ||
// } | ||
// } | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/site/examready2025/quiz/domain/choice/controller/ChoiceController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package site.examready2025.quiz.domain.choice.controller; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
import site.examready2025.quiz.domain.choice.dto.ChoiceBatchRequestDto; | ||
import site.examready2025.quiz.domain.choice.dto.ChoiceRequestDto; | ||
import site.examready2025.quiz.domain.choice.dto.ChoiceResponseDto; | ||
import site.examready2025.quiz.domain.choice.service.ChoiceService; | ||
|
||
import java.util.List; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@CrossOrigin(origins = "http://localhost:5173") | ||
public class ChoiceController { | ||
|
||
private final ChoiceService choiceService; | ||
|
||
// @PostMapping("/api/choices") | ||
// public ResponseEntity<String> addChoices(@RequestBody List<ChoiceRequestDto> choiceRequestDtos){ | ||
// choiceService.addChoices(choiceRequestDtos); | ||
// return ResponseEntity.status(HttpStatus.CREATED).body("보기 저장 완료"); | ||
// } | ||
|
||
@PostMapping("/api/choices") | ||
public ResponseEntity<String> addChoices(@RequestBody ChoiceBatchRequestDto choiceBatchRequestDto){ | ||
choiceService.addChoices(choiceBatchRequestDto.getQuizId(), choiceBatchRequestDto.getChoices()); | ||
return ResponseEntity.status(HttpStatus.CREATED).body("보기 저장 완료"); | ||
} | ||
|
||
// 특정 퀴즈 속한 choice 반환 | ||
@GetMapping("/api/choices/{quizId}") | ||
public ResponseEntity<List<ChoiceResponseDto>> getChoicesByQuiz(@PathVariable("quizId") Long quizId){ | ||
List<ChoiceResponseDto> choices = choiceService.getChoicesByQuiz(quizId); | ||
return ResponseEntity.ok(choices); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/site/examready2025/quiz/domain/choice/dto/ChoiceBatchRequestDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package site.examready2025.quiz.domain.choice.dto; | ||
|
||
import lombok.Getter; | ||
|
||
import java.util.List; | ||
|
||
@Getter | ||
public class ChoiceBatchRequestDto { | ||
|
||
private Long quizId; | ||
private List<ChoiceRequestDto> choices; | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/site/examready2025/quiz/domain/choice/dto/ChoiceRequestDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package site.examready2025.quiz.domain.choice.dto; | ||
|
||
import lombok.Getter; | ||
|
||
import java.util.List; | ||
|
||
@Getter | ||
public class ChoiceRequestDto { | ||
|
||
private Long questionId; | ||
private String correctAnswer; | ||
private List<String> wrongAnswers; | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/site/examready2025/quiz/domain/choice/dto/ChoiceResponseDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package site.examready2025.quiz.domain.choice.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public class ChoiceResponseDto { | ||
|
||
private Long id; | ||
private Long questionId; | ||
private String answer; | ||
private boolean isCorrect; | ||
} |
41 changes: 41 additions & 0 deletions
41
src/main/java/site/examready2025/quiz/domain/choice/entity/Choice.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package site.examready2025.quiz.domain.choice.entity; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import site.examready2025.quiz.domain.question.entity.Question; | ||
import site.examready2025.quiz.domain.quiz.entity.Quiz; | ||
|
||
@Entity | ||
@Getter | ||
@NoArgsConstructor | ||
@Table(name = "choice") | ||
public class Choice { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "quiz_id", nullable = false) | ||
private Quiz quiz; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "question_id", nullable = false) | ||
private Question question; | ||
|
||
@Column(nullable = false, length = 50) | ||
private String answer; | ||
|
||
@Column(nullable = false) | ||
private boolean isCorrect; | ||
|
||
@Builder | ||
public Choice(Quiz quiz, Question question, String answer, boolean isCorrect) { | ||
this.quiz = quiz; | ||
this.question = question; | ||
this.answer = answer; | ||
this.isCorrect = isCorrect; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/site/examready2025/quiz/domain/choice/repository/ChoiceRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package site.examready2025.quiz.domain.choice.repository; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
import site.examready2025.quiz.domain.choice.entity.Choice; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
@Repository | ||
public interface ChoiceRepository extends JpaRepository<Choice, Long> { | ||
|
||
//@Query("SELECT c FROM Choice c WHERE c.quiz.id = :quizId AND c.question.id = :questionId AND c.id = :choiceId") | ||
Optional<Choice> findByQuizIdAndQuestionIdAndId(Long quizId, Long questionId, Long choiceId); | ||
|
||
List<Choice> findByQuizId(Long quizId); | ||
} |
Oops, something went wrong.