diff --git a/majorLink/src/main/java/com/example/majorLink/controller/LectureController.java b/majorLink/src/main/java/com/example/majorLink/controller/LectureController.java index 1238038..d469f41 100644 --- a/majorLink/src/main/java/com/example/majorLink/controller/LectureController.java +++ b/majorLink/src/main/java/com/example/majorLink/controller/LectureController.java @@ -68,13 +68,17 @@ public void deleteLecture(@PathVariable(name = "lectureId") Long lectureId, @GetMapping("/list") @ResponseBody // 스웨거 세팅 후 파라미터 등 설명 추가 - public LectureResponseDTO.LecturePreViewList getLectures(@RequestParam(name = "page") Integer page){ + public LectureResponseDTO.LecturePreViewList getLectures(@RequestParam(name = "page", defaultValue = "1") Integer page){ Page lectureList = lectureService.getLectureList(page-1); return LectureResponseDTO.LecturePreViewList.builder() .lectureList(lectureList.stream() .map(lecture -> LectureResponseDTO.LecturePreView.builder() .name(lecture.getName()) + .cNum(lecture.getCNum()) + .pNum(lecture.getPNum()) + .mainCategory(lecture.getCategory().getMainCategory()) + .subCategory(lecture.getCategory().getSubCategory()) .build()) .collect(Collectors.toList())) .listSize(lectureList.getNumberOfElements()) @@ -85,6 +89,31 @@ public LectureResponseDTO.LecturePreViewList getLectures(@RequestParam(name = "p .build(); } + // 강의 상세페이지 + @GetMapping("/{lectureId}/details") + @ResponseBody + public LectureResponseDTO.LectureDetails getLecture(@PathVariable(name = "lectureId") Long lectureId){ + Lecture lecture = lectureService.getLecture(lectureId); + + return LectureResponseDTO.LectureDetails.builder() + .name(lecture.getName()) + .body(lecture.getBody()) + .curri(lecture.getCurri()) + .info(lecture.getInfo()) + .level(lecture.getLevel().name()) + .cNum(lecture.getCNum()) + .pNum(lecture.getPNum()) + .time(lecture.getTime().toString()) + .day(lecture.getDay().name()) + .startDate(lecture.getStartDate()) + .exam(lecture.getExam().name()) + .tag(lecture.getTag()) + .tutor(lecture.getTutor()) + .mainCategory(lecture.getCategory().getMainCategory()) + .subCategory(lecture.getCategory().getSubCategory()) + .build(); + } + // 강의 수강 신청 api @PostMapping("/{lectureId}/register") @ResponseBody @@ -100,16 +129,6 @@ public LectureResponseDTO.CreateTuteeLecture createTuteeLecture(@PathVariable(na .build(); } - // 강의 취소 api - @DeleteMapping("/{lectureId}/cancel") - @ResponseBody - public void cancelLecture(@PathVariable(name = "lectureId") Long lectureId, - @AuthenticationPrincipal AuthUser authUser){ - User user = authUser.getUser(); - - lectureService.cancelLecture(user.getId(), lectureId); - } - // 강의 좋아요 토글 api @PostMapping("/{lectureId}/like") @ResponseBody @@ -123,13 +142,17 @@ public Boolean toggleLike(@PathVariable(name = "lectureId") Long lectureId, // 좋아요 많은 강의 조회 api @GetMapping("/mostLiked") @ResponseBody - public LectureResponseDTO.LecturePreViewList getMostLikedLectures(@RequestParam(name = "page") Integer page){ + public LectureResponseDTO.LecturePreViewList getMostLikedLectures(@RequestParam(name = "page", defaultValue = "1") Integer page){ Page lectureList = lectureService.getMostLikedLecture(page-1); return LectureResponseDTO.LecturePreViewList.builder() .lectureList(lectureList.stream() .map(lecture -> LectureResponseDTO.LecturePreView.builder() .name(lecture.getName()) + .mainCategory(lecture.getCategory().getMainCategory()) + .subCategory(lecture.getCategory().getSubCategory()) + .cNum(lecture.getCNum()) + .pNum(lecture.getPNum()) .build()) .collect(Collectors.toList())) .listSize(lectureList.getNumberOfElements()) @@ -143,13 +166,17 @@ public LectureResponseDTO.LecturePreViewList getMostLikedLectures(@RequestParam( // 최신 강의 조회 api @GetMapping("/new") @ResponseBody - public LectureResponseDTO.LecturePreViewList getNewLectures(@RequestParam(name = "page") Integer page){ + public LectureResponseDTO.LecturePreViewList getNewLectures(@RequestParam(name = "page", defaultValue = "1") Integer page){ Page lectureList = lectureService.getNewLecture(page-1); return LectureResponseDTO.LecturePreViewList.builder() .lectureList(lectureList.stream() .map(lecture -> LectureResponseDTO.LecturePreView.builder() .name(lecture.getName()) + .mainCategory(lecture.getCategory().getMainCategory()) + .subCategory(lecture.getCategory().getSubCategory()) + .cNum(lecture.getCNum()) + .pNum(lecture.getPNum()) .build()) .collect(Collectors.toList())) .listSize(lectureList.getNumberOfElements()) @@ -163,13 +190,17 @@ public LectureResponseDTO.LecturePreViewList getNewLectures(@RequestParam(name = // 가장 많이 모집된 강의 조회 api @GetMapping("/mostRecruited") @ResponseBody - public LectureResponseDTO.LecturePreViewList getMostRecruitedLectures(@RequestParam(name = "page") Integer page){ + public LectureResponseDTO.LecturePreViewList getMostRecruitedLectures(@RequestParam(name = "page", defaultValue = "1") Integer page){ Page lectureList = lectureService.getMostRecruitedLecture(page-1); return LectureResponseDTO.LecturePreViewList.builder() .lectureList(lectureList.stream() .map(lecture -> LectureResponseDTO.LecturePreView.builder() .name(lecture.getName()) + .mainCategory(lecture.getCategory().getMainCategory()) + .subCategory(lecture.getCategory().getSubCategory()) + .cNum(lecture.getCNum()) + .pNum(lecture.getPNum()) .build()) .collect(Collectors.toList())) .listSize(lectureList.getNumberOfElements()) @@ -183,7 +214,7 @@ public LectureResponseDTO.LecturePreViewList getMostRecruitedLectures(@RequestPa // 카테고리별 강의 조회 api @GetMapping("/{categoryId}") @ResponseBody - public LectureResponseDTO.LecturePreViewList getLecturesByCategory(@RequestParam(name = "page") Integer page, + public LectureResponseDTO.LecturePreViewList getLecturesByCategory(@RequestParam(name = "page", defaultValue = "1") Integer page, @PathVariable(name = "categoryId") Long categoryId){ Page lectureList = lectureService.getLectureByCategory(page-1, categoryId); @@ -191,6 +222,10 @@ public LectureResponseDTO.LecturePreViewList getLecturesByCategory(@RequestParam .lectureList(lectureList.stream() .map(lecture -> LectureResponseDTO.LecturePreView.builder() .name(lecture.getName()) + .mainCategory(lecture.getCategory().getMainCategory()) + .subCategory(lecture.getCategory().getSubCategory()) + .cNum(lecture.getCNum()) + .pNum(lecture.getPNum()) .build()) .collect(Collectors.toList())) .listSize(lectureList.getNumberOfElements()) @@ -200,4 +235,30 @@ public LectureResponseDTO.LecturePreViewList getLecturesByCategory(@RequestParam .isLast(lectureList.isLast()) .build(); } + + // 메인 카테고리 조회 api + @GetMapping("/categories/main") + @ResponseBody + public LectureResponseDTO.MainCategory getMainCategory() { + return LectureResponseDTO.MainCategory.builder() + .mainCategoryList(lectureService.getMainCategory()) + .build(); + } + + // 서브 카테고리 조회 api + @GetMapping("/categories/sub") + @ResponseBody + public LectureResponseDTO.SubCategory getSubCategory(@RequestParam(name = "mainCategory") String mainCategory) { + return LectureResponseDTO.SubCategory.builder() + .subCategoryList(lectureService.getSubCategory(mainCategory)) + .build(); + } + + // 카테고리 id 조회 api + @GetMapping("/categories/id") + @ResponseBody + public Long getCategoryId(@RequestParam(name = "mainCategory") String mainCategory, + @RequestParam(name = "subCategory") String subCategory) { + return lectureService.getCategoryId(mainCategory, subCategory); + } } diff --git a/majorLink/src/main/java/com/example/majorLink/controller/ReviewController.java b/majorLink/src/main/java/com/example/majorLink/controller/ReviewController.java index f9d2995..b4b2a7b 100644 --- a/majorLink/src/main/java/com/example/majorLink/controller/ReviewController.java +++ b/majorLink/src/main/java/com/example/majorLink/controller/ReviewController.java @@ -72,6 +72,8 @@ public ReviewResponseDTO.ReviewPreViewList getReviews(@PathVariable(name = "lect .reviewList(reviewList.stream() .map(review -> ReviewResponseDTO.ReviewPreView.builder() .ownerNickname(review.getUser().getUsername()) + .createdAt(review.getCreatedAt()) + .title(review.getTitle()) .rate(review.getRate()) .build()) .collect(Collectors.toList())) @@ -86,11 +88,12 @@ public ReviewResponseDTO.ReviewPreViewList getReviews(@PathVariable(name = "lect // 리뷰 내용 조회 api @GetMapping("/{reviewId}/details") @ResponseBody - public ReviewResponseDTO.ReviewPreView getReview(@PathVariable(name = "reviewId") Long reviewId){ + public ReviewResponseDTO.ReviewDetails getReview(@PathVariable(name = "reviewId") Long reviewId){ Review review = reviewService.getReview(reviewId); - return ReviewResponseDTO.ReviewPreView.builder() + return ReviewResponseDTO.ReviewDetails.builder() .ownerNickname(review.getUser().getUsername()) + .title(review.getTitle()) .rate(review.getRate()) .content(review.getContent()) .createdAt(review.getCreatedAt()) diff --git a/majorLink/src/main/java/com/example/majorLink/domain/Lecture.java b/majorLink/src/main/java/com/example/majorLink/domain/Lecture.java index 28b9286..ec0d14d 100644 --- a/majorLink/src/main/java/com/example/majorLink/domain/Lecture.java +++ b/majorLink/src/main/java/com/example/majorLink/domain/Lecture.java @@ -27,7 +27,7 @@ public class Lecture extends BaseEntity{ private String body; @Column(nullable = false) - private int curri; + private Integer curri; @Column(nullable = false, length = 1000) private String info; @@ -38,11 +38,11 @@ public class Lecture extends BaseEntity{ // 총 인원 @Column(nullable = false) - private int pNum; + private Integer pNum; // 현재 신청 인원 @Column(nullable = false) - private int curPNum; + private Integer cNum; private LocalTime time; @@ -57,7 +57,7 @@ public class Lecture extends BaseEntity{ @Column(nullable = false, columnDefinition = "VARCHAR(10)") private Exam exam; - @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) + @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "category_id") private Category category; @@ -83,10 +83,10 @@ public void updateLecture(String name, String body, int curri, String info, Leve } public void addCurPNum(){ - this.curPNum++; + this.cNum++; } public void subCurPNum(){ - this.curPNum--; + this.cNum--; } } \ No newline at end of file diff --git a/majorLink/src/main/java/com/example/majorLink/dto/request/LectureRequestDTO.java b/majorLink/src/main/java/com/example/majorLink/dto/request/LectureRequestDTO.java index 52d4385..d9078a3 100644 --- a/majorLink/src/main/java/com/example/majorLink/dto/request/LectureRequestDTO.java +++ b/majorLink/src/main/java/com/example/majorLink/dto/request/LectureRequestDTO.java @@ -3,24 +3,30 @@ import com.example.majorLink.domain.enums.Day; import com.example.majorLink.domain.enums.Exam; import com.example.majorLink.domain.enums.Level; +import lombok.AllArgsConstructor; import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; import java.time.LocalTime; import java.util.Date; @Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor public class LectureRequestDTO { // 새로운 강의 등록할때 필요한 정보들 작성 String name; String body; // 강의 개요 - int curri; // 강의 횟수 + Integer curri; // 강의 횟수 String info; // 강의 정보 Level level; - int pNum; LocalTime time; Day day; // 요일 Date startDate; Exam exam; // 시험 유무 Long categoryId; String tag; + Integer num; // 정원 } diff --git a/majorLink/src/main/java/com/example/majorLink/dto/response/LectureResponseDTO.java b/majorLink/src/main/java/com/example/majorLink/dto/response/LectureResponseDTO.java index a74dccc..ed6109d 100644 --- a/majorLink/src/main/java/com/example/majorLink/dto/response/LectureResponseDTO.java +++ b/majorLink/src/main/java/com/example/majorLink/dto/response/LectureResponseDTO.java @@ -6,6 +6,7 @@ import lombok.NoArgsConstructor; import java.time.LocalDateTime; +import java.util.Date; import java.util.List; public class LectureResponseDTO { @@ -24,6 +25,32 @@ public static class CreateLecture { @NoArgsConstructor public static class LecturePreView { String name; + Integer cNum; + Integer pNum; + String mainCategory; + String subCategory; + } + + @Builder + @Getter + @AllArgsConstructor + @NoArgsConstructor + public static class LectureDetails { + String name; + String body; + Integer curri; + String info; + String level; + Integer cNum; + Integer pNum; + String time; + String day; + Date startDate; + String exam; + String tag; + String tutor; + String mainCategory; + String subCategory; } @Builder @@ -56,4 +83,20 @@ public static class CreateTuteeLecture { Long tuteeLectureId; LocalDateTime createdAt; } + + @Builder + @Getter + @AllArgsConstructor + @NoArgsConstructor + public static class MainCategory { + List mainCategoryList; + } + + @Builder + @Getter + @AllArgsConstructor + @NoArgsConstructor + public static class SubCategory { + List subCategoryList; + } } diff --git a/majorLink/src/main/java/com/example/majorLink/dto/response/ReviewResponseDTO.java b/majorLink/src/main/java/com/example/majorLink/dto/response/ReviewResponseDTO.java index 7818397..9940175 100644 --- a/majorLink/src/main/java/com/example/majorLink/dto/response/ReviewResponseDTO.java +++ b/majorLink/src/main/java/com/example/majorLink/dto/response/ReviewResponseDTO.java @@ -26,6 +26,18 @@ public static class CreateReview { public static class ReviewPreView { String ownerNickname; int rate; + String title; + LocalDateTime createdAt; + } + + @Builder + @Getter + @AllArgsConstructor + @NoArgsConstructor + public static class ReviewDetails { + String ownerNickname; + int rate; + String title; String content; LocalDateTime createdAt; } diff --git a/majorLink/src/main/java/com/example/majorLink/repository/CategoryRepository.java b/majorLink/src/main/java/com/example/majorLink/repository/CategoryRepository.java index b4cf253..9a5bb21 100644 --- a/majorLink/src/main/java/com/example/majorLink/repository/CategoryRepository.java +++ b/majorLink/src/main/java/com/example/majorLink/repository/CategoryRepository.java @@ -2,9 +2,19 @@ import com.example.majorLink.domain.Category; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; import org.springframework.stereotype.Repository; +import java.util.List; +import java.util.Optional; + @Repository public interface CategoryRepository extends JpaRepository { - // 필요한 추가 쿼리 메소드가 있다면 여기에 정의 + @Query("SELECT DISTINCT c.mainCategory FROM Category c") + List findMainCategory(); + + @Query("SELECT c.subCategory FROM Category c WHERE c.mainCategory = :mainCategory") + List findSubCategory(String mainCategory); + + Optional findByMainCategoryAndSubCategory(String mainCategory, String subCategory); } diff --git a/majorLink/src/main/java/com/example/majorLink/repository/LectureRepository.java b/majorLink/src/main/java/com/example/majorLink/repository/LectureRepository.java index 8a54c65..6107002 100644 --- a/majorLink/src/main/java/com/example/majorLink/repository/LectureRepository.java +++ b/majorLink/src/main/java/com/example/majorLink/repository/LectureRepository.java @@ -1,7 +1,6 @@ package com.example.majorLink.repository; import com.example.majorLink.domain.Lecture; -import com.example.majorLink.domain.User; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; @@ -11,7 +10,7 @@ public interface LectureRepository extends JpaRepository { @Query("SELECT l FROM Lecture l ORDER BY (SELECT COUNT(lk) FROM Liked lk WHERE lk.lecture.id = l.id) DESC") Page orderByLikedCount(Pageable pageable); - @Query("SELECT l FROM Lecture l ORDER BY l.curPNum DESC") + @Query("SELECT l FROM Lecture l ORDER BY l.cNum DESC") Page orderByCurPNum(Pageable pageable); @Query("SELECT l FROM Lecture l WHERE l.category.id = :categoryId") diff --git a/majorLink/src/main/java/com/example/majorLink/repository/LikedRepository.java b/majorLink/src/main/java/com/example/majorLink/repository/LikedRepository.java index a1afd57..34cacf6 100644 --- a/majorLink/src/main/java/com/example/majorLink/repository/LikedRepository.java +++ b/majorLink/src/main/java/com/example/majorLink/repository/LikedRepository.java @@ -9,4 +9,6 @@ public interface LikedRepository extends JpaRepository { Boolean existsByUserAndLecture(User user, Lecture lecture); void deleteByUserAndLecture(User user, Lecture lecture); + + void deleteAllByLecture(Lecture lecture); } \ No newline at end of file diff --git a/majorLink/src/main/java/com/example/majorLink/repository/TuteeLectureRepository.java b/majorLink/src/main/java/com/example/majorLink/repository/TuteeLectureRepository.java index bba3ec3..e8a7d10 100644 --- a/majorLink/src/main/java/com/example/majorLink/repository/TuteeLectureRepository.java +++ b/majorLink/src/main/java/com/example/majorLink/repository/TuteeLectureRepository.java @@ -1,5 +1,6 @@ package com.example.majorLink.repository; +import com.example.majorLink.domain.Lecture; import com.example.majorLink.domain.mapping.TuteeLecture; import org.springframework.data.jpa.repository.JpaRepository; @@ -7,5 +8,5 @@ import java.util.UUID; public interface TuteeLectureRepository extends JpaRepository { - Optional findByUserIdAndLectureId(UUID userId, Long lectureId); + void deleteAllByLecture(Lecture lecture); } \ No newline at end of file diff --git a/majorLink/src/main/java/com/example/majorLink/repository/TutorLectureRepository.java b/majorLink/src/main/java/com/example/majorLink/repository/TutorLectureRepository.java index 373f2ec..e6caa4f 100644 --- a/majorLink/src/main/java/com/example/majorLink/repository/TutorLectureRepository.java +++ b/majorLink/src/main/java/com/example/majorLink/repository/TutorLectureRepository.java @@ -1,5 +1,6 @@ package com.example.majorLink.repository; +import com.example.majorLink.domain.Lecture; import com.example.majorLink.domain.mapping.TutorLecture; import org.springframework.data.jpa.repository.JpaRepository; @@ -7,6 +8,7 @@ import java.util.UUID; public interface TutorLectureRepository extends JpaRepository { - Optional findByUserId(UUID id); Optional findByLectureId(Long id); + + void deleteAllByLecture(Lecture lecture); } diff --git a/majorLink/src/main/java/com/example/majorLink/service/LectureService.java b/majorLink/src/main/java/com/example/majorLink/service/LectureService.java index ae410b3..16cef2d 100644 --- a/majorLink/src/main/java/com/example/majorLink/service/LectureService.java +++ b/majorLink/src/main/java/com/example/majorLink/service/LectureService.java @@ -5,6 +5,7 @@ import com.example.majorLink.dto.request.LectureRequestDTO; import org.springframework.data.domain.Page; +import java.util.List; import java.util.UUID; public interface LectureService { @@ -13,9 +14,9 @@ public interface LectureService { void DeleteLecture(UUID userId, Long lectureId); Page getLectureList(Integer page); + Lecture getLecture(Long lectureId); TuteeLecture addLecture(UUID userId, Long lectureId); - void cancelLecture(UUID userId, Long lectureId); Boolean toggleLike(UUID userId, Long lectureId); @@ -23,4 +24,9 @@ public interface LectureService { Page getNewLecture(Integer page); Page getMostRecruitedLecture(Integer page); Page getLectureByCategory(Integer page, Long categoryId); + + List getMainCategory(); + List getSubCategory(String mainCategory); + + Long getCategoryId(String mainCategory, String subCategory); } \ No newline at end of file diff --git a/majorLink/src/main/java/com/example/majorLink/service/LectureServiceImpl.java b/majorLink/src/main/java/com/example/majorLink/service/LectureServiceImpl.java index c609dfd..93bf963 100644 --- a/majorLink/src/main/java/com/example/majorLink/service/LectureServiceImpl.java +++ b/majorLink/src/main/java/com/example/majorLink/service/LectureServiceImpl.java @@ -14,6 +14,7 @@ import org.springframework.data.domain.PageRequest; import org.springframework.stereotype.Service; +import java.util.List; import java.util.UUID; @Service @@ -46,8 +47,7 @@ public Lecture createLecture(UUID userId, LectureRequestDTO request) { .curri(request.getCurri()) .info(request.getInfo()) .level(request.getLevel()) - .pNum(request.getPNum()) - .curPNum(0) + .pNum(request.getNum()) .time(request.getTime()) .day(request.getDay()) .startDate(request.getStartDate()) @@ -55,6 +55,7 @@ public Lecture createLecture(UUID userId, LectureRequestDTO request) { .category(category) .tag(request.getTag()) .tutor(user.getNickname()) + .cNum(0) .build(); Lecture saveLecture = lectureRepository.save(lecture); @@ -99,7 +100,7 @@ public Lecture updateLecture(UUID userId, LectureRequestDTO request, Long lectur request.getCurri(), request.getInfo(), request.getLevel(), - request.getPNum(), + request.getNum(), request.getTime(), request.getDay(), request.getStartDate(), @@ -130,6 +131,10 @@ public void DeleteLecture(UUID userId, Long lectureId) { throw new IllegalStateException("You do not have permission to delete this lecture"); } + tutorLectureRepository.deleteAllByLecture(lecture); + tuteeLectureRepository.deleteAllByLecture(lecture); + likedRepository.deleteAllByLecture(lecture); + // Lecture 엔티티 삭제 lectureRepository.delete(lecture); } @@ -142,6 +147,13 @@ public Page getLectureList(Integer page) { return lecturePage; } + // 강의 상세 내용 조회 + @Override + public Lecture getLecture(Long lectureId) { + return lectureRepository.findById(lectureId) + .orElseThrow(() -> new IllegalArgumentException("Invalid lecture ID")); + } + // 강의 수강 신청 @Override public TuteeLecture addLecture(UUID userId, Long lectureId) { @@ -151,7 +163,7 @@ public TuteeLecture addLecture(UUID userId, Long lectureId) { Lecture lecture = lectureRepository.findById(lectureId) .orElseThrow(() -> new IllegalArgumentException("Invalid lecture ID")); - if (lecture.getPNum() >= lecture.getCurPNum()) { + if (lecture.getPNum() <= lecture.getCNum()) { throw new IllegalStateException("The lecture is full"); } @@ -165,23 +177,6 @@ public TuteeLecture addLecture(UUID userId, Long lectureId) { return tuteeLectureRepository.save(tuteeLecture); } - // 강의 수강 취소 - @Override - public void cancelLecture(UUID userId, Long lectureId) { - User user = userRepository.findById(userId) - .orElseThrow(() -> new IllegalArgumentException("Invalid user ID")); - - Lecture lecture = lectureRepository.findById(lectureId) - .orElseThrow(() -> new IllegalArgumentException("Invalid lecture ID")); - - TuteeLecture tuteeLecture = tuteeLectureRepository.findByUserIdAndLectureId(userId, lectureId) - .orElseThrow(() -> new IllegalArgumentException("Invalid user ID or lecture ID")); - - lecture.subCurPNum(); - - tuteeLectureRepository.delete(tuteeLecture); - } - // 강의 좋아요 @Override public Boolean toggleLike(UUID userId, Long lectureId) { @@ -237,4 +232,21 @@ public Page getLectureByCategory(Integer page, Long categoryId) { return lectureRepository.orderByCategoryId(categoryId, PageRequest.of(page, 10)); } + + // 메인 카테고리 조회 + public List getMainCategory() { + return categoryRepository.findMainCategory(); + } + + // 서브 카테고리 조회 + public List getSubCategory(String mainCategory) { + return categoryRepository.findSubCategory(mainCategory); + } + + // 카테고리 ID 조회 + public Long getCategoryId(String mainCategory, String subCategory) { + Category category = categoryRepository.findByMainCategoryAndSubCategory(mainCategory, subCategory) + .orElseThrow(() -> new IllegalArgumentException("Category not found")); + return category.getId(); + } } \ No newline at end of file