Skip to content

Commit

Permalink
[#3] chore : 강의 노트 삭제
Browse files Browse the repository at this point in the history
  • Loading branch information
sangminee committed May 15, 2023
1 parent e13f256 commit f347cdd
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,5 @@
import com.mju.course.domain.model.other.Result.CommonResult;

public interface LectureService {
CommonResult createLectureNote(Long lecture_index, String note, String lectureNote);
CommonResult updateLectureNote(Long lecture_index, String note, String lectureNote);
CommonResult deleteLectureNote(Long lecture_index, String note);

CommonResult readLecture(Long lecture_index, String tab);
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,39 +77,4 @@ public LectureCurriculumReadDto readCurriculumLecture(Long lecture_index) {
.build();
}

@Override
public CommonResult createLectureNote(Long lecture_index, String note, String lectureNote) {
Lecture lecture = lectureRepository.findById(lecture_index)
.orElseThrow(() -> new CourseException(NOT_EXISTENT_LECTURE));

// 강의 노트 와 유저 비교해서 예외 확인하기

// 강의와 유저를 findBy 해서 이미 강의 노트가 존재하면 수정

// lectureNote 가 null 일 때

LectureNote saveLectureNote = LectureNote.of(lecture, lectureNote);
lectureNoteRepository.save(saveLectureNote);

return responseService.getSuccessfulResult();
}

@Override
public CommonResult updateLectureNote(Long lecture_index, String note, String lectureNote) {
Lecture lecture = lectureRepository.findById(lecture_index)
.orElseThrow(() -> new CourseException(NOT_EXISTENT_LECTURE));

// 수정 사항이 없을 경우


return null;
}

@Override
public CommonResult deleteLectureNote(Long lecture_index, String note) {
Lecture lecture = lectureRepository.findById(lecture_index)
.orElseThrow(() -> new CourseException(NOT_EXISTENT_LECTURE));

return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import java.util.Optional;

@Repository
public interface LectureRepository extends JpaRepository<Lecture, Long> {
public interface LectureRepository extends JpaRepository<Lecture, Long>, LectureRepositoryCustom {

List<Lecture> findByCurriculum(Curriculum curriculum);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.mju.course.domain.repository.lecture;

public interface LectureRepositoryCustom {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.mju.course.domain.repository.lecture;

import com.querydsl.jpa.impl.JPAQueryFactory;
import jakarta.persistence.EntityManager;

public class LectureRepositoryImpl implements LectureRepositoryCustom{

// private final JPAQueryFactory queryFactory;
//
// public LectureRepositoryImpl(EntityManager em) {
// this.queryFactory = new JPAQueryFactory(em);
// }
//

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ private void checkAdmin(){
// order - 생성일(createdAt - 기본값), 코스 번호(courseIndex), 난이도(difficulty), 강사 이름(lecture), 가격(price), 강의 시간(courseTime), 조회수(hit)
// 카테 고리(category)
// 페이징 처리 - page=0&size=5
@Operation(summary = "(공통) 코스 조회", description = "코스 조회 API 입니다. ")
@Operation(summary = "(운영자) 코스 조회 리스트 조회", description = "코스 조회 API 입니다. ")
@Parameters({
@Parameter(name = "page", description = "페이지 번호", required = true),
@Parameter(name = "size", description = "한 페이지에 표시되는 코스 수", required = true),
Expand All @@ -46,6 +46,8 @@ public CommonResult readAdminCourseList(@RequestParam(value = "order", required
return adminService.readAdminCourseList(state,order,pageable);
}

// 운영자 용 코스 조회

@Operation(summary = "(운영자) 코스 삭제 - 완전 삭제", description = "courseState : delete ---> 완전 삭제")
@Parameter(name = "course_index", description = "코스 인덱스")
@DeleteMapping("/manage/delete/{course_index}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,38 +29,6 @@ public CommonResult readBasicLecture(@PathVariable Long lecture_index,
return lectureService.readLecture(lecture_index, tab);
}

//////////////////////////////////////////////////////////////////////////
// 강의 노트 - 유저로 구분하기 때문에 추후 개발
// 강의 노트 작성
@PostMapping("/{lecture_index}/my-note")
public CommonResult createLectureNote(@PathVariable Long lecture_index,
@RequestParam("tab") String note,
@RequestBody String lectureNote){
return lectureService.createLectureNote(lecture_index, note, lectureNote);
}

// 강의 노트 수정
@PutMapping("/{lecture_index}/my-note")
public CommonResult updateLectureNote(@PathVariable Long lecture_index,
@RequestParam("tab") String note,
@RequestBody String lectureNote){
return lectureService.updateLectureNote(lecture_index, note, lectureNote);
}

// 강의 노트 삭제
@DeleteMapping("/{lecture_index}/my-note")
public CommonResult deleteLectureNote(@PathVariable Long lecture_index,
@RequestParam("tab") String note){
return lectureService.deleteLectureNote(lecture_index, note);
}

// 강의 질문








}

0 comments on commit f347cdd

Please sign in to comment.