diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/campaign/repository/CampaignRepositoryCustom.java b/LearnsMate/src/main/java/intbyte4/learnsmate/campaign/repository/CampaignRepositoryCustom.java index 63f287a3..cd5e9cb5 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/campaign/repository/CampaignRepositoryCustom.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/campaign/repository/CampaignRepositoryCustom.java @@ -1,10 +1,11 @@ package intbyte4.learnsmate.campaign.repository; +import intbyte4.learnsmate.campaign.domain.dto.CampaignDTO; import intbyte4.learnsmate.campaign.domain.entity.Campaign; import java.time.LocalDateTime; import java.util.List; public interface CampaignRepositoryCustom { - List searchBy(Campaign campaign, LocalDateTime startDate, LocalDateTime endDate); + List searchBy(CampaignDTO campaignDTO, LocalDateTime startDate, LocalDateTime endDate); } diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/campaign/repository/CampaignRepositoryImpl.java b/LearnsMate/src/main/java/intbyte4/learnsmate/campaign/repository/CampaignRepositoryImpl.java index 55c4b1d9..161ebd5d 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/campaign/repository/CampaignRepositoryImpl.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/campaign/repository/CampaignRepositoryImpl.java @@ -2,7 +2,9 @@ import com.querydsl.core.BooleanBuilder; import com.querydsl.jpa.impl.JPAQueryFactory; +import intbyte4.learnsmate.campaign.domain.dto.CampaignDTO; import intbyte4.learnsmate.campaign.domain.entity.Campaign; +import intbyte4.learnsmate.campaign.domain.entity.CampaignTypeEnum; import intbyte4.learnsmate.campaign.domain.entity.QCampaign; import intbyte4.learnsmate.common.exception.CommonException; import intbyte4.learnsmate.common.exception.StatusEnum; @@ -14,40 +16,40 @@ @RequiredArgsConstructor public class CampaignRepositoryImpl implements CampaignRepositoryCustom { private final JPAQueryFactory queryFactory; - private final QCampaign qCampaign; + private final QCampaign qCampaign = QCampaign.campaign; @Override - public List searchBy(Campaign campaign, LocalDateTime startDate, LocalDateTime endDate) { + public List searchBy(CampaignDTO campaignDTO, LocalDateTime startDate, LocalDateTime endDate) { return queryFactory .selectFrom(qCampaign) - .where(searchByType(campaign) - .and(searchByTitle(campaign)) - .and(searchByPeriod(campaign, startDate, endDate)) - .and(searchBySentStatus(campaign)) - .and(searchByScheduledStatus(campaign)) + .where(searchByType(campaignDTO) + .and(searchByTitle(campaignDTO)) + .and(searchByPeriod(campaignDTO, startDate, endDate)) + .and(searchBySentStatus(campaignDTO)) + .and(searchByScheduledStatus(campaignDTO)) ) .fetch(); } - public BooleanBuilder searchByType(Campaign campaign) { + public BooleanBuilder searchByType(CampaignDTO campaignDTO) { BooleanBuilder booleanBuilder = new BooleanBuilder(); - if (campaign.getCampaignType() != null) { - booleanBuilder.and(qCampaign.campaignType.eq(campaign.getCampaignType())); + if (campaignDTO.getCampaignType() != null) { + booleanBuilder.and(qCampaign.campaignType.eq(CampaignTypeEnum.valueOf(campaignDTO.getCampaignType()))); } return booleanBuilder; } - public BooleanBuilder searchByTitle(Campaign campaign) { + public BooleanBuilder searchByTitle(CampaignDTO campaignDTO) { BooleanBuilder booleanBuilder = new BooleanBuilder(); - if (campaign.getCampaignTitle() == null) { + if (campaignDTO.getCampaignTitle() == null) { return booleanBuilder; } - String[] keywords = campaign.getCampaignTitle().split(" "); + String[] keywords = campaignDTO.getCampaignTitle().split(" "); if (keywords.length < 2) { throw new CommonException(StatusEnum.MINIMUM_KEYWORD_LENGTH_REQUIRED); } @@ -59,9 +61,9 @@ public BooleanBuilder searchByTitle(Campaign campaign) { return booleanBuilder; } - public BooleanBuilder searchByPeriod(Campaign campaign, LocalDateTime startDate, LocalDateTime endDate) { + public BooleanBuilder searchByPeriod(CampaignDTO campaignDTO, LocalDateTime startDate, LocalDateTime endDate) { BooleanBuilder booleanBuilder = new BooleanBuilder(); - if (campaign.getCampaignSendDate() == null) return booleanBuilder; + if (campaignDTO.getCampaignSendDate() == null) return booleanBuilder; if (startDate != null) { booleanBuilder.and(qCampaign.campaignSendDate.goe(startDate)); @@ -74,18 +76,18 @@ public BooleanBuilder searchByPeriod(Campaign campaign, LocalDateTime startDate, return booleanBuilder; } - public BooleanBuilder searchBySentStatus(Campaign campaign) { + public BooleanBuilder searchBySentStatus(CampaignDTO campaignDTO) { BooleanBuilder booleanBuilder = new BooleanBuilder(); - if (campaign.getCampaignSendDate() == null) return booleanBuilder; + if (campaignDTO.getCampaignSendDate() == null) return booleanBuilder; booleanBuilder.and(qCampaign.campaignSendDate.loe(LocalDateTime.now())); return booleanBuilder; } - public BooleanBuilder searchByScheduledStatus(Campaign campaign) { + public BooleanBuilder searchByScheduledStatus(CampaignDTO campaignDTO) { BooleanBuilder booleanBuilder = new BooleanBuilder(); - if (campaign.getCampaignSendDate() == null) return booleanBuilder; + if (campaignDTO.getCampaignSendDate() == null) return booleanBuilder; booleanBuilder.and(qCampaign.campaignSendDate.goe(LocalDateTime.now())); diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/campaign/service/CampaignServiceImpl.java b/LearnsMate/src/main/java/intbyte4/learnsmate/campaign/service/CampaignServiceImpl.java index 50e27f6d..467d2f80 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/campaign/service/CampaignServiceImpl.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/campaign/service/CampaignServiceImpl.java @@ -198,11 +198,9 @@ public CampaignDTO findCampaign(CampaignDTO request) { @Override public List findCampaignListByCondition (CampaignDTO request, LocalDateTime startDate, LocalDateTime endDate) { - AdminDTO adminDTO = adminService.findByAdminCode(request.getAdminCode()); - Admin admin = adminMapper.toEntity(adminDTO); List campaign = campaignRepositoryCustom - .searchBy(campaignMapper.toEntity(request,admin), startDate, endDate); + .searchBy(request, startDate, endDate); List campaignDTOList = new ArrayList<>(); campaign.forEach(entity -> campaignDTOList.add(campaignMapper.toDTO(entity))); diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/comment/controller/CommentController.java b/LearnsMate/src/main/java/intbyte4/learnsmate/comment/controller/CommentController.java index 681b09e2..e7c6f732 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/comment/controller/CommentController.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/comment/controller/CommentController.java @@ -4,31 +4,24 @@ import intbyte4.learnsmate.comment.domain.vo.request.ResponseFindCommentVO; import intbyte4.learnsmate.comment.mapper.CommentMapper; import intbyte4.learnsmate.comment.service.CommentService; -import org.springframework.beans.factory.annotation.Autowired; +import io.swagger.v3.oas.annotations.Operation; +import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import java.util.List; import java.util.stream.Collectors; @RestController @RequestMapping("/comment") +@RequiredArgsConstructor public class CommentController { private final CommentService commentService; private final CommentMapper commentMapper; - @Autowired - public CommentController(CommentService commentService, CommentMapper commentMapper) { - this.commentService = commentService; - this.commentMapper = commentMapper; - } - - // 1. comment 모두 조회 -> 사실 이게 우리쪽에서 comment를 봐야하는가? 봐야하지 않을까? 블랙리스트에서 어떤 코멘트가 신고먹었는지는? + @Operation(summary = "모든 댓글 조회") @GetMapping public ResponseEntity> findAllComments() { List commentDTOList = commentService.findAllComments(); @@ -38,7 +31,7 @@ public ResponseEntity> findAllComments() { .collect(Collectors.toList())); } - // 1-2. commentCode로 단건 조회 + @Operation(summary = "댓글 단건 조회") @GetMapping("/{commentcode}") public ResponseEntity findCommentByCommentCode(@PathVariable("commentcode") Long commentCode) { CommentDTO commentDTO = commentService.findComentByCommentCode(commentCode); @@ -46,4 +39,15 @@ public ResponseEntity findCommentByCommentCode(@PathVaria return ResponseEntity.status(HttpStatus.OK) .body(commentMapper.fromCommentDTOToResponseFindCommentVO(commentDTO)); } + + + @Operation(summary = "강의별 댓글 조회") + @GetMapping("/lecture/{lectureCode}") + public ResponseEntity> findCommentByLectureCode(@PathVariable("lectureCode") Long lectureCode ) { + List commentDTOList = commentService.findCommentByLectureCode(lectureCode); + + return ResponseEntity.status(HttpStatus.OK).body(commentDTOList.stream() + .map(commentMapper::fromCommentDTOToResponseFindCommentVO) + .collect(Collectors.toList())); + } } diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/comment/repository/CommentRepository.java b/LearnsMate/src/main/java/intbyte4/learnsmate/comment/repository/CommentRepository.java index 2ffb3c7c..837e5b89 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/comment/repository/CommentRepository.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/comment/repository/CommentRepository.java @@ -1,9 +1,13 @@ package intbyte4.learnsmate.comment.repository; import intbyte4.learnsmate.comment.domain.entity.Comment; +import intbyte4.learnsmate.lecture.domain.entity.Lecture; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; +import java.util.List; + @Repository public interface CommentRepository extends JpaRepository { + List findByLecture(Lecture lecture); } diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/comment/service/CommentService.java b/LearnsMate/src/main/java/intbyte4/learnsmate/comment/service/CommentService.java index 347bea09..b47283a3 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/comment/service/CommentService.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/comment/service/CommentService.java @@ -8,4 +8,7 @@ public interface CommentService { List findAllComments(); CommentDTO findComentByCommentCode(Long commentCode); + + // 강의별 댓글 1개 조회 + List findCommentByLectureCode(Long lectureCode); } diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/comment/service/CommentServiceImpl.java b/LearnsMate/src/main/java/intbyte4/learnsmate/comment/service/CommentServiceImpl.java index 00a26456..adc28a6e 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/comment/service/CommentServiceImpl.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/comment/service/CommentServiceImpl.java @@ -7,6 +7,15 @@ import intbyte4.learnsmate.comment.repository.CommentRepository; import intbyte4.learnsmate.common.exception.CommonException; import intbyte4.learnsmate.common.exception.StatusEnum; +import intbyte4.learnsmate.lecture.domain.dto.LectureDTO; +import intbyte4.learnsmate.lecture.domain.entity.Lecture; +import intbyte4.learnsmate.lecture.mapper.LectureMapper; +import intbyte4.learnsmate.lecture.service.LectureService; +import intbyte4.learnsmate.member.domain.MemberType; +import intbyte4.learnsmate.member.domain.dto.MemberDTO; +import intbyte4.learnsmate.member.domain.entity.Member; +import intbyte4.learnsmate.member.mapper.MemberMapper; +import intbyte4.learnsmate.member.service.MemberService; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -19,6 +28,10 @@ public class CommentServiceImpl implements CommentService { private final CommentRepository commentRepository; private final CommentMapper commentMapper; + private final LectureService lectureService; + private final LectureMapper lectureMapper; + private final MemberService memberService; + private final MemberMapper memberMapper; @Override // 모든 댓글 조회 @@ -39,4 +52,20 @@ public CommentDTO findComentByCommentCode(Long commentCode) { return commentMapper.fromCommentToCommentDTO(comment); } + + @Override + // 강의별 댓글 1개 조회 + public List findCommentByLectureCode(Long lectureCode) { + LectureDTO lectureDTO = lectureService.getLectureById(lectureCode); + + MemberDTO studentDTO = memberService.findMemberByMemberCode(lectureDTO.getLectureCode(), MemberType.STUDENT); + Member member = memberMapper.fromMemberDTOtoMember(studentDTO); + Lecture lecture = lectureMapper.toEntity(lectureDTO,member); + + List commentList = commentRepository.findByLecture(lecture); + + return commentList.stream() + .map(commentMapper::fromCommentToCommentDTO) + .collect(Collectors.toList()); + } } diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/config/QuerydslConfig.java b/LearnsMate/src/main/java/intbyte4/learnsmate/config/QuerydslConfig.java index eb12fd7d..54d221ac 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/config/QuerydslConfig.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/config/QuerydslConfig.java @@ -1,7 +1,6 @@ package intbyte4.learnsmate.config; import com.querydsl.jpa.impl.JPAQueryFactory; -import intbyte4.learnsmate.campaign.domain.entity.QCampaign; import jakarta.persistence.EntityManager; import jakarta.persistence.PersistenceContext; import org.springframework.context.annotation.Bean; @@ -17,7 +16,4 @@ public class QuerydslConfig { public JPAQueryFactory jpaQueryFactory() { return new JPAQueryFactory(entityManager); } - - @Bean - public QCampaign qCampaign() { return QCampaign.campaign; } } diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/contractprocess/repository/ContractProcessRepository.java b/LearnsMate/src/main/java/intbyte4/learnsmate/contractprocess/repository/ContractProcessRepository.java index 68e5a867..c50a76f1 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/contractprocess/repository/ContractProcessRepository.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/contractprocess/repository/ContractProcessRepository.java @@ -15,4 +15,6 @@ public interface ContractProcessRepository extends JpaRepository findByLectureAndApprovalProcess(Lecture lecture, Integer approvalProcess); + + long countByLecture(Lecture lecture); } \ No newline at end of file diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/contractprocess/service/ContractProcessService.java b/LearnsMate/src/main/java/intbyte4/learnsmate/contractprocess/service/ContractProcessService.java index 9065db47..fc53bc3b 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/contractprocess/service/ContractProcessService.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/contractprocess/service/ContractProcessService.java @@ -1,9 +1,6 @@ package intbyte4.learnsmate.contractprocess.service; import intbyte4.learnsmate.contractprocess.domain.dto.ContractProcessDTO; -import org.springframework.transaction.annotation.Transactional; - -import java.util.List; public interface ContractProcessService { // 단건 조회 @@ -14,4 +11,5 @@ public interface ContractProcessService { // 계약과정 등록 ContractProcessDTO createContractProcess(Long lectureCode, ContractProcessDTO contractProcessDTO); + } diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/contractprocess/service/ContractProcessServiceImpl.java b/LearnsMate/src/main/java/intbyte4/learnsmate/contractprocess/service/ContractProcessServiceImpl.java index d6507d2b..b9276fea 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/contractprocess/service/ContractProcessServiceImpl.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/contractprocess/service/ContractProcessServiceImpl.java @@ -14,10 +14,6 @@ import intbyte4.learnsmate.lecture.domain.entity.Lecture; import intbyte4.learnsmate.lecture.mapper.LectureMapper; import intbyte4.learnsmate.lecture.service.LectureService; -import intbyte4.learnsmate.lecture_category.domain.dto.LectureCategoryDTO; -import intbyte4.learnsmate.lecture_category.domain.entity.LectureCategory; -import intbyte4.learnsmate.lecture_category.mapper.LectureCategoryMapper; -import intbyte4.learnsmate.lecture_category.service.LectureCategoryService; import intbyte4.learnsmate.member.domain.MemberType; import intbyte4.learnsmate.member.domain.dto.MemberDTO; import intbyte4.learnsmate.member.domain.entity.Member; @@ -35,8 +31,6 @@ public class ContractProcessServiceImpl implements ContractProcessService { private final ContractProcessRepository contractProcessRepository; private final ContractProcessMapper contractProcessMapper; - private final LectureCategoryService lectureCategoryService; - private final LectureCategoryMapper lectureCategoryMapper; private final AdminService adminService; private final AdminMapper adminMapper; private final MemberService memberService; @@ -62,10 +56,6 @@ public ContractProcessDTO getApprovalProcessByLectureCode(Long lectureCode) { MemberDTO tutorDTO = memberService.findMemberByMemberCode(lecturedto.getLectureCode(), MemberType.TUTOR); Member tutor = memberMapper.fromMemberDTOtoMember(tutorDTO); -// LectureCategoryDTO lectureCategoryDTO = lectureCategoryService.findByLectureCategoryCode(lecturedto.getLectureCategoryCode()); -// LectureCategory lectureCategory = lectureCategoryMapper.toEntity(lectureCategoryDTO); - -// Lecture lecture = lectureMapper.toEntity(lecturedto, tutor, lectureCategory); Lecture lecture = lectureMapper.toEntity(lecturedto, tutor); ContractProcess contractProcess = contractProcessRepository.findByLecture(lecture); @@ -87,10 +77,6 @@ public ContractProcessDTO createContractProcess(Long lectureCode, ContractProces MemberDTO tutorDTO = memberService.findMemberByMemberCode(lectureDTO.getTutorCode(), MemberType.TUTOR); Member tutor = memberMapper.fromMemberDTOtoMember(tutorDTO); -// LectureCategoryDTO lectureCategoryDTO = lectureCategoryService.findByLectureCategoryCode(lectureDTO.getLectureCategoryCode()); -// LectureCategory category = lectureCategoryMapper.toEntity(lectureCategoryDTO); - -// Lecture lecture = lectureMapper.toEntity(lectureDTO, tutor, category); Lecture lecture = lectureMapper.toEntity(lectureDTO, tutor); AdminDTO adminDTO = adminService.findByAdminCode(contractProcessDTO.getAdminCode()); @@ -116,6 +102,14 @@ public ContractProcessDTO createContractProcess(Long lectureCode, ContractProces contractProcessRepository.save(contractProcess); + long contractProcessCount = contractProcessRepository.countByLecture(lecture); + LectureDTO lecturedto = lectureMapper.toDTO(lecture); + + // 계약과정이 7개일 경우 강의 승인 상태 변경 + if (contractProcessCount == 7) { + lectureService.updateLectureConfirmStatus(lecturedto.getLectureCode()); + } + return contractProcessMapper.toDTO(contractProcess); } diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/coupon/controller/CouponController.java b/LearnsMate/src/main/java/intbyte4/learnsmate/coupon/controller/CouponController.java index 5c3df310..5fe326c1 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/coupon/controller/CouponController.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/coupon/controller/CouponController.java @@ -8,7 +8,7 @@ import intbyte4.learnsmate.coupon.mapper.CouponMapper; import intbyte4.learnsmate.coupon.service.CouponService; import intbyte4.learnsmate.coupon_category.domain.CouponCategory; -import intbyte4.learnsmate.facade.CouponLectureFacade; +import intbyte4.learnsmate.coupon.service.CouponFacade; import intbyte4.learnsmate.member.domain.entity.Member; import io.swagger.v3.oas.annotations.Operation; import lombok.RequiredArgsConstructor; @@ -27,7 +27,7 @@ public class CouponController { private final CouponService couponService; private final CouponMapper couponMapper; - private final CouponLectureFacade couponLectureFacade; + private final CouponFacade couponFacade; @Operation(summary = "쿠폰 전체 조회") @GetMapping("/coupons") @@ -65,7 +65,7 @@ public ResponseEntity createCoupon(@RequestBody AdminC @Operation(summary = "강사 - 쿠폰 등록") @PostMapping("/tutor/register") public ResponseEntity createCoupon(@RequestBody TutorCouponRegisterRequestVO request, Member tutor, CouponCategory couponCategory, Long lectureCode) { - CouponDTO couponDTO = couponLectureFacade.tutorRegisterCoupon(request, tutor, couponCategory, lectureCode); + CouponDTO couponDTO = couponFacade.tutorRegisterCoupon(request, tutor, couponCategory, lectureCode); return ResponseEntity.status(HttpStatus.CREATED).body(couponMapper.fromDTOToRegisterResponseVO(couponDTO)); } diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/facade/CouponLectureFacade.java b/LearnsMate/src/main/java/intbyte4/learnsmate/coupon/service/CouponFacade.java similarity index 93% rename from LearnsMate/src/main/java/intbyte4/learnsmate/facade/CouponLectureFacade.java rename to LearnsMate/src/main/java/intbyte4/learnsmate/coupon/service/CouponFacade.java index 2e2149c2..6718183c 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/facade/CouponLectureFacade.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/coupon/service/CouponFacade.java @@ -1,10 +1,9 @@ -package intbyte4.learnsmate.facade; +package intbyte4.learnsmate.coupon.service; import intbyte4.learnsmate.coupon.domain.dto.CouponDTO; import intbyte4.learnsmate.coupon.domain.entity.CouponEntity; import intbyte4.learnsmate.coupon.domain.vo.request.TutorCouponRegisterRequestVO; import intbyte4.learnsmate.coupon.mapper.CouponMapper; -import intbyte4.learnsmate.coupon.service.CouponService; import intbyte4.learnsmate.coupon_by_lecture.service.CouponByLectureService; import intbyte4.learnsmate.coupon_category.domain.CouponCategory; import intbyte4.learnsmate.lecture.domain.dto.LectureDTO; @@ -18,7 +17,7 @@ @Service @RequiredArgsConstructor -public class CouponLectureFacade { +public class CouponFacade { private final CouponService couponService; private final LectureService lectureService; diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/issue_coupon/controller/IssueCouponController.java b/LearnsMate/src/main/java/intbyte4/learnsmate/issue_coupon/controller/IssueCouponController.java index 5e042699..47a14b80 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/issue_coupon/controller/IssueCouponController.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/issue_coupon/controller/IssueCouponController.java @@ -1,6 +1,6 @@ package intbyte4.learnsmate.issue_coupon.controller; -import intbyte4.learnsmate.facade.MemberCouponFacade; +import intbyte4.learnsmate.issue_coupon.service.IssueCouponFacade; import intbyte4.learnsmate.issue_coupon.domain.dto.IssueCouponDTO; import intbyte4.learnsmate.issue_coupon.domain.vo.request.IssueCouponRegisterRequestVO; import intbyte4.learnsmate.issue_coupon.domain.vo.response.IssueCouponFindResponseVO; @@ -26,12 +26,12 @@ public class IssueCouponController { private final IssueCouponService issueCouponService; private final IssueCouponMapper issueCouponMapper; - private final MemberCouponFacade memberCouponFacade; + private final IssueCouponFacade issueCouponFacade; @Operation(summary = "학생에게 쿠폰 발급") @PostMapping("/register") public ResponseEntity> registerIssuedCoupons(@RequestBody IssueCouponRegisterRequestVO request) { - List issuedCoupons = memberCouponFacade.issueCouponsToStudents(request); + List issuedCoupons = issueCouponFacade.issueCouponsToStudents(request); List responseList = issuedCoupons.stream() .map(issueCouponMapper::fromDtoToRegisterResponseVO) .collect(Collectors.toList()); diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/facade/MemberCouponFacade.java b/LearnsMate/src/main/java/intbyte4/learnsmate/issue_coupon/service/IssueCouponFacade.java similarity index 91% rename from LearnsMate/src/main/java/intbyte4/learnsmate/facade/MemberCouponFacade.java rename to LearnsMate/src/main/java/intbyte4/learnsmate/issue_coupon/service/IssueCouponFacade.java index 4e830de9..79cb6e96 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/facade/MemberCouponFacade.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/issue_coupon/service/IssueCouponFacade.java @@ -1,8 +1,7 @@ -package intbyte4.learnsmate.facade; +package intbyte4.learnsmate.issue_coupon.service; import intbyte4.learnsmate.issue_coupon.domain.dto.IssueCouponDTO; import intbyte4.learnsmate.issue_coupon.domain.vo.request.IssueCouponRegisterRequestVO; -import intbyte4.learnsmate.issue_coupon.service.IssueCouponService; import intbyte4.learnsmate.member.domain.entity.Member; import intbyte4.learnsmate.member.service.MemberService; import jakarta.transaction.Transactional; @@ -14,7 +13,7 @@ @Service @RequiredArgsConstructor -public class MemberCouponFacade { +public class IssueCouponFacade { private final MemberService memberService; private final IssueCouponService issueCouponService; diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/controller/LectureController.java b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/controller/LectureController.java index b852c5d3..a87e6a80 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/controller/LectureController.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/controller/LectureController.java @@ -1,6 +1,6 @@ package intbyte4.learnsmate.lecture.controller; -import intbyte4.learnsmate.facade.LectureFacade; +import intbyte4.learnsmate.lecture.service.LectureFacade; import intbyte4.learnsmate.lecture.domain.dto.LectureDTO; import intbyte4.learnsmate.lecture.domain.dto.LectureDetailDTO; import intbyte4.learnsmate.lecture.domain.vo.request.RequestEditLectureInfoVO; @@ -11,6 +11,7 @@ import intbyte4.learnsmate.lecture.domain.vo.response.ResponseRemoveLectureVO; import intbyte4.learnsmate.lecture.mapper.LectureMapper; import intbyte4.learnsmate.lecture.service.LectureService; +import intbyte4.learnsmate.video_by_lecture.domain.dto.VideoByLectureDTO; import io.swagger.v3.oas.annotations.Operation; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -32,6 +33,17 @@ public class LectureController { private final LectureMapper lectureMapper; private final LectureFacade lectureFacade; + @Operation(summary = "학생이 강의를 클릭할 때 클릭 수 증가") + @PostMapping("/{lectureCode}/click") + public ResponseEntity incrementClickCount(@PathVariable("lectureCode") Long lectureCode) { + try { + lectureService.getLecturesByStudentCode(lectureCode); + return ResponseEntity.status(HttpStatus.OK).build(); + } catch (Exception e) { + return ResponseEntity.status(HttpStatus.NOT_FOUND).build(); + } + } + @Operation(summary = "강의 정보 전체 조회") @GetMapping public ResponseEntity> getAllLectures() { @@ -49,14 +61,22 @@ public ResponseEntity getLecture(@PathVariable("lectureCo return ResponseEntity.status(HttpStatus.OK).body(lectureMapper.fromDtoToResponseVO(lectureDTO)); } - @Operation(summary = "강의와 강의별 강의 카테고리 등록") + @Operation(summary = "강의와 강의별 동영상, 강의별 카테고리 및 동영상 등록") @PutMapping("/{lectureCode}") public ResponseEntity registerLecture( @RequestBody RequestRegisterLectureVO registerLectureVO) { - LectureDTO lectureDTO = LectureFacade.registerLecture(lectureMapper.fromRegisterRequestVOtoDto(registerLectureVO), registerLectureVO.getLectureCategoryCodeList()); - return ResponseEntity.status(HttpStatus.CREATED).body(lectureMapper.fromDtoToRegisterResponseVO(lectureDTO)); + + LectureDTO lectureDTO = lectureMapper.fromRegisterRequestVOtoDto(registerLectureVO); + List lectureCategoryCodeList = registerLectureVO.getLectureCategoryCodeList(); + List videoByLectureDTOList = registerLectureVO.getVideoByLectureDTOList(); + + LectureDTO registeredLectureDTO = lectureFacade.registerLecture(lectureDTO, lectureCategoryCodeList, videoByLectureDTOList); + + return ResponseEntity.status(HttpStatus.CREATED) + .body(lectureMapper.fromDtoToRegisterResponseVO(registeredLectureDTO)); } + @Operation(summary = "강의 수정") @PatchMapping("/{lectureCode}/info") public ResponseEntity updateLecture( diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/domain/entity/Lecture.java b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/domain/entity/Lecture.java index 0c5a60fe..64578483 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/domain/entity/Lecture.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/domain/entity/Lecture.java @@ -2,7 +2,6 @@ import intbyte4.learnsmate.lecture.domain.dto.LectureDTO; import intbyte4.learnsmate.lecture.enums.LectureLevelEnum; -import intbyte4.learnsmate.lecture_category.domain.entity.LectureCategory; import intbyte4.learnsmate.member.domain.entity.Member; import jakarta.persistence.*; import lombok.*; @@ -73,4 +72,13 @@ public void toDelete(){ this.updatedAt = LocalDateTime.now(); } + public void toAcceptConfirmStatus(){ + this.lectureConfirmStatus = true; + this.updatedAt = LocalDateTime.now(); + } + + public void incrementClickCount() { + this.lectureClickCount++; + } + } diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/domain/vo/request/RequestRegisterLectureVO.java b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/domain/vo/request/RequestRegisterLectureVO.java index dd1a5489..235d9143 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/domain/vo/request/RequestRegisterLectureVO.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/domain/vo/request/RequestRegisterLectureVO.java @@ -3,6 +3,7 @@ import com.fasterxml.jackson.databind.PropertyNamingStrategies; import com.fasterxml.jackson.databind.annotation.JsonNaming; import intbyte4.learnsmate.lecture.enums.LectureLevelEnum; +import intbyte4.learnsmate.video_by_lecture.domain.dto.VideoByLectureDTO; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; @@ -29,4 +30,5 @@ public class RequestRegisterLectureVO { private LectureLevelEnum lectureLevel; private List lectureCategoryCodeList; + private List videoByLectureDTOList; } diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/domain/vo/response/ResponseRegisterLectureVO.java b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/domain/vo/response/ResponseRegisterLectureVO.java index f07ae844..64f66173 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/domain/vo/response/ResponseRegisterLectureVO.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/domain/vo/response/ResponseRegisterLectureVO.java @@ -3,12 +3,14 @@ import com.fasterxml.jackson.databind.PropertyNamingStrategies; import com.fasterxml.jackson.databind.annotation.JsonNaming; import intbyte4.learnsmate.lecture.enums.LectureLevelEnum; +import intbyte4.learnsmate.video_by_lecture.domain.dto.VideoByLectureDTO; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; import java.time.LocalDateTime; +import java.util.List; @NoArgsConstructor @AllArgsConstructor @@ -27,4 +29,6 @@ public class ResponseRegisterLectureVO { private Boolean lectureStatus; private Integer lectureClickCount; private LectureLevelEnum lectureLevel; + private List lectureCategoryCodeList; + private List videoByLectureDTOList; } diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/enums/LectureLevelEnum.java b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/enums/LectureLevelEnum.java index 44424fae..0f89648b 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/enums/LectureLevelEnum.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/enums/LectureLevelEnum.java @@ -1,7 +1,9 @@ package intbyte4.learnsmate.lecture.enums; public enum LectureLevelEnum { - BEGINNER, - INTERMEDIATE, - ADVANCED +// BEGINNER("BEGINNER"), +// INTERMEDIATE("INTERMEDIATE"), +// ADVANCED("ADVANCED"); + + } \ No newline at end of file diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/facade/LectureFacade.java b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/service/LectureFacade.java similarity index 86% rename from LearnsMate/src/main/java/intbyte4/learnsmate/facade/LectureFacade.java rename to LearnsMate/src/main/java/intbyte4/learnsmate/lecture/service/LectureFacade.java index c0bdfaca..41631ebd 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/facade/LectureFacade.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/service/LectureFacade.java @@ -1,4 +1,4 @@ -package intbyte4.learnsmate.facade; +package intbyte4.learnsmate.lecture.service; import intbyte4.learnsmate.common.exception.CommonException; import intbyte4.learnsmate.common.exception.StatusEnum; @@ -23,7 +23,7 @@ import intbyte4.learnsmate.lecture_by_student.domain.entity.LectureByStudent; import intbyte4.learnsmate.lecture_by_student.repository.LectureByStudentRepository; import intbyte4.learnsmate.lecture_by_student.service.LectureByStudentService; -import intbyte4.learnsmate.lecture.service.LectureService; +import intbyte4.learnsmate.lecture_category_by_lecture.domain.dto.OneLectureCategoryListDTO; import intbyte4.learnsmate.lecture_category_by_lecture.service.LectureCategoryByLectureService; import intbyte4.learnsmate.member.domain.MemberType; import intbyte4.learnsmate.member.domain.dto.MemberDTO; @@ -106,36 +106,15 @@ public void updateOwnStatus(Lecture lecture) { lectureByStudentRepository.saveAll(lectureByStudents); } - // 강사별 강의 모두 조회 - public List getLecturesByTutorCode(Long tutorCode) { - MemberDTO tutorDTO = memberService.findMemberByMemberCode(tutorCode, MemberType.TUTOR); - Member tutor = memberMapper.fromMemberDTOtoMember(tutorDTO); - - List lectures = lectureRepository.findAllByTutor(tutor); - - if (lectures.isEmpty()) { - throw new CommonException(StatusEnum.LECTURE_NOT_FOUND); - } - - return lectures.stream() - .map(lectureMapper::toDTO) - .collect(Collectors.toList()); - } - - // 강의 등록 -> 강의별 강의 카테고리 등록 메소드 가져오기 . @Transactional - public LectureDTO registerLecture(LectureDTO lectureDTO, List lectureCategoryCodeList) { - -// lectureCategoryByLectureService의 등록 메서드 호출 필요 -// OneLectureCategoryListDTO oneLectureCategoryListDTO -// = new OneLectureCategoryListDTO(lectureDTO.getLectureCode(), lectureCategoryCodeList); -// lectureCategoryByLectureService.saveLectureCategoryByLecture(oneLectureCategoryListDTO); - + public LectureDTO registerLecture(LectureDTO lectureDTO, List lectureCategoryCodeList, List videoByLectureDTOList) { + // 강의를 담당하는 튜터 정보 조회 및 변환 MemberDTO memberDTO = memberService.findMemberByMemberCode(lectureDTO.getTutorCode(), MemberType.TUTOR); - Member member = memberMapper.fromMemberDTOtoMember(memberDTO); + Member tutor = memberMapper.fromMemberDTOtoMember(memberDTO); + // 강의 엔티티 생성 및 저장 Lecture lecture = Lecture.builder() .lectureTitle(lectureDTO.getLectureTitle()) .lectureConfirmStatus(false) @@ -143,18 +122,28 @@ public LectureDTO registerLecture(LectureDTO lectureDTO, List lectureCa .updatedAt(LocalDateTime.now()) .lectureImage(lectureDTO.getLectureImage()) .lecturePrice(lectureDTO.getLecturePrice()) - .tutor(member) + .tutor(tutor) .lectureStatus(true) .lectureClickCount(0) .lectureLevel(lectureDTO.getLectureLevel()) .build(); lectureRepository.save(lecture); - return lectureMapper.toDTO(lecture); - } + // 강의별 카테고리 등록 + OneLectureCategoryListDTO oneLectureCategoryListDTO + = new OneLectureCategoryListDTO(lecture.getLectureCode(), lectureCategoryCodeList); + lectureCategoryByLectureService.saveLectureCategoryByLecture(oneLectureCategoryListDTO); - //강의별 계약과정이 강의 코드가 7개 라면 강의컬럼의 승인여부 true로 변환 + Long lectureCode = lecture.getLectureCode(); + + videoByLectureDTOList.forEach(videoDTO -> { + videoByLectureService.registerVideoByLecture(lectureCode, videoDTO); + }); + + // 강의 정보 DTO로 변환하여 반환 + return lectureMapper.toDTO(lecture); + } // 강의 모두 조회 diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/service/LectureService.java b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/service/LectureService.java index e56cc9ae..fa816130 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/service/LectureService.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/service/LectureService.java @@ -8,5 +8,8 @@ public interface LectureService { List getAllLecture(); LectureDTO getLectureById(Long lectureCode); + LectureDTO getLecturesByStudentCode(Long studentCode); + List getLecturesByTutorCode(Long tutorCode); LectureDTO updateLecture(LectureDTO lectureDTO); + LectureDTO updateLectureConfirmStatus(Long lectureCode); } \ No newline at end of file diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/service/LectureServiceImpl.java b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/service/LectureServiceImpl.java index 20f53643..ed903733 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/service/LectureServiceImpl.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/service/LectureServiceImpl.java @@ -7,6 +7,11 @@ import intbyte4.learnsmate.lecture.domain.entity.Lecture; import intbyte4.learnsmate.lecture.mapper.LectureMapper; import intbyte4.learnsmate.lecture.repository.LectureRepository; +import intbyte4.learnsmate.member.domain.MemberType; +import intbyte4.learnsmate.member.domain.dto.MemberDTO; +import intbyte4.learnsmate.member.domain.entity.Member; +import intbyte4.learnsmate.member.mapper.MemberMapper; +import intbyte4.learnsmate.member.service.MemberService; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -20,6 +25,8 @@ public class LectureServiceImpl implements LectureService { private final LectureRepository lectureRepository; private final LectureMapper lectureMapper; + private final MemberService memberService; + private final MemberMapper memberMapper; // 전체 강의 조회 @Override @@ -41,6 +48,45 @@ public LectureDTO getLectureById(Long lectureCode) { return lectureMapper.toDTO(lecture); } + // 유저별 조회에서 count++ lectureClickCount int 올리기 + @Override + public LectureDTO getLecturesByStudentCode(Long studentCode) { + // 학생 정보 조회 + MemberDTO studentDTO = memberService.findMemberByMemberCode(studentCode, MemberType.STUDENT); + Member student = memberMapper.fromMemberDTOtoMember(studentDTO); + + // 학생이 조회하려는 강의를 가져옴 + LectureDTO lectureDTO = getLectureById(studentCode); + + // 해당 강의의 클릭 수 증가 + Lecture lecture = lectureMapper.toEntity(lectureDTO,student); + lecture.incrementClickCount(); // 클릭 수를 증가시키는 메서드 추가 필요 + + // 강의 정보 업데이트 + lectureRepository.save(lecture); + + // 업데이트된 강의를 DTO로 변환하여 반환 + return lectureMapper.toDTO(lecture); + } + + + // 강사별 강의 모두 조회 + @Override + public List getLecturesByTutorCode(Long tutorCode) { + MemberDTO tutorDTO = memberService.findMemberByMemberCode(tutorCode, MemberType.TUTOR); + Member tutor = memberMapper.fromMemberDTOtoMember(tutorDTO); + + List lectures = lectureRepository.findAllByTutor(tutor); + + if (lectures.isEmpty()) { + throw new CommonException(StatusEnum.LECTURE_NOT_FOUND); + } + + return lectures.stream() + .map(lectureMapper::toDTO) + .collect(Collectors.toList()); + } + // 카테고리별 강의 조회 // public List filterLectures(LectureFilterDTO filter) { // Specification spec = LectureSpecifications.filterByCriteria(filter); @@ -58,4 +104,15 @@ public LectureDTO updateLecture(LectureDTO lectureDTO) { lectureRepository.save(lecture); return lectureMapper.toDTO(lecture); } + + // 강의별 계약과정이 강의 코드가 7개 라면 강의컬럼의 승인여부 true로 변환 + @Override + @Transactional + public LectureDTO updateLectureConfirmStatus(Long lectureCode) { + Lecture lecture = lectureRepository.findById(lectureCode) + .orElseThrow(() -> new CommonException(StatusEnum.LECTURE_NOT_FOUND)); + lecture.toAcceptConfirmStatus(); + lectureRepository.save(lecture); + return lectureMapper.toDTO(lecture); + } } diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture_category_by_lecture/service/LectureCategoryByLectureService.java b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture_category_by_lecture/service/LectureCategoryByLectureService.java index 78b09ee7..275d58a6 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture_category_by_lecture/service/LectureCategoryByLectureService.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture_category_by_lecture/service/LectureCategoryByLectureService.java @@ -3,11 +3,9 @@ import intbyte4.learnsmate.common.exception.CommonException; import intbyte4.learnsmate.common.exception.StatusEnum; import intbyte4.learnsmate.lecture.domain.dto.LectureDTO; -import intbyte4.learnsmate.lecture.domain.dto.LectureDetailDTO; -import intbyte4.learnsmate.lecture.domain.entity.Lecture; + import intbyte4.learnsmate.lecture.domain.entity.Lecture; import intbyte4.learnsmate.lecture.mapper.LectureMapper; import intbyte4.learnsmate.lecture.service.LectureService; -import intbyte4.learnsmate.lecture_by_student.service.LectureByStudentService; import intbyte4.learnsmate.lecture_category.domain.dto.LectureCategoryDTO; import intbyte4.learnsmate.lecture_category.domain.entity.LectureCategory; import intbyte4.learnsmate.lecture_category.mapper.LectureCategoryMapper; diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/member/controller/MemberController.java b/LearnsMate/src/main/java/intbyte4/learnsmate/member/controller/MemberController.java index 8905ce4a..f2e4240c 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/member/controller/MemberController.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/member/controller/MemberController.java @@ -2,7 +2,10 @@ import intbyte4.learnsmate.member.domain.dto.FindSingleStudentDTO; import intbyte4.learnsmate.member.domain.dto.FindSingleTutorDTO; +import intbyte4.learnsmate.member.domain.dto.MemberFilterRequestDTO; import intbyte4.learnsmate.member.domain.vo.request.RequestEditMemberVO; +import intbyte4.learnsmate.member.domain.vo.request.RequestFilterStudentVO; +import intbyte4.learnsmate.member.domain.vo.request.RequestFilterTutorVO; import intbyte4.learnsmate.member.domain.vo.response.ResponseFindStudentDetailVO; import intbyte4.learnsmate.member.domain.vo.response.ResponseFindTutorDetailVO; import intbyte4.learnsmate.member.mapper.MemberMapper; @@ -12,6 +15,7 @@ import intbyte4.learnsmate.member.domain.vo.response.ResponseFindMemberVO; import intbyte4.learnsmate.member.service.MemberFacade; import intbyte4.learnsmate.member.service.MemberService; +import io.swagger.v3.oas.annotations.Operation; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -114,4 +118,34 @@ public ResponseEntity deleteMember(@PathVariable("membercode") Long memb return ResponseEntity.status(HttpStatus.OK).body("삭제 성공"); } + + @Operation(summary = "직원 - 학생 필터링 검색") + @GetMapping("/filter/student") + public ResponseEntity> findStudentByFilter(@RequestBody RequestFilterStudentVO request) { + + MemberFilterRequestDTO dto = + memberMapper.fromRequestFilterStudentVOtoMemberFilterRequestDTO(request); + + List memberDTOList = memberService.filterStudent(dto); + + return ResponseEntity.status(HttpStatus.OK) + .body(memberDTOList.stream() + .map(memberMapper::fromMemberDTOtoResponseFindMemberVO) + .collect(Collectors.toList())); + } + + @Operation(summary = "직원 - 강사 필터링 검색") + @GetMapping("/filter/tutor") + public ResponseEntity findTutorByFilter(@RequestBody RequestFilterTutorVO request) { + + MemberFilterRequestDTO dto = + memberMapper.fromRequestFiltertutorVOtoMemberFilterRequestDTO(request); + + List memberDTOList = memberService.filterTutor(dto); + + return ResponseEntity.status(HttpStatus.OK) + .body(memberDTOList.stream() + .map(memberMapper::fromMemberDTOtoResponseFindMemberVO) + .collect(Collectors.toList())); + } } diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/member/domain/vo/MemberFilterRequestVO.java b/LearnsMate/src/main/java/intbyte4/learnsmate/member/domain/dto/MemberFilterRequestDTO.java similarity index 80% rename from LearnsMate/src/main/java/intbyte4/learnsmate/member/domain/vo/MemberFilterRequestVO.java rename to LearnsMate/src/main/java/intbyte4/learnsmate/member/domain/dto/MemberFilterRequestDTO.java index 532f0443..4030ea70 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/member/domain/vo/MemberFilterRequestVO.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/member/domain/dto/MemberFilterRequestDTO.java @@ -1,14 +1,17 @@ -package intbyte4.learnsmate.member.domain.vo; +package intbyte4.learnsmate.member.domain.dto; import intbyte4.learnsmate.member.domain.MemberType; -import lombok.Getter; -import lombok.Setter; +import lombok.*; import java.time.LocalDateTime; @Getter @Setter -public class MemberFilterRequestVO { +@AllArgsConstructor +@NoArgsConstructor +@Builder +@ToString +public class MemberFilterRequestDTO { private Long memberCode; private MemberType memberType; private String memberEmail; diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/member/domain/vo/request/RequestFilterStudentVO.java b/LearnsMate/src/main/java/intbyte4/learnsmate/member/domain/vo/request/RequestFilterStudentVO.java new file mode 100644 index 00000000..c5ed054a --- /dev/null +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/member/domain/vo/request/RequestFilterStudentVO.java @@ -0,0 +1,37 @@ +package intbyte4.learnsmate.member.domain.vo.request; + +import com.fasterxml.jackson.databind.PropertyNamingStrategies; +import com.fasterxml.jackson.databind.annotation.JsonNaming; +import intbyte4.learnsmate.member.domain.MemberType; +import lombok.*; + +import java.time.LocalDateTime; + +@Getter +@AllArgsConstructor +@NoArgsConstructor +@Builder +@ToString +@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) +public class RequestFilterStudentVO { + + private Long memberCode; + private MemberType memberType; + private String memberEmail; + private String memberName; + private Integer memberAge; + private String memberPhone; + private String memberAddress; + + // 생년월일 범위 + private LocalDateTime birthStartDate; + private LocalDateTime birthEndDate; + + // 생성일 범위 + private LocalDateTime createdStartDate; + private LocalDateTime createdEndDate; + + // 수정일 범위 + private LocalDateTime updatedStartDate; + private LocalDateTime updatedEndDate; +} diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/member/domain/vo/request/RequestFilterTutorVO.java b/LearnsMate/src/main/java/intbyte4/learnsmate/member/domain/vo/request/RequestFilterTutorVO.java new file mode 100644 index 00000000..40c51448 --- /dev/null +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/member/domain/vo/request/RequestFilterTutorVO.java @@ -0,0 +1,26 @@ +package intbyte4.learnsmate.member.domain.vo.request; + +import com.fasterxml.jackson.databind.PropertyNamingStrategies; +import com.fasterxml.jackson.databind.annotation.JsonNaming; +import lombok.*; + +import java.time.LocalDateTime; + +@Getter +@AllArgsConstructor +@NoArgsConstructor +@Builder +@ToString +@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) +public class RequestFilterTutorVO { + + private Long memberCode; + private String memberName; // 이름 + private String memberPhone; // 연락처 + private String memberEmail; // 이메일 + private String memberAddress; // 주소 + private Integer memberAge; // 나이 + private LocalDateTime birthStartDate; // 생년월일 시작 범위 + private LocalDateTime birthEndDate; // 생년월일 종료 범위 + private String memberStatus; // 계정 상태 +} diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/member/mapper/MemberMapper.java b/LearnsMate/src/main/java/intbyte4/learnsmate/member/mapper/MemberMapper.java index 286981b0..3a42c47c 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/member/mapper/MemberMapper.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/member/mapper/MemberMapper.java @@ -5,8 +5,11 @@ import intbyte4.learnsmate.member.domain.dto.FindSingleStudentDTO; import intbyte4.learnsmate.member.domain.dto.FindSingleTutorDTO; import intbyte4.learnsmate.member.domain.dto.MemberDTO; +import intbyte4.learnsmate.member.domain.dto.MemberFilterRequestDTO; import intbyte4.learnsmate.member.domain.entity.Member; import intbyte4.learnsmate.member.domain.vo.request.RequestEditMemberVO; +import intbyte4.learnsmate.member.domain.vo.request.RequestFilterStudentVO; +import intbyte4.learnsmate.member.domain.vo.request.RequestFilterTutorVO; import intbyte4.learnsmate.member.domain.vo.request.RequestSaveMemberVO; import intbyte4.learnsmate.member.domain.vo.response.ResponseFindStudentDetailVO; import intbyte4.learnsmate.member.domain.vo.response.ResponseFindMemberVO; @@ -181,4 +184,39 @@ public ResponseFindTutorDetailVO fromFindSingleTutorDTOtoResponseFindTutorDetail .tutorLectureDetailList(dto.getTutorLectureDetailList()) .build(); } + + public MemberFilterRequestDTO fromRequestFilterStudentVOtoMemberFilterRequestDTO(RequestFilterStudentVO request) { + return MemberFilterRequestDTO.builder() + .memberCode(request.getMemberCode()) + .memberType(request.getMemberType()) + .memberEmail(request.getMemberEmail()) + .memberName(request.getMemberName()) + .memberAge(request.getMemberAge()) + .memberPhone(request.getMemberPhone()) + .memberAddress(request.getMemberAddress()) + .birthStartDate(request.getBirthStartDate()) + .birthEndDate(request.getBirthEndDate()) + .createdStartDate(request.getCreatedStartDate()) + .createdEndDate(request.getCreatedEndDate()) + .updatedStartDate(request.getUpdatedStartDate()) + .updatedEndDate(request.getUpdatedEndDate()) + .build(); + } + public MemberFilterRequestDTO fromRequestFiltertutorVOtoMemberFilterRequestDTO(RequestFilterTutorVO request) { + return MemberFilterRequestDTO.builder() + .memberCode(request.getMemberCode()) +// .memberType(request.getMemberType()) + .memberEmail(request.getMemberEmail()) + .memberName(request.getMemberName()) + .memberAge(request.getMemberAge()) + .memberPhone(request.getMemberPhone()) + .memberAddress(request.getMemberAddress()) + .birthStartDate(request.getBirthStartDate()) + .birthEndDate(request.getBirthEndDate()) +// .createdStartDate(request.getCreatedStartDate()) +// .createdEndDate(request.getCreatedEndDate()) +// .updatedStartDate(request.getUpdatedStartDate()) +// .updatedEndDate(request.getUpdatedEndDate()) + .build(); + } } diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/member/repository/MemberRepositoryCustom.java b/LearnsMate/src/main/java/intbyte4/learnsmate/member/repository/MemberRepositoryCustom.java index 0a5cb5b0..a6e6eb9d 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/member/repository/MemberRepositoryCustom.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/member/repository/MemberRepositoryCustom.java @@ -1,10 +1,10 @@ package intbyte4.learnsmate.member.repository; import intbyte4.learnsmate.member.domain.entity.Member; -import intbyte4.learnsmate.member.domain.vo.MemberFilterRequestVO; +import intbyte4.learnsmate.member.domain.dto.MemberFilterRequestDTO; import java.util.List; public interface MemberRepositoryCustom { - List searchBy(MemberFilterRequestVO request); + List searchBy(MemberFilterRequestDTO request); } diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/member/repository/MemberRepositoryImpl.java b/LearnsMate/src/main/java/intbyte4/learnsmate/member/repository/MemberRepositoryImpl.java index 094f54c9..4939991f 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/member/repository/MemberRepositoryImpl.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/member/repository/MemberRepositoryImpl.java @@ -6,7 +6,7 @@ import intbyte4.learnsmate.member.domain.MemberType; import intbyte4.learnsmate.member.domain.entity.Member; import intbyte4.learnsmate.member.domain.entity.QMember; -import intbyte4.learnsmate.member.domain.vo.MemberFilterRequestVO; +import intbyte4.learnsmate.member.domain.dto.MemberFilterRequestDTO; import lombok.RequiredArgsConstructor; import java.time.LocalDateTime; @@ -18,7 +18,7 @@ public class MemberRepositoryImpl implements MemberRepositoryCustom { private final JPAQueryFactory queryFactory; @Override - public List searchBy(MemberFilterRequestVO request) { + public List searchBy(MemberFilterRequestDTO request) { QMember member = QMember.member; BooleanBuilder builder = new BooleanBuilder() diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/member/service/MemberService.java b/LearnsMate/src/main/java/intbyte4/learnsmate/member/service/MemberService.java index c4b384af..693ddc0a 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/member/service/MemberService.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/member/service/MemberService.java @@ -2,24 +2,20 @@ import intbyte4.learnsmate.common.exception.CommonException; import intbyte4.learnsmate.common.exception.StatusEnum; -import intbyte4.learnsmate.issue_coupon.domain.dto.IssueCouponDTO; -import intbyte4.learnsmate.issue_coupon.service.IssueCouponService; -import intbyte4.learnsmate.member.domain.dto.MemberIssueCouponDTO; -import intbyte4.learnsmate.member.domain.dto.MemberVOCDTO; +import intbyte4.learnsmate.member.domain.dto.MemberFilterRequestDTO; import intbyte4.learnsmate.member.mapper.MemberMapper; import intbyte4.learnsmate.member.domain.MemberType; import intbyte4.learnsmate.member.domain.dto.MemberDTO; import intbyte4.learnsmate.member.domain.entity.Member; import intbyte4.learnsmate.member.repository.MemberRepository; -import intbyte4.learnsmate.voc.domain.dto.VOCDTO; -import intbyte4.learnsmate.voc.service.VOCService; +import intbyte4.learnsmate.member.repository.MemberRepositoryCustom; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; -import java.util.Map; +import java.util.stream.Collectors; @Service @RequiredArgsConstructor @@ -27,6 +23,7 @@ public class MemberService { private final MemberRepository memberRepository; private final MemberMapper memberMapper; + private final MemberRepositoryCustom memberRepositoryCustom; public void saveMember(MemberDTO memberDTO) { LocalDateTime now = LocalDateTime.now(); @@ -92,4 +89,22 @@ public MemberDTO findById(Long memberCode){ return memberMapper.fromMembertoMemberDTO(member); } + + // 학생 필터링하는 서비스 코드 + public List filterStudent(MemberFilterRequestDTO dto){ + List memberList = memberRepositoryCustom.searchBy(dto); + + return memberList.stream() + .map(memberMapper::fromMembertoMemberDTO) + .collect(Collectors.toList()); + } + + // 강사 필터링하는 코드 -> 강사 필터링은 조건이 더 적음(멤버에 다 포함됨) + public List filterTutor(MemberFilterRequestDTO dto) { + List memberList = memberRepositoryCustom.searchBy(dto); + + return memberList.stream() + .map(memberMapper::fromMembertoMemberDTO) + .collect(Collectors.toList()); + } } diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/payment/controller/PaymentController.java b/LearnsMate/src/main/java/intbyte4/learnsmate/payment/controller/PaymentController.java index 6b3e4b49..fcc36338 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/payment/controller/PaymentController.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/payment/controller/PaymentController.java @@ -1,7 +1,7 @@ package intbyte4.learnsmate.payment.controller; -import intbyte4.learnsmate.facade.PaymentFacade; -import intbyte4.learnsmate.facade.LectureFacade; +import intbyte4.learnsmate.payment.service.PaymentFacade; +import intbyte4.learnsmate.lecture.service.LectureFacade; import intbyte4.learnsmate.issue_coupon.domain.dto.IssueCouponDTO; import intbyte4.learnsmate.issue_coupon.mapper.IssueCouponMapper; import intbyte4.learnsmate.lecture.domain.dto.LectureDTO; @@ -10,12 +10,14 @@ import intbyte4.learnsmate.member.mapper.MemberMapper; import intbyte4.learnsmate.payment.domain.dto.PaymentDTO; import intbyte4.learnsmate.payment.domain.dto.PaymentDetailDTO; +import intbyte4.learnsmate.payment.domain.dto.PaymentFilterDTO; import intbyte4.learnsmate.payment.domain.vo.ResponseFindPaymentVO; import intbyte4.learnsmate.payment.domain.vo.*; import intbyte4.learnsmate.payment.mapper.PaymentMapper; import intbyte4.learnsmate.payment.service.PaymentServiceImpl; import io.swagger.v3.oas.annotations.Operation; import lombok.RequiredArgsConstructor; +import org.apache.coyote.Response; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; @@ -81,6 +83,12 @@ public ResponseEntity getPaymentDetails(@PathVariable("pa return ResponseEntity.ok(responseList); } + @Operation(summary = "필터별 결제 내역 조회") + @GetMapping("/filter") + public ResponseEntity> getPaymentsByFilters(@RequestBody PaymentFilterRequestVO request) { + List payments = paymentService.getPaymentsByFilters(request); + return ResponseEntity.status(HttpStatus.OK).body(payments); + } // // 직원이 예상 매출액과 할인 매출액을 비교해서 조회 (추가 예시 메서드) // @GetMapping("/revenue") // public ResponseEntity getRevenueComparison() { diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/payment/domain/dto/PaymentDetailDTO.java b/LearnsMate/src/main/java/intbyte4/learnsmate/payment/domain/dto/PaymentDetailDTO.java index 45398c1a..52c8ebad 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/payment/domain/dto/PaymentDetailDTO.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/payment/domain/dto/PaymentDetailDTO.java @@ -27,5 +27,4 @@ public class PaymentDetailDTO { private LectureLevelEnum lectureLevel; // 강의 난이도 private String couponIssuanceCode; // 적용 쿠폰 코드 private String couponIssuanceName; // 적용 쿠폰명 - } diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/payment/domain/dto/PaymentFilterDTO.java b/LearnsMate/src/main/java/intbyte4/learnsmate/payment/domain/dto/PaymentFilterDTO.java new file mode 100644 index 00000000..fc72224e --- /dev/null +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/payment/domain/dto/PaymentFilterDTO.java @@ -0,0 +1,26 @@ +package intbyte4.learnsmate.payment.domain.dto; + +import lombok.*; + +import java.time.LocalDateTime; + +@Getter +@Builder +@ToString +@NoArgsConstructor +@AllArgsConstructor +public class PaymentFilterDTO { + private Long paymentCode; + private Integer paymentPrice; + private LocalDateTime createdAt; + private Long lectureCode; // 강의코드 + private String lectureTitle; // 강의명 + private Integer lecturePrice; // 강의 원가 + private Long tutorCode; // 강사 코드 + private String tutorName; // 강사 명 + private Long studentCode; // 학생 코드 + private String studentName; // 학생 명 + private Integer lectureCategoryCode; // 강의 카테고리 + private String couponIssuanceCode; // 적용 쿠폰 코드 + private String couponIssuanceName; // 적용 쿠폰명 +} diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/payment/domain/vo/PaymentFilterRequestVO.java b/LearnsMate/src/main/java/intbyte4/learnsmate/payment/domain/vo/PaymentFilterRequestVO.java new file mode 100644 index 00000000..38516c31 --- /dev/null +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/payment/domain/vo/PaymentFilterRequestVO.java @@ -0,0 +1,62 @@ +package intbyte4.learnsmate.payment.domain.vo; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.*; + +import java.time.LocalDateTime; + +@Getter +@AllArgsConstructor +@NoArgsConstructor +@Builder +@ToString +public class PaymentFilterRequestVO { + + @JsonProperty("payment_code") + private Long paymentCode; + + @JsonProperty("min_payment_price") + private Integer minPaymentPrice; + + @JsonProperty("max_payment_price") + private Integer maxPaymentPrice; + + @JsonProperty("start_created_at") + private LocalDateTime startCreatedAt; + + @JsonProperty("end_created_at") + private LocalDateTime endCreatedAt; + + @JsonProperty("leture_code") + private Long lectureCode; // 강의코드 + + @JsonProperty("lecture_title") + private String lectureTitle; // 강의명 + + @JsonProperty("min_lecture_price") + private Integer minLecturePrice; // 강의 원가 + + @JsonProperty("max_lecture_price") + private Integer maxLecturePrice; + + @JsonProperty("tutor_code") + private Long tutorCode; // 강사 코드 + + @JsonProperty("tutor_name") + private String tutorName; // 강사명 + + @JsonProperty("student_code") + private Long studentCode; // 학생 코드 + + @JsonProperty("student_name") + private String studentName; // 학생명 + + @JsonProperty("lecture_category") + private Integer lectureCategoryCode; // 강의 카테고리 + + @JsonProperty("coupon_issuance_code") + private String couponIssuanceCode; // 적용 쿠폰 코드 + + @JsonProperty("coupon_issuance_name") + private String couponIssuanceName; // 적용 쿠폰명 +} diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/payment/repository/CustomPaymentRepository.java b/LearnsMate/src/main/java/intbyte4/learnsmate/payment/repository/CustomPaymentRepository.java new file mode 100644 index 00000000..2cd230b0 --- /dev/null +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/payment/repository/CustomPaymentRepository.java @@ -0,0 +1,11 @@ +package intbyte4.learnsmate.payment.repository; + +import intbyte4.learnsmate.payment.domain.dto.PaymentFilterDTO; +import intbyte4.learnsmate.payment.domain.vo.PaymentFilterRequestVO; + +import java.util.List; + +public interface CustomPaymentRepository { + + List findPaymentByFilters(PaymentFilterRequestVO request); +} diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/payment/repository/CustomPaymentRepositoryImpl.java b/LearnsMate/src/main/java/intbyte4/learnsmate/payment/repository/CustomPaymentRepositoryImpl.java new file mode 100644 index 00000000..15edd0be --- /dev/null +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/payment/repository/CustomPaymentRepositoryImpl.java @@ -0,0 +1,167 @@ +package intbyte4.learnsmate.payment.repository; + +import com.querydsl.core.BooleanBuilder; +import com.querydsl.core.types.Projections; +import com.querydsl.core.types.dsl.BooleanExpression; +import com.querydsl.jpa.impl.JPAQueryFactory; +import intbyte4.learnsmate.lecture.domain.entity.QLecture; +import intbyte4.learnsmate.lecture_by_student.domain.entity.QLectureByStudent; +import intbyte4.learnsmate.lecture_category.domain.entity.QLectureCategory; +import intbyte4.learnsmate.lecture_category_by_lecture.domain.entity.QLectureCategoryByLecture; +import intbyte4.learnsmate.payment.domain.dto.PaymentFilterDTO; +import intbyte4.learnsmate.payment.domain.entity.QPayment; +import intbyte4.learnsmate.payment.domain.vo.PaymentFilterRequestVO; +import jakarta.persistence.EntityManager; +import org.springframework.stereotype.Repository; + +import java.time.LocalDateTime; +import java.util.List; + +@Repository +public class CustomPaymentRepositoryImpl implements CustomPaymentRepository { + + private final JPAQueryFactory queryFactory; + + public CustomPaymentRepositoryImpl(EntityManager entityManager) { + this.queryFactory = new JPAQueryFactory(entityManager); + } + + @Override + public List findPaymentByFilters(PaymentFilterRequestVO request) { + QPayment payment = QPayment.payment; + QLectureByStudent lectureByStudent = QLectureByStudent.lectureByStudent; + QLecture lecture = QLecture.lecture; + QLectureCategoryByLecture lectureCategoryByLecture = QLectureCategoryByLecture.lectureCategoryByLecture; + QLectureCategory lectureCategory = QLectureCategory.lectureCategory; + + BooleanBuilder builder = new BooleanBuilder() + .and(eqPaymentCode(request.getPaymentCode())) + .and(betweenPaymentPrice(request.getMinPaymentPrice(), request.getMaxPaymentPrice())) + .and(betweenCreatedAt(request.getStartCreatedAt(), request.getEndCreatedAt())) + .and(eqLectureCode(request.getLectureCode())) + .and(likeLectureTitle(request.getLectureTitle())) + .and(betweenLecturePrice(request.getMinLecturePrice(), request.getMaxLecturePrice())) + .and(eqTutorCode(request.getTutorCode())) + .and(eqTutorName(request.getTutorName())) + .and(eqStudentCode(request.getStudentCode())) + .and(eqStudentName(request.getStudentName())) + .and(eqLectureCategoryCode(request.getLectureCategoryCode())) + .and(eqCouponIssuanceCode(request.getCouponIssuanceCode())) + .and(likeCouponIssuanceName(request.getCouponIssuanceName())); + + return queryFactory + .select(Projections.constructor( + PaymentFilterDTO.class, + payment.paymentCode, + payment.paymentPrice, + payment.createdAt, + lecture.lectureCode, + lecture.lectureTitle, + lecture.lecturePrice, + lecture.tutor.memberCode, + lecture.tutor.memberName, + lectureByStudent.student.memberCode, + lectureByStudent.student.memberName, + lectureCategory.lectureCategoryCode, + lectureCategory.lectureCategoryName, + payment.couponIssuance.couponIssuanceCode, + payment.couponIssuance.coupon.couponName + )) + .from(payment) + .join(payment.lectureByStudent, lectureByStudent) // Payment → LectureByStudent + .join(lectureByStudent.lecture, lecture) // LectureByStudent → Lecture + .join(lectureCategoryByLecture).on(lectureCategoryByLecture.lecture.eq(lecture)) // Lecture → LectureCategoryByLecture + .join(lectureCategoryByLecture.lectureCategory, lectureCategory) // LectureCategoryByLecture → LectureCategory + .where(builder) + .fetch(); + } + + private BooleanExpression eqPaymentCode(Long paymentCode) { + return paymentCode == null ? null : QPayment.payment.paymentCode.eq(paymentCode); + } + + private BooleanExpression betweenPaymentPrice(Integer minPaymentPrice, Integer maxPaymentPrice) { + if (minPaymentPrice == null && maxPaymentPrice == null) { + return null; + } + + if (minPaymentPrice == null) { + return QPayment.payment.paymentCode.loe(maxPaymentPrice); + } + + if (maxPaymentPrice == null) { + return QPayment.payment.paymentCode.goe(minPaymentPrice); + } + + return QPayment.payment.paymentCode.between(minPaymentPrice, maxPaymentPrice); + } + + private BooleanExpression betweenCreatedAt(LocalDateTime startCreatedAt, LocalDateTime endCreatedAt) { + if (startCreatedAt == null && endCreatedAt == null) { + return null; + } + + if (startCreatedAt == null) { + return QPayment.payment.createdAt.loe(endCreatedAt); + } + + if (endCreatedAt == null) { + return QPayment.payment.createdAt.goe(startCreatedAt); + } + + return QPayment.payment.createdAt.between(startCreatedAt, endCreatedAt); + } + + private BooleanExpression eqLectureCode(Long lectureCode) { + return lectureCode == null ? null : QPayment.payment.lectureByStudent.lecture.lectureCode.eq(lectureCode); + } + + private BooleanExpression likeLectureTitle(String lectureTitle) { + return lectureTitle == null ? null : QPayment.payment.lectureByStudent.lecture.lectureTitle.likeIgnoreCase(lectureTitle); + } + + private BooleanExpression betweenLecturePrice(Integer minLecturePrice, Integer maxLecturePrice) { + if (minLecturePrice == null && maxLecturePrice == null) { + return null; + } + + if (minLecturePrice == null) { + return QPayment.payment.lectureByStudent.lecture.lecturePrice.loe(maxLecturePrice); + } + + if (maxLecturePrice == null) { + return QPayment.payment.lectureByStudent.lecture.lecturePrice.goe(minLecturePrice); + } + + return QPayment.payment.lectureByStudent.lecture.lecturePrice.between(minLecturePrice, maxLecturePrice); + } + + private BooleanExpression eqTutorCode(Long tutorCode) { + return tutorCode == null ? null : QPayment.payment.lectureByStudent.lecture.tutor.memberCode.eq(tutorCode); + } + + private BooleanExpression eqTutorName(String tutorName) { + return tutorName == null ? null : QPayment.payment.lectureByStudent.lecture.tutor.memberName.eq(tutorName); + } + + private BooleanExpression eqStudentCode(Long studentCode) { + return studentCode == null ? null : QPayment.payment.lectureByStudent.student.memberCode.eq(studentCode); + } + + private BooleanExpression eqStudentName(String studentName) { + return studentName == null ? null : QPayment.payment.lectureByStudent.student.memberName.eq(studentName); + } + + private BooleanExpression eqLectureCategoryCode(Integer lectureCategoryCode) { + return lectureCategoryCode == null ? null : QLectureCategoryByLecture.lectureCategoryByLecture + .lectureCategory.lectureCategoryCode.eq(lectureCategoryCode); + } + + private BooleanExpression eqCouponIssuanceCode(String couponIssuanceCode) { + return couponIssuanceCode == null ? null : QPayment.payment.couponIssuance.couponIssuanceCode.eq(couponIssuanceCode); + } + + private BooleanExpression likeCouponIssuanceName(String couponIssuanceName) { + return couponIssuanceName == null ? null : QPayment.payment.couponIssuance.coupon.couponName.likeIgnoreCase(couponIssuanceName); + } +} diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/payment/repository/PaymentRepository.java b/LearnsMate/src/main/java/intbyte4/learnsmate/payment/repository/PaymentRepository.java index d6beb3c8..d825c771 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/payment/repository/PaymentRepository.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/payment/repository/PaymentRepository.java @@ -1,9 +1,10 @@ package intbyte4.learnsmate.payment.repository; +import intbyte4.learnsmate.coupon.repository.CustomCouponRepository; import intbyte4.learnsmate.payment.domain.entity.Payment; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; @Repository -public interface PaymentRepository extends JpaRepository { +public interface PaymentRepository extends JpaRepository, CustomPaymentRepository { } diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/facade/PaymentFacade.java b/LearnsMate/src/main/java/intbyte4/learnsmate/payment/service/PaymentFacade.java similarity index 98% rename from LearnsMate/src/main/java/intbyte4/learnsmate/facade/PaymentFacade.java rename to LearnsMate/src/main/java/intbyte4/learnsmate/payment/service/PaymentFacade.java index 62249c25..72404be8 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/facade/PaymentFacade.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/payment/service/PaymentFacade.java @@ -1,4 +1,4 @@ -package intbyte4.learnsmate.facade; +package intbyte4.learnsmate.payment.service; import intbyte4.learnsmate.common.exception.CommonException; import intbyte4.learnsmate.common.exception.StatusEnum; diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/payment/service/PaymentService.java b/LearnsMate/src/main/java/intbyte4/learnsmate/payment/service/PaymentService.java index 3d4da1ca..74c3cdbe 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/payment/service/PaymentService.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/payment/service/PaymentService.java @@ -5,6 +5,9 @@ import intbyte4.learnsmate.lecture.domain.dto.LectureDTO; import intbyte4.learnsmate.member.domain.dto.MemberDTO; import intbyte4.learnsmate.payment.domain.dto.PaymentDTO; +import intbyte4.learnsmate.payment.domain.dto.PaymentDetailDTO; +import intbyte4.learnsmate.payment.domain.dto.PaymentFilterDTO; +import intbyte4.learnsmate.payment.domain.vo.PaymentFilterRequestVO; import java.util.List; @@ -12,6 +15,8 @@ public interface PaymentService { // 직원이 전체 결제 내역을 조회 List getAllPayments(); + List getPaymentsByFilters(PaymentFilterRequestVO request); + // 직원이 특정 결제 내역을 단건 상세 조회 PaymentDTO getPaymentDetails(Long paymentCode); diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/payment/service/PaymentServiceImpl.java b/LearnsMate/src/main/java/intbyte4/learnsmate/payment/service/PaymentServiceImpl.java index 29fe1fd5..d085e18a 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/payment/service/PaymentServiceImpl.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/payment/service/PaymentServiceImpl.java @@ -17,7 +17,6 @@ import intbyte4.learnsmate.lecture.domain.dto.LectureDTO; import intbyte4.learnsmate.lecture.domain.entity.Lecture; import intbyte4.learnsmate.lecture.mapper.LectureMapper; -import intbyte4.learnsmate.lecture.service.LectureService; import intbyte4.learnsmate.lecture_by_student.domain.dto.LectureByStudentDTO; import intbyte4.learnsmate.lecture_by_student.domain.entity.LectureByStudent; import intbyte4.learnsmate.lecture_by_student.mapper.LectureByStudentMapper; @@ -28,7 +27,10 @@ import intbyte4.learnsmate.member.mapper.MemberMapper; import intbyte4.learnsmate.member.service.MemberService; import intbyte4.learnsmate.payment.domain.dto.PaymentDTO; +import intbyte4.learnsmate.payment.domain.dto.PaymentDetailDTO; +import intbyte4.learnsmate.payment.domain.dto.PaymentFilterDTO; import intbyte4.learnsmate.payment.domain.entity.Payment; +import intbyte4.learnsmate.payment.domain.vo.PaymentFilterRequestVO; import intbyte4.learnsmate.payment.mapper.PaymentMapper; import intbyte4.learnsmate.payment.repository.PaymentRepository; import lombok.RequiredArgsConstructor; @@ -48,7 +50,6 @@ public class PaymentServiceImpl implements PaymentService { private final MemberMapper memberMapper; private final LectureByStudentMapper lectureByStudentMapper; private final IssueCouponMapper issueCouponMapper; - private final LectureService lectureService; private final MemberService memberService; private final LectureByStudentService lectureByStudentService; private final CouponService couponService; @@ -70,6 +71,10 @@ public List getAllPayments() { .collect(Collectors.toList()); } + @Override + public List getPaymentsByFilters(PaymentFilterRequestVO request) { + return paymentRepository.findPaymentByFilters(request); + } // 직원이 특정 결제 내역을 단건 상세 조회 @Override diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/video_by_lecture/service/VideoByLectureFacade.java b/LearnsMate/src/main/java/intbyte4/learnsmate/video_by_lecture/service/VideoByLectureFacade.java index cc4278fc..3192b1e3 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/video_by_lecture/service/VideoByLectureFacade.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/video_by_lecture/service/VideoByLectureFacade.java @@ -1,10 +1,10 @@ package intbyte4.learnsmate.video_by_lecture.service; -import intbyte4.learnsmate.facade.LectureFacade; import intbyte4.learnsmate.lecture.domain.dto.LectureDTO; import intbyte4.learnsmate.lecture.domain.entity.Lecture; import intbyte4.learnsmate.lecture.mapper.LectureMapper; +import intbyte4.learnsmate.lecture.service.LectureService; import intbyte4.learnsmate.lecture_by_student.service.LectureByStudentService; import intbyte4.learnsmate.member.domain.MemberType; import intbyte4.learnsmate.member.domain.dto.MemberDTO; @@ -24,7 +24,7 @@ public class VideoByLectureFacade { private final VideoByLectureRepository videoByLectureRepository; - private final LectureFacade lectureFacade; + private final LectureService lectureService; private final MemberService memberService; private final LectureMapper lectureMapper; private final LectureByStudentService lectureByStudentService; @@ -37,7 +37,7 @@ public List getVideoByLecture(Long tutorCode) { Member tutor = memberMapper.fromMemberDTOtoMember(tutorDTO); // 튜터와 관련된 강의 목록 조회 - List lectureDTOList = lectureFacade.getLecturesByTutorCode(tutor.getMemberCode()); + List lectureDTOList = lectureService.getLecturesByTutorCode(tutor.getMemberCode()); // 결과를 저장할 리스트 준비 List result = new ArrayList<>(); diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/video_by_lecture/service/VideoByLectureService.java b/LearnsMate/src/main/java/intbyte4/learnsmate/video_by_lecture/service/VideoByLectureService.java index 89de8312..4d4092bd 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/video_by_lecture/service/VideoByLectureService.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/video_by_lecture/service/VideoByLectureService.java @@ -7,4 +7,6 @@ public interface VideoByLectureService { // 강의코드별 모든 강의별 동영상 조회 List findVideoByLectureByLectureCode(Long lectureCode); + + void registerVideoByLecture(Long lectureCode, VideoByLectureDTO videoByLectureDTO); } diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/video_by_lecture/service/VideoByLectureServiceImpl.java b/LearnsMate/src/main/java/intbyte4/learnsmate/video_by_lecture/service/VideoByLectureServiceImpl.java index d9c4d71e..f089fbfd 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/video_by_lecture/service/VideoByLectureServiceImpl.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/video_by_lecture/service/VideoByLectureServiceImpl.java @@ -2,18 +2,15 @@ import intbyte4.learnsmate.common.exception.CommonException; import intbyte4.learnsmate.common.exception.StatusEnum; -import intbyte4.learnsmate.facade.LectureFacade; import intbyte4.learnsmate.lecture.domain.dto.LectureDTO; import intbyte4.learnsmate.lecture.domain.entity.Lecture; import intbyte4.learnsmate.lecture.mapper.LectureMapper; import intbyte4.learnsmate.lecture.service.LectureService; -import intbyte4.learnsmate.lecture_by_student.service.LectureByStudentService; import intbyte4.learnsmate.member.domain.MemberType; import intbyte4.learnsmate.member.domain.dto.MemberDTO; import intbyte4.learnsmate.member.domain.entity.Member; import intbyte4.learnsmate.member.mapper.MemberMapper; import intbyte4.learnsmate.member.service.MemberService; -import intbyte4.learnsmate.video_by_lecture.domain.dto.CountVideoByLectureDTO; import intbyte4.learnsmate.video_by_lecture.domain.dto.VideoByLectureDTO; import intbyte4.learnsmate.video_by_lecture.domain.entity.VideoByLecture; import intbyte4.learnsmate.video_by_lecture.mapper.VideoByLectureMapper; @@ -21,7 +18,6 @@ import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; -import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; @@ -55,6 +51,29 @@ public List findVideoByLectureByLectureCode(Long lectureCode) return videoByLectures.stream() .map(videoByLectureMapper::toDTO) .collect(Collectors.toList()); -} + } + + // 강의별 동영상 등록 + @Override + public void registerVideoByLecture(Long lectureCode, VideoByLectureDTO videoByLectureDTO) { + + LectureDTO lectureDTO = lectureService.getLectureById(lectureCode); + + MemberDTO tutorDTO = memberService.findMemberByMemberCode(lectureDTO.getTutorCode(), MemberType.TUTOR); + Member tutor = memberMapper.fromMemberDTOtoMember(tutorDTO); + + Lecture lecture = lectureMapper.toEntity(lectureDTO, tutor); + + VideoByLecture videoByLecture = VideoByLecture.builder() + .lecture(lecture) // 강의 설정 + .videoTitle(videoByLectureDTO.getVideoTitle()) + .videoLink(videoByLectureDTO.getVideoLink()) + .build(); + + VideoByLecture savedVideoByLecture = videoByLectureRepository.save(videoByLecture); + + videoByLectureMapper.toDTO(savedVideoByLecture); + } + }