diff --git a/src/main/java/com/mju/course/application/lecture/LectureServiceImpl.java b/src/main/java/com/mju/course/application/lecture/LectureServiceImpl.java index 23fdbbf..d0ba12e 100644 --- a/src/main/java/com/mju/course/application/lecture/LectureServiceImpl.java +++ b/src/main/java/com/mju/course/application/lecture/LectureServiceImpl.java @@ -12,8 +12,8 @@ import com.mju.course.domain.service.LectureDomainService; import com.mju.course.domain.service.ResponseService; import com.mju.course.presentation.dto.request.LectureQuestionCreateDto; -import com.mju.course.presentation.dto.request.LectureReadAnswerDto; -import com.mju.course.presentation.dto.request.LectureReadQAndADto; +import com.mju.course.presentation.dto.response.LectureAnswerReadDto; +import com.mju.course.presentation.dto.response.LectureQAndAReadDto; import com.mju.course.presentation.dto.response.*; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -84,20 +84,20 @@ public CommonResult readQAndA(Long question_index) { lectureQuestionRepository.save(lectureQuestion); // 질문 dto - LectureReadQuestionDto lectureReadQuestionDto = LectureReadQuestionDto.of(lectureQuestion); + LectureQuestionReadDto lectureQuestionReadDto = LectureQuestionReadDto.of(lectureQuestion); // 답변들 - List list = new ArrayList<>(); + List list = new ArrayList<>(); if(lectureQuestion.getLectureAnswerList() != null && lectureQuestion.getLectureAnswerList().size() != 0){ lectureQuestion.getLectureAnswerList() .forEach(s ->{ - list.add(LectureReadAnswerDto.of(s)); + list.add(LectureAnswerReadDto.of(s)); }); } - return responseService.getSingleResult(LectureReadQAndADto.builder() - .lectureReadQuestionDto(lectureReadQuestionDto) - .lectureReadAnswerDtos(list) + return responseService.getSingleResult(LectureQAndAReadDto.builder() + .lectureQuestionReadDto(lectureQuestionReadDto) + .lectureAnswerReadDtos(list) .build()); } @@ -109,7 +109,7 @@ public CommonResult readQAndA(Long question_index) { public CommonResult readQuestions(Long lecture_index, Pageable pageable) { Lecture lecture = lectureRepository.findById(lecture_index) .orElseThrow(() -> new CourseException(NOT_EXISTENT_LECTURE)); - Page result = lectureRepository.readQuestions(lecture, pageable); + Page result = lectureRepository.readQuestions(lecture, pageable); return responseService.getSingleResult(result); } diff --git a/src/main/java/com/mju/course/domain/repository/lecture/LectureRepositoryCustom.java b/src/main/java/com/mju/course/domain/repository/lecture/LectureRepositoryCustom.java index 74c826d..8e2feb6 100644 --- a/src/main/java/com/mju/course/domain/repository/lecture/LectureRepositoryCustom.java +++ b/src/main/java/com/mju/course/domain/repository/lecture/LectureRepositoryCustom.java @@ -1,10 +1,10 @@ package com.mju.course.domain.repository.lecture; import com.mju.course.domain.model.lecture.Lecture; -import com.mju.course.presentation.dto.response.LectureReadQuestionDto; +import com.mju.course.presentation.dto.response.LectureQuestionReadDto; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; public interface LectureRepositoryCustom { - Page readQuestions(Lecture lecture, Pageable pageable); + Page readQuestions(Lecture lecture, Pageable pageable); } diff --git a/src/main/java/com/mju/course/domain/repository/lecture/LectureRepositoryImpl.java b/src/main/java/com/mju/course/domain/repository/lecture/LectureRepositoryImpl.java index a0e6ae8..193b646 100644 --- a/src/main/java/com/mju/course/domain/repository/lecture/LectureRepositoryImpl.java +++ b/src/main/java/com/mju/course/domain/repository/lecture/LectureRepositoryImpl.java @@ -3,7 +3,7 @@ import com.mju.course.domain.model.lecture.Lecture; import com.mju.course.domain.model.lecture.LectureQuestion; import com.mju.course.domain.model.lecture.QLectureQuestion; -import com.mju.course.presentation.dto.response.LectureReadQuestionDto; +import com.mju.course.presentation.dto.response.LectureQuestionReadDto; import com.querydsl.jpa.JPQLQuery; import com.querydsl.jpa.impl.JPAQuery; import com.querydsl.jpa.impl.JPAQueryFactory; @@ -24,7 +24,7 @@ public LectureRepositoryImpl(EntityManager em) { } @Override - public Page readQuestions(Lecture lecture, Pageable pageable) { + public Page readQuestions(Lecture lecture, Pageable pageable) { QLectureQuestion lectureQuestion = QLectureQuestion.lectureQuestion1; JPQLQuery query = queryFactory.selectFrom(lectureQuestion) @@ -34,9 +34,9 @@ public Page readQuestions(Lecture lecture, Pageable page List lectureQuestionList = query.fetch(); - List content = new ArrayList<>(); + List content = new ArrayList<>(); lectureQuestionList.forEach(s->{ - content.add(LectureReadQuestionDto.of(s)); + content.add(LectureQuestionReadDto.of(s)); }); JPAQuery countQuery = queryFactory.selectFrom(lectureQuestion); diff --git a/src/main/java/com/mju/course/presentation/controller/LectureController.java b/src/main/java/com/mju/course/presentation/controller/LectureController.java index 9a54dc3..223475e 100644 --- a/src/main/java/com/mju/course/presentation/controller/LectureController.java +++ b/src/main/java/com/mju/course/presentation/controller/LectureController.java @@ -72,9 +72,6 @@ public CommonResult deleteQuestion(@PathVariable Long question_index){ return lectureService.deleteQuestion(question_index); } - // 강의 답변 CUD - - // 강의 질문 북마크, 북마크 취소 @Operation(summary = "강의 질문 북마크, 북마크 취소", description = "강의 질문 북마크, 북마크 취소 API 입니다. ") @GetMapping("/{question_index}/bookmark") @@ -83,4 +80,13 @@ public CommonResult lectureQuestionBookmark(@PathVariable Long question_index, return lectureService.lectureQuestionBookmark(question_index,userId); } +// // 강의 답변 CUD +// @Operation(summary = "강의 답변 작성하기", description = "강의 답변 작성하기 API 입니다. ") +// @PostMapping("/{question_index}/answer") +// public CommonResult createAnswer(@PathVariable Long question_index, +// @RequestPart(value="images", required=false) List images, +// @RequestPart(value="lectureQuestionDto") @Validated LectureQuestionCreateDto lectureQuestionCreateDto){ +// return lectureService.createAnswer(question_index, images, lectureQuestionCreateDto); +// } + } diff --git a/src/main/java/com/mju/course/presentation/dto/request/LectureReadQAndADto.java b/src/main/java/com/mju/course/presentation/dto/request/LectureReadQAndADto.java deleted file mode 100644 index 5d0d9a6..0000000 --- a/src/main/java/com/mju/course/presentation/dto/request/LectureReadQAndADto.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.mju.course.presentation.dto.request; - -import com.mju.course.presentation.dto.response.LectureReadQuestionDto; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; - -import java.util.List; - -@Getter -@AllArgsConstructor -@NoArgsConstructor -@Builder -public class LectureReadQAndADto { - private LectureReadQuestionDto lectureReadQuestionDto; - private List lectureReadAnswerDtos; -} diff --git a/src/main/java/com/mju/course/presentation/dto/request/LectureReadAnswerDto.java b/src/main/java/com/mju/course/presentation/dto/response/LectureAnswerReadDto.java similarity index 82% rename from src/main/java/com/mju/course/presentation/dto/request/LectureReadAnswerDto.java rename to src/main/java/com/mju/course/presentation/dto/response/LectureAnswerReadDto.java index 3799811..cfe03ab 100644 --- a/src/main/java/com/mju/course/presentation/dto/request/LectureReadAnswerDto.java +++ b/src/main/java/com/mju/course/presentation/dto/response/LectureAnswerReadDto.java @@ -1,4 +1,4 @@ -package com.mju.course.presentation.dto.request; +package com.mju.course.presentation.dto.response; import com.mju.course.domain.model.lecture.LectureAnswer; import io.swagger.v3.oas.annotations.media.Schema; @@ -13,7 +13,7 @@ @AllArgsConstructor @NoArgsConstructor @Builder -public class LectureReadAnswerDto { +public class LectureAnswerReadDto { @Schema(description = "질문 답변 index") private Long lectureAnswerIndex; @@ -26,8 +26,8 @@ public class LectureReadAnswerDto { @Schema(description = "답변 시간") private LocalDateTime createdAt; - public static LectureReadAnswerDto of(LectureAnswer lectureAnswer) { - return LectureReadAnswerDto.builder() + public static LectureAnswerReadDto of(LectureAnswer lectureAnswer) { + return LectureAnswerReadDto.builder() .lectureAnswerIndex(lectureAnswer.getId()) .username("답변자") .lectureAnswer(lectureAnswer.getLectureAnswer()) diff --git a/src/main/java/com/mju/course/presentation/dto/response/LectureQAndAReadDto.java b/src/main/java/com/mju/course/presentation/dto/response/LectureQAndAReadDto.java new file mode 100644 index 0000000..065f55c --- /dev/null +++ b/src/main/java/com/mju/course/presentation/dto/response/LectureQAndAReadDto.java @@ -0,0 +1,17 @@ +package com.mju.course.presentation.dto.response; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Getter +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class LectureQAndAReadDto { + private LectureQuestionReadDto lectureQuestionReadDto; + private List lectureAnswerReadDtos; +} diff --git a/src/main/java/com/mju/course/presentation/dto/response/LectureReadQuestionDto.java b/src/main/java/com/mju/course/presentation/dto/response/LectureQuestionReadDto.java similarity index 91% rename from src/main/java/com/mju/course/presentation/dto/response/LectureReadQuestionDto.java rename to src/main/java/com/mju/course/presentation/dto/response/LectureQuestionReadDto.java index e4f8e06..5e75b7f 100644 --- a/src/main/java/com/mju/course/presentation/dto/response/LectureReadQuestionDto.java +++ b/src/main/java/com/mju/course/presentation/dto/response/LectureQuestionReadDto.java @@ -13,7 +13,7 @@ @AllArgsConstructor @NoArgsConstructor @Builder -public class LectureReadQuestionDto { +public class LectureQuestionReadDto { @Schema(description = "강의 질문 index") private Long lectureQuestionIndex; @@ -38,8 +38,8 @@ public class LectureReadQuestionDto { @Schema(description = "답변 수") private long answerSum; - public static LectureReadQuestionDto of(LectureQuestion lectureQuestion) { - return LectureReadQuestionDto.builder() + public static LectureQuestionReadDto of(LectureQuestion lectureQuestion) { + return LectureQuestionReadDto.builder() .lectureQuestionIndex(lectureQuestion.getId()) .lectureQuestionTitle(lectureQuestion.getLectureQuestionTitle()) .lectureQuestion(lectureQuestion.getLectureQuestion())