From 459bf9725e17d2e6c617352efebfe5d75e0a8f69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=B0=95=EC=A0=95=EB=AF=BC?= Date: Fri, 19 Jul 2024 13:39:03 +0900 Subject: [PATCH 1/2] feat: q&a , answer --- .../qna/controller/QnaController.java | 70 ++++++++++++--- .../com/edufocus/edufocus/qna/entity/Qna.java | 8 +- .../edufocus/qna/entity/QnaRequestDto.java | 24 +++++ .../edufocus/qna/entity/QnaResponseDto.java | 38 ++++++++ .../qna/repository/QnaRepository.java | 7 +- .../edufocus/qna/service/QnaService.java | 13 ++- .../edufocus/qna/service/QnaServiceImpl.java | 89 ++++++++++++++++--- 7 files changed, 217 insertions(+), 32 deletions(-) create mode 100644 backend/src/main/java/com/edufocus/edufocus/qna/entity/QnaRequestDto.java create mode 100644 backend/src/main/java/com/edufocus/edufocus/qna/entity/QnaResponseDto.java diff --git a/backend/src/main/java/com/edufocus/edufocus/qna/controller/QnaController.java b/backend/src/main/java/com/edufocus/edufocus/qna/controller/QnaController.java index 0a4c1d2..48cc08a 100644 --- a/backend/src/main/java/com/edufocus/edufocus/qna/controller/QnaController.java +++ b/backend/src/main/java/com/edufocus/edufocus/qna/controller/QnaController.java @@ -1,6 +1,8 @@ package com.edufocus.edufocus.qna.controller; import com.edufocus.edufocus.qna.entity.Qna; +import com.edufocus.edufocus.qna.entity.QnaRequestDto; +import com.edufocus.edufocus.qna.entity.QnaResponseDto; import com.edufocus.edufocus.qna.service.QnaService; import com.edufocus.edufocus.user.util.JWTUtil; import jakarta.servlet.http.HttpServletRequest; @@ -21,28 +23,71 @@ import java.util.List; public class QnaController { private final QnaService qnaService; private final JWTUtil jwtUtil; + private static int PAGE_SIZE=10; - @PostMapping - public ResponseEntity createQna(@RequestBody Qna qna , HttpServletRequest request) { + + @PostMapping("/{lecture_id}") + public ResponseEntity createQna(@PathVariable("lecture_id") Long lecture_id, @RequestBody QnaRequestDto qnaRequestDto , HttpServletRequest request) { try{ String token = request.getHeader("Authorization"); Long userId = Long.parseLong(jwtUtil.getUserId(token)); - qnaService.createQna(userId,qna); - return new ResponseEntity<>(qna, HttpStatus.CREATED); + QnaResponseDto qnaResponseDto= qnaService.createQna(userId,qnaRequestDto,lecture_id); + return new ResponseEntity<>( qnaResponseDto,HttpStatus.CREATED); }catch (Exception e){ throw new RuntimeException(e); } } + + @PostMapping({"/answer/create/{qna_id}"}) + public ResponseEntity createAnswer(@PathVariable("qna_id") Long qna_id, @RequestBody QnaRequestDto qnaRequestDto) + { + try { + QnaResponseDto responseDto = qnaService.createAnswer(qna_id,qnaRequestDto); + return new ResponseEntity<>(responseDto,HttpStatus.ACCEPTED); + } + catch (Exception e) + { + throw new RuntimeException(e); + } + } + + @PutMapping({"/answer/update/{qna_id}"}) + public ResponseEntity updateAnswer(@PathVariable("qna_id") Long qna_id, @RequestBody QnaRequestDto qnaRequestDto) + { + try { + QnaResponseDto responseDto = qnaService.updateAnswer(qna_id,qnaRequestDto); + return new ResponseEntity<>(responseDto,HttpStatus.ACCEPTED); + } + catch (Exception e) + { + throw new RuntimeException(e); + } + } + + @DeleteMapping("/answer/delete/{qna_id}") + public ResponseEntity deleteAnswer(@PathVariable("qna_id") Long qna_id) + { + try { + qnaService.deleteAnswer(qna_id); + return new ResponseEntity<>(HttpStatus.ACCEPTED); + } + catch (Exception e) + { + throw new RuntimeException(e); + } + } + + @PutMapping("/{id}") - public ResponseEntity updateQna(@PathVariable Long id, @RequestBody Qna qna) { + public ResponseEntity updateQna(@PathVariable Long id, @RequestBody QnaRequestDto qnaRequestDto) { try{ - qnaService.updateQna(id,qna); - return new ResponseEntity<>(qna, HttpStatus.ACCEPTED); + QnaResponseDto qnaResponseDto= qnaService.updateQna(id,qnaRequestDto); + return new ResponseEntity<>(qnaResponseDto, HttpStatus.ACCEPTED); }catch (Exception e) { @@ -72,15 +117,12 @@ public class QnaController { } @GetMapping("/all/{id}") - public ResponseEntity> getAllQna(@PathVariable Long id) { + public ResponseEntity> getAllQna(@PathVariable Long id) { try { - System.out.print("@@@@@@@@@@@@@@@@@@@@@@@>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); - List qnaList= qnaService.getAllQnasByLecture(id); - for(Qna qna:qnaList) - { - System.out.print(qna.toString()); - } + + List qnaList= qnaService.getAllQnasByLecture(id,PAGE_SIZE); + return new ResponseEntity<>(qnaList, HttpStatus.ACCEPTED); } catch (SQLException e) { throw new RuntimeException(e); diff --git a/backend/src/main/java/com/edufocus/edufocus/qna/entity/Qna.java b/backend/src/main/java/com/edufocus/edufocus/qna/entity/Qna.java index 4451568..993484e 100644 --- a/backend/src/main/java/com/edufocus/edufocus/qna/entity/Qna.java +++ b/backend/src/main/java/com/edufocus/edufocus/qna/entity/Qna.java @@ -3,8 +3,7 @@ package com.edufocus.edufocus.qna.entity; import com.edufocus.edufocus.lecture.entity.Lecture; import com.edufocus.edufocus.user.model.entity.User; import jakarta.persistence.*; -import lombok.Getter; -import lombok.Setter; +import lombok.*; import org.checkerframework.checker.units.qual.C; import java.util.Date; @@ -12,6 +11,9 @@ import java.util.Date; @Entity @Getter @Setter +@Builder +@NoArgsConstructor +@AllArgsConstructor public class Qna { // 연관관계 주인 @@ -42,6 +44,7 @@ public class Qna { private String answer; + private String name; @ManyToOne @JoinColumn(name= "id") private User user; @@ -51,4 +54,5 @@ public class Qna { private Lecture lecture; + } diff --git a/backend/src/main/java/com/edufocus/edufocus/qna/entity/QnaRequestDto.java b/backend/src/main/java/com/edufocus/edufocus/qna/entity/QnaRequestDto.java new file mode 100644 index 0000000..f73eeae --- /dev/null +++ b/backend/src/main/java/com/edufocus/edufocus/qna/entity/QnaRequestDto.java @@ -0,0 +1,24 @@ +package com.edufocus.edufocus.qna.entity; + +import jakarta.persistence.Column; +import lombok.*; + +@Getter +public class QnaRequestDto { + + + private String title; + private String content; + private String answer; + + public static Qna toEntity(QnaRequestDto qnaRequestDto) { + { + + return Qna.builder() + .content(qnaRequestDto.getContent()) + .title(qnaRequestDto.getTitle()) + .answer(qnaRequestDto.getAnswer()) + .build(); + } + } +} diff --git a/backend/src/main/java/com/edufocus/edufocus/qna/entity/QnaResponseDto.java b/backend/src/main/java/com/edufocus/edufocus/qna/entity/QnaResponseDto.java new file mode 100644 index 0000000..3ef0b6a --- /dev/null +++ b/backend/src/main/java/com/edufocus/edufocus/qna/entity/QnaResponseDto.java @@ -0,0 +1,38 @@ +package com.edufocus.edufocus.qna.entity; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.Date; + +@Getter + +@NoArgsConstructor +@AllArgsConstructor +public class QnaResponseDto { + + + private String title; + private String username; + private String content; + private Date createtAt; + private String answer; + public static QnaResponseDto toEntity(Qna qna) + { + return new QnaResponseDto( + + qna.getTitle(), + qna.getUser().getName(), + qna.getContent(), + qna.getCreatedAt(), + qna.getAnswer() + ); + } + + +} + + + diff --git a/backend/src/main/java/com/edufocus/edufocus/qna/repository/QnaRepository.java b/backend/src/main/java/com/edufocus/edufocus/qna/repository/QnaRepository.java index beeba54..d2cbf7f 100644 --- a/backend/src/main/java/com/edufocus/edufocus/qna/repository/QnaRepository.java +++ b/backend/src/main/java/com/edufocus/edufocus/qna/repository/QnaRepository.java @@ -1,6 +1,8 @@ package com.edufocus.edufocus.qna.repository; import com.edufocus.edufocus.qna.entity.Qna; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; @@ -11,8 +13,7 @@ import java.util.List; @Repository public interface QnaRepository extends JpaRepository { - @Query(value = "SELECT * FROM qna WHERE lecture_id = :lectureId", nativeQuery = true) - List findLecture(@Param("lectureId") Long lectureId); - + List findByLectureId(Long lecturerId); + Page findByLectureId(Long lectureId, Pageable pageable); } diff --git a/backend/src/main/java/com/edufocus/edufocus/qna/service/QnaService.java b/backend/src/main/java/com/edufocus/edufocus/qna/service/QnaService.java index 8acf0f5..2c84b6d 100644 --- a/backend/src/main/java/com/edufocus/edufocus/qna/service/QnaService.java +++ b/backend/src/main/java/com/edufocus/edufocus/qna/service/QnaService.java @@ -2,6 +2,8 @@ package com.edufocus.edufocus.qna.service; import com.edufocus.edufocus.lecture.entity.Lecture; import com.edufocus.edufocus.qna.entity.Qna; +import com.edufocus.edufocus.qna.entity.QnaRequestDto; +import com.edufocus.edufocus.qna.entity.QnaResponseDto; import jakarta.transaction.Transactional; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -11,9 +13,14 @@ import java.util.List; @Service public interface QnaService { - void createQna(Long id,Qna qna) throws SQLException; - void updateQna(Long id,Qna qna) throws SQLException; + QnaResponseDto createQna(Long id, QnaRequestDto qnaRequestDto, Long lecture_id) throws SQLException; + QnaResponseDto updateQna(Long id,QnaRequestDto qnaRequestDto) throws SQLException; void deleteQna(Long id) throws SQLException; Qna getQna(Long id) throws SQLException; - List getAllQnasByLecture(Long lectureId) throws SQLException; + + List getAllQnasByLecture(Long lectureId,int pageNumber) throws SQLException; + QnaResponseDto createAnswer(Long id,QnaRequestDto qnaRequestDto) throws SQLException; + QnaResponseDto updateAnswer(Long id,QnaRequestDto qnaRequestDto) throws SQLException; + void deleteAnswer(Long id) throws SQLException; + } diff --git a/backend/src/main/java/com/edufocus/edufocus/qna/service/QnaServiceImpl.java b/backend/src/main/java/com/edufocus/edufocus/qna/service/QnaServiceImpl.java index 4e6cdc2..e53f585 100644 --- a/backend/src/main/java/com/edufocus/edufocus/qna/service/QnaServiceImpl.java +++ b/backend/src/main/java/com/edufocus/edufocus/qna/service/QnaServiceImpl.java @@ -1,15 +1,28 @@ package com.edufocus.edufocus.qna.service; +import com.edufocus.edufocus.lecture.entity.Lecture; +import com.edufocus.edufocus.lecture.repository.LectureRepository; import com.edufocus.edufocus.qna.entity.Qna; +import com.edufocus.edufocus.qna.entity.QnaRequestDto; +import com.edufocus.edufocus.qna.entity.QnaResponseDto; import com.edufocus.edufocus.qna.repository.QnaRepository; +import com.edufocus.edufocus.user.model.entity.User; +import com.edufocus.edufocus.user.model.repository.UserRepository; import jakarta.transaction.Transactional; import lombok.RequiredArgsConstructor; import lombok.Setter; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; import org.springframework.stereotype.Service; +import java.sql.SQLException; +import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Optional; +import java.util.stream.Collectors; @Service @Transactional @@ -17,25 +30,46 @@ import java.util.Optional; public class QnaServiceImpl implements QnaService{ private final QnaRepository qnaRepository; + private final LectureRepository lectureRepository; + private final UserRepository userRepository; + @Override - public void createQna(Long id,Qna qna) { + public QnaResponseDto createQna(Long id, QnaRequestDto qnaRequestDto, Long lecture_id) { - qna.setId(id); + Lecture lecture = lectureRepository.findById(lecture_id).orElse(null); + + User user = userRepository.findById(id).orElse(null); + + + + Qna qna = QnaRequestDto.toEntity(qnaRequestDto); + qna.setLecture(lecture); + qna.setUser(user); + + qna.setCreatedAt(new Date()); + qnaRepository.save(qna); - + return QnaResponseDto.toEntity(qna); } @Override - public void updateQna(Long id,Qna qna) { + public QnaResponseDto updateQna(Long id,QnaRequestDto qnaRequestDto) { - Optional findQna = qnaRepository.findById(id); + Qna findQna = qnaRepository.findById(id) + .orElseThrow(() -> new RuntimeException("QnA not found")); - qna.setModifiedAt(new Date()); - qnaRepository.save(qna); + findQna.setModifiedAt(new Date()); + findQna.setTitle(qnaRequestDto.getTitle()); + findQna.setContent(qnaRequestDto.getContent()); + + qnaRepository.save(findQna); + + + return QnaResponseDto.toEntity(findQna); } @@ -51,11 +85,46 @@ qnaRepository.deleteById(id); } @Override - public List getAllQnasByLecture(Long lectureId) { + public List getAllQnasByLecture(Long lectureId,int pageSize) + { + + Pageable pageable = PageRequest.of(0, pageSize); + + Page qnaPage = qnaRepository.findByLectureId(lectureId, pageable); - System.out.printf(lectureId+"!!!!!!!!!!!!!!!!!!!!!!"); - return qnaRepository.findLecture(lectureId); + return qnaPage.getContent().stream() + .map(QnaResponseDto::toEntity) + .collect(Collectors.toList()); } + + @Override + public QnaResponseDto createAnswer(Long id, QnaRequestDto qnaRequestDto) throws SQLException { + + Qna findQna = qnaRepository.findById(id).orElse(null); + findQna.setAnswer(qnaRequestDto.getAnswer()); + + qnaRepository.save(findQna); + + return QnaResponseDto.toEntity(findQna); + + } + + @Override + public QnaResponseDto updateAnswer(Long id, QnaRequestDto qnaRequestDto) throws SQLException { + + Qna findQna = qnaRepository.findById(id).orElse(null); + findQna.setAnswer(qnaRequestDto.getAnswer()); + + qnaRepository.save(findQna); + + return QnaResponseDto.toEntity(findQna); + } + + @Override + public void deleteAnswer(Long id) throws SQLException { + + qnaRepository.deleteById(id); + } } From c04142afd1e70f5d0ca99cfc0d2aae60de4363e8 Mon Sep 17 00:00:00 2001 From: kgc9007 Date: Fri, 19 Jul 2024 13:44:32 +0900 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20Lecture=20=EA=B0=95=EC=9D=98=20?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=20=EC=88=98=EC=A0=95,=20=EB=82=B4=20?= =?UTF-8?q?=EA=B0=95=EC=9D=98=EB=AA=A9=EB=A1=9D=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lecture/controller/LectureController.java | 14 ++++- .../edufocus/lecture/entity/Lecture.java | 8 +-- .../lecture/repository/LectureRepository.java | 6 +- .../lecture/service/LectureService.java | 2 + .../lecture/service/LectureServiceImpl.java | 58 ++++++++++++++----- 5 files changed, 68 insertions(+), 20 deletions(-) diff --git a/backend/src/main/java/com/edufocus/edufocus/lecture/controller/LectureController.java b/backend/src/main/java/com/edufocus/edufocus/lecture/controller/LectureController.java index e532525..ec71557 100644 --- a/backend/src/main/java/com/edufocus/edufocus/lecture/controller/LectureController.java +++ b/backend/src/main/java/com/edufocus/edufocus/lecture/controller/LectureController.java @@ -1,5 +1,6 @@ package com.edufocus.edufocus.lecture.controller; +import com.edufocus.edufocus.lecture.entity.Lecture; import com.edufocus.edufocus.lecture.entity.LectureCreateRequest; import com.edufocus.edufocus.lecture.entity.LectureSearchResponse; import com.edufocus.edufocus.lecture.entity.LectureDetailResponse; @@ -24,7 +25,6 @@ public class LectureController { private final LectureService lectureService; private final JWTUtil jwtUtil; - private final UserService userService; @PostMapping public ResponseEntity createLecture(@RequestHeader("Authorization") String accessToken, @RequestBody LectureCreateRequest lectureCreateRequest) { @@ -34,6 +34,18 @@ public class LectureController { return new ResponseEntity<>(HttpStatus.CREATED); } + @PutMapping("/{lectureId}") + public ResponseEntity updateLecture(@RequestHeader("Authorization") String accessToken, @PathVariable Long lectureId, @RequestBody LectureCreateRequest lectureCreateRequest) { + Long userId = Long.parseLong(jwtUtil.getUserId(accessToken)); + + if (!lectureService.updateLecture(userId, lectureId, lectureCreateRequest)) { + return new ResponseEntity<>(HttpStatus.BAD_REQUEST); + } + + return new ResponseEntity<>(HttpStatus.OK); + } + + @DeleteMapping("/{lectureId}") public ResponseEntity deleteLecture(@RequestBody long userId, @PathVariable long lectureId) { if (!lectureService.deleteLecture(userId, lectureId)) { diff --git a/backend/src/main/java/com/edufocus/edufocus/lecture/entity/Lecture.java b/backend/src/main/java/com/edufocus/edufocus/lecture/entity/Lecture.java index d2f220b..24adc42 100644 --- a/backend/src/main/java/com/edufocus/edufocus/lecture/entity/Lecture.java +++ b/backend/src/main/java/com/edufocus/edufocus/lecture/entity/Lecture.java @@ -3,16 +3,16 @@ package com.edufocus.edufocus.lecture.entity; import com.edufocus.edufocus.user.model.entity.User; import jakarta.persistence.*; -import lombok.Getter; -import lombok.Setter; +import lombok.*; -import java.util.ArrayList; import java.util.Date; -import java.util.List; @Entity @Getter @Setter +@Builder +@NoArgsConstructor +@AllArgsConstructor public class Lecture { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) diff --git a/backend/src/main/java/com/edufocus/edufocus/lecture/repository/LectureRepository.java b/backend/src/main/java/com/edufocus/edufocus/lecture/repository/LectureRepository.java index 431b96a..a8615d2 100644 --- a/backend/src/main/java/com/edufocus/edufocus/lecture/repository/LectureRepository.java +++ b/backend/src/main/java/com/edufocus/edufocus/lecture/repository/LectureRepository.java @@ -10,8 +10,10 @@ import java.util.List; @Repository public interface LectureRepository extends JpaRepository { - Lecture findByTitle(@Param("title") String title); + Lecture findByTitle(String title); - List findAllByUserId(@Param("userId") Long userId); + List findAllByUserId(Long userId); + + List findLecturesByUserId(Long userId); } diff --git a/backend/src/main/java/com/edufocus/edufocus/lecture/service/LectureService.java b/backend/src/main/java/com/edufocus/edufocus/lecture/service/LectureService.java index b359aa0..29eb908 100644 --- a/backend/src/main/java/com/edufocus/edufocus/lecture/service/LectureService.java +++ b/backend/src/main/java/com/edufocus/edufocus/lecture/service/LectureService.java @@ -13,6 +13,8 @@ public interface LectureService { void createLecture(long userId, LectureCreateRequest lectureCreateRequest); + boolean updateLecture(long userId, long lectureId, LectureCreateRequest lectureCreateRequest); + boolean deleteLecture(long userId, long LectureId); List findAllLecture(); diff --git a/backend/src/main/java/com/edufocus/edufocus/lecture/service/LectureServiceImpl.java b/backend/src/main/java/com/edufocus/edufocus/lecture/service/LectureServiceImpl.java index 9f9eec8..1e808ac 100644 --- a/backend/src/main/java/com/edufocus/edufocus/lecture/service/LectureServiceImpl.java +++ b/backend/src/main/java/com/edufocus/edufocus/lecture/service/LectureServiceImpl.java @@ -8,6 +8,7 @@ import com.edufocus.edufocus.lecture.repository.LectureRepository; import com.edufocus.edufocus.registration.entity.Registration; import com.edufocus.edufocus.registration.repository.RegistrationRepository; import com.edufocus.edufocus.user.model.entity.User; +import com.edufocus.edufocus.user.model.entity.UserRole; import com.edufocus.edufocus.user.model.repository.UserRepository; import jakarta.transaction.Transactional; import lombok.Builder; @@ -31,22 +32,54 @@ public class LectureServiceImpl implements LectureService { @Override public void createLecture(long userId, LectureCreateRequest lectureCreateRequest) { - User user = userRepository.findById(userId).get(); - Lecture lecture = new Lecture(); - lecture.setUser(user); - - lecture.setTitle(lectureCreateRequest.getTitle()); - lecture.setDescription(lectureCreateRequest.getDescription()); - lecture.setImage(lectureCreateRequest.getImage()); - lecture.setStartDate(lectureCreateRequest.getStartDate()); - lecture.setEndDate(lectureCreateRequest.getEndDate()); - lecture.setPlan(lectureCreateRequest.getPlan()); + Lecture lecture = new Lecture().builder() + .user(user) + .title(lectureCreateRequest.getTitle()) + .description(lectureCreateRequest.getDescription()) + .image(lectureCreateRequest.getImage()) + .startDate(lectureCreateRequest.getStartDate()) + .endDate(lectureCreateRequest.getEndDate()) + .plan(lectureCreateRequest.getPlan()) + .build(); lectureRepository.save(lecture); } + @Override + public boolean updateLecture(long userId, long lectureId, LectureCreateRequest lectureCreateRequest) { + User user = userRepository.findById(userId).get(); + + Lecture lecture = lectureRepository.findById(lectureId).get(); + + if (lecture.getUser().getId() != user.getId()) { + return false; + } + + if (lectureCreateRequest.getTitle() != null) { + lecture.setTitle(lectureCreateRequest.getTitle()); + } + if (lectureCreateRequest.getDescription() != null) { + lecture.setDescription(lectureCreateRequest.getDescription()); + } + if (lectureCreateRequest.getImage() != null) { + lecture.setImage(lectureCreateRequest.getImage()); + } + if (lectureCreateRequest.getStartDate() != null) { + lecture.setStartDate(lectureCreateRequest.getStartDate()); + } + if (lectureCreateRequest.getEndDate() != null) { + lecture.setEndDate(lectureCreateRequest.getEndDate()); + } + if (lectureCreateRequest.getPlan() != null) { + lecture.setPlan(lectureCreateRequest.getPlan()); + } + + lectureRepository.save(lecture); + return true; + } + @Override public boolean deleteLecture(long userId, long lectureId) { Lecture lecture = lectureRepository.findById(lectureId).get(); @@ -105,9 +138,8 @@ public class LectureServiceImpl implements LectureService { List myLectureList = new ArrayList<>(); - if (user.getRole().equals("ADMIN")) { - List lectureList = lectureRepository.findAllByUserId(userId); - + if (user.getRole() == UserRole.ADMIN) { + List lectureList = lectureRepository.findLecturesByUserId(userId); for (Lecture lecture : lectureList) { LectureSearchResponse lectureSearchResponse = new LectureSearchResponse().builder() .id(lecture.getId())