diff --git a/src/main/java/umc/kkijuk/server/career/domain/Activity.java b/src/main/java/umc/kkijuk/server/career/domain/Activity.java index 169a457c..ba499925 100644 --- a/src/main/java/umc/kkijuk/server/career/domain/Activity.java +++ b/src/main/java/umc/kkijuk/server/career/domain/Activity.java @@ -39,10 +39,10 @@ public void setSummary(String summary) { @Builder public Activity(Long memberId, String name, String alias, Boolean unknown, - LocalDate startdate, LocalDate enddate, String organizer, + LocalDate startDate, LocalDate endDate, String organizer, String role, int teamSize, int contribution, Boolean isTeam) { - super(memberId, name, alias, unknown, startdate, enddate); + super(memberId, name, alias, unknown, startDate, endDate); this.organizer = organizer; this.role = role; this.teamSize = teamSize; diff --git a/src/main/java/umc/kkijuk/server/career/domain/CareerEtc.java b/src/main/java/umc/kkijuk/server/career/domain/CareerEtc.java index 4981e9aa..1987267f 100644 --- a/src/main/java/umc/kkijuk/server/career/domain/CareerEtc.java +++ b/src/main/java/umc/kkijuk/server/career/domain/CareerEtc.java @@ -2,11 +2,8 @@ import jakarta.persistence.*; import lombok.*; -import umc.kkijuk.server.detail.domain.BaseCareerDetail; import java.time.LocalDate; -import java.util.ArrayList; -import java.util.List; @Entity @Getter diff --git a/src/main/java/umc/kkijuk/server/career/dto/converter/BaseCareerConverter.java b/src/main/java/umc/kkijuk/server/career/dto/converter/BaseCareerConverter.java index fa772224..15cba1ef 100644 --- a/src/main/java/umc/kkijuk/server/career/dto/converter/BaseCareerConverter.java +++ b/src/main/java/umc/kkijuk/server/career/dto/converter/BaseCareerConverter.java @@ -67,8 +67,8 @@ public static Activity toAvtivity(Member requestMember, ActivityReqDto activityR .name(activityReqDto.getName()) .alias(activityReqDto.getAlias()) .unknown(activityReqDto.getUnknown()) - .startdate(activityReqDto.getStartdate()) - .enddate(activityReqDto.getEnddate()) + .startDate(activityReqDto.getStartdate()) + .endDate(activityReqDto.getEnddate()) .organizer(activityReqDto.getOrganizer()) .role(activityReqDto.getRole()) .contribution(activityReqDto.getContribution()) diff --git a/src/main/java/umc/kkijuk/server/career/repository/ActivityJpaRepository.java b/src/main/java/umc/kkijuk/server/career/repository/ActivityJpaRepository.java new file mode 100644 index 00000000..1434827b --- /dev/null +++ b/src/main/java/umc/kkijuk/server/career/repository/ActivityJpaRepository.java @@ -0,0 +1,11 @@ +package umc.kkijuk.server.career.repository; + +import org.springframework.data.jpa.repository.JpaRepository; +import umc.kkijuk.server.career.domain.Activity; + +import java.util.List; + +public interface ActivityJpaRepository extends JpaRepository { + List findByMemberId(Long memberId); + List findByMemberIdAndNameContaining(Long memberId, String keyword); +} diff --git a/src/main/java/umc/kkijuk/server/career/repository/ActivityRepository.java b/src/main/java/umc/kkijuk/server/career/repository/ActivityRepository.java index 20813cbe..7d6c77f3 100644 --- a/src/main/java/umc/kkijuk/server/career/repository/ActivityRepository.java +++ b/src/main/java/umc/kkijuk/server/career/repository/ActivityRepository.java @@ -1,11 +1,16 @@ package umc.kkijuk.server.career.repository; -import org.springframework.data.jpa.repository.JpaRepository; import umc.kkijuk.server.career.domain.Activity; import java.util.List; +import java.util.Optional; -public interface ActivityRepository extends JpaRepository { +public interface ActivityRepository { List findByMemberId(Long memberId); List findByMemberIdAndNameContaining(Long memberId, String keyword); + Activity save(Activity activity); + + Optional findById(Long activityId); + + void delete(Activity activity); } diff --git a/src/main/java/umc/kkijuk/server/career/repository/ActivityRepositoryImpl.java b/src/main/java/umc/kkijuk/server/career/repository/ActivityRepositoryImpl.java new file mode 100644 index 00000000..04c74d1a --- /dev/null +++ b/src/main/java/umc/kkijuk/server/career/repository/ActivityRepositoryImpl.java @@ -0,0 +1,35 @@ +package umc.kkijuk.server.career.repository; + +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Repository; +import umc.kkijuk.server.career.domain.Activity; + +import java.util.List; +import java.util.Optional; + +@Repository +@RequiredArgsConstructor +public class ActivityRepositoryImpl implements ActivityRepository{ + private final ActivityJpaRepository activityJpaRepository; + @Override + public List findByMemberId(Long memberId) { + return activityJpaRepository.findByMemberId(memberId); + } + @Override + public List findByMemberIdAndNameContaining(Long memberId, String keyword) { + return activityJpaRepository.findByMemberIdAndNameContaining(memberId,keyword); + } + @Override + public Activity save(Activity activity) { + return activityJpaRepository.save(activity); + } + @Override + public Optional findById(Long activityId) { + return activityJpaRepository.findById(activityId); + } + + @Override + public void delete(Activity activity) { + activityJpaRepository.delete(activity); + } +} diff --git a/src/main/java/umc/kkijuk/server/career/repository/CareerEtcJpaRepository.java b/src/main/java/umc/kkijuk/server/career/repository/CareerEtcJpaRepository.java new file mode 100644 index 00000000..f939f622 --- /dev/null +++ b/src/main/java/umc/kkijuk/server/career/repository/CareerEtcJpaRepository.java @@ -0,0 +1,12 @@ +package umc.kkijuk.server.career.repository; + +import org.springframework.data.jpa.repository.JpaRepository; +import umc.kkijuk.server.career.domain.CareerEtc; + +import java.util.List; + +public interface CareerEtcJpaRepository extends JpaRepository { + List findByMemberId(Long memberId); + + List findByMemberIdAndNameContaining(Long id, String keyword); +} diff --git a/src/main/java/umc/kkijuk/server/career/repository/CareerEtcRepository.java b/src/main/java/umc/kkijuk/server/career/repository/CareerEtcRepository.java index dd170011..9549fa14 100644 --- a/src/main/java/umc/kkijuk/server/career/repository/CareerEtcRepository.java +++ b/src/main/java/umc/kkijuk/server/career/repository/CareerEtcRepository.java @@ -1,12 +1,18 @@ package umc.kkijuk.server.career.repository; -import org.springframework.data.jpa.repository.JpaRepository; import umc.kkijuk.server.career.domain.CareerEtc; import java.util.List; +import java.util.Optional; -public interface CareerEtcRepository extends JpaRepository { +public interface CareerEtcRepository { List findByMemberId(Long memberId); List findByMemberIdAndNameContaining(Long id, String keyword); + + CareerEtc save(CareerEtc etc); + + Optional findById(Long etcId); + + void delete(CareerEtc etc); } diff --git a/src/main/java/umc/kkijuk/server/career/repository/CareerEtcRepositoryImpl.java b/src/main/java/umc/kkijuk/server/career/repository/CareerEtcRepositoryImpl.java new file mode 100644 index 00000000..ada8fe50 --- /dev/null +++ b/src/main/java/umc/kkijuk/server/career/repository/CareerEtcRepositoryImpl.java @@ -0,0 +1,35 @@ +package umc.kkijuk.server.career.repository; + +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Repository; +import umc.kkijuk.server.career.domain.CareerEtc; + +import java.util.List; +import java.util.Optional; + +@Repository +@RequiredArgsConstructor +public class CareerEtcRepositoryImpl implements CareerEtcRepository{ + private final CareerEtcJpaRepository careerEtcJpaRepository; + @Override + public List findByMemberId(Long memberId) { + return careerEtcJpaRepository.findByMemberId(memberId); + } + + @Override + public List findByMemberIdAndNameContaining(Long id, String keyword) { + return careerEtcJpaRepository.findByMemberIdAndNameContaining(id, keyword); + } + @Override + public CareerEtc save(CareerEtc etc) { + return careerEtcJpaRepository.save(etc); + } + @Override + public Optional findById(Long etcId) { + return careerEtcJpaRepository.findById(etcId); + } + @Override + public void delete(CareerEtc etc) { + careerEtcJpaRepository.delete(etc); + } +} diff --git a/src/main/java/umc/kkijuk/server/career/repository/CircleJpaRepository.java b/src/main/java/umc/kkijuk/server/career/repository/CircleJpaRepository.java new file mode 100644 index 00000000..f88847ad --- /dev/null +++ b/src/main/java/umc/kkijuk/server/career/repository/CircleJpaRepository.java @@ -0,0 +1,11 @@ +package umc.kkijuk.server.career.repository; + +import org.springframework.data.jpa.repository.JpaRepository; +import umc.kkijuk.server.career.domain.Circle; + +import java.util.List; + +public interface CircleJpaRepository extends JpaRepository { + List findByMemberId(Long memberId); + List findByMemberIdAndNameContaining(Long memberId, String keyword); +} diff --git a/src/main/java/umc/kkijuk/server/career/repository/CircleRepository.java b/src/main/java/umc/kkijuk/server/career/repository/CircleRepository.java index d4f8acc5..be7b48fb 100644 --- a/src/main/java/umc/kkijuk/server/career/repository/CircleRepository.java +++ b/src/main/java/umc/kkijuk/server/career/repository/CircleRepository.java @@ -1,11 +1,17 @@ package umc.kkijuk.server.career.repository; -import org.springframework.data.jpa.repository.JpaRepository; import umc.kkijuk.server.career.domain.Circle; import java.util.List; +import java.util.Optional; -public interface CircleRepository extends JpaRepository { +public interface CircleRepository { List findByMemberId(Long memberId); List findByMemberIdAndNameContaining(Long memberId, String keyword); + + Circle save(Circle circle); + + Optional findById(Long circleId); + + void delete(Circle circle); } diff --git a/src/main/java/umc/kkijuk/server/career/repository/CircleRepositoryImpl.java b/src/main/java/umc/kkijuk/server/career/repository/CircleRepositoryImpl.java new file mode 100644 index 00000000..26732766 --- /dev/null +++ b/src/main/java/umc/kkijuk/server/career/repository/CircleRepositoryImpl.java @@ -0,0 +1,38 @@ +package umc.kkijuk.server.career.repository; + +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Repository; +import umc.kkijuk.server.career.domain.Circle; + +import java.util.List; +import java.util.Optional; + +@Repository +@RequiredArgsConstructor +public class CircleRepositoryImpl implements CircleRepository{ + private final CircleJpaRepository circleJpaRepository; + @Override + public List findByMemberId(Long memberId) { + return circleJpaRepository.findByMemberId(memberId); + } + + @Override + public List findByMemberIdAndNameContaining(Long memberId, String keyword) { + return circleJpaRepository.findByMemberIdAndNameContaining(memberId,keyword); + } + + @Override + public Circle save(Circle circle) { + return circleJpaRepository.save(circle); + } + + @Override + public Optional findById(Long circleId) { + return circleJpaRepository.findById(circleId); + } + + @Override + public void delete(Circle circle) { + circleJpaRepository.delete(circle); + } +} diff --git a/src/main/java/umc/kkijuk/server/career/repository/CompetitionJpaRepository.java b/src/main/java/umc/kkijuk/server/career/repository/CompetitionJpaRepository.java new file mode 100644 index 00000000..a0b7d08a --- /dev/null +++ b/src/main/java/umc/kkijuk/server/career/repository/CompetitionJpaRepository.java @@ -0,0 +1,11 @@ +package umc.kkijuk.server.career.repository; + +import org.springframework.data.jpa.repository.JpaRepository; +import umc.kkijuk.server.career.domain.Competition; + +import java.util.List; + +public interface CompetitionJpaRepository extends JpaRepository { + List findByMemberId(Long memberId); + List findByMemberIdAndNameContaining(Long memberId, String keyword); +} diff --git a/src/main/java/umc/kkijuk/server/career/repository/CompetitionRepository.java b/src/main/java/umc/kkijuk/server/career/repository/CompetitionRepository.java index 0e01d190..8eabdff0 100644 --- a/src/main/java/umc/kkijuk/server/career/repository/CompetitionRepository.java +++ b/src/main/java/umc/kkijuk/server/career/repository/CompetitionRepository.java @@ -1,11 +1,17 @@ package umc.kkijuk.server.career.repository; -import org.springframework.data.jpa.repository.JpaRepository; import umc.kkijuk.server.career.domain.Competition; import java.util.List; +import java.util.Optional; -public interface CompetitionRepository extends JpaRepository { +public interface CompetitionRepository { List findByMemberId(Long memberId); List findByMemberIdAndNameContaining(Long memberId, String keyword); + + Competition save(Competition competition); + + Optional findById(Long competitionId); + + void delete(Competition comp); } diff --git a/src/main/java/umc/kkijuk/server/career/repository/CompetitionRepositoryImpl.java b/src/main/java/umc/kkijuk/server/career/repository/CompetitionRepositoryImpl.java new file mode 100644 index 00000000..c68237bf --- /dev/null +++ b/src/main/java/umc/kkijuk/server/career/repository/CompetitionRepositoryImpl.java @@ -0,0 +1,37 @@ +package umc.kkijuk.server.career.repository; + +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Repository; +import umc.kkijuk.server.career.domain.Competition; + +import java.util.List; +import java.util.Optional; + +@Repository +@RequiredArgsConstructor +public class CompetitionRepositoryImpl implements CompetitionRepository{ + private final CompetitionJpaRepository competitionJpaRepository; + @Override + public List findByMemberId(Long memberId) { + return competitionJpaRepository.findByMemberId(memberId); + } + @Override + public List findByMemberIdAndNameContaining(Long memberId, String keyword) { + return competitionJpaRepository.findByMemberIdAndNameContaining(memberId,keyword); + } + + @Override + public Competition save(Competition competition) { + return competitionJpaRepository.save(competition); + } + + @Override + public Optional findById(Long competitionId) { + return competitionJpaRepository.findById(competitionId); + } + + @Override + public void delete(Competition comp) { + competitionJpaRepository.delete(comp); + } +} diff --git a/src/main/java/umc/kkijuk/server/career/repository/EduCareerJpaRepository.java b/src/main/java/umc/kkijuk/server/career/repository/EduCareerJpaRepository.java new file mode 100644 index 00000000..2142d029 --- /dev/null +++ b/src/main/java/umc/kkijuk/server/career/repository/EduCareerJpaRepository.java @@ -0,0 +1,11 @@ +package umc.kkijuk.server.career.repository; + +import org.springframework.data.jpa.repository.JpaRepository; +import umc.kkijuk.server.career.domain.EduCareer; + +import java.util.List; + +public interface EduCareerJpaRepository extends JpaRepository { + List findByMemberId(Long memberId); + List findByMemberIdAndNameContaining(Long memberId, String keyword); +} diff --git a/src/main/java/umc/kkijuk/server/career/repository/EduCareerRepository.java b/src/main/java/umc/kkijuk/server/career/repository/EduCareerRepository.java index b9cdca8c..14c00625 100644 --- a/src/main/java/umc/kkijuk/server/career/repository/EduCareerRepository.java +++ b/src/main/java/umc/kkijuk/server/career/repository/EduCareerRepository.java @@ -1,11 +1,17 @@ package umc.kkijuk.server.career.repository; -import org.springframework.data.jpa.repository.JpaRepository; import umc.kkijuk.server.career.domain.EduCareer; import java.util.List; +import java.util.Optional; -public interface EduCareerRepository extends JpaRepository { +public interface EduCareerRepository { List findByMemberId(Long memberId); List findByMemberIdAndNameContaining(Long memberId, String keyword); + + EduCareer save(EduCareer edu); + + Optional findById(Long educareerId); + + void delete(EduCareer eduCareer); } diff --git a/src/main/java/umc/kkijuk/server/career/repository/EduCareerRepositoryImpl.java b/src/main/java/umc/kkijuk/server/career/repository/EduCareerRepositoryImpl.java new file mode 100644 index 00000000..166dbd24 --- /dev/null +++ b/src/main/java/umc/kkijuk/server/career/repository/EduCareerRepositoryImpl.java @@ -0,0 +1,38 @@ +package umc.kkijuk.server.career.repository; + +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Repository; +import umc.kkijuk.server.career.domain.EduCareer; + +import java.util.List; +import java.util.Optional; + +@Repository +@RequiredArgsConstructor +public class EduCareerRepositoryImpl implements EduCareerRepository{ + private final EduCareerJpaRepository eduCareerJpaRepository; + @Override + public List findByMemberId(Long memberId) { + return eduCareerJpaRepository.findByMemberId(memberId); + } + + @Override + public List findByMemberIdAndNameContaining(Long memberId, String keyword) { + return eduCareerJpaRepository.findByMemberIdAndNameContaining(memberId,keyword); + } + + @Override + public EduCareer save(EduCareer edu) { + return eduCareerJpaRepository.save(edu); + } + + @Override + public Optional findById(Long educareerId) { + return eduCareerJpaRepository.findById(educareerId); + } + + @Override + public void delete(EduCareer eduCareer) { + eduCareerJpaRepository.delete(eduCareer); + } +} diff --git a/src/main/java/umc/kkijuk/server/career/repository/EmploymentJpaRepository.java b/src/main/java/umc/kkijuk/server/career/repository/EmploymentJpaRepository.java new file mode 100644 index 00000000..b56ddb70 --- /dev/null +++ b/src/main/java/umc/kkijuk/server/career/repository/EmploymentJpaRepository.java @@ -0,0 +1,11 @@ +package umc.kkijuk.server.career.repository; + +import org.springframework.data.jpa.repository.JpaRepository; +import umc.kkijuk.server.career.domain.Employment; + +import java.util.List; + +public interface EmploymentJpaRepository extends JpaRepository { + List findByMemberId(Long memberId); + List findByMemberIdAndNameContaining(Long memberId, String keyword); +} diff --git a/src/main/java/umc/kkijuk/server/career/repository/EmploymentRepository.java b/src/main/java/umc/kkijuk/server/career/repository/EmploymentRepository.java index 1b72b64f..c585131e 100644 --- a/src/main/java/umc/kkijuk/server/career/repository/EmploymentRepository.java +++ b/src/main/java/umc/kkijuk/server/career/repository/EmploymentRepository.java @@ -1,11 +1,17 @@ package umc.kkijuk.server.career.repository; -import org.springframework.data.jpa.repository.JpaRepository; import umc.kkijuk.server.career.domain.Employment; import java.util.List; +import java.util.Optional; -public interface EmploymentRepository extends JpaRepository { +public interface EmploymentRepository { List findByMemberId(Long memberId); List findByMemberIdAndNameContaining(Long memberId, String keyword); + + Employment save(Employment emp); + + Optional findById(Long employmentId); + + void delete(Employment employment); } diff --git a/src/main/java/umc/kkijuk/server/career/repository/EmploymentRepositoryImpl.java b/src/main/java/umc/kkijuk/server/career/repository/EmploymentRepositoryImpl.java new file mode 100644 index 00000000..0034e3aa --- /dev/null +++ b/src/main/java/umc/kkijuk/server/career/repository/EmploymentRepositoryImpl.java @@ -0,0 +1,38 @@ +package umc.kkijuk.server.career.repository; + +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Repository; +import umc.kkijuk.server.career.domain.Employment; + +import java.util.List; +import java.util.Optional; + +@Repository +@RequiredArgsConstructor +public class EmploymentRepositoryImpl implements EmploymentRepository{ + private final EmploymentJpaRepository employmentJpaRepository; + @Override + public List findByMemberId(Long memberId) { + return employmentJpaRepository.findByMemberId(memberId); + } + + @Override + public List findByMemberIdAndNameContaining(Long memberId, String keyword) { + return employmentJpaRepository.findByMemberIdAndNameContaining(memberId, keyword); + } + + @Override + public Employment save(Employment emp) { + return employmentJpaRepository.save(emp); + } + + @Override + public Optional findById(Long employmentId) { + return employmentJpaRepository.findById(employmentId); + } + + @Override + public void delete(Employment employment) { + employmentJpaRepository.delete(employment); + } +} diff --git a/src/main/java/umc/kkijuk/server/career/repository/ProjectJpaRepository.java b/src/main/java/umc/kkijuk/server/career/repository/ProjectJpaRepository.java new file mode 100644 index 00000000..28d95c4c --- /dev/null +++ b/src/main/java/umc/kkijuk/server/career/repository/ProjectJpaRepository.java @@ -0,0 +1,11 @@ +package umc.kkijuk.server.career.repository; + +import org.springframework.data.jpa.repository.JpaRepository; +import umc.kkijuk.server.career.domain.Project; + +import java.util.List; + +public interface ProjectJpaRepository extends JpaRepository { + List findByMemberId(Long memberId); + List findByMemberIdAndNameContaining(Long memberId, String keyword); +} diff --git a/src/main/java/umc/kkijuk/server/career/repository/ProjectRepository.java b/src/main/java/umc/kkijuk/server/career/repository/ProjectRepository.java index 1c6aeedc..631ebbb1 100644 --- a/src/main/java/umc/kkijuk/server/career/repository/ProjectRepository.java +++ b/src/main/java/umc/kkijuk/server/career/repository/ProjectRepository.java @@ -1,11 +1,17 @@ package umc.kkijuk.server.career.repository; -import org.springframework.data.jpa.repository.JpaRepository; import umc.kkijuk.server.career.domain.Project; import java.util.List; +import java.util.Optional; -public interface ProjectRepository extends JpaRepository { +public interface ProjectRepository { List findByMemberId(Long memberId); List findByMemberIdAndNameContaining(Long memberId, String keyword); + + Project save(Project project); + + Optional findById(Long projectId); + + void delete(Project project); } diff --git a/src/main/java/umc/kkijuk/server/career/repository/ProjectRepositoryImpl.java b/src/main/java/umc/kkijuk/server/career/repository/ProjectRepositoryImpl.java new file mode 100644 index 00000000..12555f28 --- /dev/null +++ b/src/main/java/umc/kkijuk/server/career/repository/ProjectRepositoryImpl.java @@ -0,0 +1,38 @@ +package umc.kkijuk.server.career.repository; + +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Repository; +import umc.kkijuk.server.career.domain.Project; + +import java.util.List; +import java.util.Optional; + +@Repository +@RequiredArgsConstructor +public class ProjectRepositoryImpl implements ProjectRepository{ + private final ProjectJpaRepository projectJpaRepository; + @Override + public List findByMemberId(Long memberId) { + return projectJpaRepository.findByMemberId(memberId); + } + + @Override + public List findByMemberIdAndNameContaining(Long memberId, String keyword) { + return projectJpaRepository.findByMemberIdAndNameContaining(memberId,keyword); + } + + @Override + public Project save(Project project) { + return projectJpaRepository.save(project); + } + + @Override + public Optional findById(Long projectId) { + return projectJpaRepository.findById(projectId); + } + + @Override + public void delete(Project project) { + projectJpaRepository.delete(project); + } +} diff --git a/src/main/java/umc/kkijuk/server/career/service/CareerSearchServiceImpl.java b/src/main/java/umc/kkijuk/server/career/service/CareerSearchServiceImpl.java index 6f4de381..f23a5a15 100644 --- a/src/main/java/umc/kkijuk/server/career/service/CareerSearchServiceImpl.java +++ b/src/main/java/umc/kkijuk/server/career/service/CareerSearchServiceImpl.java @@ -1,5 +1,6 @@ package umc.kkijuk.server.career.service; +import lombok.Builder; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import umc.kkijuk.server.career.controller.response.*; @@ -9,7 +10,7 @@ import umc.kkijuk.server.detail.controller.response.BaseCareerDetailResponse; import umc.kkijuk.server.detail.domain.BaseCareerDetail; import umc.kkijuk.server.detail.domain.CareerType; -import umc.kkijuk.server.detail.repository.BaseCareerDetailRepository; +import umc.kkijuk.server.detail.repository.CareerDetailRepository; import umc.kkijuk.server.member.domain.Member; import umc.kkijuk.server.tag.domain.Tag; import umc.kkijuk.server.tag.repository.TagRepository; @@ -20,16 +21,17 @@ import java.util.stream.Collectors; @Service +@Builder @RequiredArgsConstructor public class CareerSearchServiceImpl implements CareerSearchService{ private final ActivityRepository activityRepository; private final CircleRepository circleRepository; - private final CompetitionRepository competitionRepository; - private final EduCareerRepository eduCareerRepository; - private final ProjectRepository projectRepository; - private final EmploymentRepository employmentRepository; + private final CompetitionRepository competitionJpaRepository; + private final EduCareerRepository eduCareerJpaRepository; + private final ProjectRepository projectJpaRepository; + private final EmploymentRepository employmentJpaRepository; private final CareerEtcRepository etcRepository; - private final BaseCareerDetailRepository detailRepository; + private final CareerDetailRepository detailRepository; private final TagRepository tagRepository; @Override @@ -39,11 +41,11 @@ public List findCareerForTimeline(Member requestMember) { careers.addAll(activityRepository.findByMemberId(memberId)); - careers.addAll(eduCareerRepository.findByMemberId(memberId)); - careers.addAll(employmentRepository.findByMemberId(memberId)); + careers.addAll(eduCareerJpaRepository.findByMemberId(memberId)); + careers.addAll(employmentJpaRepository.findByMemberId(memberId)); careers.addAll(circleRepository.findByMemberId(memberId)); - careers.addAll(projectRepository.findByMemberId(memberId)); - careers.addAll(competitionRepository.findByMemberId(memberId)); + careers.addAll(projectJpaRepository.findByMemberId(memberId)); + careers.addAll(competitionJpaRepository.findByMemberId(memberId)); careers.addAll(etcRepository.findByMemberId(memberId)); @@ -56,17 +58,17 @@ public List findCareerForTimeline(Member requestMember) { @Override public Map> findAllCareerGroupedCategory(Long memberId) { - List eduCareers = eduCareerRepository.findByMemberId(memberId) + List eduCareers = eduCareerJpaRepository.findByMemberId(memberId) .stream().map(EduCareerResponse::new).collect(Collectors.toList()); - List employments = employmentRepository.findByMemberId(memberId) + List employments = employmentJpaRepository.findByMemberId(memberId) .stream().map(EmploymentResponse::new).collect(Collectors.toList()); - List projects = projectRepository.findByMemberId(memberId) + List projects = projectJpaRepository.findByMemberId(memberId) .stream().map(ProjectResponse::new).collect(Collectors.toList()); List activities = activityRepository.findByMemberId(memberId) .stream().map(ActivityResponse::new).collect(Collectors.toList()); List circles = circleRepository.findByMemberId(memberId) .stream().map(CircleResponse::new).collect(Collectors.toList()); - List competitions = competitionRepository.findByMemberId(memberId) + List competitions = competitionJpaRepository.findByMemberId(memberId) .stream().map(CompetitionResponse::new).collect(Collectors.toList()); List etcs = etcRepository.findByMemberId(memberId) .stream().map(EtcResponse::new).collect(Collectors.toList()); @@ -86,18 +88,18 @@ public Map> findAllCareerGroupedCategory(Long memberId) { @Override public Map> findAllCareerGroupedYear(Long memberId) { - List baseCareers = projectRepository.findByMemberId(memberId).stream() + List baseCareers = projectJpaRepository.findByMemberId(memberId).stream() .map(ProjectResponse::new) .collect(Collectors.toList()); - baseCareers.addAll(competitionRepository.findByMemberId(memberId).stream() + baseCareers.addAll(competitionJpaRepository.findByMemberId(memberId).stream() .map(CompetitionResponse::new).collect(Collectors.toList())); baseCareers.addAll(activityRepository.findByMemberId(memberId).stream() .map(ActivityResponse::new).collect(Collectors.toList())); baseCareers.addAll(circleRepository.findByMemberId(memberId).stream() .map(CircleResponse::new).collect(Collectors.toList())); - baseCareers.addAll(eduCareerRepository.findByMemberId(memberId).stream() + baseCareers.addAll(eduCareerJpaRepository.findByMemberId(memberId).stream() .map(EduCareerResponse::new).collect(Collectors.toList())); - baseCareers.addAll(employmentRepository.findByMemberId(memberId).stream() + baseCareers.addAll(employmentJpaRepository.findByMemberId(memberId).stream() .map(EmploymentResponse::new).collect(Collectors.toList())); baseCareers.addAll(etcRepository.findByMemberId(memberId).stream() .map(EtcResponse::new).collect(Collectors.toList())); @@ -126,10 +128,10 @@ public Map> findAllCareerGroupedYear(Long memberId) { @Override public List findAllCareer(Long memberId) { - List baseCareers = projectRepository.findByMemberId(memberId).stream() + List baseCareers = projectJpaRepository.findByMemberId(memberId).stream() .map(project-> new ProjectResponse(project,detailRepository.findByCareerIdAndCareerType(CareerType.PROJECT,project.getId()))) .collect(Collectors.toList()); - baseCareers.addAll(competitionRepository.findByMemberId(memberId).stream() + baseCareers.addAll(competitionJpaRepository.findByMemberId(memberId).stream() .map(comp-> new CompetitionResponse(comp, detailRepository.findByCareerIdAndCareerType(CareerType.COM,comp.getId()))) .collect(Collectors.toList())); baseCareers.addAll(activityRepository.findByMemberId(memberId).stream() @@ -138,10 +140,10 @@ public List findAllCareer(Long memberId) { baseCareers.addAll(circleRepository.findByMemberId(memberId).stream() .map(circle-> new CircleResponse(circle, detailRepository.findByCareerIdAndCareerType(CareerType.CIRCLE,circle.getId()))) .collect(Collectors.toList())); - baseCareers.addAll(eduCareerRepository.findByMemberId(memberId).stream() + baseCareers.addAll(eduCareerJpaRepository.findByMemberId(memberId).stream() .map(eduCareer -> new EduCareerResponse(eduCareer, detailRepository.findByCareerIdAndCareerType(CareerType.EDU,eduCareer.getId()))) .collect(Collectors.toList())); - baseCareers.addAll(employmentRepository.findByMemberId(memberId).stream() + baseCareers.addAll(employmentJpaRepository.findByMemberId(memberId).stream() .map(employment -> new EmploymentResponse(employment, detailRepository.findByCareerIdAndCareerType(CareerType.EMP,employment.getId()))) .collect(Collectors.toList())); @@ -173,28 +175,28 @@ public BaseCareerResponse findCareer(Member requestMember, Long careerId, String return getResponse(circle, CircleResponse::new); } case "project" -> { - Project project = projectRepository.findById(careerId).get(); + Project project = projectJpaRepository.findById(careerId).get(); if(!project.getMemberId().equals(requestMember.getId())){ throw new OwnerMismatchException(); } return getResponse(project, ProjectResponse::new); } case "edu" -> { - EduCareer eduCareer = eduCareerRepository.findById(careerId).get(); + EduCareer eduCareer = eduCareerJpaRepository.findById(careerId).get(); if(!eduCareer.getMemberId().equals(requestMember.getId())){ throw new OwnerMismatchException(); } return getResponse(eduCareer, EduCareerResponse::new); } case "competition" -> { - Competition competition = competitionRepository.findById(careerId).get(); + Competition competition = competitionJpaRepository.findById(careerId).get(); if(!competition.getMemberId().equals(requestMember.getId())){ throw new OwnerMismatchException(); } return getResponse(competition, CompetitionResponse::new); } case "employment" -> { - Employment employment = employmentRepository.findById(careerId).get(); + Employment employment = employmentJpaRepository.findById(careerId).get(); if(!employment.getMemberId().equals(requestMember.getId())){ throw new OwnerMismatchException(); } @@ -236,11 +238,11 @@ public List findAllDetailByTag(Member requestMember, Long ta public List findCareerWithKeyword(Member requestMember, String keyword, String sort) { List careers = new ArrayList<>(); careers.addAll(activityRepository.findByMemberIdAndNameContaining(requestMember.getId(),keyword)); - careers.addAll(eduCareerRepository.findByMemberIdAndNameContaining(requestMember.getId(),keyword)); - careers.addAll(employmentRepository.findByMemberIdAndNameContaining(requestMember.getId(),keyword)); + careers.addAll(eduCareerJpaRepository.findByMemberIdAndNameContaining(requestMember.getId(),keyword)); + careers.addAll(employmentJpaRepository.findByMemberIdAndNameContaining(requestMember.getId(),keyword)); careers.addAll(circleRepository.findByMemberIdAndNameContaining(requestMember.getId(),keyword)); - careers.addAll(projectRepository.findByMemberIdAndNameContaining(requestMember.getId(),keyword)); - careers.addAll(competitionRepository.findByMemberIdAndNameContaining(requestMember.getId(),keyword)); + careers.addAll(projectJpaRepository.findByMemberIdAndNameContaining(requestMember.getId(),keyword)); + careers.addAll(competitionJpaRepository.findByMemberIdAndNameContaining(requestMember.getId(),keyword)); careers.addAll(etcRepository.findByMemberIdAndNameContaining(requestMember.getId(),keyword)); if ("new".equalsIgnoreCase(sort)) { @@ -390,22 +392,22 @@ private CareerSearchServiceImpl.FindDetailInfo extractDetailInfo(List { - Project project = projectRepository.findById(firstDetail.getCareerId()).get(); + Project project = projectJpaRepository.findById(firstDetail.getCareerId()).get(); title = project.getName(); alias = project.getAlias(); } case EMP -> { - Employment emp = employmentRepository.findById(firstDetail.getCareerId()).get(); + Employment emp = employmentJpaRepository.findById(firstDetail.getCareerId()).get(); title = emp.getName(); alias = emp.getAlias(); } case EDU -> { - EduCareer edu = eduCareerRepository.findById(firstDetail.getCareerId()).get(); + EduCareer edu = eduCareerJpaRepository.findById(firstDetail.getCareerId()).get(); title = edu.getName(); alias = edu.getAlias(); } case COM -> { - Competition competition = competitionRepository.findById(firstDetail.getCareerId()).get(); + Competition competition = competitionJpaRepository.findById(firstDetail.getCareerId()).get(); title = competition.getName(); alias = competition.getAlias(); } diff --git a/src/main/java/umc/kkijuk/server/career/service/CareerServiceImpl.java b/src/main/java/umc/kkijuk/server/career/service/CareerServiceImpl.java index 57ab3db7..3e4a93d0 100644 --- a/src/main/java/umc/kkijuk/server/career/service/CareerServiceImpl.java +++ b/src/main/java/umc/kkijuk/server/career/service/CareerServiceImpl.java @@ -1,5 +1,6 @@ package umc.kkijuk.server.career.service; +import lombok.Builder; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -12,7 +13,7 @@ import umc.kkijuk.server.common.domian.exception.ResourceNotFoundException; import umc.kkijuk.server.detail.domain.BaseCareerDetail; import umc.kkijuk.server.detail.domain.CareerType; -import umc.kkijuk.server.detail.repository.BaseCareerDetailRepository; +import umc.kkijuk.server.detail.repository.CareerDetailRepository; import umc.kkijuk.server.member.domain.Member; import java.time.LocalDate; @@ -20,15 +21,16 @@ import java.util.function.BiFunction; @Service +@Builder @RequiredArgsConstructor public class CareerServiceImpl implements CareerService{ private final ActivityRepository activityRepository; private final CircleRepository circleRepository; private final CompetitionRepository competitionRepository; private final EduCareerRepository eduCareerRepository; - private final ProjectRepository projectRepository; + private final ProjectRepository projectJpaRepository; private final EmploymentRepository employmentRepository; - private final BaseCareerDetailRepository detailRepository; + private final CareerDetailRepository detailRepository; private final CareerEtcRepository etcRepository; @Override @@ -77,7 +79,7 @@ public EmploymentResponse createEmployment(Member requestMember, EmploymentReqDt public ProjectResponse createProject(Member requestMember, ProjectReqDto projectReqDto) { Project project = BaseCareerConverter.toProject(requestMember, projectReqDto); setCommonFields(project); - return new ProjectResponse(projectRepository.save(project)); + return new ProjectResponse(projectJpaRepository.save(project)); } @Override @Transactional @@ -165,13 +167,13 @@ public void deleteEmp(Member requestMember, Long employmentId) { @Override @Transactional public void deleteProject(Member requestMember, Long projectId) { - Project project = projectRepository.findById(projectId).orElseThrow( + Project project = projectJpaRepository.findById(projectId).orElseThrow( () -> new ResourceNotFoundException("Project",projectId) ); if(!project.getMemberId().equals(requestMember.getId())){ throw new OwnerMismatchException(); } - projectRepository.delete(project); + projectJpaRepository.delete(project); } @Override @Transactional @@ -319,7 +321,7 @@ public EtcResponse updateEtc(Member requestMember, Long etcId, EtcReqDto request @Override @Transactional public ProjectResponse updateProject(Member requestMember, Long projectId, ProjectReqDto request) { - Project updateProject = projectRepository.findById(projectId).orElseThrow( + Project updateProject = projectJpaRepository.findById(projectId).orElseThrow( () -> new ResourceNotFoundException("Project",projectId) ); if(!updateProject.getMemberId().equals(requestMember.getId())){ @@ -354,7 +356,7 @@ public BaseCareerResponse createSummary(Member requestMember, Long careerId, Car return getResponse(activity, ActivityResponse::new); } case PROJECT -> { - Project project = projectRepository.findById(careerId) + Project project = projectJpaRepository.findById(careerId) .orElseThrow(() -> new ResourceNotFoundException("Project", careerId)); if(!project.getMemberId().equals(requestMember.getId())){ throw new OwnerMismatchException(); diff --git a/src/main/java/umc/kkijuk/server/dashboard/service/DashBoardServiceImpl.java b/src/main/java/umc/kkijuk/server/dashboard/service/DashBoardServiceImpl.java index a90e7ad7..41a28beb 100644 --- a/src/main/java/umc/kkijuk/server/dashboard/service/DashBoardServiceImpl.java +++ b/src/main/java/umc/kkijuk/server/dashboard/service/DashBoardServiceImpl.java @@ -27,12 +27,12 @@ public class DashBoardServiceImpl implements DashBoardService { private final RecruitService recruitService; private final IntroduceRepository introduceRepository; private final ActivityRepository activityRepository; - private final CircleRepository circleRepository; - private final CompetitionRepository competitionRepository; - private final EduCareerRepository eduCareerRepository; - private final EmploymentRepository employmentRepository; - private final ProjectRepository projectRepository; - private final CareerEtcRepository etcRepository; + private final CircleJpaRepository circleRepository; + private final CompetitionJpaRepository competitionJpaRepository; + private final EduCareerJpaRepository eduCareerJpaRepository; + private final EmploymentJpaRepository employmentJpaRepository; + private final ProjectJpaRepository projectJpaRepository; + private final CareerEtcJpaRepository etcRepository; @Override public DashBoardUserInfoResponse getUserInfo(Member requestMember) { @@ -60,10 +60,10 @@ private long getCareerCount(Long memberId) { return Stream.of( activityRepository.findByMemberId(memberId), circleRepository.findByMemberId(memberId), - competitionRepository.findByMemberId(memberId), - eduCareerRepository.findByMemberId(memberId), - employmentRepository.findByMemberId(memberId), - projectRepository.findByMemberId(memberId), + competitionJpaRepository.findByMemberId(memberId), + eduCareerJpaRepository.findByMemberId(memberId), + employmentJpaRepository.findByMemberId(memberId), + projectJpaRepository.findByMemberId(memberId), etcRepository.findByMemberId(memberId) ) diff --git a/src/main/java/umc/kkijuk/server/detail/repository/BaseCareerDetailRepository.java b/src/main/java/umc/kkijuk/server/detail/repository/CareerDetailJpaRepository.java similarity index 96% rename from src/main/java/umc/kkijuk/server/detail/repository/BaseCareerDetailRepository.java rename to src/main/java/umc/kkijuk/server/detail/repository/CareerDetailJpaRepository.java index dbc5215c..d458fca6 100644 --- a/src/main/java/umc/kkijuk/server/detail/repository/BaseCareerDetailRepository.java +++ b/src/main/java/umc/kkijuk/server/detail/repository/CareerDetailJpaRepository.java @@ -3,13 +3,12 @@ import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -import umc.kkijuk.server.career.domain.*; import umc.kkijuk.server.detail.domain.BaseCareerDetail; import umc.kkijuk.server.detail.domain.CareerType; import java.util.List; -public interface BaseCareerDetailRepository extends JpaRepository { +public interface CareerDetailJpaRepository extends JpaRepository { // @Query("SELECT DISTINCT bcd FROM BaseCareerDetail bcd " + // "LEFT JOIN FETCH bcd.careerTagList ct " + // "LEFT JOIN FETCH ct.tag t " + diff --git a/src/main/java/umc/kkijuk/server/detail/repository/CareerDetailRepository.java b/src/main/java/umc/kkijuk/server/detail/repository/CareerDetailRepository.java new file mode 100644 index 00000000..dcce867f --- /dev/null +++ b/src/main/java/umc/kkijuk/server/detail/repository/CareerDetailRepository.java @@ -0,0 +1,21 @@ +package umc.kkijuk.server.detail.repository; + +import umc.kkijuk.server.detail.domain.BaseCareerDetail; +import umc.kkijuk.server.detail.domain.CareerType; + +import java.util.List; +import java.util.Optional; + +public interface CareerDetailRepository { + BaseCareerDetail save(BaseCareerDetail newBaseCareerDetail); + + Optional findById(Long detailId); + + void delete(BaseCareerDetail baseCareerDetail); + + List findByCareerIdAndCareerType(CareerType careerType, Long id); + + List findByMemberIdAndKeyword(Long id, String keyword); + + List findByTag(Long id); +} diff --git a/src/main/java/umc/kkijuk/server/detail/repository/CareerDetailRepositoryImpl.java b/src/main/java/umc/kkijuk/server/detail/repository/CareerDetailRepositoryImpl.java new file mode 100644 index 00000000..37041fe4 --- /dev/null +++ b/src/main/java/umc/kkijuk/server/detail/repository/CareerDetailRepositoryImpl.java @@ -0,0 +1,44 @@ +package umc.kkijuk.server.detail.repository; + +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Repository; +import umc.kkijuk.server.detail.domain.BaseCareerDetail; +import umc.kkijuk.server.detail.domain.CareerType; + +import java.util.List; +import java.util.Optional; + +@Repository +@RequiredArgsConstructor +public class CareerDetailRepositoryImpl implements CareerDetailRepository{ + private final CareerDetailJpaRepository careerDetailJpaRepository; + @Override + public BaseCareerDetail save(BaseCareerDetail baseCareerDetail) { + return careerDetailJpaRepository.save(baseCareerDetail); + } + + @Override + public Optional findById(Long detailId) { + return careerDetailJpaRepository.findById(detailId); + } + + @Override + public void delete(BaseCareerDetail baseCareerDetail) { + careerDetailJpaRepository.delete(baseCareerDetail); + } + + @Override + public List findByCareerIdAndCareerType(CareerType careerType, Long id) { + return careerDetailJpaRepository.findByCareerIdAndCareerType(careerType,id); + } + + @Override + public List findByMemberIdAndKeyword(Long id, String keyword) { + return careerDetailJpaRepository.findByMemberIdAndKeyword(id, keyword); + } + + @Override + public List findByTag(Long id) { + return careerDetailJpaRepository.findByTag(id); + } +} diff --git a/src/main/java/umc/kkijuk/server/detail/repository/CareerDetailTagJpaRepository.java b/src/main/java/umc/kkijuk/server/detail/repository/CareerDetailTagJpaRepository.java new file mode 100644 index 00000000..8fb5510c --- /dev/null +++ b/src/main/java/umc/kkijuk/server/detail/repository/CareerDetailTagJpaRepository.java @@ -0,0 +1,7 @@ +package umc.kkijuk.server.detail.repository; + +import org.springframework.data.jpa.repository.JpaRepository; +import umc.kkijuk.server.detail.domain.mapping.CareerDetailTag; + +public interface CareerDetailTagJpaRepository extends JpaRepository { +} diff --git a/src/main/java/umc/kkijuk/server/detail/repository/CareerDetailTagRepository.java b/src/main/java/umc/kkijuk/server/detail/repository/CareerDetailTagRepository.java index d9829b4b..3a0a0dea 100644 --- a/src/main/java/umc/kkijuk/server/detail/repository/CareerDetailTagRepository.java +++ b/src/main/java/umc/kkijuk/server/detail/repository/CareerDetailTagRepository.java @@ -1,7 +1,7 @@ package umc.kkijuk.server.detail.repository; -import org.springframework.data.jpa.repository.JpaRepository; import umc.kkijuk.server.detail.domain.mapping.CareerDetailTag; -public interface CareerDetailTagRepository extends JpaRepository { +public interface CareerDetailTagRepository { + void delete(CareerDetailTag careerDetailTag); } diff --git a/src/main/java/umc/kkijuk/server/detail/repository/CareerDetailTagRepositoryImpl.java b/src/main/java/umc/kkijuk/server/detail/repository/CareerDetailTagRepositoryImpl.java new file mode 100644 index 00000000..967d5a96 --- /dev/null +++ b/src/main/java/umc/kkijuk/server/detail/repository/CareerDetailTagRepositoryImpl.java @@ -0,0 +1,15 @@ +package umc.kkijuk.server.detail.repository; + +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Repository; +import umc.kkijuk.server.detail.domain.mapping.CareerDetailTag; + +@Repository +@RequiredArgsConstructor +public class CareerDetailTagRepositoryImpl implements CareerDetailTagRepository{ + private final CareerDetailTagJpaRepository careerDetailTagJpaRepository; + @Override + public void delete(CareerDetailTag careerDetailTag) { + careerDetailTagJpaRepository.delete(careerDetailTag); + } +} diff --git a/src/main/java/umc/kkijuk/server/detail/service/BaseCareerDetailServiceImpl.java b/src/main/java/umc/kkijuk/server/detail/service/BaseCareerDetailServiceImpl.java index c8df5331..c104bbf4 100644 --- a/src/main/java/umc/kkijuk/server/detail/service/BaseCareerDetailServiceImpl.java +++ b/src/main/java/umc/kkijuk/server/detail/service/BaseCareerDetailServiceImpl.java @@ -1,6 +1,7 @@ package umc.kkijuk.server.detail.service; +import lombok.Builder; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -23,17 +24,18 @@ import java.util.stream.Collectors; @Service +@Builder @RequiredArgsConstructor @Transactional(readOnly = true) public class BaseCareerDetailServiceImpl implements BaseCareerDetailService{ - private final BaseCareerDetailRepository baseCareerDetailRepository; + private final CareerDetailRepository careerDetailRepository; private final CareerDetailTagRepository careerDetailTagRepository; private final ActivityRepository activityRepository; - private final EduCareerRepository eduCareerRepository; - private final ProjectRepository projectRepository; + private final EduCareerRepository eduCareerJpaRepository; + private final ProjectRepository projectJpaRepository; private final CircleRepository circleRepository; - private final EmploymentRepository employmentRepository; - private final CompetitionRepository competitionRepository; + private final EmploymentRepository employmentJpaRepository; + private final CompetitionRepository competitionJpaRepository; private final TagRepository tagRepository; @Override @@ -47,25 +49,25 @@ public BaseCareerDetailResponse createDetail(Member requestMember, CareerDetailR // addDetailToCareer(career, newBaseCareerDetail); detailTagList.forEach(tag -> tag.setBaseCareerDetail(newBaseCareerDetail)); - return new BaseCareerDetailResponse(baseCareerDetailRepository.save(newBaseCareerDetail)); + return new BaseCareerDetailResponse(careerDetailRepository.save(newBaseCareerDetail)); } @Override @Transactional public void deleteDetail(Member requestMember, Long careerId, Long detailId) { - BaseCareerDetail baseCareerDetail = baseCareerDetailRepository.findById(detailId).orElseThrow( + BaseCareerDetail baseCareerDetail = careerDetailRepository.findById(detailId).orElseThrow( () -> new ResourceNotFoundException("BaseCareerDetail", detailId)); BaseCareer baseCareer = findBaseCareerByType(baseCareerDetail.getCareerType(), careerId); validateOwner(baseCareer,requestMember); - baseCareerDetailRepository.delete(baseCareerDetail); + careerDetailRepository.delete(baseCareerDetail); } @Override @Transactional public BaseCareerDetailResponse updateDetail(Member requestMember, CareerDetailUpdateReqDto request, Long careerId, Long detailId) { - BaseCareerDetail baseCareerDetail = baseCareerDetailRepository.findById(detailId).orElseThrow( + BaseCareerDetail baseCareerDetail = careerDetailRepository.findById(detailId).orElseThrow( () -> new ResourceNotFoundException("BaseCareerDetail", detailId)); if(!baseCareerDetail.getMemberId().equals(requestMember.getId())){ @@ -85,7 +87,7 @@ public BaseCareerDetailResponse updateDetail(Member requestMember, CareerDetailU List careerDetailTags = returnCareerTagList(request.getTagList()); careerDetailTags.forEach(careerDetailTag -> careerDetailTag.setBaseCareerDetail(baseCareerDetail)); - return new BaseCareerDetailResponse(baseCareerDetailRepository.save(baseCareerDetail)); + return new BaseCareerDetailResponse(careerDetailRepository.save(baseCareerDetail)); } private void validateOwner(BaseCareer career, Member requestMember) { @@ -117,13 +119,13 @@ private BaseCareer findBaseCareerByType(CareerType careerType, Long careerId) { .orElseThrow(() -> new ResourceNotFoundException("대외활동 : ", careerId)); case CIRCLE -> circleRepository.findById(careerId) .orElseThrow(() -> new ResourceNotFoundException("동아리 : ", careerId)); - case PROJECT -> projectRepository.findById(careerId) + case PROJECT -> projectJpaRepository.findById(careerId) .orElseThrow(() -> new ResourceNotFoundException("프로젝트 : ", careerId)); - case EDU -> eduCareerRepository.findById(careerId) + case EDU -> eduCareerJpaRepository.findById(careerId) .orElseThrow(() -> new ResourceNotFoundException("교육 : ", careerId)); - case COM -> competitionRepository.findById(careerId) + case COM -> competitionJpaRepository.findById(careerId) .orElseThrow(() -> new ResourceNotFoundException("대회 : ", careerId)); - case EMP -> employmentRepository.findById(careerId) + case EMP -> employmentJpaRepository.findById(careerId) .orElseThrow(() -> new ResourceNotFoundException("경력 : ", careerId)); default -> throw new IllegalArgumentException("지원하지 않는 활동 유형입니다"); }; diff --git a/src/main/java/umc/kkijuk/server/record/service/RecordServiceImpl.java b/src/main/java/umc/kkijuk/server/record/service/RecordServiceImpl.java index 630a6564..f9cb8e8d 100644 --- a/src/main/java/umc/kkijuk/server/record/service/RecordServiceImpl.java +++ b/src/main/java/umc/kkijuk/server/record/service/RecordServiceImpl.java @@ -4,7 +4,6 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import umc.kkijuk.server.career.controller.response.*; -import umc.kkijuk.server.career.domain.*; import umc.kkijuk.server.career.repository.*; import umc.kkijuk.server.common.domian.exception.IntroFoundException; import umc.kkijuk.server.common.domian.exception.IntroOwnerMismatchException; @@ -37,10 +36,10 @@ public class RecordServiceImpl implements RecordService { private final ActivityRepository activityRepository; private final CircleRepository circleRepository; - private final CompetitionRepository competitionRepository; - private final EduCareerRepository eduCareerRepository; - private final EmploymentRepository employmentRepository; - private final ProjectRepository projectRepository; + private final CompetitionRepository competitionJpaRepository; + private final EduCareerRepository eduCareerJpaRepository; + private final EmploymentRepository employmentJpaRepository; + private final ProjectRepository projectJpaRepository; private final CareerEtcRepository etcRepository; private final FileRepository fileRepository; @@ -83,7 +82,7 @@ public RecordResponse getRecord(Long memberId) { } // 경력 - List employments = employmentRepository.findByMemberId(memberId).stream() + List employments = employmentJpaRepository.findByMemberId(memberId).stream() .map(EmploymentResponse::new) .sorted(Comparator.comparing(EmploymentResponse::getEndDate).reversed()) .toList(); @@ -101,15 +100,15 @@ public RecordResponse getRecord(Long memberId) { activitiesAndExperiences.stream().sorted(Comparator.comparing(BaseCareerResponse::getEndDate).reversed()); // 프로젝트 ( 프로젝트, 공모전/대회) - List projectsAndComp = projectRepository.findByMemberId(memberId).stream() + List projectsAndComp = projectJpaRepository.findByMemberId(memberId).stream() .map(ProjectResponse::new) .collect(Collectors.toList()); - projectsAndComp.addAll(competitionRepository.findByMemberId(memberId).stream() + projectsAndComp.addAll(competitionJpaRepository.findByMemberId(memberId).stream() .map(CompetitionResponse::new).collect(Collectors.toList())); projectsAndComp.stream().sorted(Comparator.comparing(BaseCareerResponse::getEndDate).reversed()); // 교육 ( 교육) - List eduCareers = eduCareerRepository.findByMemberId(memberId).stream() + List eduCareers = eduCareerJpaRepository.findByMemberId(memberId).stream() .map(EduCareerResponse::new) .sorted(Comparator.comparing(EduCareerResponse::getEndDate).reversed()) .toList(); @@ -160,7 +159,7 @@ public RecordResponse updateRecord(Long memberId, Long recordId, RecordReqDto re .orElseThrow(() -> new ResourceNotFoundException("member ", memberId)); //경력 - List employments = employmentRepository.findByMemberId(memberId).stream() + List employments = employmentJpaRepository.findByMemberId(memberId).stream() .map(EmploymentResponse::new) .sorted(Comparator.comparing(EmploymentResponse::getEndDate).reversed()) .toList(); @@ -177,15 +176,15 @@ public RecordResponse updateRecord(Long memberId, Long recordId, RecordReqDto re activitiesAndExperiences.stream().sorted(Comparator.comparing(BaseCareerResponse::getEndDate).reversed()); //프로젝트 ( 프로젝트, 공모전/대회) - List projectsAndComp = projectRepository.findByMemberId(memberId).stream() + List projectsAndComp = projectJpaRepository.findByMemberId(memberId).stream() .map(ProjectResponse::new) .collect(Collectors.toList()); - projectsAndComp.addAll(competitionRepository.findByMemberId(memberId).stream() + projectsAndComp.addAll(competitionJpaRepository.findByMemberId(memberId).stream() .map(CompetitionResponse::new).collect(Collectors.toList())); projectsAndComp.stream().sorted(Comparator.comparing(BaseCareerResponse::getEndDate).reversed()); //교육 ( 교육) - List eduCareers = eduCareerRepository.findByMemberId(memberId).stream() + List eduCareers = eduCareerJpaRepository.findByMemberId(memberId).stream() .map(EduCareerResponse::new) .sorted(Comparator.comparing(EduCareerResponse::getEndDate).reversed()) .toList(); @@ -233,7 +232,7 @@ public RecordDownResponse downloadResume(Long recordId, Long memberId) { .orElseThrow(() -> new ResourceNotFoundException("member ", memberId)); Record record = recordRepository.findByMemberId(memberId); - List employments = employmentRepository.findByMemberId(memberId).stream() + List employments = employmentJpaRepository.findByMemberId(memberId).stream() .map(employment -> new ResumeResponse(employment.getId(),CareerType.EMP.getDescription(),employment.getName(), employment.getAlias(),employment.getSummary(),employment.getStartdate(), employment.getEnddate())).collect(Collectors.toList()); @@ -255,17 +254,17 @@ public RecordDownResponse downloadResume(Long recordId, Long memberId) { etc.getEnddate())).collect(Collectors.toList())); //프로젝트 ( 프로젝트, 공모전/대회) - List projectsAndComp = projectRepository.findByMemberId(memberId).stream() + List projectsAndComp = projectJpaRepository.findByMemberId(memberId).stream() .map(project->new ResumeResponse(project.getId(),CareerType.PROJECT.getDescription(), project.getName(), project.getAlias(),project.getSummary(),project.getStartdate(), project.getEnddate())).collect(Collectors.toList()); - projectsAndComp.addAll(competitionRepository.findByMemberId(memberId).stream() + projectsAndComp.addAll(competitionJpaRepository.findByMemberId(memberId).stream() .map(comp -> new ResumeResponse(comp.getId(),CareerType.COM.getDescription(), comp.getName(), comp.getAlias(),comp.getSummary(),comp.getStartdate(), comp.getEnddate())).collect(Collectors.toList())); - List eduCareers = eduCareerRepository.findByMemberId(memberId).stream() + List eduCareers = eduCareerJpaRepository.findByMemberId(memberId).stream() .map(edu-> new ResumeResponse(edu.getId(),CareerType.EDU.getDescription(),edu.getName(), edu.getAlias(),edu.getSummary(),edu.getStartdate(), edu.getEnddate())).collect(Collectors.toList()); diff --git a/src/main/java/umc/kkijuk/server/tag/repository/TagJpaRepository.java b/src/main/java/umc/kkijuk/server/tag/repository/TagJpaRepository.java new file mode 100644 index 00000000..1f893206 --- /dev/null +++ b/src/main/java/umc/kkijuk/server/tag/repository/TagJpaRepository.java @@ -0,0 +1,21 @@ +package umc.kkijuk.server.tag.repository; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import umc.kkijuk.server.tag.domain.Tag; +import umc.kkijuk.server.tag.dto.TagResponseDto; + +import java.util.List; +import java.util.Optional; + +public interface TagJpaRepository extends JpaRepository { + boolean existsByNameAndMemberId(String name, Long memberId); + List findAllTagByMemberId(Long MemberId); + @Query("SELECT tag FROM Tag tag " + + "WHERE tag.memberId = :memberId " + + "AND tag.name LIKE %:keyword% " + + "ORDER BY CASE WHEN tag.name = :keyword THEN 0 ELSE 1 END, tag.name ASC") + List findByKeywordAndMemberId(@Param("keyword") String keyword, @Param("memberId") Long memberId); + Optional findById(Long Id); +} diff --git a/src/main/java/umc/kkijuk/server/tag/repository/TagRepository.java b/src/main/java/umc/kkijuk/server/tag/repository/TagRepository.java index d6d6d334..f689ebba 100644 --- a/src/main/java/umc/kkijuk/server/tag/repository/TagRepository.java +++ b/src/main/java/umc/kkijuk/server/tag/repository/TagRepository.java @@ -1,21 +1,20 @@ package umc.kkijuk.server.tag.repository; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.query.Param; import umc.kkijuk.server.tag.domain.Tag; -import umc.kkijuk.server.tag.dto.TagResponseDto; import java.util.List; import java.util.Optional; -public interface TagRepository extends JpaRepository { - boolean existsByNameAndMemberId(String name, Long memberId); - List findAllTagByMemberId(Long MemberId); - @Query("SELECT tag FROM Tag tag " + - "WHERE tag.memberId = :memberId " + - "AND tag.name LIKE %:keyword% " + - "ORDER BY CASE WHEN tag.name = :keyword THEN 0 ELSE 1 END, tag.name ASC") - List findByKeywordAndMemberId(@Param("keyword") String keyword, @Param("memberId") Long memberId); - Optional findById(Long Id); +public interface TagRepository { + boolean existsByNameAndMemberId(String tagName, Long memberId); + + Tag save(Tag newTag); + + List findAllTagByMemberId(Long id); + + Optional findById(Long tagId); + + void delete(Tag deleteTag); + + List findByKeywordAndMemberId(String keyword, Long id); } diff --git a/src/main/java/umc/kkijuk/server/tag/repository/TagRepositoryImpl.java b/src/main/java/umc/kkijuk/server/tag/repository/TagRepositoryImpl.java new file mode 100644 index 00000000..e6285d5b --- /dev/null +++ b/src/main/java/umc/kkijuk/server/tag/repository/TagRepositoryImpl.java @@ -0,0 +1,44 @@ +package umc.kkijuk.server.tag.repository; + +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Repository; +import umc.kkijuk.server.tag.domain.Tag; + +import java.util.List; +import java.util.Optional; + +@Repository +@RequiredArgsConstructor +public class TagRepositoryImpl implements TagRepository{ + private final TagJpaRepository tagJpaRepository; + + @Override + public boolean existsByNameAndMemberId(String tagName, Long memberId) { + return tagJpaRepository.existsByNameAndMemberId(tagName,memberId); + } + + @Override + public Tag save(Tag newTag) { + return tagJpaRepository.save(newTag); + } + + @Override + public List findAllTagByMemberId(Long id) { + return tagJpaRepository.findAllTagByMemberId(id); + } + + @Override + public Optional findById(Long tagId) { + return tagJpaRepository.findById(tagId); + } + + @Override + public void delete(Tag deleteTag) { + tagJpaRepository.delete(deleteTag); + } + + @Override + public List findByKeywordAndMemberId(String keyword, Long id) { + return tagJpaRepository.findByKeywordAndMemberId(keyword,id); + } +} diff --git a/src/test/java/umc/kkijuk/server/unitTest/career/controller/CareerControllerTest.java b/src/test/java/umc/kkijuk/server/unitTest/career/controller/CareerControllerTest.java index 04c92bb2..5bed4da6 100644 --- a/src/test/java/umc/kkijuk/server/unitTest/career/controller/CareerControllerTest.java +++ b/src/test/java/umc/kkijuk/server/unitTest/career/controller/CareerControllerTest.java @@ -50,8 +50,8 @@ void init() { .alias("testalias") .unknown(true) .isTeam(true) - .startdate(LocalDate.of(2023,1,1)) - .enddate(LocalDate.of(2024,1,1)) + .startDate(LocalDate.of(2023,1,1)) + .endDate(LocalDate.of(2024,1,1)) .contribution(30) .role("testrole") .teamSize(8) diff --git a/src/test/java/umc/kkijuk/server/unitTest/career/service/CareerServiceTest.java b/src/test/java/umc/kkijuk/server/unitTest/career/service/CareerServiceTest.java index 0c2dccff..db6a57d6 100644 --- a/src/test/java/umc/kkijuk/server/unitTest/career/service/CareerServiceTest.java +++ b/src/test/java/umc/kkijuk/server/unitTest/career/service/CareerServiceTest.java @@ -1,4 +1,137 @@ package umc.kkijuk.server.unitTest.career.service; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import umc.kkijuk.server.career.controller.response.ActivityResponse; +import umc.kkijuk.server.career.domain.Activity; +import umc.kkijuk.server.career.dto.ActivityReqDto; +import umc.kkijuk.server.career.repository.ActivityRepository; +import umc.kkijuk.server.career.service.CareerService; +import umc.kkijuk.server.career.service.CareerServiceImpl; +import umc.kkijuk.server.member.domain.Member; +import umc.kkijuk.server.member.domain.State; +import umc.kkijuk.server.unitTest.mock.FakeActivityRepository; + +import java.time.LocalDate; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertAll; + public class CareerServiceTest { + private CareerService careerService; + private final Long testMemberId = 3333L; + private Member requestMember; + + //test Data + private final LocalDate testStartDate = LocalDate.of(2023, 7, 19); + private final LocalDate testEndDate = LocalDate.of(2023, 12, 19); + + @BeforeEach + void init() { + this.requestMember = Member.builder() + .id(testMemberId) + .email("test-email@test.com") + .name("test-name") + .phoneNumber("test-test-test") + .birthDate(LocalDate.of(2024, 7, 25)) + .password("test-password") + .userState(State.ACTIVATE) + .build(); + + ActivityRepository activityRepository = new FakeActivityRepository(); + + this.careerService = CareerServiceImpl.builder() + .activityRepository(activityRepository) + .build(); + + Activity activity1 = Activity.builder() + .memberId(testMemberId) + .name("test activity") + .alias("test alias") + .unknown(false) + .startDate(testStartDate) + .endDate(testEndDate) + .organizer("test organizer") + .role("test role") + .teamSize(10) + .contribution(30) + .isTeam(true) + .build(); + + Activity activity2 = Activity.builder() + .memberId(testMemberId) + .name("test activity") + .alias("test alias") + .unknown(false) + .startDate(testStartDate) + .endDate(testEndDate) + .organizer("test organizer") + .role("test role") + .teamSize(10) + .contribution(30) + .isTeam(true) + .build(); + + activityRepository.save(activity1); + activityRepository.save(activity2); + } + @Test + @DisplayName("[create] 새로운 Activity 만들기 - 정상 요청") + void testCreateActivity() { + //given + ActivityReqDto activityReqDto = ActivityReqDto.builder() + .name("대외활동") + .alias("연합동아리") + .startdate(LocalDate.of(2023,5,1)) + .enddate(LocalDate.of(2023,12,12)) + .isTeam(true) + .unknown(false) + .role("백엔드") + .contribution(30) + .organizer("컴공선배") + .teamSize(10) + .build(); + //when + ActivityResponse response = careerService.createActivity(requestMember,activityReqDto); + //then + assertAll( + () -> assertThat(response.getId()).isEqualTo(3L), + () -> assertThat(response.getName()).isEqualTo("대외활동"), + () -> assertThat(response.getAlias()).isEqualTo("연합동아리"), + () -> assertThat(response.getStartdate()).isEqualTo(LocalDate.of(2023,5,1)), + () -> assertThat(response.getEndDate()).isEqualTo(LocalDate.of(2023,12,12)), + () -> assertThat(response.getIsTeam()).isEqualTo(true), + () -> assertThat(response.getUnknown()).isEqualTo(false), + () -> assertThat(response.getRole()).isEqualTo("백엔드"), + () -> assertThat(response.getContribution()).isEqualTo(30), + () -> assertThat(response.getOrganizer()).isEqualTo("컴공선배"), + () -> assertThat(response.getTeamSize()).isEqualTo(10) + + ); + } + @Test + @DisplayName("[create] 새로운 Activity 만들기 - null 허용 필드에 null 값 요청, endDate 값 null일 경우 현재 날짜로 설정") + void testCreateActivity_InvalidFields(){ + //given + ActivityReqDto activityReqDto = ActivityReqDto.builder() + .name("대외활동") + .alias("연합동아리") + .startdate(LocalDate.of(2023, 5, 1)) + .isTeam(true) + .unknown(true) + .contribution(30) + .organizer("컴공선배") + .teamSize(10) + .build(); + //when + ActivityResponse response = careerService.createActivity(requestMember,activityReqDto); + + //then + assertAll( + () -> assertThat(response).isNotNull(), + () -> assertThat(response.getRole()).isNull(), + () -> assertThat(response.getEndDate()).isEqualTo(LocalDate.now()) + ); + } } diff --git a/src/test/java/umc/kkijuk/server/unitTest/mock/FakeActivityRepository.java b/src/test/java/umc/kkijuk/server/unitTest/mock/FakeActivityRepository.java new file mode 100644 index 00000000..7a78ed50 --- /dev/null +++ b/src/test/java/umc/kkijuk/server/unitTest/mock/FakeActivityRepository.java @@ -0,0 +1,96 @@ +package umc.kkijuk.server.unitTest.mock; + +import umc.kkijuk.server.career.domain.Activity; +import umc.kkijuk.server.career.repository.ActivityRepository; + +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.concurrent.atomic.AtomicLong; + +public class FakeActivityRepository implements ActivityRepository { + private final AtomicLong autoGeneratedId = new AtomicLong(1); + private final List data = new ArrayList<>(); + + @Override + public Optional findById(Long activityId) { + return data.stream() + .filter(item -> Objects.equals(item.getId(), activityId)) + .findAny(); + } + + @Override + public List findByMemberId(Long memberId) { + return data.stream() + .filter(item -> Objects.equals(item.getMemberId(), memberId)) + .toList(); + } + + @Override + public List findByMemberIdAndNameContaining(Long memberId, String keyword) { + return data.stream() + .filter(item -> Objects.equals(item.getMemberId(), memberId) && + item.getName() != null && + item.getName().contains(keyword)) + .toList(); + } + + public Activity save(Activity activity) { + if (activity.getId() == null || activity.getId() == 0) { + Activity newActivity = Activity.builder() + .memberId(activity.getMemberId()) + .name(activity.getName()) + .alias(activity.getAlias()) + .unknown(activity.getUnknown()) + .startDate(activity.getStartdate()) + .endDate(activity.getEnddate()) + .organizer(activity.getOrganizer()) + .role(activity.getRole()) + .teamSize(activity.getTeamSize()) + .contribution(activity.getContribution()) + .isTeam(activity.getIsTeam()) + .build(); + + setEndDate(newActivity); + assignId(newActivity, autoGeneratedId.getAndIncrement()); + data.add(newActivity); + return newActivity; + } else { + data.removeIf(a -> a.getId().equals(activity.getId())); + data.add(activity); + return activity; + } + } + + @Override + public void delete(Activity activity) { + data.removeIf(item -> Objects.equals(item.getId(), activity.getId())); + } + private void assignId(Activity activity, Long id) { + try { + var field = Activity.class.getDeclaredField("id"); + field.setAccessible(true); + field.set(activity, id); + } catch (NoSuchFieldException | IllegalAccessException e) { + throw new RuntimeException("id 할당 실패 : ", e); + } + } + public List findAll() { + return new ArrayList<>(data); + } + public void clear() { + data.clear(); + autoGeneratedId.set(0); + } + private void setEndDate(Activity activity){ + if (activity.getUnknown()) { + activity.setEnddate(LocalDate.now()); + activity.setYear(LocalDate.now().getYear()); + } else { + activity.setYear(activity.getEnddate().getYear()); + } + + } +}