From 0629e6434e967258e2b62d981f24ce0424d8fdc1 Mon Sep 17 00:00:00 2001 From: Sukju Hong Date: Tue, 7 May 2024 02:17:00 +0900 Subject: [PATCH 01/22] =?UTF-8?q?refactor:=20announcement=20=EA=B5=AC?= =?UTF-8?q?=EB=B6=84=EC=9D=84=20=EC=9C=84=ED=95=9C=20team=20annoucement=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=20(#56)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../example/eumserver/domain/team/Team.java | 6 +- ...r.java => TeamAnnouncementController.java} | 38 ++++++------ ...nnouncement.java => TeamAnnouncement.java} | 6 +- ...ilter.java => TeamAnnouncementFilter.java} | 2 +- ...uest.java => TeamAnnouncementRequest.java} | 2 +- ...nse.java => TeamAnnouncementResponse.java} | 2 +- ...ava => TeamAnnouncementUpdateRequest.java} | 2 +- .../mapper/AnnouncementMapper.java | 22 ------- .../mapper/TeamAnnouncementMapper.java | 22 +++++++ .../AnnouncementCustomRepository.java | 20 ------- .../AnnouncementCustomRepositoryImpl.java | 59 ------------------- .../repository/AnnouncementRepository.java | 8 --- .../TeamAnnouncementCustomRepository.java | 20 +++++++ .../TeamAnnouncementCustomRepositoryImpl.java | 59 +++++++++++++++++++ .../TeamAnnouncementRepository.java | 8 +++ ...vice.java => TeamAnnouncementService.java} | 36 +++++------ .../AnnouncementControllerTest.java | 30 +++++----- 17 files changed, 171 insertions(+), 171 deletions(-) rename src/main/java/com/example/eumserver/domain/team/announcement/controller/{AnnouncementController.java => TeamAnnouncementController.java} (55%) rename src/main/java/com/example/eumserver/domain/team/announcement/domain/{Announcement.java => TeamAnnouncement.java} (90%) rename src/main/java/com/example/eumserver/domain/team/announcement/dto/{AnnouncementFilter.java => TeamAnnouncementFilter.java} (87%) rename src/main/java/com/example/eumserver/domain/team/announcement/dto/{AnnouncementRequest.java => TeamAnnouncementRequest.java} (93%) rename src/main/java/com/example/eumserver/domain/team/announcement/dto/{AnnouncementResponse.java => TeamAnnouncementResponse.java} (74%) rename src/main/java/com/example/eumserver/domain/team/announcement/dto/{AnnouncementUpdateRequest.java => TeamAnnouncementUpdateRequest.java} (92%) delete mode 100644 src/main/java/com/example/eumserver/domain/team/announcement/mapper/AnnouncementMapper.java create mode 100644 src/main/java/com/example/eumserver/domain/team/announcement/mapper/TeamAnnouncementMapper.java delete mode 100644 src/main/java/com/example/eumserver/domain/team/announcement/repository/AnnouncementCustomRepository.java delete mode 100644 src/main/java/com/example/eumserver/domain/team/announcement/repository/AnnouncementCustomRepositoryImpl.java delete mode 100644 src/main/java/com/example/eumserver/domain/team/announcement/repository/AnnouncementRepository.java create mode 100644 src/main/java/com/example/eumserver/domain/team/announcement/repository/TeamAnnouncementCustomRepository.java create mode 100644 src/main/java/com/example/eumserver/domain/team/announcement/repository/TeamAnnouncementCustomRepositoryImpl.java create mode 100644 src/main/java/com/example/eumserver/domain/team/announcement/repository/TeamAnnouncementRepository.java rename src/main/java/com/example/eumserver/domain/team/announcement/service/{AnnouncementService.java => TeamAnnouncementService.java} (58%) diff --git a/src/main/java/com/example/eumserver/domain/team/Team.java b/src/main/java/com/example/eumserver/domain/team/Team.java index 4bb1d00..2333eba 100644 --- a/src/main/java/com/example/eumserver/domain/team/Team.java +++ b/src/main/java/com/example/eumserver/domain/team/Team.java @@ -1,6 +1,6 @@ package com.example.eumserver.domain.team; -import com.example.eumserver.domain.team.announcement.domain.Announcement; +import com.example.eumserver.domain.team.announcement.domain.TeamAnnouncement; import com.example.eumserver.domain.team.participant.Participant; import com.fasterxml.jackson.annotation.JsonIgnore; import jakarta.persistence.*; @@ -50,13 +50,13 @@ public class Team { @JsonIgnore @Builder.Default @OneToMany(mappedBy = "team", orphanRemoval = true) - private List announcements = new ArrayList<>(); + private List announcements = new ArrayList<>(); public void addTeam(Participant participant) { this.participants.add(participant); } - public void addAnnouncement(Announcement announcement) { + public void addAnnouncement(TeamAnnouncement announcement) { this.announcements.add(announcement); } } diff --git a/src/main/java/com/example/eumserver/domain/team/announcement/controller/AnnouncementController.java b/src/main/java/com/example/eumserver/domain/team/announcement/controller/TeamAnnouncementController.java similarity index 55% rename from src/main/java/com/example/eumserver/domain/team/announcement/controller/AnnouncementController.java rename to src/main/java/com/example/eumserver/domain/team/announcement/controller/TeamAnnouncementController.java index 65ce0a8..4039331 100644 --- a/src/main/java/com/example/eumserver/domain/team/announcement/controller/AnnouncementController.java +++ b/src/main/java/com/example/eumserver/domain/team/announcement/controller/TeamAnnouncementController.java @@ -1,12 +1,12 @@ package com.example.eumserver.domain.team.announcement.controller; -import com.example.eumserver.domain.team.announcement.domain.Announcement; -import com.example.eumserver.domain.team.announcement.dto.AnnouncementFilter; -import com.example.eumserver.domain.team.announcement.dto.AnnouncementRequest; -import com.example.eumserver.domain.team.announcement.dto.AnnouncementResponse; -import com.example.eumserver.domain.team.announcement.dto.AnnouncementUpdateRequest; -import com.example.eumserver.domain.team.announcement.mapper.AnnouncementMapper; -import com.example.eumserver.domain.team.announcement.service.AnnouncementService; +import com.example.eumserver.domain.team.announcement.domain.TeamAnnouncement; +import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementFilter; +import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementRequest; +import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementResponse; +import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementUpdateRequest; +import com.example.eumserver.domain.team.announcement.mapper.TeamAnnouncementMapper; +import com.example.eumserver.domain.team.announcement.service.TeamAnnouncementService; import com.example.eumserver.global.dto.ApiResult; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -19,38 +19,38 @@ @RestController @RequestMapping("/api/team/{teamId}/announcement") @RequiredArgsConstructor -public class AnnouncementController { +public class TeamAnnouncementController { - private final AnnouncementService announcementService; + private final TeamAnnouncementService announcementService; @PostMapping("") @ResponseStatus(HttpStatus.CREATED) - public ResponseEntity> createAnnouncement( + public ResponseEntity> createAnnouncement( @PathVariable(name = "teamId") Long teamId, - @RequestBody AnnouncementRequest announcementRequest + @RequestBody TeamAnnouncementRequest announcementRequest ) { log.debug("announcement request: {}", announcementRequest); - AnnouncementResponse announcementResponse = announcementService.createAnnouncement(teamId, announcementRequest); + TeamAnnouncementResponse announcementResponse = announcementService.createAnnouncement(teamId, announcementRequest); return ResponseEntity .status(HttpStatus.CREATED) .body(new ApiResult<>("팀 공고 생성 성공", announcementResponse)); } @GetMapping("") - public ResponseEntity>> getAnnouncements( + public ResponseEntity>> getAnnouncements( @PathVariable(name = "teamId") Long teamId, @RequestParam(name = "page", defaultValue = "0") Integer page, - @RequestBody AnnouncementFilter announcementFilter + @RequestBody TeamAnnouncementFilter announcementFilter ) { - Page filteredAnnouncementsWithPaging = announcementService.getFilteredAnnouncementsWithPaging(teamId, page, announcementFilter); + Page filteredAnnouncementsWithPaging = announcementService.getFilteredAnnouncementsWithPaging(teamId, page, announcementFilter); return ResponseEntity .ok(new ApiResult<>("팀 공고 필터링 및 페이징 조회 성공", filteredAnnouncementsWithPaging)); } @GetMapping("/{announcementId}") - public ResponseEntity> getAnnouncement(@PathVariable(name = "announcementId") Long announcementId) { - Announcement announcement = announcementService.findAnnouncementById(announcementId); - AnnouncementResponse announcementResponse = AnnouncementMapper.INSTANCE.entityToResponse(announcement); + public ResponseEntity> getAnnouncement(@PathVariable(name = "announcementId") Long announcementId) { + TeamAnnouncement announcement = announcementService.findAnnouncementById(announcementId); + TeamAnnouncementResponse announcementResponse = TeamAnnouncementMapper.INSTANCE.entityToResponse(announcement); return ResponseEntity .ok(new ApiResult<>("팀 공고 조회 성공", announcementResponse)); } @@ -58,7 +58,7 @@ public ResponseEntity> getAnnouncement(@PathVari @PutMapping("/{announcementId}") public ResponseEntity> updateAnnouncement( @PathVariable(name = "announcementId") Long announcementId, - @RequestBody AnnouncementUpdateRequest announcementUpdateRequest + @RequestBody TeamAnnouncementUpdateRequest announcementUpdateRequest ) { announcementService.updateAnnouncement(announcementId, announcementUpdateRequest); return ResponseEntity diff --git a/src/main/java/com/example/eumserver/domain/team/announcement/domain/Announcement.java b/src/main/java/com/example/eumserver/domain/team/announcement/domain/TeamAnnouncement.java similarity index 90% rename from src/main/java/com/example/eumserver/domain/team/announcement/domain/Announcement.java rename to src/main/java/com/example/eumserver/domain/team/announcement/domain/TeamAnnouncement.java index 1d4679d..5e33a8e 100644 --- a/src/main/java/com/example/eumserver/domain/team/announcement/domain/Announcement.java +++ b/src/main/java/com/example/eumserver/domain/team/announcement/domain/TeamAnnouncement.java @@ -1,7 +1,7 @@ package com.example.eumserver.domain.team.announcement.domain; import com.example.eumserver.domain.team.Team; -import com.example.eumserver.domain.team.announcement.dto.AnnouncementUpdateRequest; +import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementUpdateRequest; import com.example.eumserver.global.dto.TimeStamp; import jakarta.persistence.*; import lombok.*; @@ -15,7 +15,7 @@ @Builder @NoArgsConstructor(access = AccessLevel.PROTECTED) @AllArgsConstructor -public class Announcement { +public class TeamAnnouncement { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @@ -59,7 +59,7 @@ public boolean isPublished() { return this.publishedDate != null; } - public void updateAnnouncement(AnnouncementUpdateRequest announcementUpdateRequest) { + public void updateAnnouncement(TeamAnnouncementUpdateRequest announcementUpdateRequest) { this.title = announcementUpdateRequest.title(); this.description = announcementUpdateRequest.description(); this.vacancies = announcementUpdateRequest.vacancies(); diff --git a/src/main/java/com/example/eumserver/domain/team/announcement/dto/AnnouncementFilter.java b/src/main/java/com/example/eumserver/domain/team/announcement/dto/TeamAnnouncementFilter.java similarity index 87% rename from src/main/java/com/example/eumserver/domain/team/announcement/dto/AnnouncementFilter.java rename to src/main/java/com/example/eumserver/domain/team/announcement/dto/TeamAnnouncementFilter.java index 5a8f4e5..87a325b 100644 --- a/src/main/java/com/example/eumserver/domain/team/announcement/dto/AnnouncementFilter.java +++ b/src/main/java/com/example/eumserver/domain/team/announcement/dto/TeamAnnouncementFilter.java @@ -4,7 +4,7 @@ import java.util.List; -public record AnnouncementFilter( +public record TeamAnnouncementFilter( boolean published, List occupationClassifications ) { diff --git a/src/main/java/com/example/eumserver/domain/team/announcement/dto/AnnouncementRequest.java b/src/main/java/com/example/eumserver/domain/team/announcement/dto/TeamAnnouncementRequest.java similarity index 93% rename from src/main/java/com/example/eumserver/domain/team/announcement/dto/AnnouncementRequest.java rename to src/main/java/com/example/eumserver/domain/team/announcement/dto/TeamAnnouncementRequest.java index 43429be..a3db462 100644 --- a/src/main/java/com/example/eumserver/domain/team/announcement/dto/AnnouncementRequest.java +++ b/src/main/java/com/example/eumserver/domain/team/announcement/dto/TeamAnnouncementRequest.java @@ -6,7 +6,7 @@ import java.time.LocalDateTime; import java.util.List; -public record AnnouncementRequest( +public record TeamAnnouncementRequest( String title, String description, int vacancies, diff --git a/src/main/java/com/example/eumserver/domain/team/announcement/dto/AnnouncementResponse.java b/src/main/java/com/example/eumserver/domain/team/announcement/dto/TeamAnnouncementResponse.java similarity index 74% rename from src/main/java/com/example/eumserver/domain/team/announcement/dto/AnnouncementResponse.java rename to src/main/java/com/example/eumserver/domain/team/announcement/dto/TeamAnnouncementResponse.java index 8524f52..50f7543 100644 --- a/src/main/java/com/example/eumserver/domain/team/announcement/dto/AnnouncementResponse.java +++ b/src/main/java/com/example/eumserver/domain/team/announcement/dto/TeamAnnouncementResponse.java @@ -1,6 +1,6 @@ package com.example.eumserver.domain.team.announcement.dto; -public record AnnouncementResponse( +public record TeamAnnouncementResponse( String title, String description ) { diff --git a/src/main/java/com/example/eumserver/domain/team/announcement/dto/AnnouncementUpdateRequest.java b/src/main/java/com/example/eumserver/domain/team/announcement/dto/TeamAnnouncementUpdateRequest.java similarity index 92% rename from src/main/java/com/example/eumserver/domain/team/announcement/dto/AnnouncementUpdateRequest.java rename to src/main/java/com/example/eumserver/domain/team/announcement/dto/TeamAnnouncementUpdateRequest.java index 76587cd..f6b7953 100644 --- a/src/main/java/com/example/eumserver/domain/team/announcement/dto/AnnouncementUpdateRequest.java +++ b/src/main/java/com/example/eumserver/domain/team/announcement/dto/TeamAnnouncementUpdateRequest.java @@ -6,7 +6,7 @@ import java.time.LocalDateTime; import java.util.List; -public record AnnouncementUpdateRequest( +public record TeamAnnouncementUpdateRequest( String title, String description, int vacancies, diff --git a/src/main/java/com/example/eumserver/domain/team/announcement/mapper/AnnouncementMapper.java b/src/main/java/com/example/eumserver/domain/team/announcement/mapper/AnnouncementMapper.java deleted file mode 100644 index 4051c21..0000000 --- a/src/main/java/com/example/eumserver/domain/team/announcement/mapper/AnnouncementMapper.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.example.eumserver.domain.team.announcement.mapper; - -import com.example.eumserver.domain.team.announcement.domain.Announcement; -import com.example.eumserver.domain.team.announcement.dto.AnnouncementRequest; -import com.example.eumserver.domain.team.announcement.dto.AnnouncementResponse; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.factory.Mappers; - -@Mapper -public interface AnnouncementMapper { - - AnnouncementMapper INSTANCE = Mappers.getMapper(AnnouncementMapper.class); - - AnnouncementResponse entityToResponse(Announcement announcement); - - @Mapping(target = "id", ignore = true) - @Mapping(target = "timeStamp", ignore = true) - @Mapping(target = "publishedDate", ignore = true) - @Mapping(target = "team", ignore = true) - Announcement requestToEntity(AnnouncementRequest announcementRequest); -} diff --git a/src/main/java/com/example/eumserver/domain/team/announcement/mapper/TeamAnnouncementMapper.java b/src/main/java/com/example/eumserver/domain/team/announcement/mapper/TeamAnnouncementMapper.java new file mode 100644 index 0000000..53966dc --- /dev/null +++ b/src/main/java/com/example/eumserver/domain/team/announcement/mapper/TeamAnnouncementMapper.java @@ -0,0 +1,22 @@ +package com.example.eumserver.domain.team.announcement.mapper; + +import com.example.eumserver.domain.team.announcement.domain.TeamAnnouncement; +import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementRequest; +import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementResponse; +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +import org.mapstruct.factory.Mappers; + +@Mapper +public interface TeamAnnouncementMapper { + + TeamAnnouncementMapper INSTANCE = Mappers.getMapper(TeamAnnouncementMapper.class); + + TeamAnnouncementResponse entityToResponse(TeamAnnouncement announcement); + + @Mapping(target = "id", ignore = true) + @Mapping(target = "timeStamp", ignore = true) + @Mapping(target = "publishedDate", ignore = true) + @Mapping(target = "team", ignore = true) + TeamAnnouncement requestToEntity(TeamAnnouncementRequest announcementRequest); +} diff --git a/src/main/java/com/example/eumserver/domain/team/announcement/repository/AnnouncementCustomRepository.java b/src/main/java/com/example/eumserver/domain/team/announcement/repository/AnnouncementCustomRepository.java deleted file mode 100644 index c84dca9..0000000 --- a/src/main/java/com/example/eumserver/domain/team/announcement/repository/AnnouncementCustomRepository.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.example.eumserver.domain.team.announcement.repository; - -import com.example.eumserver.domain.team.announcement.dto.AnnouncementFilter; -import com.example.eumserver.domain.team.announcement.domain.Announcement; -import com.example.eumserver.domain.team.announcement.dto.AnnouncementResponse; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; - -public interface AnnouncementCustomRepository { - - /** - * Retrieve a paginated list of announcements filtered additional criteria. - * - * @param filter An object containing filter criteria to apply to the announcements. - * @param pageable Pagination information including page number, page size, and sort order. - * @return A {@link Page} of {@link Announcement} objects that match the specified filters. - */ - Page getFilteredAnnouncementsWithPaging(Long teamId, AnnouncementFilter filter, Pageable pageable); - -} diff --git a/src/main/java/com/example/eumserver/domain/team/announcement/repository/AnnouncementCustomRepositoryImpl.java b/src/main/java/com/example/eumserver/domain/team/announcement/repository/AnnouncementCustomRepositoryImpl.java deleted file mode 100644 index d44cc1c..0000000 --- a/src/main/java/com/example/eumserver/domain/team/announcement/repository/AnnouncementCustomRepositoryImpl.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.example.eumserver.domain.team.announcement.repository; - -import com.example.eumserver.domain.team.announcement.domain.OccupationClassification; -import com.example.eumserver.domain.team.announcement.domain.QAnnouncement; -import com.example.eumserver.domain.team.announcement.dto.AnnouncementFilter; -import com.example.eumserver.domain.team.announcement.domain.Announcement; -import com.example.eumserver.domain.team.announcement.dto.AnnouncementResponse; -import com.example.eumserver.domain.team.announcement.mapper.AnnouncementMapper; -import com.querydsl.core.types.dsl.BooleanExpression; -import com.querydsl.jpa.impl.JPAQuery; -import com.querydsl.jpa.impl.JPAQueryFactory; -import lombok.RequiredArgsConstructor; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.data.support.PageableExecutionUtils; -import org.springframework.stereotype.Repository; - -import java.util.List; - -@Repository -@RequiredArgsConstructor -public class AnnouncementCustomRepositoryImpl implements AnnouncementCustomRepository { - - private final JPAQueryFactory queryFactory; - - @Override - public Page getFilteredAnnouncementsWithPaging(Long teamId, AnnouncementFilter filter, Pageable pageable) { - QAnnouncement announcement = QAnnouncement.announcement; - BooleanExpression predicate = announcement.isNotNull(); - - predicate = predicate.and(announcement.team.id.eq(teamId)); - - if (filter.published()) { - predicate = predicate.and(announcement.publishedDate.isNotNull()); - } - - List occupationClassifications = filter.occupationClassifications(); - if (occupationClassifications != null && !occupationClassifications.isEmpty()) { - predicate = predicate.and(announcement.occupationClassifications.any().in(occupationClassifications)); - } - - List announcements = queryFactory - .selectFrom(announcement) - .where(predicate) - .offset(pageable.getOffset()) - .limit(pageable.getPageSize()) - .fetch(); - - List announcementResponses = announcements.stream() - .map(AnnouncementMapper.INSTANCE::entityToResponse).toList(); - - JPAQuery count = queryFactory - .select(announcement.count()) - .from(announcement) - .where(predicate); - - return PageableExecutionUtils.getPage(announcementResponses, pageable, count::fetchOne); - } -} diff --git a/src/main/java/com/example/eumserver/domain/team/announcement/repository/AnnouncementRepository.java b/src/main/java/com/example/eumserver/domain/team/announcement/repository/AnnouncementRepository.java deleted file mode 100644 index 01139bd..0000000 --- a/src/main/java/com/example/eumserver/domain/team/announcement/repository/AnnouncementRepository.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.example.eumserver.domain.team.announcement.repository; - -import com.example.eumserver.domain.team.announcement.domain.Announcement; -import org.springframework.data.jpa.repository.JpaRepository; - -public interface AnnouncementRepository extends JpaRepository, AnnouncementCustomRepository { - -} diff --git a/src/main/java/com/example/eumserver/domain/team/announcement/repository/TeamAnnouncementCustomRepository.java b/src/main/java/com/example/eumserver/domain/team/announcement/repository/TeamAnnouncementCustomRepository.java new file mode 100644 index 0000000..d1a7b27 --- /dev/null +++ b/src/main/java/com/example/eumserver/domain/team/announcement/repository/TeamAnnouncementCustomRepository.java @@ -0,0 +1,20 @@ +package com.example.eumserver.domain.team.announcement.repository; + +import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementFilter; +import com.example.eumserver.domain.team.announcement.domain.TeamAnnouncement; +import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementResponse; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; + +public interface TeamAnnouncementCustomRepository { + + /** + * Retrieve a paginated list of announcements filtered additional criteria. + * + * @param filter An object containing filter criteria to apply to the announcements. + * @param pageable Pagination information including page number, page size, and sort order. + * @return A {@link Page} of {@link TeamAnnouncement} objects that match the specified filters. + */ + Page getFilteredAnnouncementsWithPaging(Long teamId, TeamAnnouncementFilter filter, Pageable pageable); + +} diff --git a/src/main/java/com/example/eumserver/domain/team/announcement/repository/TeamAnnouncementCustomRepositoryImpl.java b/src/main/java/com/example/eumserver/domain/team/announcement/repository/TeamAnnouncementCustomRepositoryImpl.java new file mode 100644 index 0000000..4bc44b3 --- /dev/null +++ b/src/main/java/com/example/eumserver/domain/team/announcement/repository/TeamAnnouncementCustomRepositoryImpl.java @@ -0,0 +1,59 @@ +package com.example.eumserver.domain.team.announcement.repository; + +import com.example.eumserver.domain.team.announcement.domain.OccupationClassification; +import com.example.eumserver.domain.team.announcement.domain.QTeamAnnouncement; +import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementFilter; +import com.example.eumserver.domain.team.announcement.domain.TeamAnnouncement; +import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementResponse; +import com.example.eumserver.domain.team.announcement.mapper.TeamAnnouncementMapper; +import com.querydsl.core.types.dsl.BooleanExpression; +import com.querydsl.jpa.impl.JPAQuery; +import com.querydsl.jpa.impl.JPAQueryFactory; +import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.support.PageableExecutionUtils; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +@RequiredArgsConstructor +public class TeamAnnouncementCustomRepositoryImpl implements TeamAnnouncementCustomRepository { + + private final JPAQueryFactory queryFactory; + + @Override + public Page getFilteredAnnouncementsWithPaging(Long teamId, TeamAnnouncementFilter filter, Pageable pageable) { + QTeamAnnouncement teamAnnouncement = QTeamAnnouncement.teamAnnouncement; + BooleanExpression predicate = teamAnnouncement.isNotNull(); + + predicate = predicate.and(teamAnnouncement.team.id.eq(teamId)); + + if (filter.published()) { + predicate = predicate.and(teamAnnouncement.publishedDate.isNotNull()); + } + + List occupationClassifications = filter.occupationClassifications(); + if (occupationClassifications != null && !occupationClassifications.isEmpty()) { + predicate = predicate.and(teamAnnouncement.occupationClassifications.any().in(occupationClassifications)); + } + + List announcements = queryFactory + .selectFrom(teamAnnouncement) + .where(predicate) + .offset(pageable.getOffset()) + .limit(pageable.getPageSize()) + .fetch(); + + List announcementResponses = announcements.stream() + .map(TeamAnnouncementMapper.INSTANCE::entityToResponse).toList(); + + JPAQuery count = queryFactory + .select(teamAnnouncement.count()) + .from(teamAnnouncement) + .where(predicate); + + return PageableExecutionUtils.getPage(announcementResponses, pageable, count::fetchOne); + } +} diff --git a/src/main/java/com/example/eumserver/domain/team/announcement/repository/TeamAnnouncementRepository.java b/src/main/java/com/example/eumserver/domain/team/announcement/repository/TeamAnnouncementRepository.java new file mode 100644 index 0000000..7899d7f --- /dev/null +++ b/src/main/java/com/example/eumserver/domain/team/announcement/repository/TeamAnnouncementRepository.java @@ -0,0 +1,8 @@ +package com.example.eumserver.domain.team.announcement.repository; + +import com.example.eumserver.domain.team.announcement.domain.TeamAnnouncement; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface TeamAnnouncementRepository extends JpaRepository, TeamAnnouncementCustomRepository { + +} diff --git a/src/main/java/com/example/eumserver/domain/team/announcement/service/AnnouncementService.java b/src/main/java/com/example/eumserver/domain/team/announcement/service/TeamAnnouncementService.java similarity index 58% rename from src/main/java/com/example/eumserver/domain/team/announcement/service/AnnouncementService.java rename to src/main/java/com/example/eumserver/domain/team/announcement/service/TeamAnnouncementService.java index d190d91..0e30e7a 100644 --- a/src/main/java/com/example/eumserver/domain/team/announcement/service/AnnouncementService.java +++ b/src/main/java/com/example/eumserver/domain/team/announcement/service/TeamAnnouncementService.java @@ -2,13 +2,13 @@ import com.example.eumserver.domain.team.Team; import com.example.eumserver.domain.team.TeamService; -import com.example.eumserver.domain.team.announcement.domain.Announcement; -import com.example.eumserver.domain.team.announcement.dto.AnnouncementFilter; -import com.example.eumserver.domain.team.announcement.dto.AnnouncementRequest; -import com.example.eumserver.domain.team.announcement.dto.AnnouncementResponse; -import com.example.eumserver.domain.team.announcement.dto.AnnouncementUpdateRequest; -import com.example.eumserver.domain.team.announcement.mapper.AnnouncementMapper; -import com.example.eumserver.domain.team.announcement.repository.AnnouncementRepository; +import com.example.eumserver.domain.team.announcement.domain.TeamAnnouncement; +import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementFilter; +import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementRequest; +import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementResponse; +import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementUpdateRequest; +import com.example.eumserver.domain.team.announcement.mapper.TeamAnnouncementMapper; +import com.example.eumserver.domain.team.announcement.repository.TeamAnnouncementRepository; import com.example.eumserver.global.error.exception.CustomException; import com.example.eumserver.global.error.exception.ErrorCode; import lombok.RequiredArgsConstructor; @@ -26,16 +26,16 @@ @Service @Transactional(readOnly = true) @RequiredArgsConstructor -public class AnnouncementService { +public class TeamAnnouncementService { - private final AnnouncementRepository announcementRepository; + private final TeamAnnouncementRepository announcementRepository; private final TeamService teamService; - public Page getFilteredAnnouncementsWithPaging( + public Page getFilteredAnnouncementsWithPaging( Long teamId, int page, - AnnouncementFilter filter + TeamAnnouncementFilter filter ) { List sorts = new ArrayList<>(); sorts.add(Sort.Order.desc("date_created")); @@ -44,10 +44,10 @@ public Page getFilteredAnnouncementsWithPaging( } @Transactional - public AnnouncementResponse createAnnouncement(Long teamId, AnnouncementRequest announcementRequest) { + public TeamAnnouncementResponse createAnnouncement(Long teamId, TeamAnnouncementRequest announcementRequest) { Team team = teamService.findById(teamId); - Announcement announcement = AnnouncementMapper.INSTANCE.requestToEntity(announcementRequest); + TeamAnnouncement announcement = TeamAnnouncementMapper.INSTANCE.requestToEntity(announcementRequest); announcement.setTeam(team); if (announcementRequest.publish()) { LocalDateTime localDateTime = LocalDateTime.now(); @@ -55,12 +55,12 @@ public AnnouncementResponse createAnnouncement(Long teamId, AnnouncementRequest } announcementRepository.save(announcement); - return AnnouncementMapper.INSTANCE.entityToResponse(announcement); + return TeamAnnouncementMapper.INSTANCE.entityToResponse(announcement); } @Transactional - public void updateAnnouncement(Long announcementId, AnnouncementUpdateRequest announcementUpdateRequest) { - Announcement announcement = this.findAnnouncementById(announcementId); + public void updateAnnouncement(Long announcementId, TeamAnnouncementUpdateRequest announcementUpdateRequest) { + TeamAnnouncement announcement = this.findAnnouncementById(announcementId); announcement.updateAnnouncement(announcementUpdateRequest); announcementRepository.save(announcement); } @@ -68,11 +68,11 @@ public void updateAnnouncement(Long announcementId, AnnouncementUpdateRequest an @Transactional public void deleteAnnouncement(Long announcementId) { - Announcement announcement = this.findAnnouncementById(announcementId); + TeamAnnouncement announcement = this.findAnnouncementById(announcementId); announcementRepository.delete(announcement); } - public Announcement findAnnouncementById(Long announcementId) { + public TeamAnnouncement findAnnouncementById(Long announcementId) { return announcementRepository.findById(announcementId) .orElseThrow(() -> new CustomException(ErrorCode.ANNOUNCEMENT_NOT_FOUND)); } diff --git a/src/test/java/com/example/eumserver/domain/team/announcement/controller/AnnouncementControllerTest.java b/src/test/java/com/example/eumserver/domain/team/announcement/controller/AnnouncementControllerTest.java index e1faf5c..f29f518 100644 --- a/src/test/java/com/example/eumserver/domain/team/announcement/controller/AnnouncementControllerTest.java +++ b/src/test/java/com/example/eumserver/domain/team/announcement/controller/AnnouncementControllerTest.java @@ -2,11 +2,11 @@ import com.example.eumserver.BaseIntegrationTest; import com.example.eumserver.domain.team.Team; -import com.example.eumserver.domain.team.announcement.domain.Announcement; +import com.example.eumserver.domain.team.announcement.domain.TeamAnnouncement; import com.example.eumserver.domain.team.announcement.domain.OccupationClassification; -import com.example.eumserver.domain.team.announcement.dto.AnnouncementFilter; -import com.example.eumserver.domain.team.announcement.dto.AnnouncementRequest; -import com.example.eumserver.domain.team.announcement.dto.AnnouncementUpdateRequest; +import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementFilter; +import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementRequest; +import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementUpdateRequest; import jakarta.persistence.EntityManager; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -37,8 +37,8 @@ class AnnouncementControllerTest extends BaseIntegrationTest { void create_announcement_success() throws Exception { Team team = createTeam(); - AnnouncementRequest announcementRequest = - new AnnouncementRequest( + TeamAnnouncementRequest announcementRequest = + new TeamAnnouncementRequest( "title", "description", 5, @@ -68,7 +68,7 @@ void create_announcement_success() throws Exception { @WithMockUser void get_announcement_success() throws Exception { Team team = createTeam(); - Announcement announcement = createAnnouncement(team); + TeamAnnouncement announcement = createAnnouncement(team); ResultActions resultActions = mockMvc.perform( get(BASE_URI + "/{announcementId}", team.getId(), announcement.getId()) @@ -87,9 +87,9 @@ void get_announcement_success() throws Exception { @WithMockUser void get_filtered_announcement_with_paging_success() throws Exception { Team team = createTeam(); - Announcement announcement = createAnnouncement(team); + TeamAnnouncement announcement = createAnnouncement(team); - AnnouncementFilter filter = new AnnouncementFilter( + TeamAnnouncementFilter filter = new TeamAnnouncementFilter( false, List.of(OccupationClassification.DEVELOPMENT_BACKEND, OccupationClassification.DEVELOPMENT_DEVOPS) ); @@ -117,9 +117,9 @@ void get_filtered_announcement_with_paging_success() throws Exception { @WithMockUser void update_announcement_success() throws Exception { Team team = createTeam(); - Announcement announcement = createAnnouncement(team); + TeamAnnouncement announcement = createAnnouncement(team); - AnnouncementUpdateRequest announcementUpdateRequest = new AnnouncementUpdateRequest( + TeamAnnouncementUpdateRequest announcementUpdateRequest = new TeamAnnouncementUpdateRequest( "new title", "new description", 2, @@ -141,7 +141,7 @@ void update_announcement_success() throws Exception { resultActions .andExpect(status().isOk()); - Announcement updatedAnnouncement = em.find(Announcement.class, announcement.getId()); + TeamAnnouncement updatedAnnouncement = em.find(TeamAnnouncement.class, announcement.getId()); assertEquals(announcementUpdateRequest.title(), updatedAnnouncement.getTitle()); assertEquals(announcementUpdateRequest.description(), updatedAnnouncement.getDescription()); assertEquals(announcementUpdateRequest.vacancies(), updatedAnnouncement.getVacancies()); @@ -155,7 +155,7 @@ void update_announcement_success() throws Exception { @WithMockUser void delete_announcement_success() throws Exception { Team team = createTeam(); - Announcement announcement = createAnnouncement(team); + TeamAnnouncement announcement = createAnnouncement(team); ResultActions resultActions = mockMvc.perform( delete(BASE_URI + "/{announcementId}", team.getId(), announcement.getId()) @@ -176,8 +176,8 @@ private Team createTeam() { return team; } - private Announcement createAnnouncement(Team team) { - Announcement announcement = Announcement.builder() + private TeamAnnouncement createAnnouncement(Team team) { + TeamAnnouncement announcement = TeamAnnouncement.builder() .title("test_title") .description("test_description") .vacancies(1) From dd175b80c52ead87e4431396bf8c1262a45d6e8f Mon Sep 17 00:00:00 2001 From: Sukju Hong Date: Tue, 7 May 2024 10:47:42 +0900 Subject: [PATCH 02/22] =?UTF-8?q?feat:=20isPublic=20=EC=82=AD=EC=A0=9C=20?= =?UTF-8?q?=EB=B0=8F=20=EB=A6=AC=ED=8C=A9=ED=86=A0=EB=A7=81=20(#56)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/resume/ResumeController.java | 4 +-- .../eumserver/domain/resume/ResumeMapper.java | 11 ++---- .../domain/resume/ResumeRepository.java | 2 -- .../domain/resume/ResumeService.java | 14 ++------ .../domain/resume/dto/ResumeRequest.java | 2 +- .../domain/resume/entity/Resume.java | 34 ++++++++----------- 6 files changed, 23 insertions(+), 44 deletions(-) diff --git a/src/main/java/com/example/eumserver/domain/resume/ResumeController.java b/src/main/java/com/example/eumserver/domain/resume/ResumeController.java index 180bd02..c8aac08 100644 --- a/src/main/java/com/example/eumserver/domain/resume/ResumeController.java +++ b/src/main/java/com/example/eumserver/domain/resume/ResumeController.java @@ -111,7 +111,7 @@ public ResponseEntity>> getAllMyResume( @AuthenticationPrincipal PrincipalDetails principalDetails ) { long userId = principalDetails.getUserId(); - List resumes = resumeService.getAllMyResume(userId); + List resumes = resumeService.getAllResumeByUserId(userId); return ResponseEntity .ok(new ApiResult<>("내 이력서 전부 받아오기 성공", resumes)); } @@ -124,7 +124,7 @@ public ResponseEntity>> getAllMyResume( public ResponseEntity>> getAllMyResume( @PathVariable("userId") long userId ) { - List resumes = resumeService.getAllUserResume(userId); + List resumes = resumeService.getAllResumeByUserId(userId); return ResponseEntity .ok(new ApiResult<>("타인 이력서 전부 받아오기 성공", resumes)); } diff --git a/src/main/java/com/example/eumserver/domain/resume/ResumeMapper.java b/src/main/java/com/example/eumserver/domain/resume/ResumeMapper.java index 4992959..ab46be1 100644 --- a/src/main/java/com/example/eumserver/domain/resume/ResumeMapper.java +++ b/src/main/java/com/example/eumserver/domain/resume/ResumeMapper.java @@ -12,16 +12,9 @@ public interface ResumeMapper { ResumeMapper INSTANCE = Mappers.getMapper(ResumeMapper.class); - @Mapping(source = "jobCategory", target = "jobCategory") - @Mapping(source = "jobSubcategory", target = "jobSubcategory") + @Mapping(target = "id", ignore = true) + @Mapping(target = "timeStamp", ignore = true) @Mapping(target = "user", ignore = true) - @Mapping(source = "gpa", target = "gpa") - @Mapping(source = "totalScore", target = "totalScore") - @Mapping(source = "introduction", target = "introduction") - @Mapping(source = "careers", target = "careers") - @Mapping(source = "certificates", target = "certificates") - @Mapping(source = "projects", target = "projects") - @Mapping(source = "isPublic", target = "isPublic") Resume resumeRequestToResume(ResumeRequest resumeRequest); @AfterMapping diff --git a/src/main/java/com/example/eumserver/domain/resume/ResumeRepository.java b/src/main/java/com/example/eumserver/domain/resume/ResumeRepository.java index 482f5a0..1f4c35d 100644 --- a/src/main/java/com/example/eumserver/domain/resume/ResumeRepository.java +++ b/src/main/java/com/example/eumserver/domain/resume/ResumeRepository.java @@ -7,6 +7,4 @@ public interface ResumeRepository extends JpaRepository { List findByUserId(Long userId); - - List findByUserIdAndIsPublicTrue(Long userId); } diff --git a/src/main/java/com/example/eumserver/domain/resume/ResumeService.java b/src/main/java/com/example/eumserver/domain/resume/ResumeService.java index f6c45f7..c630a38 100644 --- a/src/main/java/com/example/eumserver/domain/resume/ResumeService.java +++ b/src/main/java/com/example/eumserver/domain/resume/ResumeService.java @@ -42,9 +42,7 @@ public Resume updateResume(ResumeRequest resumeRequest, long resumeId, long user } Resume updatedResume = ResumeMapper.INSTANCE.resumeRequestToResume(resumeRequest); - resume.updateResume(updatedResume.getTitle(), updatedResume.getJobCategory(), updatedResume.getJobSubcategory(), - updatedResume.getGpa(), updatedResume.getTotalScore(), updatedResume.getCareers(), updatedResume.getActivities(), - updatedResume.getCertificates(), updatedResume.getProjects(), updatedResume.getHomepages(), updatedResume.getIsPublic()); + resume.updateResume(updatedResume); resumeRepository.save(resume); return resume; @@ -63,23 +61,17 @@ public void deleteResume(long resumeId, long userId) { resumeRepository.deleteById(resumeId); } - public List getAllMyResume(long userId) { + public List getAllResumeByUserId(long userId) { userRepository.findById(userId) .orElseThrow(() -> new CustomException(ErrorCode.USER_NOT_FOUND)); return resumeRepository.findByUserId(userId); } - public List getAllUserResume(long userId) { - userRepository.findById(userId) - .orElseThrow(() -> new CustomException(ErrorCode.USER_NOT_FOUND)); - return resumeRepository.findByUserIdAndIsPublicTrue(userId); - } - public Resume getResume(long userId, long resumeId) { Resume resume = resumeRepository.findById(resumeId) .orElseThrow(() -> new CustomException(ErrorCode.RESUME_NOT_FOUND)); - if (!resume.getIsPublic() && (userId == 0 || userId != resume.getUser().getId())) { + if (userId == 0 || userId != resume.getUser().getId()) { throw new CustomException(ErrorCode.ACCESS_DENIED); } return resume; diff --git a/src/main/java/com/example/eumserver/domain/resume/dto/ResumeRequest.java b/src/main/java/com/example/eumserver/domain/resume/dto/ResumeRequest.java index 6e087cf..552b1c0 100644 --- a/src/main/java/com/example/eumserver/domain/resume/dto/ResumeRequest.java +++ b/src/main/java/com/example/eumserver/domain/resume/dto/ResumeRequest.java @@ -6,11 +6,11 @@ public record ResumeRequest( @NotBlank String title, + @NotBlank String description, @NotBlank String jobCategory, @NotBlank String jobSubcategory, Double gpa, Double totalScore, - @NotBlank String introduction, Boolean isPublic, List careers, List certificates, diff --git a/src/main/java/com/example/eumserver/domain/resume/entity/Resume.java b/src/main/java/com/example/eumserver/domain/resume/entity/Resume.java index 0363b72..c0f3c78 100644 --- a/src/main/java/com/example/eumserver/domain/resume/entity/Resume.java +++ b/src/main/java/com/example/eumserver/domain/resume/entity/Resume.java @@ -1,5 +1,7 @@ package com.example.eumserver.domain.resume.entity; +import com.example.eumserver.domain.resume.dto.ResumeCareerRequest; +import com.example.eumserver.domain.resume.dto.ResumeRequest; import com.example.eumserver.domain.user.User; import com.example.eumserver.global.dto.TimeStamp; import com.fasterxml.jackson.annotation.JsonIgnore; @@ -62,11 +64,7 @@ public class Resume { private List homepages = new ArrayList<>(); @Column(columnDefinition = "TEXT", nullable = false) - private String introduction; - - @Builder.Default - @Column(name = "is_public", nullable = false) - private Boolean isPublic = true; + private String description; @Embedded private TimeStamp timeStamp; @@ -76,24 +74,22 @@ public void setUser(User user) { user.addResume(this); } - public void updateResume(String title, String jobCategory, String jobSubcategory, Double gpa, Double totalScore, - List careers, List activities, List certificates, - List projects, List homepages, Boolean isPublic) { - this.title = title; - this.jobCategory = jobCategory; - this.jobSubcategory = jobSubcategory; - this.gpa = gpa; - this.totalScore = totalScore; + public void updateResume(Resume resume) { + this.title = resume.getTitle(); + this.description = resume.getDescription(); + this.jobCategory = resume.getJobCategory(); + this.jobSubcategory = resume.getJobSubcategory(); + this.gpa = resume.getGpa(); + this.totalScore = resume.getTotalScore(); this.careers.clear(); - this.careers.addAll(careers); + this.careers.addAll(resume.getCareers()); this.activities.clear(); - this.activities.addAll(activities); + this.activities.addAll(resume.getActivities()); this.certificates.clear(); - this.certificates.addAll(certificates); + this.certificates.addAll(resume.getCertificates()); this.projects.clear(); - this.projects.addAll(projects); + this.projects.addAll(resume.getProjects()); this.homepages.clear(); - this.homepages.addAll(homepages); - this.isPublic = isPublic; + this.homepages.addAll(resume.getHomepages()); } } From afe81ec47c9324fac832109807a41c484c69b5c4 Mon Sep 17 00:00:00 2001 From: Sukju Hong Date: Tue, 7 May 2024 11:13:56 +0900 Subject: [PATCH 03/22] =?UTF-8?q?feat:=20=EC=9D=B4=EB=A0=A5=EC=84=9C=20?= =?UTF-8?q?=EA=B3=B5=EA=B3=A0=20Service=20=EB=A0=88=EC=9D=B4=EC=96=B4?= =?UTF-8?q?=EA=B9=8C=EC=A7=80=20=EA=B5=AC=ED=98=84=20(#56)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/resume/ResumeRepository.java | 2 + .../domain/ResumeAnnouncement.java | 26 +++++++++++ .../dto/ResumeAnnouncementRequest.java | 6 +++ .../mapper/ResumeAnnouncementMapper.java | 17 +++++++ .../ResumeAnnouncementRepository.java | 6 +++ .../service/ResumeAnnouncementService.java | 45 +++++++++++++++++++ .../domain/resume/entity/Resume.java | 25 +++++++++-- 7 files changed, 123 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/example/eumserver/domain/resume/announcement/domain/ResumeAnnouncement.java create mode 100644 src/main/java/com/example/eumserver/domain/resume/announcement/dto/ResumeAnnouncementRequest.java create mode 100644 src/main/java/com/example/eumserver/domain/resume/announcement/mapper/ResumeAnnouncementMapper.java create mode 100644 src/main/java/com/example/eumserver/domain/resume/announcement/repository/ResumeAnnouncementRepository.java create mode 100644 src/main/java/com/example/eumserver/domain/resume/announcement/service/ResumeAnnouncementService.java diff --git a/src/main/java/com/example/eumserver/domain/resume/ResumeRepository.java b/src/main/java/com/example/eumserver/domain/resume/ResumeRepository.java index 1f4c35d..9a1d01c 100644 --- a/src/main/java/com/example/eumserver/domain/resume/ResumeRepository.java +++ b/src/main/java/com/example/eumserver/domain/resume/ResumeRepository.java @@ -4,7 +4,9 @@ import org.springframework.data.jpa.repository.JpaRepository; import java.util.List; +import java.util.Optional; public interface ResumeRepository extends JpaRepository { + Optional findById(Long resumeId); List findByUserId(Long userId); } diff --git a/src/main/java/com/example/eumserver/domain/resume/announcement/domain/ResumeAnnouncement.java b/src/main/java/com/example/eumserver/domain/resume/announcement/domain/ResumeAnnouncement.java new file mode 100644 index 0000000..7b69960 --- /dev/null +++ b/src/main/java/com/example/eumserver/domain/resume/announcement/domain/ResumeAnnouncement.java @@ -0,0 +1,26 @@ +package com.example.eumserver.domain.resume.announcement.domain; + +import com.example.eumserver.domain.resume.entity.Resume; +import jakarta.persistence.*; +import lombok.*; + +@Entity +@Table(name = "resume_announcements") +@Getter +@Builder +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor +public class ResumeAnnouncement { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "resume_announcement_id") + private Long id; + + @Column(nullable = false) + private String introduction; + + @Setter + @OneToOne(mappedBy = "resumeAnnouncement") + private Resume resume; +} diff --git a/src/main/java/com/example/eumserver/domain/resume/announcement/dto/ResumeAnnouncementRequest.java b/src/main/java/com/example/eumserver/domain/resume/announcement/dto/ResumeAnnouncementRequest.java new file mode 100644 index 0000000..4f6d42b --- /dev/null +++ b/src/main/java/com/example/eumserver/domain/resume/announcement/dto/ResumeAnnouncementRequest.java @@ -0,0 +1,6 @@ +package com.example.eumserver.domain.resume.announcement.dto; + +public record ResumeAnnouncementRequest( + String introduction +) { +} diff --git a/src/main/java/com/example/eumserver/domain/resume/announcement/mapper/ResumeAnnouncementMapper.java b/src/main/java/com/example/eumserver/domain/resume/announcement/mapper/ResumeAnnouncementMapper.java new file mode 100644 index 0000000..eff57e8 --- /dev/null +++ b/src/main/java/com/example/eumserver/domain/resume/announcement/mapper/ResumeAnnouncementMapper.java @@ -0,0 +1,17 @@ +package com.example.eumserver.domain.resume.announcement.mapper; + +import com.example.eumserver.domain.resume.announcement.domain.ResumeAnnouncement; +import com.example.eumserver.domain.resume.announcement.dto.ResumeAnnouncementRequest; +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +import org.mapstruct.factory.Mappers; + +@Mapper +public interface ResumeAnnouncementMapper { + + ResumeAnnouncementMapper INSTANCE = Mappers.getMapper(ResumeAnnouncementMapper.class); + + @Mapping(target = "id", ignore = true) + @Mapping(target = "resume", ignore = true) + ResumeAnnouncement requestToEntity(ResumeAnnouncementRequest resumeAnnouncementRequest); +} diff --git a/src/main/java/com/example/eumserver/domain/resume/announcement/repository/ResumeAnnouncementRepository.java b/src/main/java/com/example/eumserver/domain/resume/announcement/repository/ResumeAnnouncementRepository.java new file mode 100644 index 0000000..b470160 --- /dev/null +++ b/src/main/java/com/example/eumserver/domain/resume/announcement/repository/ResumeAnnouncementRepository.java @@ -0,0 +1,6 @@ +package com.example.eumserver.domain.resume.announcement.repository; + +import com.example.eumserver.domain.resume.announcement.domain.ResumeAnnouncement; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface ResumeAnnouncementRepository extends JpaRepository { } diff --git a/src/main/java/com/example/eumserver/domain/resume/announcement/service/ResumeAnnouncementService.java b/src/main/java/com/example/eumserver/domain/resume/announcement/service/ResumeAnnouncementService.java new file mode 100644 index 0000000..6b0a06b --- /dev/null +++ b/src/main/java/com/example/eumserver/domain/resume/announcement/service/ResumeAnnouncementService.java @@ -0,0 +1,45 @@ +package com.example.eumserver.domain.resume.announcement.service; + +import com.example.eumserver.domain.resume.ResumeRepository; +import com.example.eumserver.domain.resume.announcement.domain.ResumeAnnouncement; +import com.example.eumserver.domain.resume.announcement.dto.ResumeAnnouncementRequest; +import com.example.eumserver.domain.resume.announcement.mapper.ResumeAnnouncementMapper; +import com.example.eumserver.domain.resume.announcement.repository.ResumeAnnouncementRepository; +import com.example.eumserver.domain.resume.entity.Resume; +import com.example.eumserver.global.error.exception.CustomException; +import com.example.eumserver.global.error.exception.ErrorCode; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@RequiredArgsConstructor +@Transactional(readOnly = true) +public class ResumeAnnouncementService { + + private final ResumeRepository resumeRepository; + private final ResumeAnnouncementRepository resumeAnnouncementRepository; + + public ResumeAnnouncement publishResume(Long resumeId, ResumeAnnouncementRequest resumeAnnouncementRequest) { + Resume resume = resumeRepository.findById(resumeId) + .orElseThrow(() -> new CustomException(ErrorCode.RESUME_NOT_FOUND)); + + ResumeAnnouncement resumeAnnouncement = ResumeAnnouncementMapper.INSTANCE + .requestToEntity(resumeAnnouncementRequest); + + resume.publishResume(resumeAnnouncement); + resumeRepository.save(resume); + return resumeAnnouncementRepository.save(resumeAnnouncement); + } + + public void unpublishResume(Long resumeId) { + Resume resume = resumeRepository.findById(resumeId) + .orElseThrow(() -> new CustomException(ErrorCode.RESUME_NOT_FOUND)); + ResumeAnnouncement resumeAnnouncement = resume.getResumeAnnouncement(); + + resume.unpublishResume(); + resumeRepository.save(resume); + resumeAnnouncementRepository.delete(resumeAnnouncement); + } + +} diff --git a/src/main/java/com/example/eumserver/domain/resume/entity/Resume.java b/src/main/java/com/example/eumserver/domain/resume/entity/Resume.java index c0f3c78..68988d0 100644 --- a/src/main/java/com/example/eumserver/domain/resume/entity/Resume.java +++ b/src/main/java/com/example/eumserver/domain/resume/entity/Resume.java @@ -1,7 +1,6 @@ package com.example.eumserver.domain.resume.entity; -import com.example.eumserver.domain.resume.dto.ResumeCareerRequest; -import com.example.eumserver.domain.resume.dto.ResumeRequest; +import com.example.eumserver.domain.resume.announcement.domain.ResumeAnnouncement; import com.example.eumserver.domain.user.User; import com.example.eumserver.global.dto.TimeStamp; import com.fasterxml.jackson.annotation.JsonIgnore; @@ -31,6 +30,9 @@ public class Resume { @Column private String title; + @Column(columnDefinition = "TEXT", nullable = false) + private String description; + @Column(name = "job_category", nullable = false) private String jobCategory; @@ -63,8 +65,12 @@ public class Resume { @OneToMany(mappedBy = "resume", cascade = CascadeType.ALL, orphanRemoval = true) private List homepages = new ArrayList<>(); - @Column(columnDefinition = "TEXT", nullable = false) - private String description; + @OneToOne(fetch = FetchType.LAZY, orphanRemoval = true) + @JoinColumn(name = "resume_announcement_id") + private ResumeAnnouncement resumeAnnouncement; + + @Builder.Default + private Boolean isPublished = false; @Embedded private TimeStamp timeStamp; @@ -92,4 +98,15 @@ public void updateResume(Resume resume) { this.homepages.clear(); this.homepages.addAll(resume.getHomepages()); } + + public void publishResume(ResumeAnnouncement resumeAnnouncement) { + this.resumeAnnouncement = resumeAnnouncement; + resumeAnnouncement.setResume(this); + this.isPublished = true; + } + + public void unpublishResume() { + this.resumeAnnouncement = null; + this.isPublished = false; + } } From d4381e24c7499ad120bcfcba1569c7e9446bff91 Mon Sep 17 00:00:00 2001 From: Sukju Hong Date: Tue, 7 May 2024 11:15:04 +0900 Subject: [PATCH 04/22] =?UTF-8?q?feat:=20ResumeMapper=20target=20=EB=88=84?= =?UTF-8?q?=EB=9D=BD=20(#56)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/example/eumserver/domain/resume/ResumeMapper.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/example/eumserver/domain/resume/ResumeMapper.java b/src/main/java/com/example/eumserver/domain/resume/ResumeMapper.java index ab46be1..4f8ba27 100644 --- a/src/main/java/com/example/eumserver/domain/resume/ResumeMapper.java +++ b/src/main/java/com/example/eumserver/domain/resume/ResumeMapper.java @@ -15,6 +15,8 @@ public interface ResumeMapper { @Mapping(target = "id", ignore = true) @Mapping(target = "timeStamp", ignore = true) @Mapping(target = "user", ignore = true) + @Mapping(target = "resumeAnnouncement", ignore = true) + @Mapping(target = "isPublished", ignore = true) Resume resumeRequestToResume(ResumeRequest resumeRequest); @AfterMapping From 315f0145dcff7ed1e62968b60485f3a4c449d3aa Mon Sep 17 00:00:00 2001 From: Sukju Hong Date: Tue, 7 May 2024 15:08:31 +0900 Subject: [PATCH 05/22] =?UTF-8?q?refactor:=20announcement=20=EB=B6=84?= =?UTF-8?q?=EB=A6=AC=20(#56)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resume}/domain/ResumeAnnouncement.java | 2 +- .../resume}/dto/ResumeAnnouncementRequest.java | 2 +- .../resume}/mapper/ResumeAnnouncementMapper.java | 6 +++--- .../repository/ResumeAnnouncementRepository.java | 4 ++-- .../service/ResumeAnnouncementService.java | 10 +++++----- .../controller/TeamAnnouncementController.java | 16 ++++++++-------- .../team}/domain/OccupationClassification.java | 2 +- .../team}/domain/RecruitmentTypes.java | 2 +- .../team}/domain/TeamAnnouncement.java | 4 ++-- .../team}/dto/TeamAnnouncementFilter.java | 4 ++-- .../team}/dto/TeamAnnouncementRequest.java | 4 ++-- .../team}/dto/TeamAnnouncementResponse.java | 2 +- .../team}/dto/TeamAnnouncementUpdateRequest.java | 4 ++-- .../team}/mapper/TeamAnnouncementMapper.java | 8 ++++---- .../TeamAnnouncementCustomRepository.java | 8 ++++---- .../TeamAnnouncementCustomRepositoryImpl.java | 12 ++++++------ .../repository/TeamAnnouncementRepository.java | 4 ++-- .../team}/service/TeamAnnouncementService.java | 16 ++++++++-------- .../eumserver/domain/resume/entity/Resume.java | 2 +- .../com/example/eumserver/domain/team/Team.java | 2 +- .../controller/AnnouncementControllerTest.java | 10 +++++----- 21 files changed, 62 insertions(+), 62 deletions(-) rename src/main/java/com/example/eumserver/domain/{resume/announcement => announcement/resume}/domain/ResumeAnnouncement.java (89%) rename src/main/java/com/example/eumserver/domain/{resume/announcement => announcement/resume}/dto/ResumeAnnouncementRequest.java (55%) rename src/main/java/com/example/eumserver/domain/{resume/announcement => announcement/resume}/mapper/ResumeAnnouncementMapper.java (71%) rename src/main/java/com/example/eumserver/domain/{resume/announcement => announcement/resume}/repository/ResumeAnnouncementRepository.java (59%) rename src/main/java/com/example/eumserver/domain/{resume/announcement => announcement/resume}/service/ResumeAnnouncementService.java (84%) rename src/main/java/com/example/eumserver/domain/{team/announcement => announcement/team}/controller/TeamAnnouncementController.java (86%) rename src/main/java/com/example/eumserver/domain/{team/announcement => announcement/team}/domain/OccupationClassification.java (97%) rename src/main/java/com/example/eumserver/domain/{team/announcement => announcement/team}/domain/RecruitmentTypes.java (75%) rename src/main/java/com/example/eumserver/domain/{team/announcement => announcement/team}/domain/TeamAnnouncement.java (94%) rename src/main/java/com/example/eumserver/domain/{team/announcement => announcement/team}/dto/TeamAnnouncementFilter.java (59%) rename src/main/java/com/example/eumserver/domain/{team/announcement => announcement/team}/dto/TeamAnnouncementRequest.java (78%) rename src/main/java/com/example/eumserver/domain/{team/announcement => announcement/team}/dto/TeamAnnouncementResponse.java (61%) rename src/main/java/com/example/eumserver/domain/{team/announcement => announcement/team}/dto/TeamAnnouncementUpdateRequest.java (78%) rename src/main/java/com/example/eumserver/domain/{team/announcement => announcement/team}/mapper/TeamAnnouncementMapper.java (71%) rename src/main/java/com/example/eumserver/domain/{team/announcement => announcement/team}/repository/TeamAnnouncementCustomRepository.java (74%) rename src/main/java/com/example/eumserver/domain/{team/announcement => announcement/team}/repository/TeamAnnouncementCustomRepositoryImpl.java (85%) rename src/main/java/com/example/eumserver/domain/{team/announcement => announcement/team}/repository/TeamAnnouncementRepository.java (62%) rename src/main/java/com/example/eumserver/domain/{team/announcement => announcement/team}/service/TeamAnnouncementService.java (85%) diff --git a/src/main/java/com/example/eumserver/domain/resume/announcement/domain/ResumeAnnouncement.java b/src/main/java/com/example/eumserver/domain/announcement/resume/domain/ResumeAnnouncement.java similarity index 89% rename from src/main/java/com/example/eumserver/domain/resume/announcement/domain/ResumeAnnouncement.java rename to src/main/java/com/example/eumserver/domain/announcement/resume/domain/ResumeAnnouncement.java index 7b69960..53107de 100644 --- a/src/main/java/com/example/eumserver/domain/resume/announcement/domain/ResumeAnnouncement.java +++ b/src/main/java/com/example/eumserver/domain/announcement/resume/domain/ResumeAnnouncement.java @@ -1,4 +1,4 @@ -package com.example.eumserver.domain.resume.announcement.domain; +package com.example.eumserver.domain.announcement.resume.domain; import com.example.eumserver.domain.resume.entity.Resume; import jakarta.persistence.*; diff --git a/src/main/java/com/example/eumserver/domain/resume/announcement/dto/ResumeAnnouncementRequest.java b/src/main/java/com/example/eumserver/domain/announcement/resume/dto/ResumeAnnouncementRequest.java similarity index 55% rename from src/main/java/com/example/eumserver/domain/resume/announcement/dto/ResumeAnnouncementRequest.java rename to src/main/java/com/example/eumserver/domain/announcement/resume/dto/ResumeAnnouncementRequest.java index 4f6d42b..880406f 100644 --- a/src/main/java/com/example/eumserver/domain/resume/announcement/dto/ResumeAnnouncementRequest.java +++ b/src/main/java/com/example/eumserver/domain/announcement/resume/dto/ResumeAnnouncementRequest.java @@ -1,4 +1,4 @@ -package com.example.eumserver.domain.resume.announcement.dto; +package com.example.eumserver.domain.announcement.resume.dto; public record ResumeAnnouncementRequest( String introduction diff --git a/src/main/java/com/example/eumserver/domain/resume/announcement/mapper/ResumeAnnouncementMapper.java b/src/main/java/com/example/eumserver/domain/announcement/resume/mapper/ResumeAnnouncementMapper.java similarity index 71% rename from src/main/java/com/example/eumserver/domain/resume/announcement/mapper/ResumeAnnouncementMapper.java rename to src/main/java/com/example/eumserver/domain/announcement/resume/mapper/ResumeAnnouncementMapper.java index eff57e8..bddc6ae 100644 --- a/src/main/java/com/example/eumserver/domain/resume/announcement/mapper/ResumeAnnouncementMapper.java +++ b/src/main/java/com/example/eumserver/domain/announcement/resume/mapper/ResumeAnnouncementMapper.java @@ -1,7 +1,7 @@ -package com.example.eumserver.domain.resume.announcement.mapper; +package com.example.eumserver.domain.announcement.resume.mapper; -import com.example.eumserver.domain.resume.announcement.domain.ResumeAnnouncement; -import com.example.eumserver.domain.resume.announcement.dto.ResumeAnnouncementRequest; +import com.example.eumserver.domain.announcement.resume.domain.ResumeAnnouncement; +import com.example.eumserver.domain.announcement.resume.dto.ResumeAnnouncementRequest; import org.mapstruct.Mapper; import org.mapstruct.Mapping; import org.mapstruct.factory.Mappers; diff --git a/src/main/java/com/example/eumserver/domain/resume/announcement/repository/ResumeAnnouncementRepository.java b/src/main/java/com/example/eumserver/domain/announcement/resume/repository/ResumeAnnouncementRepository.java similarity index 59% rename from src/main/java/com/example/eumserver/domain/resume/announcement/repository/ResumeAnnouncementRepository.java rename to src/main/java/com/example/eumserver/domain/announcement/resume/repository/ResumeAnnouncementRepository.java index b470160..f43fd0e 100644 --- a/src/main/java/com/example/eumserver/domain/resume/announcement/repository/ResumeAnnouncementRepository.java +++ b/src/main/java/com/example/eumserver/domain/announcement/resume/repository/ResumeAnnouncementRepository.java @@ -1,6 +1,6 @@ -package com.example.eumserver.domain.resume.announcement.repository; +package com.example.eumserver.domain.announcement.resume.repository; -import com.example.eumserver.domain.resume.announcement.domain.ResumeAnnouncement; +import com.example.eumserver.domain.announcement.resume.domain.ResumeAnnouncement; import org.springframework.data.jpa.repository.JpaRepository; public interface ResumeAnnouncementRepository extends JpaRepository { } diff --git a/src/main/java/com/example/eumserver/domain/resume/announcement/service/ResumeAnnouncementService.java b/src/main/java/com/example/eumserver/domain/announcement/resume/service/ResumeAnnouncementService.java similarity index 84% rename from src/main/java/com/example/eumserver/domain/resume/announcement/service/ResumeAnnouncementService.java rename to src/main/java/com/example/eumserver/domain/announcement/resume/service/ResumeAnnouncementService.java index 6b0a06b..d82ec79 100644 --- a/src/main/java/com/example/eumserver/domain/resume/announcement/service/ResumeAnnouncementService.java +++ b/src/main/java/com/example/eumserver/domain/announcement/resume/service/ResumeAnnouncementService.java @@ -1,10 +1,10 @@ -package com.example.eumserver.domain.resume.announcement.service; +package com.example.eumserver.domain.announcement.resume.service; +import com.example.eumserver.domain.announcement.resume.mapper.ResumeAnnouncementMapper; +import com.example.eumserver.domain.announcement.resume.repository.ResumeAnnouncementRepository; import com.example.eumserver.domain.resume.ResumeRepository; -import com.example.eumserver.domain.resume.announcement.domain.ResumeAnnouncement; -import com.example.eumserver.domain.resume.announcement.dto.ResumeAnnouncementRequest; -import com.example.eumserver.domain.resume.announcement.mapper.ResumeAnnouncementMapper; -import com.example.eumserver.domain.resume.announcement.repository.ResumeAnnouncementRepository; +import com.example.eumserver.domain.announcement.resume.domain.ResumeAnnouncement; +import com.example.eumserver.domain.announcement.resume.dto.ResumeAnnouncementRequest; import com.example.eumserver.domain.resume.entity.Resume; import com.example.eumserver.global.error.exception.CustomException; import com.example.eumserver.global.error.exception.ErrorCode; diff --git a/src/main/java/com/example/eumserver/domain/team/announcement/controller/TeamAnnouncementController.java b/src/main/java/com/example/eumserver/domain/announcement/team/controller/TeamAnnouncementController.java similarity index 86% rename from src/main/java/com/example/eumserver/domain/team/announcement/controller/TeamAnnouncementController.java rename to src/main/java/com/example/eumserver/domain/announcement/team/controller/TeamAnnouncementController.java index 4039331..825adc8 100644 --- a/src/main/java/com/example/eumserver/domain/team/announcement/controller/TeamAnnouncementController.java +++ b/src/main/java/com/example/eumserver/domain/announcement/team/controller/TeamAnnouncementController.java @@ -1,12 +1,12 @@ -package com.example.eumserver.domain.team.announcement.controller; +package com.example.eumserver.domain.announcement.team.controller; -import com.example.eumserver.domain.team.announcement.domain.TeamAnnouncement; -import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementFilter; -import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementRequest; -import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementResponse; -import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementUpdateRequest; -import com.example.eumserver.domain.team.announcement.mapper.TeamAnnouncementMapper; -import com.example.eumserver.domain.team.announcement.service.TeamAnnouncementService; +import com.example.eumserver.domain.announcement.team.domain.TeamAnnouncement; +import com.example.eumserver.domain.announcement.team.dto.TeamAnnouncementFilter; +import com.example.eumserver.domain.announcement.team.dto.TeamAnnouncementRequest; +import com.example.eumserver.domain.announcement.team.dto.TeamAnnouncementResponse; +import com.example.eumserver.domain.announcement.team.dto.TeamAnnouncementUpdateRequest; +import com.example.eumserver.domain.announcement.team.mapper.TeamAnnouncementMapper; +import com.example.eumserver.domain.announcement.team.service.TeamAnnouncementService; import com.example.eumserver.global.dto.ApiResult; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; diff --git a/src/main/java/com/example/eumserver/domain/team/announcement/domain/OccupationClassification.java b/src/main/java/com/example/eumserver/domain/announcement/team/domain/OccupationClassification.java similarity index 97% rename from src/main/java/com/example/eumserver/domain/team/announcement/domain/OccupationClassification.java rename to src/main/java/com/example/eumserver/domain/announcement/team/domain/OccupationClassification.java index 15b819e..48ed6d8 100644 --- a/src/main/java/com/example/eumserver/domain/team/announcement/domain/OccupationClassification.java +++ b/src/main/java/com/example/eumserver/domain/announcement/team/domain/OccupationClassification.java @@ -1,4 +1,4 @@ -package com.example.eumserver.domain.team.announcement.domain; +package com.example.eumserver.domain.announcement.team.domain; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; diff --git a/src/main/java/com/example/eumserver/domain/team/announcement/domain/RecruitmentTypes.java b/src/main/java/com/example/eumserver/domain/announcement/team/domain/RecruitmentTypes.java similarity index 75% rename from src/main/java/com/example/eumserver/domain/team/announcement/domain/RecruitmentTypes.java rename to src/main/java/com/example/eumserver/domain/announcement/team/domain/RecruitmentTypes.java index 3d4919e..ca2efe8 100644 --- a/src/main/java/com/example/eumserver/domain/team/announcement/domain/RecruitmentTypes.java +++ b/src/main/java/com/example/eumserver/domain/announcement/team/domain/RecruitmentTypes.java @@ -1,4 +1,4 @@ -package com.example.eumserver.domain.team.announcement.domain; +package com.example.eumserver.domain.announcement.team.domain; /** * 모집 공고의 모집 유형을 나타낸 Enum Class 입니다. diff --git a/src/main/java/com/example/eumserver/domain/team/announcement/domain/TeamAnnouncement.java b/src/main/java/com/example/eumserver/domain/announcement/team/domain/TeamAnnouncement.java similarity index 94% rename from src/main/java/com/example/eumserver/domain/team/announcement/domain/TeamAnnouncement.java rename to src/main/java/com/example/eumserver/domain/announcement/team/domain/TeamAnnouncement.java index 5e33a8e..e2e4e99 100644 --- a/src/main/java/com/example/eumserver/domain/team/announcement/domain/TeamAnnouncement.java +++ b/src/main/java/com/example/eumserver/domain/announcement/team/domain/TeamAnnouncement.java @@ -1,7 +1,7 @@ -package com.example.eumserver.domain.team.announcement.domain; +package com.example.eumserver.domain.announcement.team.domain; +import com.example.eumserver.domain.announcement.team.dto.TeamAnnouncementUpdateRequest; import com.example.eumserver.domain.team.Team; -import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementUpdateRequest; import com.example.eumserver.global.dto.TimeStamp; import jakarta.persistence.*; import lombok.*; diff --git a/src/main/java/com/example/eumserver/domain/team/announcement/dto/TeamAnnouncementFilter.java b/src/main/java/com/example/eumserver/domain/announcement/team/dto/TeamAnnouncementFilter.java similarity index 59% rename from src/main/java/com/example/eumserver/domain/team/announcement/dto/TeamAnnouncementFilter.java rename to src/main/java/com/example/eumserver/domain/announcement/team/dto/TeamAnnouncementFilter.java index 87a325b..98a1906 100644 --- a/src/main/java/com/example/eumserver/domain/team/announcement/dto/TeamAnnouncementFilter.java +++ b/src/main/java/com/example/eumserver/domain/announcement/team/dto/TeamAnnouncementFilter.java @@ -1,6 +1,6 @@ -package com.example.eumserver.domain.team.announcement.dto; +package com.example.eumserver.domain.announcement.team.dto; -import com.example.eumserver.domain.team.announcement.domain.OccupationClassification; +import com.example.eumserver.domain.announcement.team.domain.OccupationClassification; import java.util.List; diff --git a/src/main/java/com/example/eumserver/domain/team/announcement/dto/TeamAnnouncementRequest.java b/src/main/java/com/example/eumserver/domain/announcement/team/dto/TeamAnnouncementRequest.java similarity index 78% rename from src/main/java/com/example/eumserver/domain/team/announcement/dto/TeamAnnouncementRequest.java rename to src/main/java/com/example/eumserver/domain/announcement/team/dto/TeamAnnouncementRequest.java index a3db462..65a87b1 100644 --- a/src/main/java/com/example/eumserver/domain/team/announcement/dto/TeamAnnouncementRequest.java +++ b/src/main/java/com/example/eumserver/domain/announcement/team/dto/TeamAnnouncementRequest.java @@ -1,6 +1,6 @@ -package com.example.eumserver.domain.team.announcement.dto; +package com.example.eumserver.domain.announcement.team.dto; -import com.example.eumserver.domain.team.announcement.domain.OccupationClassification; +import com.example.eumserver.domain.announcement.team.domain.OccupationClassification; import org.springframework.format.annotation.DateTimeFormat; import java.time.LocalDateTime; diff --git a/src/main/java/com/example/eumserver/domain/team/announcement/dto/TeamAnnouncementResponse.java b/src/main/java/com/example/eumserver/domain/announcement/team/dto/TeamAnnouncementResponse.java similarity index 61% rename from src/main/java/com/example/eumserver/domain/team/announcement/dto/TeamAnnouncementResponse.java rename to src/main/java/com/example/eumserver/domain/announcement/team/dto/TeamAnnouncementResponse.java index 50f7543..5702ec1 100644 --- a/src/main/java/com/example/eumserver/domain/team/announcement/dto/TeamAnnouncementResponse.java +++ b/src/main/java/com/example/eumserver/domain/announcement/team/dto/TeamAnnouncementResponse.java @@ -1,4 +1,4 @@ -package com.example.eumserver.domain.team.announcement.dto; +package com.example.eumserver.domain.announcement.team.dto; public record TeamAnnouncementResponse( String title, diff --git a/src/main/java/com/example/eumserver/domain/team/announcement/dto/TeamAnnouncementUpdateRequest.java b/src/main/java/com/example/eumserver/domain/announcement/team/dto/TeamAnnouncementUpdateRequest.java similarity index 78% rename from src/main/java/com/example/eumserver/domain/team/announcement/dto/TeamAnnouncementUpdateRequest.java rename to src/main/java/com/example/eumserver/domain/announcement/team/dto/TeamAnnouncementUpdateRequest.java index f6b7953..b400f6c 100644 --- a/src/main/java/com/example/eumserver/domain/team/announcement/dto/TeamAnnouncementUpdateRequest.java +++ b/src/main/java/com/example/eumserver/domain/announcement/team/dto/TeamAnnouncementUpdateRequest.java @@ -1,6 +1,6 @@ -package com.example.eumserver.domain.team.announcement.dto; +package com.example.eumserver.domain.announcement.team.dto; -import com.example.eumserver.domain.team.announcement.domain.OccupationClassification; +import com.example.eumserver.domain.announcement.team.domain.OccupationClassification; import org.springframework.format.annotation.DateTimeFormat; import java.time.LocalDateTime; diff --git a/src/main/java/com/example/eumserver/domain/team/announcement/mapper/TeamAnnouncementMapper.java b/src/main/java/com/example/eumserver/domain/announcement/team/mapper/TeamAnnouncementMapper.java similarity index 71% rename from src/main/java/com/example/eumserver/domain/team/announcement/mapper/TeamAnnouncementMapper.java rename to src/main/java/com/example/eumserver/domain/announcement/team/mapper/TeamAnnouncementMapper.java index 53966dc..1476835 100644 --- a/src/main/java/com/example/eumserver/domain/team/announcement/mapper/TeamAnnouncementMapper.java +++ b/src/main/java/com/example/eumserver/domain/announcement/team/mapper/TeamAnnouncementMapper.java @@ -1,8 +1,8 @@ -package com.example.eumserver.domain.team.announcement.mapper; +package com.example.eumserver.domain.announcement.team.mapper; -import com.example.eumserver.domain.team.announcement.domain.TeamAnnouncement; -import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementRequest; -import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementResponse; +import com.example.eumserver.domain.announcement.team.dto.TeamAnnouncementResponse; +import com.example.eumserver.domain.announcement.team.domain.TeamAnnouncement; +import com.example.eumserver.domain.announcement.team.dto.TeamAnnouncementRequest; import org.mapstruct.Mapper; import org.mapstruct.Mapping; import org.mapstruct.factory.Mappers; diff --git a/src/main/java/com/example/eumserver/domain/team/announcement/repository/TeamAnnouncementCustomRepository.java b/src/main/java/com/example/eumserver/domain/announcement/team/repository/TeamAnnouncementCustomRepository.java similarity index 74% rename from src/main/java/com/example/eumserver/domain/team/announcement/repository/TeamAnnouncementCustomRepository.java rename to src/main/java/com/example/eumserver/domain/announcement/team/repository/TeamAnnouncementCustomRepository.java index d1a7b27..43be412 100644 --- a/src/main/java/com/example/eumserver/domain/team/announcement/repository/TeamAnnouncementCustomRepository.java +++ b/src/main/java/com/example/eumserver/domain/announcement/team/repository/TeamAnnouncementCustomRepository.java @@ -1,8 +1,8 @@ -package com.example.eumserver.domain.team.announcement.repository; +package com.example.eumserver.domain.announcement.team.repository; -import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementFilter; -import com.example.eumserver.domain.team.announcement.domain.TeamAnnouncement; -import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementResponse; +import com.example.eumserver.domain.announcement.team.dto.TeamAnnouncementFilter; +import com.example.eumserver.domain.announcement.team.dto.TeamAnnouncementResponse; +import com.example.eumserver.domain.announcement.team.domain.TeamAnnouncement; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; diff --git a/src/main/java/com/example/eumserver/domain/team/announcement/repository/TeamAnnouncementCustomRepositoryImpl.java b/src/main/java/com/example/eumserver/domain/announcement/team/repository/TeamAnnouncementCustomRepositoryImpl.java similarity index 85% rename from src/main/java/com/example/eumserver/domain/team/announcement/repository/TeamAnnouncementCustomRepositoryImpl.java rename to src/main/java/com/example/eumserver/domain/announcement/team/repository/TeamAnnouncementCustomRepositoryImpl.java index 4bc44b3..1f99959 100644 --- a/src/main/java/com/example/eumserver/domain/team/announcement/repository/TeamAnnouncementCustomRepositoryImpl.java +++ b/src/main/java/com/example/eumserver/domain/announcement/team/repository/TeamAnnouncementCustomRepositoryImpl.java @@ -1,11 +1,11 @@ -package com.example.eumserver.domain.team.announcement.repository; +package com.example.eumserver.domain.announcement.team.repository; -import com.example.eumserver.domain.team.announcement.domain.OccupationClassification; +import com.example.eumserver.domain.announcement.team.dto.TeamAnnouncementFilter; +import com.example.eumserver.domain.announcement.team.dto.TeamAnnouncementResponse; +import com.example.eumserver.domain.announcement.team.mapper.TeamAnnouncementMapper; +import com.example.eumserver.domain.announcement.team.domain.OccupationClassification; import com.example.eumserver.domain.team.announcement.domain.QTeamAnnouncement; -import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementFilter; -import com.example.eumserver.domain.team.announcement.domain.TeamAnnouncement; -import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementResponse; -import com.example.eumserver.domain.team.announcement.mapper.TeamAnnouncementMapper; +import com.example.eumserver.domain.announcement.team.domain.TeamAnnouncement; import com.querydsl.core.types.dsl.BooleanExpression; import com.querydsl.jpa.impl.JPAQuery; import com.querydsl.jpa.impl.JPAQueryFactory; diff --git a/src/main/java/com/example/eumserver/domain/team/announcement/repository/TeamAnnouncementRepository.java b/src/main/java/com/example/eumserver/domain/announcement/team/repository/TeamAnnouncementRepository.java similarity index 62% rename from src/main/java/com/example/eumserver/domain/team/announcement/repository/TeamAnnouncementRepository.java rename to src/main/java/com/example/eumserver/domain/announcement/team/repository/TeamAnnouncementRepository.java index 7899d7f..dbee457 100644 --- a/src/main/java/com/example/eumserver/domain/team/announcement/repository/TeamAnnouncementRepository.java +++ b/src/main/java/com/example/eumserver/domain/announcement/team/repository/TeamAnnouncementRepository.java @@ -1,6 +1,6 @@ -package com.example.eumserver.domain.team.announcement.repository; +package com.example.eumserver.domain.announcement.team.repository; -import com.example.eumserver.domain.team.announcement.domain.TeamAnnouncement; +import com.example.eumserver.domain.announcement.team.domain.TeamAnnouncement; import org.springframework.data.jpa.repository.JpaRepository; public interface TeamAnnouncementRepository extends JpaRepository, TeamAnnouncementCustomRepository { diff --git a/src/main/java/com/example/eumserver/domain/team/announcement/service/TeamAnnouncementService.java b/src/main/java/com/example/eumserver/domain/announcement/team/service/TeamAnnouncementService.java similarity index 85% rename from src/main/java/com/example/eumserver/domain/team/announcement/service/TeamAnnouncementService.java rename to src/main/java/com/example/eumserver/domain/announcement/team/service/TeamAnnouncementService.java index 0e30e7a..84bba4d 100644 --- a/src/main/java/com/example/eumserver/domain/team/announcement/service/TeamAnnouncementService.java +++ b/src/main/java/com/example/eumserver/domain/announcement/team/service/TeamAnnouncementService.java @@ -1,14 +1,14 @@ -package com.example.eumserver.domain.team.announcement.service; +package com.example.eumserver.domain.announcement.team.service; import com.example.eumserver.domain.team.Team; import com.example.eumserver.domain.team.TeamService; -import com.example.eumserver.domain.team.announcement.domain.TeamAnnouncement; -import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementFilter; -import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementRequest; -import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementResponse; -import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementUpdateRequest; -import com.example.eumserver.domain.team.announcement.mapper.TeamAnnouncementMapper; -import com.example.eumserver.domain.team.announcement.repository.TeamAnnouncementRepository; +import com.example.eumserver.domain.announcement.team.domain.TeamAnnouncement; +import com.example.eumserver.domain.announcement.team.dto.TeamAnnouncementFilter; +import com.example.eumserver.domain.announcement.team.dto.TeamAnnouncementRequest; +import com.example.eumserver.domain.announcement.team.dto.TeamAnnouncementResponse; +import com.example.eumserver.domain.announcement.team.dto.TeamAnnouncementUpdateRequest; +import com.example.eumserver.domain.announcement.team.mapper.TeamAnnouncementMapper; +import com.example.eumserver.domain.announcement.team.repository.TeamAnnouncementRepository; import com.example.eumserver.global.error.exception.CustomException; import com.example.eumserver.global.error.exception.ErrorCode; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/example/eumserver/domain/resume/entity/Resume.java b/src/main/java/com/example/eumserver/domain/resume/entity/Resume.java index 68988d0..82b0717 100644 --- a/src/main/java/com/example/eumserver/domain/resume/entity/Resume.java +++ b/src/main/java/com/example/eumserver/domain/resume/entity/Resume.java @@ -1,6 +1,6 @@ package com.example.eumserver.domain.resume.entity; -import com.example.eumserver.domain.resume.announcement.domain.ResumeAnnouncement; +import com.example.eumserver.domain.announcement.resume.domain.ResumeAnnouncement; import com.example.eumserver.domain.user.User; import com.example.eumserver.global.dto.TimeStamp; import com.fasterxml.jackson.annotation.JsonIgnore; diff --git a/src/main/java/com/example/eumserver/domain/team/Team.java b/src/main/java/com/example/eumserver/domain/team/Team.java index 2333eba..41a4bad 100644 --- a/src/main/java/com/example/eumserver/domain/team/Team.java +++ b/src/main/java/com/example/eumserver/domain/team/Team.java @@ -1,6 +1,6 @@ package com.example.eumserver.domain.team; -import com.example.eumserver.domain.team.announcement.domain.TeamAnnouncement; +import com.example.eumserver.domain.announcement.team.domain.TeamAnnouncement; import com.example.eumserver.domain.team.participant.Participant; import com.fasterxml.jackson.annotation.JsonIgnore; import jakarta.persistence.*; diff --git a/src/test/java/com/example/eumserver/domain/team/announcement/controller/AnnouncementControllerTest.java b/src/test/java/com/example/eumserver/domain/team/announcement/controller/AnnouncementControllerTest.java index f29f518..aaabe86 100644 --- a/src/test/java/com/example/eumserver/domain/team/announcement/controller/AnnouncementControllerTest.java +++ b/src/test/java/com/example/eumserver/domain/team/announcement/controller/AnnouncementControllerTest.java @@ -2,11 +2,11 @@ import com.example.eumserver.BaseIntegrationTest; import com.example.eumserver.domain.team.Team; -import com.example.eumserver.domain.team.announcement.domain.TeamAnnouncement; -import com.example.eumserver.domain.team.announcement.domain.OccupationClassification; -import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementFilter; -import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementRequest; -import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementUpdateRequest; +import com.example.eumserver.domain.announcement.team.domain.TeamAnnouncement; +import com.example.eumserver.domain.announcement.team.domain.OccupationClassification; +import com.example.eumserver.domain.announcement.team.dto.TeamAnnouncementFilter; +import com.example.eumserver.domain.announcement.team.dto.TeamAnnouncementRequest; +import com.example.eumserver.domain.announcement.team.dto.TeamAnnouncementUpdateRequest; import jakarta.persistence.EntityManager; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; From 22c74499d91a30714a5e977de4898dca32c4b79c Mon Sep 17 00:00:00 2001 From: Sukju Hong Date: Tue, 7 May 2024 15:43:17 +0900 Subject: [PATCH 06/22] =?UTF-8?q?refactor:=20=EA=B3=B5=EA=B3=A0=20?= =?UTF-8?q?=ED=95=84=ED=84=B0=20=EB=AA=A8=EB=93=88=ED=99=94=20(#56)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/OccupationClassification.java | 2 +- .../domain/RecruitmentTypes.java | 2 +- .../ResumeAnnouncementController.java | 22 +++++++++++++++++++ .../team/domain/TeamAnnouncement.java | 1 + .../team/dto/TeamAnnouncementFilter.java | 2 +- .../team/dto/TeamAnnouncementRequest.java | 2 +- .../dto/TeamAnnouncementUpdateRequest.java | 2 +- .../TeamAnnouncementCustomRepositoryImpl.java | 2 +- .../AnnouncementControllerTest.java | 2 +- 9 files changed, 30 insertions(+), 7 deletions(-) rename src/main/java/com/example/eumserver/domain/announcement/{team => filter}/domain/OccupationClassification.java (97%) rename src/main/java/com/example/eumserver/domain/announcement/{team => filter}/domain/RecruitmentTypes.java (75%) create mode 100644 src/main/java/com/example/eumserver/domain/announcement/resume/controller/ResumeAnnouncementController.java diff --git a/src/main/java/com/example/eumserver/domain/announcement/team/domain/OccupationClassification.java b/src/main/java/com/example/eumserver/domain/announcement/filter/domain/OccupationClassification.java similarity index 97% rename from src/main/java/com/example/eumserver/domain/announcement/team/domain/OccupationClassification.java rename to src/main/java/com/example/eumserver/domain/announcement/filter/domain/OccupationClassification.java index 48ed6d8..2c42502 100644 --- a/src/main/java/com/example/eumserver/domain/announcement/team/domain/OccupationClassification.java +++ b/src/main/java/com/example/eumserver/domain/announcement/filter/domain/OccupationClassification.java @@ -1,4 +1,4 @@ -package com.example.eumserver.domain.announcement.team.domain; +package com.example.eumserver.domain.announcement.filter.domain; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; diff --git a/src/main/java/com/example/eumserver/domain/announcement/team/domain/RecruitmentTypes.java b/src/main/java/com/example/eumserver/domain/announcement/filter/domain/RecruitmentTypes.java similarity index 75% rename from src/main/java/com/example/eumserver/domain/announcement/team/domain/RecruitmentTypes.java rename to src/main/java/com/example/eumserver/domain/announcement/filter/domain/RecruitmentTypes.java index ca2efe8..deb122a 100644 --- a/src/main/java/com/example/eumserver/domain/announcement/team/domain/RecruitmentTypes.java +++ b/src/main/java/com/example/eumserver/domain/announcement/filter/domain/RecruitmentTypes.java @@ -1,4 +1,4 @@ -package com.example.eumserver.domain.announcement.team.domain; +package com.example.eumserver.domain.announcement.filter.domain; /** * 모집 공고의 모집 유형을 나타낸 Enum Class 입니다. diff --git a/src/main/java/com/example/eumserver/domain/announcement/resume/controller/ResumeAnnouncementController.java b/src/main/java/com/example/eumserver/domain/announcement/resume/controller/ResumeAnnouncementController.java new file mode 100644 index 0000000..eccef8e --- /dev/null +++ b/src/main/java/com/example/eumserver/domain/announcement/resume/controller/ResumeAnnouncementController.java @@ -0,0 +1,22 @@ +package com.example.eumserver.domain.announcement.resume.controller; + +import com.example.eumserver.domain.announcement.resume.domain.ResumeAnnouncement; +import com.example.eumserver.domain.announcement.resume.service.ResumeAnnouncementService; +import com.example.eumserver.domain.resume.entity.Resume; +import com.example.eumserver.global.dto.ApiResult; +import lombok.RequiredArgsConstructor; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/api/resume/{resumeId}/announcement") +@RequiredArgsConstructor +public class ResumeAnnouncementController { + + private final ResumeAnnouncementService resumeAnnouncementService; + + @PostMapping("") + public ResponseEntity> +} diff --git a/src/main/java/com/example/eumserver/domain/announcement/team/domain/TeamAnnouncement.java b/src/main/java/com/example/eumserver/domain/announcement/team/domain/TeamAnnouncement.java index e2e4e99..d1e49ea 100644 --- a/src/main/java/com/example/eumserver/domain/announcement/team/domain/TeamAnnouncement.java +++ b/src/main/java/com/example/eumserver/domain/announcement/team/domain/TeamAnnouncement.java @@ -1,5 +1,6 @@ package com.example.eumserver.domain.announcement.team.domain; +import com.example.eumserver.domain.announcement.filter.domain.OccupationClassification; import com.example.eumserver.domain.announcement.team.dto.TeamAnnouncementUpdateRequest; import com.example.eumserver.domain.team.Team; import com.example.eumserver.global.dto.TimeStamp; diff --git a/src/main/java/com/example/eumserver/domain/announcement/team/dto/TeamAnnouncementFilter.java b/src/main/java/com/example/eumserver/domain/announcement/team/dto/TeamAnnouncementFilter.java index 98a1906..b76ad9d 100644 --- a/src/main/java/com/example/eumserver/domain/announcement/team/dto/TeamAnnouncementFilter.java +++ b/src/main/java/com/example/eumserver/domain/announcement/team/dto/TeamAnnouncementFilter.java @@ -1,6 +1,6 @@ package com.example.eumserver.domain.announcement.team.dto; -import com.example.eumserver.domain.announcement.team.domain.OccupationClassification; +import com.example.eumserver.domain.announcement.filter.domain.OccupationClassification; import java.util.List; diff --git a/src/main/java/com/example/eumserver/domain/announcement/team/dto/TeamAnnouncementRequest.java b/src/main/java/com/example/eumserver/domain/announcement/team/dto/TeamAnnouncementRequest.java index 65a87b1..d923435 100644 --- a/src/main/java/com/example/eumserver/domain/announcement/team/dto/TeamAnnouncementRequest.java +++ b/src/main/java/com/example/eumserver/domain/announcement/team/dto/TeamAnnouncementRequest.java @@ -1,6 +1,6 @@ package com.example.eumserver.domain.announcement.team.dto; -import com.example.eumserver.domain.announcement.team.domain.OccupationClassification; +import com.example.eumserver.domain.announcement.filter.domain.OccupationClassification; import org.springframework.format.annotation.DateTimeFormat; import java.time.LocalDateTime; diff --git a/src/main/java/com/example/eumserver/domain/announcement/team/dto/TeamAnnouncementUpdateRequest.java b/src/main/java/com/example/eumserver/domain/announcement/team/dto/TeamAnnouncementUpdateRequest.java index b400f6c..ea5dbf8 100644 --- a/src/main/java/com/example/eumserver/domain/announcement/team/dto/TeamAnnouncementUpdateRequest.java +++ b/src/main/java/com/example/eumserver/domain/announcement/team/dto/TeamAnnouncementUpdateRequest.java @@ -1,6 +1,6 @@ package com.example.eumserver.domain.announcement.team.dto; -import com.example.eumserver.domain.announcement.team.domain.OccupationClassification; +import com.example.eumserver.domain.announcement.filter.domain.OccupationClassification; import org.springframework.format.annotation.DateTimeFormat; import java.time.LocalDateTime; diff --git a/src/main/java/com/example/eumserver/domain/announcement/team/repository/TeamAnnouncementCustomRepositoryImpl.java b/src/main/java/com/example/eumserver/domain/announcement/team/repository/TeamAnnouncementCustomRepositoryImpl.java index 1f99959..769c29f 100644 --- a/src/main/java/com/example/eumserver/domain/announcement/team/repository/TeamAnnouncementCustomRepositoryImpl.java +++ b/src/main/java/com/example/eumserver/domain/announcement/team/repository/TeamAnnouncementCustomRepositoryImpl.java @@ -3,7 +3,7 @@ import com.example.eumserver.domain.announcement.team.dto.TeamAnnouncementFilter; import com.example.eumserver.domain.announcement.team.dto.TeamAnnouncementResponse; import com.example.eumserver.domain.announcement.team.mapper.TeamAnnouncementMapper; -import com.example.eumserver.domain.announcement.team.domain.OccupationClassification; +import com.example.eumserver.domain.announcement.filter.domain.OccupationClassification; import com.example.eumserver.domain.team.announcement.domain.QTeamAnnouncement; import com.example.eumserver.domain.announcement.team.domain.TeamAnnouncement; import com.querydsl.core.types.dsl.BooleanExpression; diff --git a/src/test/java/com/example/eumserver/domain/team/announcement/controller/AnnouncementControllerTest.java b/src/test/java/com/example/eumserver/domain/team/announcement/controller/AnnouncementControllerTest.java index aaabe86..6363509 100644 --- a/src/test/java/com/example/eumserver/domain/team/announcement/controller/AnnouncementControllerTest.java +++ b/src/test/java/com/example/eumserver/domain/team/announcement/controller/AnnouncementControllerTest.java @@ -3,7 +3,7 @@ import com.example.eumserver.BaseIntegrationTest; import com.example.eumserver.domain.team.Team; import com.example.eumserver.domain.announcement.team.domain.TeamAnnouncement; -import com.example.eumserver.domain.announcement.team.domain.OccupationClassification; +import com.example.eumserver.domain.announcement.filter.domain.OccupationClassification; import com.example.eumserver.domain.announcement.team.dto.TeamAnnouncementFilter; import com.example.eumserver.domain.announcement.team.dto.TeamAnnouncementRequest; import com.example.eumserver.domain.announcement.team.dto.TeamAnnouncementUpdateRequest; From 70af6a18da42797068a5d7368ca402ba26483ad7 Mon Sep 17 00:00:00 2001 From: Sukju Hong Date: Tue, 7 May 2024 15:51:39 +0900 Subject: [PATCH 07/22] =?UTF-8?q?feat:=20=EC=9D=B4=EB=A0=A5=EC=84=9C=20?= =?UTF-8?q?=EA=B3=B5=EA=B3=A0=20endpoint=20=EC=83=9D=EC=84=B1=20(#56)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ResumeAnnouncementController.java | 28 +++++++++++++++---- .../service/ResumeAnnouncementService.java | 5 ++-- .../team/service/TeamAnnouncementService.java | 2 +- .../global/error/exception/ErrorCode.java | 4 ++- 4 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/example/eumserver/domain/announcement/resume/controller/ResumeAnnouncementController.java b/src/main/java/com/example/eumserver/domain/announcement/resume/controller/ResumeAnnouncementController.java index eccef8e..f553f88 100644 --- a/src/main/java/com/example/eumserver/domain/announcement/resume/controller/ResumeAnnouncementController.java +++ b/src/main/java/com/example/eumserver/domain/announcement/resume/controller/ResumeAnnouncementController.java @@ -1,14 +1,12 @@ package com.example.eumserver.domain.announcement.resume.controller; -import com.example.eumserver.domain.announcement.resume.domain.ResumeAnnouncement; +import com.example.eumserver.domain.announcement.resume.dto.ResumeAnnouncementRequest; import com.example.eumserver.domain.announcement.resume.service.ResumeAnnouncementService; -import com.example.eumserver.domain.resume.entity.Resume; import com.example.eumserver.global.dto.ApiResult; import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; @RestController @RequestMapping("/api/resume/{resumeId}/announcement") @@ -18,5 +16,23 @@ public class ResumeAnnouncementController { private final ResumeAnnouncementService resumeAnnouncementService; @PostMapping("") - public ResponseEntity> + @ResponseStatus(HttpStatus.CREATED) + public ResponseEntity> createResumeAnnouncement( + @PathVariable Long resumeId, + @RequestBody ResumeAnnouncementRequest request) { + resumeAnnouncementService.publishResume(resumeId, request); + return ResponseEntity + .status(HttpStatus.CREATED) + .body(new ApiResult<>("이력서 공고 생성")); + } + + @DeleteMapping("/{resumeAnnouncementId}") + public ResponseEntity> deleteResumeAnnouncement( + @PathVariable Long resumeId, + @PathVariable Long resumeAnnouncementId) { + resumeAnnouncementService.unpublishResume(resumeId, resumeAnnouncementId); + return ResponseEntity + .status(HttpStatus.CREATED) + .body(new ApiResult<>("이력서 공고 생성")); + } } diff --git a/src/main/java/com/example/eumserver/domain/announcement/resume/service/ResumeAnnouncementService.java b/src/main/java/com/example/eumserver/domain/announcement/resume/service/ResumeAnnouncementService.java index d82ec79..037932a 100644 --- a/src/main/java/com/example/eumserver/domain/announcement/resume/service/ResumeAnnouncementService.java +++ b/src/main/java/com/example/eumserver/domain/announcement/resume/service/ResumeAnnouncementService.java @@ -32,10 +32,11 @@ public ResumeAnnouncement publishResume(Long resumeId, ResumeAnnouncementRequest return resumeAnnouncementRepository.save(resumeAnnouncement); } - public void unpublishResume(Long resumeId) { + public void unpublishResume(Long resumeId, Long resumeAnnouncementId) { Resume resume = resumeRepository.findById(resumeId) .orElseThrow(() -> new CustomException(ErrorCode.RESUME_NOT_FOUND)); - ResumeAnnouncement resumeAnnouncement = resume.getResumeAnnouncement(); + ResumeAnnouncement resumeAnnouncement = resumeAnnouncementRepository.findById(resumeAnnouncementId) + .orElseThrow(() -> new CustomException(ErrorCode.RESUME_ANNOUNCEMENT_NOT_FOUND)); resume.unpublishResume(); resumeRepository.save(resume); diff --git a/src/main/java/com/example/eumserver/domain/announcement/team/service/TeamAnnouncementService.java b/src/main/java/com/example/eumserver/domain/announcement/team/service/TeamAnnouncementService.java index 84bba4d..3b4c720 100644 --- a/src/main/java/com/example/eumserver/domain/announcement/team/service/TeamAnnouncementService.java +++ b/src/main/java/com/example/eumserver/domain/announcement/team/service/TeamAnnouncementService.java @@ -74,6 +74,6 @@ public void deleteAnnouncement(Long announcementId) { public TeamAnnouncement findAnnouncementById(Long announcementId) { return announcementRepository.findById(announcementId) - .orElseThrow(() -> new CustomException(ErrorCode.ANNOUNCEMENT_NOT_FOUND)); + .orElseThrow(() -> new CustomException(ErrorCode.TEAM_ANNOUNCEMENT_NOT_FOUND)); } } diff --git a/src/main/java/com/example/eumserver/global/error/exception/ErrorCode.java b/src/main/java/com/example/eumserver/global/error/exception/ErrorCode.java index 225f7d1..115e9b7 100644 --- a/src/main/java/com/example/eumserver/global/error/exception/ErrorCode.java +++ b/src/main/java/com/example/eumserver/global/error/exception/ErrorCode.java @@ -30,7 +30,9 @@ public enum ErrorCode { INVITE_NOT_FOUND(400, "INVITE-001", "초대를 찾을 수 없음"), EXPIRED_INVITE(400, "INVITE-002", "해당 초대가 만료됨"), - ANNOUNCEMENT_NOT_FOUND(400, "ANNOUNCEMENT-001", "팀 공고를 찾을 수 없음"); + TEAM_ANNOUNCEMENT_NOT_FOUND(400, "TEAM-ANNOUNCEMENT-001", "팀 공고를 찾을 수 없음"), + + RESUME_ANNOUNCEMENT_NOT_FOUND(400, "RESUME-ANNOUNCEMENT-001", "이력서 공고를 찾을 수 없음."); private final int status; private final String code; From e92075abdc89847a06911db110bc39937af42efb Mon Sep 17 00:00:00 2001 From: Sukju Hong Date: Tue, 7 May 2024 15:52:26 +0900 Subject: [PATCH 08/22] =?UTF-8?q?chore:=20publishResume=20return=20?= =?UTF-8?q?=EA=B0=92=20=EB=B3=80=EA=B2=BD=20(#56)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resume/service/ResumeAnnouncementService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/example/eumserver/domain/announcement/resume/service/ResumeAnnouncementService.java b/src/main/java/com/example/eumserver/domain/announcement/resume/service/ResumeAnnouncementService.java index 037932a..06966ed 100644 --- a/src/main/java/com/example/eumserver/domain/announcement/resume/service/ResumeAnnouncementService.java +++ b/src/main/java/com/example/eumserver/domain/announcement/resume/service/ResumeAnnouncementService.java @@ -20,7 +20,7 @@ public class ResumeAnnouncementService { private final ResumeRepository resumeRepository; private final ResumeAnnouncementRepository resumeAnnouncementRepository; - public ResumeAnnouncement publishResume(Long resumeId, ResumeAnnouncementRequest resumeAnnouncementRequest) { + public void publishResume(Long resumeId, ResumeAnnouncementRequest resumeAnnouncementRequest) { Resume resume = resumeRepository.findById(resumeId) .orElseThrow(() -> new CustomException(ErrorCode.RESUME_NOT_FOUND)); @@ -29,7 +29,7 @@ public ResumeAnnouncement publishResume(Long resumeId, ResumeAnnouncementRequest resume.publishResume(resumeAnnouncement); resumeRepository.save(resume); - return resumeAnnouncementRepository.save(resumeAnnouncement); + resumeAnnouncementRepository.save(resumeAnnouncement); } public void unpublishResume(Long resumeId, Long resumeAnnouncementId) { From 8d2a412fa87f9b8b912a5c55818aaabc0c64770a Mon Sep 17 00:00:00 2001 From: Sukju Hong Date: Tue, 7 May 2024 15:56:56 +0900 Subject: [PATCH 09/22] =?UTF-8?q?fix:=20=ED=8C=80=20=EA=B3=B5=EA=B3=A0=20i?= =?UTF-8?q?mport=20=EC=98=A4=EB=A5=98=20(#56)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../team/repository/TeamAnnouncementCustomRepositoryImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/example/eumserver/domain/announcement/team/repository/TeamAnnouncementCustomRepositoryImpl.java b/src/main/java/com/example/eumserver/domain/announcement/team/repository/TeamAnnouncementCustomRepositoryImpl.java index 769c29f..dff1904 100644 --- a/src/main/java/com/example/eumserver/domain/announcement/team/repository/TeamAnnouncementCustomRepositoryImpl.java +++ b/src/main/java/com/example/eumserver/domain/announcement/team/repository/TeamAnnouncementCustomRepositoryImpl.java @@ -1,10 +1,10 @@ package com.example.eumserver.domain.announcement.team.repository; +import com.example.eumserver.domain.announcement.team.domain.QTeamAnnouncement; import com.example.eumserver.domain.announcement.team.dto.TeamAnnouncementFilter; import com.example.eumserver.domain.announcement.team.dto.TeamAnnouncementResponse; import com.example.eumserver.domain.announcement.team.mapper.TeamAnnouncementMapper; import com.example.eumserver.domain.announcement.filter.domain.OccupationClassification; -import com.example.eumserver.domain.team.announcement.domain.QTeamAnnouncement; import com.example.eumserver.domain.announcement.team.domain.TeamAnnouncement; import com.querydsl.core.types.dsl.BooleanExpression; import com.querydsl.jpa.impl.JPAQuery; From eaad3d97d70931b1be4a337f47340279a6a600a7 Mon Sep 17 00:00:00 2001 From: Sukju Hong Date: Tue, 7 May 2024 16:01:07 +0900 Subject: [PATCH 10/22] =?UTF-8?q?refactor:=20TeamAnnouncementControllerTes?= =?UTF-8?q?t=EB=A1=9C=20=EB=B3=80=EA=B2=BD=20(#56)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../team/controller/TeamAnnouncementControllerTest.java} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename src/test/java/com/example/eumserver/domain/{team/announcement/controller/AnnouncementControllerTest.java => announcement/team/controller/TeamAnnouncementControllerTest.java} (98%) diff --git a/src/test/java/com/example/eumserver/domain/team/announcement/controller/AnnouncementControllerTest.java b/src/test/java/com/example/eumserver/domain/announcement/team/controller/TeamAnnouncementControllerTest.java similarity index 98% rename from src/test/java/com/example/eumserver/domain/team/announcement/controller/AnnouncementControllerTest.java rename to src/test/java/com/example/eumserver/domain/announcement/team/controller/TeamAnnouncementControllerTest.java index 6363509..033d8d2 100644 --- a/src/test/java/com/example/eumserver/domain/team/announcement/controller/AnnouncementControllerTest.java +++ b/src/test/java/com/example/eumserver/domain/announcement/team/controller/TeamAnnouncementControllerTest.java @@ -1,4 +1,4 @@ -package com.example.eumserver.domain.team.announcement.controller; +package com.example.eumserver.domain.announcement.team.controller; import com.example.eumserver.BaseIntegrationTest; import com.example.eumserver.domain.team.Team; @@ -24,7 +24,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -class AnnouncementControllerTest extends BaseIntegrationTest { +class TeamAnnouncementControllerTest extends BaseIntegrationTest { final String BASE_URI = "/api/team/{teamId}/announcement"; From 43fc838fbd097b1ab55d89dba75b5dd234a65fdc Mon Sep 17 00:00:00 2001 From: Sukju Hong Date: Tue, 7 May 2024 16:34:13 +0900 Subject: [PATCH 11/22] =?UTF-8?q?feat:=20=EC=9D=B4=EB=A0=A5=EC=84=9C=20?= =?UTF-8?q?=EA=B3=B5=EA=B3=A0=20=ED=95=84=ED=84=B0=EB=A7=81=20=EB=B0=8F=20?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=A7=95=20(#56)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ResumeAnnouncementController.java | 20 +++++-- .../resume/domain/ResumeAnnouncement.java | 14 ++++- .../resume/dto/ResumeAnnouncementFilter.java | 10 ++++ .../resume/dto/ResumeAnnouncementRequest.java | 1 + .../dto/ResumeAnnouncementResponse.java | 13 ++++ .../ResumeAnnouncementCustomRepository.java | 11 ++++ ...esumeAnnouncementCustomRepositoryImpl.java | 59 +++++++++++++++++++ .../ResumeAnnouncementRepository.java | 2 +- .../service/ResumeAnnouncementService.java | 30 ++++++---- .../eumserver/domain/resume/ResumeMapper.java | 2 - .../domain/resume/ResumeRepository.java | 3 +- .../domain/resume/entity/Resume.java | 17 ------ 12 files changed, 144 insertions(+), 38 deletions(-) create mode 100644 src/main/java/com/example/eumserver/domain/announcement/resume/dto/ResumeAnnouncementFilter.java create mode 100644 src/main/java/com/example/eumserver/domain/announcement/resume/dto/ResumeAnnouncementResponse.java create mode 100644 src/main/java/com/example/eumserver/domain/announcement/resume/repository/ResumeAnnouncementCustomRepository.java create mode 100644 src/main/java/com/example/eumserver/domain/announcement/resume/repository/ResumeAnnouncementCustomRepositoryImpl.java diff --git a/src/main/java/com/example/eumserver/domain/announcement/resume/controller/ResumeAnnouncementController.java b/src/main/java/com/example/eumserver/domain/announcement/resume/controller/ResumeAnnouncementController.java index f553f88..121de60 100644 --- a/src/main/java/com/example/eumserver/domain/announcement/resume/controller/ResumeAnnouncementController.java +++ b/src/main/java/com/example/eumserver/domain/announcement/resume/controller/ResumeAnnouncementController.java @@ -1,15 +1,18 @@ package com.example.eumserver.domain.announcement.resume.controller; +import com.example.eumserver.domain.announcement.resume.dto.ResumeAnnouncementFilter; import com.example.eumserver.domain.announcement.resume.dto.ResumeAnnouncementRequest; +import com.example.eumserver.domain.announcement.resume.dto.ResumeAnnouncementResponse; import com.example.eumserver.domain.announcement.resume.service.ResumeAnnouncementService; import com.example.eumserver.global.dto.ApiResult; import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Page; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; @RestController -@RequestMapping("/api/resume/{resumeId}/announcement") +@RequestMapping("/api/resume-announcement") @RequiredArgsConstructor public class ResumeAnnouncementController { @@ -18,9 +21,8 @@ public class ResumeAnnouncementController { @PostMapping("") @ResponseStatus(HttpStatus.CREATED) public ResponseEntity> createResumeAnnouncement( - @PathVariable Long resumeId, @RequestBody ResumeAnnouncementRequest request) { - resumeAnnouncementService.publishResume(resumeId, request); + resumeAnnouncementService.publishResume(request); return ResponseEntity .status(HttpStatus.CREATED) .body(new ApiResult<>("이력서 공고 생성")); @@ -28,11 +30,19 @@ public ResponseEntity> createResumeAnnouncement( @DeleteMapping("/{resumeAnnouncementId}") public ResponseEntity> deleteResumeAnnouncement( - @PathVariable Long resumeId, @PathVariable Long resumeAnnouncementId) { - resumeAnnouncementService.unpublishResume(resumeId, resumeAnnouncementId); + resumeAnnouncementService.unpublishResume(resumeAnnouncementId); return ResponseEntity .status(HttpStatus.CREATED) .body(new ApiResult<>("이력서 공고 생성")); } + + @GetMapping("") + public ResponseEntity>> getResumeAnnouncements( + @RequestBody ResumeAnnouncementFilter filter, + @RequestParam(name = "page", defaultValue = "0") int page + ) { + Page resumeAnnouncementResponses = resumeAnnouncementService.getResumeAnnouncements(filter, page); + return ResponseEntity.ok(new ApiResult<>("이력서 공고 필터링 및 페이징 조회 성공", resumeAnnouncementResponses)); + } } diff --git a/src/main/java/com/example/eumserver/domain/announcement/resume/domain/ResumeAnnouncement.java b/src/main/java/com/example/eumserver/domain/announcement/resume/domain/ResumeAnnouncement.java index 53107de..f38e06c 100644 --- a/src/main/java/com/example/eumserver/domain/announcement/resume/domain/ResumeAnnouncement.java +++ b/src/main/java/com/example/eumserver/domain/announcement/resume/domain/ResumeAnnouncement.java @@ -1,9 +1,13 @@ package com.example.eumserver.domain.announcement.resume.domain; +import com.example.eumserver.domain.announcement.filter.domain.OccupationClassification; import com.example.eumserver.domain.resume.entity.Resume; +import com.example.eumserver.global.dto.TimeStamp; import jakarta.persistence.*; import lombok.*; +import java.util.List; + @Entity @Table(name = "resume_announcements") @Getter @@ -20,7 +24,15 @@ public class ResumeAnnouncement { @Column(nullable = false) private String introduction; + @ElementCollection(targetClass = OccupationClassification.class) + @Enumerated(EnumType.STRING) + private List occupationClassifications; + @Setter - @OneToOne(mappedBy = "resumeAnnouncement") + @OneToOne(fetch = FetchType.LAZY, orphanRemoval = true) + @JoinColumn(name = "resume_id") private Resume resume; + + @Embedded + private TimeStamp timeStamp; } diff --git a/src/main/java/com/example/eumserver/domain/announcement/resume/dto/ResumeAnnouncementFilter.java b/src/main/java/com/example/eumserver/domain/announcement/resume/dto/ResumeAnnouncementFilter.java new file mode 100644 index 0000000..0148a49 --- /dev/null +++ b/src/main/java/com/example/eumserver/domain/announcement/resume/dto/ResumeAnnouncementFilter.java @@ -0,0 +1,10 @@ +package com.example.eumserver.domain.announcement.resume.dto; + +import com.example.eumserver.domain.announcement.filter.domain.OccupationClassification; + +import java.util.List; + +public record ResumeAnnouncementFilter( + List occupationClassifications +) { +} diff --git a/src/main/java/com/example/eumserver/domain/announcement/resume/dto/ResumeAnnouncementRequest.java b/src/main/java/com/example/eumserver/domain/announcement/resume/dto/ResumeAnnouncementRequest.java index 880406f..2347466 100644 --- a/src/main/java/com/example/eumserver/domain/announcement/resume/dto/ResumeAnnouncementRequest.java +++ b/src/main/java/com/example/eumserver/domain/announcement/resume/dto/ResumeAnnouncementRequest.java @@ -1,6 +1,7 @@ package com.example.eumserver.domain.announcement.resume.dto; public record ResumeAnnouncementRequest( + Long resumeId, String introduction ) { } diff --git a/src/main/java/com/example/eumserver/domain/announcement/resume/dto/ResumeAnnouncementResponse.java b/src/main/java/com/example/eumserver/domain/announcement/resume/dto/ResumeAnnouncementResponse.java new file mode 100644 index 0000000..dfc57c1 --- /dev/null +++ b/src/main/java/com/example/eumserver/domain/announcement/resume/dto/ResumeAnnouncementResponse.java @@ -0,0 +1,13 @@ +package com.example.eumserver.domain.announcement.resume.dto; + +import com.example.eumserver.domain.announcement.filter.domain.OccupationClassification; + +import java.util.List; + +public record ResumeAnnouncementResponse( + Long id, + Long resumeId, + String introduction, + List occupationClassifications +) { +} diff --git a/src/main/java/com/example/eumserver/domain/announcement/resume/repository/ResumeAnnouncementCustomRepository.java b/src/main/java/com/example/eumserver/domain/announcement/resume/repository/ResumeAnnouncementCustomRepository.java new file mode 100644 index 0000000..033315e --- /dev/null +++ b/src/main/java/com/example/eumserver/domain/announcement/resume/repository/ResumeAnnouncementCustomRepository.java @@ -0,0 +1,11 @@ +package com.example.eumserver.domain.announcement.resume.repository; + +import com.example.eumserver.domain.announcement.resume.dto.ResumeAnnouncementFilter; +import com.example.eumserver.domain.announcement.resume.dto.ResumeAnnouncementResponse; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; + +public interface ResumeAnnouncementCustomRepository { + + Page findResumeAnnouncementsWithFilteredAndPagination(ResumeAnnouncementFilter filter, Pageable pageable); +} diff --git a/src/main/java/com/example/eumserver/domain/announcement/resume/repository/ResumeAnnouncementCustomRepositoryImpl.java b/src/main/java/com/example/eumserver/domain/announcement/resume/repository/ResumeAnnouncementCustomRepositoryImpl.java new file mode 100644 index 0000000..3c8512e --- /dev/null +++ b/src/main/java/com/example/eumserver/domain/announcement/resume/repository/ResumeAnnouncementCustomRepositoryImpl.java @@ -0,0 +1,59 @@ +package com.example.eumserver.domain.announcement.resume.repository; + +import com.example.eumserver.domain.announcement.filter.domain.OccupationClassification; +import com.example.eumserver.domain.announcement.resume.domain.QResumeAnnouncement; +import com.example.eumserver.domain.announcement.resume.domain.ResumeAnnouncement; +import com.example.eumserver.domain.announcement.resume.dto.ResumeAnnouncementFilter; +import com.example.eumserver.domain.announcement.resume.dto.ResumeAnnouncementResponse; +import com.querydsl.core.types.dsl.BooleanExpression; +import com.querydsl.jpa.impl.JPAQuery; +import com.querydsl.jpa.impl.JPAQueryFactory; +import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.support.PageableExecutionUtils; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +@RequiredArgsConstructor +public class ResumeAnnouncementCustomRepositoryImpl implements ResumeAnnouncementCustomRepository { + + private final JPAQueryFactory queryFactory; + + @Override + public Page findResumeAnnouncementsWithFilteredAndPagination(ResumeAnnouncementFilter filter, Pageable pageable) { + + QResumeAnnouncement resumeAnnouncement = QResumeAnnouncement.resumeAnnouncement; + BooleanExpression predicate = resumeAnnouncement.isNotNull(); + + List occupationClassifications = filter.occupationClassifications(); + if (occupationClassifications != null && !occupationClassifications.isEmpty()) { + predicate = predicate.and(resumeAnnouncement.occupationClassifications.any().in(occupationClassifications)); + } + + List announcements = queryFactory + .select(resumeAnnouncement) + .where(predicate) + .offset(pageable.getOffset()) + .limit(pageable.getPageSize()) + .fetch(); + + List resumeAnnouncementResponses = announcements.stream() + .map(announcement -> + new ResumeAnnouncementResponse( + announcement.getId(), + announcement.getResume().getId(), + announcement.getIntroduction(), + announcement.getOccupationClassifications())).toList(); + + JPAQuery count = queryFactory + .select(resumeAnnouncement.count()) + .from(resumeAnnouncement) + .where(predicate); + + return PageableExecutionUtils.getPage(resumeAnnouncementResponses, pageable, count::fetchOne); + } + +} diff --git a/src/main/java/com/example/eumserver/domain/announcement/resume/repository/ResumeAnnouncementRepository.java b/src/main/java/com/example/eumserver/domain/announcement/resume/repository/ResumeAnnouncementRepository.java index f43fd0e..2904ea5 100644 --- a/src/main/java/com/example/eumserver/domain/announcement/resume/repository/ResumeAnnouncementRepository.java +++ b/src/main/java/com/example/eumserver/domain/announcement/resume/repository/ResumeAnnouncementRepository.java @@ -3,4 +3,4 @@ import com.example.eumserver.domain.announcement.resume.domain.ResumeAnnouncement; import org.springframework.data.jpa.repository.JpaRepository; -public interface ResumeAnnouncementRepository extends JpaRepository { } +public interface ResumeAnnouncementRepository extends JpaRepository, ResumeAnnouncementCustomRepository { } diff --git a/src/main/java/com/example/eumserver/domain/announcement/resume/service/ResumeAnnouncementService.java b/src/main/java/com/example/eumserver/domain/announcement/resume/service/ResumeAnnouncementService.java index 06966ed..79049ad 100644 --- a/src/main/java/com/example/eumserver/domain/announcement/resume/service/ResumeAnnouncementService.java +++ b/src/main/java/com/example/eumserver/domain/announcement/resume/service/ResumeAnnouncementService.java @@ -1,5 +1,7 @@ package com.example.eumserver.domain.announcement.resume.service; +import com.example.eumserver.domain.announcement.resume.dto.ResumeAnnouncementFilter; +import com.example.eumserver.domain.announcement.resume.dto.ResumeAnnouncementResponse; import com.example.eumserver.domain.announcement.resume.mapper.ResumeAnnouncementMapper; import com.example.eumserver.domain.announcement.resume.repository.ResumeAnnouncementRepository; import com.example.eumserver.domain.resume.ResumeRepository; @@ -9,9 +11,16 @@ import com.example.eumserver.global.error.exception.CustomException; import com.example.eumserver.global.error.exception.ErrorCode; import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.util.ArrayList; +import java.util.List; + @Service @RequiredArgsConstructor @Transactional(readOnly = true) @@ -20,27 +29,26 @@ public class ResumeAnnouncementService { private final ResumeRepository resumeRepository; private final ResumeAnnouncementRepository resumeAnnouncementRepository; - public void publishResume(Long resumeId, ResumeAnnouncementRequest resumeAnnouncementRequest) { - Resume resume = resumeRepository.findById(resumeId) + public void publishResume(ResumeAnnouncementRequest resumeAnnouncementRequest) { + Resume resume = resumeRepository.findById(resumeAnnouncementRequest.resumeId()) .orElseThrow(() -> new CustomException(ErrorCode.RESUME_NOT_FOUND)); ResumeAnnouncement resumeAnnouncement = ResumeAnnouncementMapper.INSTANCE .requestToEntity(resumeAnnouncementRequest); - - resume.publishResume(resumeAnnouncement); - resumeRepository.save(resume); + resumeAnnouncement.setResume(resume); resumeAnnouncementRepository.save(resumeAnnouncement); } - public void unpublishResume(Long resumeId, Long resumeAnnouncementId) { - Resume resume = resumeRepository.findById(resumeId) - .orElseThrow(() -> new CustomException(ErrorCode.RESUME_NOT_FOUND)); + public void unpublishResume(Long resumeAnnouncementId) { ResumeAnnouncement resumeAnnouncement = resumeAnnouncementRepository.findById(resumeAnnouncementId) .orElseThrow(() -> new CustomException(ErrorCode.RESUME_ANNOUNCEMENT_NOT_FOUND)); - - resume.unpublishResume(); - resumeRepository.save(resume); resumeAnnouncementRepository.delete(resumeAnnouncement); } + public Page getResumeAnnouncements(ResumeAnnouncementFilter filter, int page) { + List sorts = new ArrayList<>(); + sorts.add(Sort.Order.desc("date_created")); + Pageable pageable = PageRequest.of(page, 12, Sort.by(sorts)); + return resumeRepository.findResumeAnnouncementsWithFilteredAndPagination(filter, pageable); + } } diff --git a/src/main/java/com/example/eumserver/domain/resume/ResumeMapper.java b/src/main/java/com/example/eumserver/domain/resume/ResumeMapper.java index 4f8ba27..ab46be1 100644 --- a/src/main/java/com/example/eumserver/domain/resume/ResumeMapper.java +++ b/src/main/java/com/example/eumserver/domain/resume/ResumeMapper.java @@ -15,8 +15,6 @@ public interface ResumeMapper { @Mapping(target = "id", ignore = true) @Mapping(target = "timeStamp", ignore = true) @Mapping(target = "user", ignore = true) - @Mapping(target = "resumeAnnouncement", ignore = true) - @Mapping(target = "isPublished", ignore = true) Resume resumeRequestToResume(ResumeRequest resumeRequest); @AfterMapping diff --git a/src/main/java/com/example/eumserver/domain/resume/ResumeRepository.java b/src/main/java/com/example/eumserver/domain/resume/ResumeRepository.java index 9a1d01c..7b488a4 100644 --- a/src/main/java/com/example/eumserver/domain/resume/ResumeRepository.java +++ b/src/main/java/com/example/eumserver/domain/resume/ResumeRepository.java @@ -1,12 +1,13 @@ package com.example.eumserver.domain.resume; +import com.example.eumserver.domain.announcement.resume.repository.ResumeAnnouncementCustomRepository; import com.example.eumserver.domain.resume.entity.Resume; import org.springframework.data.jpa.repository.JpaRepository; import java.util.List; import java.util.Optional; -public interface ResumeRepository extends JpaRepository { +public interface ResumeRepository extends JpaRepository, ResumeAnnouncementCustomRepository { Optional findById(Long resumeId); List findByUserId(Long userId); } diff --git a/src/main/java/com/example/eumserver/domain/resume/entity/Resume.java b/src/main/java/com/example/eumserver/domain/resume/entity/Resume.java index 82b0717..944aa83 100644 --- a/src/main/java/com/example/eumserver/domain/resume/entity/Resume.java +++ b/src/main/java/com/example/eumserver/domain/resume/entity/Resume.java @@ -1,6 +1,5 @@ package com.example.eumserver.domain.resume.entity; -import com.example.eumserver.domain.announcement.resume.domain.ResumeAnnouncement; import com.example.eumserver.domain.user.User; import com.example.eumserver.global.dto.TimeStamp; import com.fasterxml.jackson.annotation.JsonIgnore; @@ -65,12 +64,6 @@ public class Resume { @OneToMany(mappedBy = "resume", cascade = CascadeType.ALL, orphanRemoval = true) private List homepages = new ArrayList<>(); - @OneToOne(fetch = FetchType.LAZY, orphanRemoval = true) - @JoinColumn(name = "resume_announcement_id") - private ResumeAnnouncement resumeAnnouncement; - - @Builder.Default - private Boolean isPublished = false; @Embedded private TimeStamp timeStamp; @@ -99,14 +92,4 @@ public void updateResume(Resume resume) { this.homepages.addAll(resume.getHomepages()); } - public void publishResume(ResumeAnnouncement resumeAnnouncement) { - this.resumeAnnouncement = resumeAnnouncement; - resumeAnnouncement.setResume(this); - this.isPublished = true; - } - - public void unpublishResume() { - this.resumeAnnouncement = null; - this.isPublished = false; - } } From a58776ee49b1273f348df01180922da7cd53d835 Mon Sep 17 00:00:00 2001 From: Sukju Hong Date: Tue, 7 May 2024 02:17:00 +0900 Subject: [PATCH 12/22] =?UTF-8?q?refactor:=20announcement=20=EA=B5=AC?= =?UTF-8?q?=EB=B6=84=EC=9D=84=20=EC=9C=84=ED=95=9C=20team=20annoucement=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=20(#56)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../example/eumserver/domain/team/Team.java | 6 +- ...r.java => TeamAnnouncementController.java} | 38 ++++++------ ...nnouncement.java => TeamAnnouncement.java} | 6 +- ...ilter.java => TeamAnnouncementFilter.java} | 2 +- ...uest.java => TeamAnnouncementRequest.java} | 2 +- ...nse.java => TeamAnnouncementResponse.java} | 2 +- ...ava => TeamAnnouncementUpdateRequest.java} | 2 +- .../mapper/AnnouncementMapper.java | 22 ------- .../mapper/TeamAnnouncementMapper.java | 22 +++++++ .../AnnouncementCustomRepository.java | 20 ------- .../AnnouncementCustomRepositoryImpl.java | 59 ------------------- .../repository/AnnouncementRepository.java | 8 --- .../TeamAnnouncementCustomRepository.java | 20 +++++++ .../TeamAnnouncementCustomRepositoryImpl.java | 59 +++++++++++++++++++ .../TeamAnnouncementRepository.java | 8 +++ ...vice.java => TeamAnnouncementService.java} | 36 +++++------ .../AnnouncementControllerTest.java | 30 +++++----- 17 files changed, 171 insertions(+), 171 deletions(-) rename src/main/java/com/example/eumserver/domain/team/announcement/controller/{AnnouncementController.java => TeamAnnouncementController.java} (55%) rename src/main/java/com/example/eumserver/domain/team/announcement/domain/{Announcement.java => TeamAnnouncement.java} (90%) rename src/main/java/com/example/eumserver/domain/team/announcement/dto/{AnnouncementFilter.java => TeamAnnouncementFilter.java} (87%) rename src/main/java/com/example/eumserver/domain/team/announcement/dto/{AnnouncementRequest.java => TeamAnnouncementRequest.java} (93%) rename src/main/java/com/example/eumserver/domain/team/announcement/dto/{AnnouncementResponse.java => TeamAnnouncementResponse.java} (74%) rename src/main/java/com/example/eumserver/domain/team/announcement/dto/{AnnouncementUpdateRequest.java => TeamAnnouncementUpdateRequest.java} (92%) delete mode 100644 src/main/java/com/example/eumserver/domain/team/announcement/mapper/AnnouncementMapper.java create mode 100644 src/main/java/com/example/eumserver/domain/team/announcement/mapper/TeamAnnouncementMapper.java delete mode 100644 src/main/java/com/example/eumserver/domain/team/announcement/repository/AnnouncementCustomRepository.java delete mode 100644 src/main/java/com/example/eumserver/domain/team/announcement/repository/AnnouncementCustomRepositoryImpl.java delete mode 100644 src/main/java/com/example/eumserver/domain/team/announcement/repository/AnnouncementRepository.java create mode 100644 src/main/java/com/example/eumserver/domain/team/announcement/repository/TeamAnnouncementCustomRepository.java create mode 100644 src/main/java/com/example/eumserver/domain/team/announcement/repository/TeamAnnouncementCustomRepositoryImpl.java create mode 100644 src/main/java/com/example/eumserver/domain/team/announcement/repository/TeamAnnouncementRepository.java rename src/main/java/com/example/eumserver/domain/team/announcement/service/{AnnouncementService.java => TeamAnnouncementService.java} (58%) diff --git a/src/main/java/com/example/eumserver/domain/team/Team.java b/src/main/java/com/example/eumserver/domain/team/Team.java index 4bb1d00..2333eba 100644 --- a/src/main/java/com/example/eumserver/domain/team/Team.java +++ b/src/main/java/com/example/eumserver/domain/team/Team.java @@ -1,6 +1,6 @@ package com.example.eumserver.domain.team; -import com.example.eumserver.domain.team.announcement.domain.Announcement; +import com.example.eumserver.domain.team.announcement.domain.TeamAnnouncement; import com.example.eumserver.domain.team.participant.Participant; import com.fasterxml.jackson.annotation.JsonIgnore; import jakarta.persistence.*; @@ -50,13 +50,13 @@ public class Team { @JsonIgnore @Builder.Default @OneToMany(mappedBy = "team", orphanRemoval = true) - private List announcements = new ArrayList<>(); + private List announcements = new ArrayList<>(); public void addTeam(Participant participant) { this.participants.add(participant); } - public void addAnnouncement(Announcement announcement) { + public void addAnnouncement(TeamAnnouncement announcement) { this.announcements.add(announcement); } } diff --git a/src/main/java/com/example/eumserver/domain/team/announcement/controller/AnnouncementController.java b/src/main/java/com/example/eumserver/domain/team/announcement/controller/TeamAnnouncementController.java similarity index 55% rename from src/main/java/com/example/eumserver/domain/team/announcement/controller/AnnouncementController.java rename to src/main/java/com/example/eumserver/domain/team/announcement/controller/TeamAnnouncementController.java index 65ce0a8..4039331 100644 --- a/src/main/java/com/example/eumserver/domain/team/announcement/controller/AnnouncementController.java +++ b/src/main/java/com/example/eumserver/domain/team/announcement/controller/TeamAnnouncementController.java @@ -1,12 +1,12 @@ package com.example.eumserver.domain.team.announcement.controller; -import com.example.eumserver.domain.team.announcement.domain.Announcement; -import com.example.eumserver.domain.team.announcement.dto.AnnouncementFilter; -import com.example.eumserver.domain.team.announcement.dto.AnnouncementRequest; -import com.example.eumserver.domain.team.announcement.dto.AnnouncementResponse; -import com.example.eumserver.domain.team.announcement.dto.AnnouncementUpdateRequest; -import com.example.eumserver.domain.team.announcement.mapper.AnnouncementMapper; -import com.example.eumserver.domain.team.announcement.service.AnnouncementService; +import com.example.eumserver.domain.team.announcement.domain.TeamAnnouncement; +import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementFilter; +import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementRequest; +import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementResponse; +import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementUpdateRequest; +import com.example.eumserver.domain.team.announcement.mapper.TeamAnnouncementMapper; +import com.example.eumserver.domain.team.announcement.service.TeamAnnouncementService; import com.example.eumserver.global.dto.ApiResult; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -19,38 +19,38 @@ @RestController @RequestMapping("/api/team/{teamId}/announcement") @RequiredArgsConstructor -public class AnnouncementController { +public class TeamAnnouncementController { - private final AnnouncementService announcementService; + private final TeamAnnouncementService announcementService; @PostMapping("") @ResponseStatus(HttpStatus.CREATED) - public ResponseEntity> createAnnouncement( + public ResponseEntity> createAnnouncement( @PathVariable(name = "teamId") Long teamId, - @RequestBody AnnouncementRequest announcementRequest + @RequestBody TeamAnnouncementRequest announcementRequest ) { log.debug("announcement request: {}", announcementRequest); - AnnouncementResponse announcementResponse = announcementService.createAnnouncement(teamId, announcementRequest); + TeamAnnouncementResponse announcementResponse = announcementService.createAnnouncement(teamId, announcementRequest); return ResponseEntity .status(HttpStatus.CREATED) .body(new ApiResult<>("팀 공고 생성 성공", announcementResponse)); } @GetMapping("") - public ResponseEntity>> getAnnouncements( + public ResponseEntity>> getAnnouncements( @PathVariable(name = "teamId") Long teamId, @RequestParam(name = "page", defaultValue = "0") Integer page, - @RequestBody AnnouncementFilter announcementFilter + @RequestBody TeamAnnouncementFilter announcementFilter ) { - Page filteredAnnouncementsWithPaging = announcementService.getFilteredAnnouncementsWithPaging(teamId, page, announcementFilter); + Page filteredAnnouncementsWithPaging = announcementService.getFilteredAnnouncementsWithPaging(teamId, page, announcementFilter); return ResponseEntity .ok(new ApiResult<>("팀 공고 필터링 및 페이징 조회 성공", filteredAnnouncementsWithPaging)); } @GetMapping("/{announcementId}") - public ResponseEntity> getAnnouncement(@PathVariable(name = "announcementId") Long announcementId) { - Announcement announcement = announcementService.findAnnouncementById(announcementId); - AnnouncementResponse announcementResponse = AnnouncementMapper.INSTANCE.entityToResponse(announcement); + public ResponseEntity> getAnnouncement(@PathVariable(name = "announcementId") Long announcementId) { + TeamAnnouncement announcement = announcementService.findAnnouncementById(announcementId); + TeamAnnouncementResponse announcementResponse = TeamAnnouncementMapper.INSTANCE.entityToResponse(announcement); return ResponseEntity .ok(new ApiResult<>("팀 공고 조회 성공", announcementResponse)); } @@ -58,7 +58,7 @@ public ResponseEntity> getAnnouncement(@PathVari @PutMapping("/{announcementId}") public ResponseEntity> updateAnnouncement( @PathVariable(name = "announcementId") Long announcementId, - @RequestBody AnnouncementUpdateRequest announcementUpdateRequest + @RequestBody TeamAnnouncementUpdateRequest announcementUpdateRequest ) { announcementService.updateAnnouncement(announcementId, announcementUpdateRequest); return ResponseEntity diff --git a/src/main/java/com/example/eumserver/domain/team/announcement/domain/Announcement.java b/src/main/java/com/example/eumserver/domain/team/announcement/domain/TeamAnnouncement.java similarity index 90% rename from src/main/java/com/example/eumserver/domain/team/announcement/domain/Announcement.java rename to src/main/java/com/example/eumserver/domain/team/announcement/domain/TeamAnnouncement.java index 1d4679d..5e33a8e 100644 --- a/src/main/java/com/example/eumserver/domain/team/announcement/domain/Announcement.java +++ b/src/main/java/com/example/eumserver/domain/team/announcement/domain/TeamAnnouncement.java @@ -1,7 +1,7 @@ package com.example.eumserver.domain.team.announcement.domain; import com.example.eumserver.domain.team.Team; -import com.example.eumserver.domain.team.announcement.dto.AnnouncementUpdateRequest; +import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementUpdateRequest; import com.example.eumserver.global.dto.TimeStamp; import jakarta.persistence.*; import lombok.*; @@ -15,7 +15,7 @@ @Builder @NoArgsConstructor(access = AccessLevel.PROTECTED) @AllArgsConstructor -public class Announcement { +public class TeamAnnouncement { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @@ -59,7 +59,7 @@ public boolean isPublished() { return this.publishedDate != null; } - public void updateAnnouncement(AnnouncementUpdateRequest announcementUpdateRequest) { + public void updateAnnouncement(TeamAnnouncementUpdateRequest announcementUpdateRequest) { this.title = announcementUpdateRequest.title(); this.description = announcementUpdateRequest.description(); this.vacancies = announcementUpdateRequest.vacancies(); diff --git a/src/main/java/com/example/eumserver/domain/team/announcement/dto/AnnouncementFilter.java b/src/main/java/com/example/eumserver/domain/team/announcement/dto/TeamAnnouncementFilter.java similarity index 87% rename from src/main/java/com/example/eumserver/domain/team/announcement/dto/AnnouncementFilter.java rename to src/main/java/com/example/eumserver/domain/team/announcement/dto/TeamAnnouncementFilter.java index 5a8f4e5..87a325b 100644 --- a/src/main/java/com/example/eumserver/domain/team/announcement/dto/AnnouncementFilter.java +++ b/src/main/java/com/example/eumserver/domain/team/announcement/dto/TeamAnnouncementFilter.java @@ -4,7 +4,7 @@ import java.util.List; -public record AnnouncementFilter( +public record TeamAnnouncementFilter( boolean published, List occupationClassifications ) { diff --git a/src/main/java/com/example/eumserver/domain/team/announcement/dto/AnnouncementRequest.java b/src/main/java/com/example/eumserver/domain/team/announcement/dto/TeamAnnouncementRequest.java similarity index 93% rename from src/main/java/com/example/eumserver/domain/team/announcement/dto/AnnouncementRequest.java rename to src/main/java/com/example/eumserver/domain/team/announcement/dto/TeamAnnouncementRequest.java index 43429be..a3db462 100644 --- a/src/main/java/com/example/eumserver/domain/team/announcement/dto/AnnouncementRequest.java +++ b/src/main/java/com/example/eumserver/domain/team/announcement/dto/TeamAnnouncementRequest.java @@ -6,7 +6,7 @@ import java.time.LocalDateTime; import java.util.List; -public record AnnouncementRequest( +public record TeamAnnouncementRequest( String title, String description, int vacancies, diff --git a/src/main/java/com/example/eumserver/domain/team/announcement/dto/AnnouncementResponse.java b/src/main/java/com/example/eumserver/domain/team/announcement/dto/TeamAnnouncementResponse.java similarity index 74% rename from src/main/java/com/example/eumserver/domain/team/announcement/dto/AnnouncementResponse.java rename to src/main/java/com/example/eumserver/domain/team/announcement/dto/TeamAnnouncementResponse.java index 8524f52..50f7543 100644 --- a/src/main/java/com/example/eumserver/domain/team/announcement/dto/AnnouncementResponse.java +++ b/src/main/java/com/example/eumserver/domain/team/announcement/dto/TeamAnnouncementResponse.java @@ -1,6 +1,6 @@ package com.example.eumserver.domain.team.announcement.dto; -public record AnnouncementResponse( +public record TeamAnnouncementResponse( String title, String description ) { diff --git a/src/main/java/com/example/eumserver/domain/team/announcement/dto/AnnouncementUpdateRequest.java b/src/main/java/com/example/eumserver/domain/team/announcement/dto/TeamAnnouncementUpdateRequest.java similarity index 92% rename from src/main/java/com/example/eumserver/domain/team/announcement/dto/AnnouncementUpdateRequest.java rename to src/main/java/com/example/eumserver/domain/team/announcement/dto/TeamAnnouncementUpdateRequest.java index 76587cd..f6b7953 100644 --- a/src/main/java/com/example/eumserver/domain/team/announcement/dto/AnnouncementUpdateRequest.java +++ b/src/main/java/com/example/eumserver/domain/team/announcement/dto/TeamAnnouncementUpdateRequest.java @@ -6,7 +6,7 @@ import java.time.LocalDateTime; import java.util.List; -public record AnnouncementUpdateRequest( +public record TeamAnnouncementUpdateRequest( String title, String description, int vacancies, diff --git a/src/main/java/com/example/eumserver/domain/team/announcement/mapper/AnnouncementMapper.java b/src/main/java/com/example/eumserver/domain/team/announcement/mapper/AnnouncementMapper.java deleted file mode 100644 index 4051c21..0000000 --- a/src/main/java/com/example/eumserver/domain/team/announcement/mapper/AnnouncementMapper.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.example.eumserver.domain.team.announcement.mapper; - -import com.example.eumserver.domain.team.announcement.domain.Announcement; -import com.example.eumserver.domain.team.announcement.dto.AnnouncementRequest; -import com.example.eumserver.domain.team.announcement.dto.AnnouncementResponse; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.factory.Mappers; - -@Mapper -public interface AnnouncementMapper { - - AnnouncementMapper INSTANCE = Mappers.getMapper(AnnouncementMapper.class); - - AnnouncementResponse entityToResponse(Announcement announcement); - - @Mapping(target = "id", ignore = true) - @Mapping(target = "timeStamp", ignore = true) - @Mapping(target = "publishedDate", ignore = true) - @Mapping(target = "team", ignore = true) - Announcement requestToEntity(AnnouncementRequest announcementRequest); -} diff --git a/src/main/java/com/example/eumserver/domain/team/announcement/mapper/TeamAnnouncementMapper.java b/src/main/java/com/example/eumserver/domain/team/announcement/mapper/TeamAnnouncementMapper.java new file mode 100644 index 0000000..53966dc --- /dev/null +++ b/src/main/java/com/example/eumserver/domain/team/announcement/mapper/TeamAnnouncementMapper.java @@ -0,0 +1,22 @@ +package com.example.eumserver.domain.team.announcement.mapper; + +import com.example.eumserver.domain.team.announcement.domain.TeamAnnouncement; +import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementRequest; +import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementResponse; +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +import org.mapstruct.factory.Mappers; + +@Mapper +public interface TeamAnnouncementMapper { + + TeamAnnouncementMapper INSTANCE = Mappers.getMapper(TeamAnnouncementMapper.class); + + TeamAnnouncementResponse entityToResponse(TeamAnnouncement announcement); + + @Mapping(target = "id", ignore = true) + @Mapping(target = "timeStamp", ignore = true) + @Mapping(target = "publishedDate", ignore = true) + @Mapping(target = "team", ignore = true) + TeamAnnouncement requestToEntity(TeamAnnouncementRequest announcementRequest); +} diff --git a/src/main/java/com/example/eumserver/domain/team/announcement/repository/AnnouncementCustomRepository.java b/src/main/java/com/example/eumserver/domain/team/announcement/repository/AnnouncementCustomRepository.java deleted file mode 100644 index c84dca9..0000000 --- a/src/main/java/com/example/eumserver/domain/team/announcement/repository/AnnouncementCustomRepository.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.example.eumserver.domain.team.announcement.repository; - -import com.example.eumserver.domain.team.announcement.dto.AnnouncementFilter; -import com.example.eumserver.domain.team.announcement.domain.Announcement; -import com.example.eumserver.domain.team.announcement.dto.AnnouncementResponse; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; - -public interface AnnouncementCustomRepository { - - /** - * Retrieve a paginated list of announcements filtered additional criteria. - * - * @param filter An object containing filter criteria to apply to the announcements. - * @param pageable Pagination information including page number, page size, and sort order. - * @return A {@link Page} of {@link Announcement} objects that match the specified filters. - */ - Page getFilteredAnnouncementsWithPaging(Long teamId, AnnouncementFilter filter, Pageable pageable); - -} diff --git a/src/main/java/com/example/eumserver/domain/team/announcement/repository/AnnouncementCustomRepositoryImpl.java b/src/main/java/com/example/eumserver/domain/team/announcement/repository/AnnouncementCustomRepositoryImpl.java deleted file mode 100644 index d44cc1c..0000000 --- a/src/main/java/com/example/eumserver/domain/team/announcement/repository/AnnouncementCustomRepositoryImpl.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.example.eumserver.domain.team.announcement.repository; - -import com.example.eumserver.domain.team.announcement.domain.OccupationClassification; -import com.example.eumserver.domain.team.announcement.domain.QAnnouncement; -import com.example.eumserver.domain.team.announcement.dto.AnnouncementFilter; -import com.example.eumserver.domain.team.announcement.domain.Announcement; -import com.example.eumserver.domain.team.announcement.dto.AnnouncementResponse; -import com.example.eumserver.domain.team.announcement.mapper.AnnouncementMapper; -import com.querydsl.core.types.dsl.BooleanExpression; -import com.querydsl.jpa.impl.JPAQuery; -import com.querydsl.jpa.impl.JPAQueryFactory; -import lombok.RequiredArgsConstructor; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.data.support.PageableExecutionUtils; -import org.springframework.stereotype.Repository; - -import java.util.List; - -@Repository -@RequiredArgsConstructor -public class AnnouncementCustomRepositoryImpl implements AnnouncementCustomRepository { - - private final JPAQueryFactory queryFactory; - - @Override - public Page getFilteredAnnouncementsWithPaging(Long teamId, AnnouncementFilter filter, Pageable pageable) { - QAnnouncement announcement = QAnnouncement.announcement; - BooleanExpression predicate = announcement.isNotNull(); - - predicate = predicate.and(announcement.team.id.eq(teamId)); - - if (filter.published()) { - predicate = predicate.and(announcement.publishedDate.isNotNull()); - } - - List occupationClassifications = filter.occupationClassifications(); - if (occupationClassifications != null && !occupationClassifications.isEmpty()) { - predicate = predicate.and(announcement.occupationClassifications.any().in(occupationClassifications)); - } - - List announcements = queryFactory - .selectFrom(announcement) - .where(predicate) - .offset(pageable.getOffset()) - .limit(pageable.getPageSize()) - .fetch(); - - List announcementResponses = announcements.stream() - .map(AnnouncementMapper.INSTANCE::entityToResponse).toList(); - - JPAQuery count = queryFactory - .select(announcement.count()) - .from(announcement) - .where(predicate); - - return PageableExecutionUtils.getPage(announcementResponses, pageable, count::fetchOne); - } -} diff --git a/src/main/java/com/example/eumserver/domain/team/announcement/repository/AnnouncementRepository.java b/src/main/java/com/example/eumserver/domain/team/announcement/repository/AnnouncementRepository.java deleted file mode 100644 index 01139bd..0000000 --- a/src/main/java/com/example/eumserver/domain/team/announcement/repository/AnnouncementRepository.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.example.eumserver.domain.team.announcement.repository; - -import com.example.eumserver.domain.team.announcement.domain.Announcement; -import org.springframework.data.jpa.repository.JpaRepository; - -public interface AnnouncementRepository extends JpaRepository, AnnouncementCustomRepository { - -} diff --git a/src/main/java/com/example/eumserver/domain/team/announcement/repository/TeamAnnouncementCustomRepository.java b/src/main/java/com/example/eumserver/domain/team/announcement/repository/TeamAnnouncementCustomRepository.java new file mode 100644 index 0000000..d1a7b27 --- /dev/null +++ b/src/main/java/com/example/eumserver/domain/team/announcement/repository/TeamAnnouncementCustomRepository.java @@ -0,0 +1,20 @@ +package com.example.eumserver.domain.team.announcement.repository; + +import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementFilter; +import com.example.eumserver.domain.team.announcement.domain.TeamAnnouncement; +import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementResponse; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; + +public interface TeamAnnouncementCustomRepository { + + /** + * Retrieve a paginated list of announcements filtered additional criteria. + * + * @param filter An object containing filter criteria to apply to the announcements. + * @param pageable Pagination information including page number, page size, and sort order. + * @return A {@link Page} of {@link TeamAnnouncement} objects that match the specified filters. + */ + Page getFilteredAnnouncementsWithPaging(Long teamId, TeamAnnouncementFilter filter, Pageable pageable); + +} diff --git a/src/main/java/com/example/eumserver/domain/team/announcement/repository/TeamAnnouncementCustomRepositoryImpl.java b/src/main/java/com/example/eumserver/domain/team/announcement/repository/TeamAnnouncementCustomRepositoryImpl.java new file mode 100644 index 0000000..4bc44b3 --- /dev/null +++ b/src/main/java/com/example/eumserver/domain/team/announcement/repository/TeamAnnouncementCustomRepositoryImpl.java @@ -0,0 +1,59 @@ +package com.example.eumserver.domain.team.announcement.repository; + +import com.example.eumserver.domain.team.announcement.domain.OccupationClassification; +import com.example.eumserver.domain.team.announcement.domain.QTeamAnnouncement; +import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementFilter; +import com.example.eumserver.domain.team.announcement.domain.TeamAnnouncement; +import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementResponse; +import com.example.eumserver.domain.team.announcement.mapper.TeamAnnouncementMapper; +import com.querydsl.core.types.dsl.BooleanExpression; +import com.querydsl.jpa.impl.JPAQuery; +import com.querydsl.jpa.impl.JPAQueryFactory; +import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.support.PageableExecutionUtils; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +@RequiredArgsConstructor +public class TeamAnnouncementCustomRepositoryImpl implements TeamAnnouncementCustomRepository { + + private final JPAQueryFactory queryFactory; + + @Override + public Page getFilteredAnnouncementsWithPaging(Long teamId, TeamAnnouncementFilter filter, Pageable pageable) { + QTeamAnnouncement teamAnnouncement = QTeamAnnouncement.teamAnnouncement; + BooleanExpression predicate = teamAnnouncement.isNotNull(); + + predicate = predicate.and(teamAnnouncement.team.id.eq(teamId)); + + if (filter.published()) { + predicate = predicate.and(teamAnnouncement.publishedDate.isNotNull()); + } + + List occupationClassifications = filter.occupationClassifications(); + if (occupationClassifications != null && !occupationClassifications.isEmpty()) { + predicate = predicate.and(teamAnnouncement.occupationClassifications.any().in(occupationClassifications)); + } + + List announcements = queryFactory + .selectFrom(teamAnnouncement) + .where(predicate) + .offset(pageable.getOffset()) + .limit(pageable.getPageSize()) + .fetch(); + + List announcementResponses = announcements.stream() + .map(TeamAnnouncementMapper.INSTANCE::entityToResponse).toList(); + + JPAQuery count = queryFactory + .select(teamAnnouncement.count()) + .from(teamAnnouncement) + .where(predicate); + + return PageableExecutionUtils.getPage(announcementResponses, pageable, count::fetchOne); + } +} diff --git a/src/main/java/com/example/eumserver/domain/team/announcement/repository/TeamAnnouncementRepository.java b/src/main/java/com/example/eumserver/domain/team/announcement/repository/TeamAnnouncementRepository.java new file mode 100644 index 0000000..7899d7f --- /dev/null +++ b/src/main/java/com/example/eumserver/domain/team/announcement/repository/TeamAnnouncementRepository.java @@ -0,0 +1,8 @@ +package com.example.eumserver.domain.team.announcement.repository; + +import com.example.eumserver.domain.team.announcement.domain.TeamAnnouncement; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface TeamAnnouncementRepository extends JpaRepository, TeamAnnouncementCustomRepository { + +} diff --git a/src/main/java/com/example/eumserver/domain/team/announcement/service/AnnouncementService.java b/src/main/java/com/example/eumserver/domain/team/announcement/service/TeamAnnouncementService.java similarity index 58% rename from src/main/java/com/example/eumserver/domain/team/announcement/service/AnnouncementService.java rename to src/main/java/com/example/eumserver/domain/team/announcement/service/TeamAnnouncementService.java index d190d91..0e30e7a 100644 --- a/src/main/java/com/example/eumserver/domain/team/announcement/service/AnnouncementService.java +++ b/src/main/java/com/example/eumserver/domain/team/announcement/service/TeamAnnouncementService.java @@ -2,13 +2,13 @@ import com.example.eumserver.domain.team.Team; import com.example.eumserver.domain.team.TeamService; -import com.example.eumserver.domain.team.announcement.domain.Announcement; -import com.example.eumserver.domain.team.announcement.dto.AnnouncementFilter; -import com.example.eumserver.domain.team.announcement.dto.AnnouncementRequest; -import com.example.eumserver.domain.team.announcement.dto.AnnouncementResponse; -import com.example.eumserver.domain.team.announcement.dto.AnnouncementUpdateRequest; -import com.example.eumserver.domain.team.announcement.mapper.AnnouncementMapper; -import com.example.eumserver.domain.team.announcement.repository.AnnouncementRepository; +import com.example.eumserver.domain.team.announcement.domain.TeamAnnouncement; +import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementFilter; +import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementRequest; +import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementResponse; +import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementUpdateRequest; +import com.example.eumserver.domain.team.announcement.mapper.TeamAnnouncementMapper; +import com.example.eumserver.domain.team.announcement.repository.TeamAnnouncementRepository; import com.example.eumserver.global.error.exception.CustomException; import com.example.eumserver.global.error.exception.ErrorCode; import lombok.RequiredArgsConstructor; @@ -26,16 +26,16 @@ @Service @Transactional(readOnly = true) @RequiredArgsConstructor -public class AnnouncementService { +public class TeamAnnouncementService { - private final AnnouncementRepository announcementRepository; + private final TeamAnnouncementRepository announcementRepository; private final TeamService teamService; - public Page getFilteredAnnouncementsWithPaging( + public Page getFilteredAnnouncementsWithPaging( Long teamId, int page, - AnnouncementFilter filter + TeamAnnouncementFilter filter ) { List sorts = new ArrayList<>(); sorts.add(Sort.Order.desc("date_created")); @@ -44,10 +44,10 @@ public Page getFilteredAnnouncementsWithPaging( } @Transactional - public AnnouncementResponse createAnnouncement(Long teamId, AnnouncementRequest announcementRequest) { + public TeamAnnouncementResponse createAnnouncement(Long teamId, TeamAnnouncementRequest announcementRequest) { Team team = teamService.findById(teamId); - Announcement announcement = AnnouncementMapper.INSTANCE.requestToEntity(announcementRequest); + TeamAnnouncement announcement = TeamAnnouncementMapper.INSTANCE.requestToEntity(announcementRequest); announcement.setTeam(team); if (announcementRequest.publish()) { LocalDateTime localDateTime = LocalDateTime.now(); @@ -55,12 +55,12 @@ public AnnouncementResponse createAnnouncement(Long teamId, AnnouncementRequest } announcementRepository.save(announcement); - return AnnouncementMapper.INSTANCE.entityToResponse(announcement); + return TeamAnnouncementMapper.INSTANCE.entityToResponse(announcement); } @Transactional - public void updateAnnouncement(Long announcementId, AnnouncementUpdateRequest announcementUpdateRequest) { - Announcement announcement = this.findAnnouncementById(announcementId); + public void updateAnnouncement(Long announcementId, TeamAnnouncementUpdateRequest announcementUpdateRequest) { + TeamAnnouncement announcement = this.findAnnouncementById(announcementId); announcement.updateAnnouncement(announcementUpdateRequest); announcementRepository.save(announcement); } @@ -68,11 +68,11 @@ public void updateAnnouncement(Long announcementId, AnnouncementUpdateRequest an @Transactional public void deleteAnnouncement(Long announcementId) { - Announcement announcement = this.findAnnouncementById(announcementId); + TeamAnnouncement announcement = this.findAnnouncementById(announcementId); announcementRepository.delete(announcement); } - public Announcement findAnnouncementById(Long announcementId) { + public TeamAnnouncement findAnnouncementById(Long announcementId) { return announcementRepository.findById(announcementId) .orElseThrow(() -> new CustomException(ErrorCode.ANNOUNCEMENT_NOT_FOUND)); } diff --git a/src/test/java/com/example/eumserver/domain/team/announcement/controller/AnnouncementControllerTest.java b/src/test/java/com/example/eumserver/domain/team/announcement/controller/AnnouncementControllerTest.java index fb3e9a1..aa2e37b 100644 --- a/src/test/java/com/example/eumserver/domain/team/announcement/controller/AnnouncementControllerTest.java +++ b/src/test/java/com/example/eumserver/domain/team/announcement/controller/AnnouncementControllerTest.java @@ -2,11 +2,11 @@ import com.example.eumserver.BaseIntegrationTest; import com.example.eumserver.domain.team.Team; -import com.example.eumserver.domain.team.announcement.domain.Announcement; +import com.example.eumserver.domain.team.announcement.domain.TeamAnnouncement; import com.example.eumserver.domain.team.announcement.domain.OccupationClassification; -import com.example.eumserver.domain.team.announcement.dto.AnnouncementFilter; -import com.example.eumserver.domain.team.announcement.dto.AnnouncementRequest; -import com.example.eumserver.domain.team.announcement.dto.AnnouncementUpdateRequest; +import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementFilter; +import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementRequest; +import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementUpdateRequest; import jakarta.persistence.EntityManager; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -38,8 +38,8 @@ class AnnouncementControllerTest extends BaseIntegrationTest { void create_announcement_success() throws Exception { Team team = createTeam(); - AnnouncementRequest announcementRequest = - new AnnouncementRequest( + TeamAnnouncementRequest announcementRequest = + new TeamAnnouncementRequest( "title", "description", 5, @@ -69,7 +69,7 @@ void create_announcement_success() throws Exception { @WithMockUser void get_announcement_success() throws Exception { Team team = createTeam(); - Announcement announcement = createAnnouncement(team); + TeamAnnouncement announcement = createAnnouncement(team); ResultActions resultActions = mockMvc.perform( get(BASE_URI + "/{announcementId}", team.getId(), announcement.getId()) @@ -88,9 +88,9 @@ void get_announcement_success() throws Exception { @WithMockUser void get_filtered_announcement_with_paging_success() throws Exception { Team team = createTeam(); - Announcement announcement = createAnnouncement(team); + TeamAnnouncement announcement = createAnnouncement(team); - AnnouncementFilter filter = new AnnouncementFilter( + TeamAnnouncementFilter filter = new TeamAnnouncementFilter( false, List.of(OccupationClassification.DEVELOPMENT_BACKEND, OccupationClassification.DEVELOPMENT_DEVOPS) ); @@ -118,9 +118,9 @@ void get_filtered_announcement_with_paging_success() throws Exception { @WithMockUser void update_announcement_success() throws Exception { Team team = createTeam(); - Announcement announcement = createAnnouncement(team); + TeamAnnouncement announcement = createAnnouncement(team); - AnnouncementUpdateRequest announcementUpdateRequest = new AnnouncementUpdateRequest( + TeamAnnouncementUpdateRequest announcementUpdateRequest = new TeamAnnouncementUpdateRequest( "new title", "new description", 2, @@ -142,7 +142,7 @@ void update_announcement_success() throws Exception { resultActions .andExpect(status().isOk()); - Announcement updatedAnnouncement = em.find(Announcement.class, announcement.getId()); + TeamAnnouncement updatedAnnouncement = em.find(TeamAnnouncement.class, announcement.getId()); assertEquals(announcementUpdateRequest.title(), updatedAnnouncement.getTitle()); assertEquals(announcementUpdateRequest.description(), updatedAnnouncement.getDescription()); assertEquals(announcementUpdateRequest.vacancies(), updatedAnnouncement.getVacancies()); @@ -156,7 +156,7 @@ void update_announcement_success() throws Exception { @WithMockUser void delete_announcement_success() throws Exception { Team team = createTeam(); - Announcement announcement = createAnnouncement(team); + TeamAnnouncement announcement = createAnnouncement(team); ResultActions resultActions = mockMvc.perform( delete(BASE_URI + "/{announcementId}", team.getId(), announcement.getId()) @@ -177,8 +177,8 @@ private Team createTeam() { return team; } - private Announcement createAnnouncement(Team team) { - Announcement announcement = Announcement.builder() + private TeamAnnouncement createAnnouncement(Team team) { + TeamAnnouncement announcement = TeamAnnouncement.builder() .title("test_title") .description("test_description") .vacancies(1) From b8e8b9d9d4ff4f385fc6c39e1201e4a61ec04106 Mon Sep 17 00:00:00 2001 From: Sukju Hong Date: Tue, 7 May 2024 10:47:42 +0900 Subject: [PATCH 13/22] =?UTF-8?q?feat:=20isPublic=20=EC=82=AD=EC=A0=9C=20?= =?UTF-8?q?=EB=B0=8F=20=EB=A6=AC=ED=8C=A9=ED=86=A0=EB=A7=81=20(#56)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/resume/ResumeController.java | 4 +-- .../eumserver/domain/resume/ResumeMapper.java | 11 ++---- .../domain/resume/ResumeRepository.java | 2 -- .../domain/resume/ResumeService.java | 14 ++------ .../domain/resume/dto/ResumeRequest.java | 2 +- .../domain/resume/entity/Resume.java | 34 ++++++++----------- 6 files changed, 23 insertions(+), 44 deletions(-) diff --git a/src/main/java/com/example/eumserver/domain/resume/ResumeController.java b/src/main/java/com/example/eumserver/domain/resume/ResumeController.java index 180bd02..c8aac08 100644 --- a/src/main/java/com/example/eumserver/domain/resume/ResumeController.java +++ b/src/main/java/com/example/eumserver/domain/resume/ResumeController.java @@ -111,7 +111,7 @@ public ResponseEntity>> getAllMyResume( @AuthenticationPrincipal PrincipalDetails principalDetails ) { long userId = principalDetails.getUserId(); - List resumes = resumeService.getAllMyResume(userId); + List resumes = resumeService.getAllResumeByUserId(userId); return ResponseEntity .ok(new ApiResult<>("내 이력서 전부 받아오기 성공", resumes)); } @@ -124,7 +124,7 @@ public ResponseEntity>> getAllMyResume( public ResponseEntity>> getAllMyResume( @PathVariable("userId") long userId ) { - List resumes = resumeService.getAllUserResume(userId); + List resumes = resumeService.getAllResumeByUserId(userId); return ResponseEntity .ok(new ApiResult<>("타인 이력서 전부 받아오기 성공", resumes)); } diff --git a/src/main/java/com/example/eumserver/domain/resume/ResumeMapper.java b/src/main/java/com/example/eumserver/domain/resume/ResumeMapper.java index 4992959..ab46be1 100644 --- a/src/main/java/com/example/eumserver/domain/resume/ResumeMapper.java +++ b/src/main/java/com/example/eumserver/domain/resume/ResumeMapper.java @@ -12,16 +12,9 @@ public interface ResumeMapper { ResumeMapper INSTANCE = Mappers.getMapper(ResumeMapper.class); - @Mapping(source = "jobCategory", target = "jobCategory") - @Mapping(source = "jobSubcategory", target = "jobSubcategory") + @Mapping(target = "id", ignore = true) + @Mapping(target = "timeStamp", ignore = true) @Mapping(target = "user", ignore = true) - @Mapping(source = "gpa", target = "gpa") - @Mapping(source = "totalScore", target = "totalScore") - @Mapping(source = "introduction", target = "introduction") - @Mapping(source = "careers", target = "careers") - @Mapping(source = "certificates", target = "certificates") - @Mapping(source = "projects", target = "projects") - @Mapping(source = "isPublic", target = "isPublic") Resume resumeRequestToResume(ResumeRequest resumeRequest); @AfterMapping diff --git a/src/main/java/com/example/eumserver/domain/resume/ResumeRepository.java b/src/main/java/com/example/eumserver/domain/resume/ResumeRepository.java index 482f5a0..1f4c35d 100644 --- a/src/main/java/com/example/eumserver/domain/resume/ResumeRepository.java +++ b/src/main/java/com/example/eumserver/domain/resume/ResumeRepository.java @@ -7,6 +7,4 @@ public interface ResumeRepository extends JpaRepository { List findByUserId(Long userId); - - List findByUserIdAndIsPublicTrue(Long userId); } diff --git a/src/main/java/com/example/eumserver/domain/resume/ResumeService.java b/src/main/java/com/example/eumserver/domain/resume/ResumeService.java index f6c45f7..c630a38 100644 --- a/src/main/java/com/example/eumserver/domain/resume/ResumeService.java +++ b/src/main/java/com/example/eumserver/domain/resume/ResumeService.java @@ -42,9 +42,7 @@ public Resume updateResume(ResumeRequest resumeRequest, long resumeId, long user } Resume updatedResume = ResumeMapper.INSTANCE.resumeRequestToResume(resumeRequest); - resume.updateResume(updatedResume.getTitle(), updatedResume.getJobCategory(), updatedResume.getJobSubcategory(), - updatedResume.getGpa(), updatedResume.getTotalScore(), updatedResume.getCareers(), updatedResume.getActivities(), - updatedResume.getCertificates(), updatedResume.getProjects(), updatedResume.getHomepages(), updatedResume.getIsPublic()); + resume.updateResume(updatedResume); resumeRepository.save(resume); return resume; @@ -63,23 +61,17 @@ public void deleteResume(long resumeId, long userId) { resumeRepository.deleteById(resumeId); } - public List getAllMyResume(long userId) { + public List getAllResumeByUserId(long userId) { userRepository.findById(userId) .orElseThrow(() -> new CustomException(ErrorCode.USER_NOT_FOUND)); return resumeRepository.findByUserId(userId); } - public List getAllUserResume(long userId) { - userRepository.findById(userId) - .orElseThrow(() -> new CustomException(ErrorCode.USER_NOT_FOUND)); - return resumeRepository.findByUserIdAndIsPublicTrue(userId); - } - public Resume getResume(long userId, long resumeId) { Resume resume = resumeRepository.findById(resumeId) .orElseThrow(() -> new CustomException(ErrorCode.RESUME_NOT_FOUND)); - if (!resume.getIsPublic() && (userId == 0 || userId != resume.getUser().getId())) { + if (userId == 0 || userId != resume.getUser().getId()) { throw new CustomException(ErrorCode.ACCESS_DENIED); } return resume; diff --git a/src/main/java/com/example/eumserver/domain/resume/dto/ResumeRequest.java b/src/main/java/com/example/eumserver/domain/resume/dto/ResumeRequest.java index 6e087cf..552b1c0 100644 --- a/src/main/java/com/example/eumserver/domain/resume/dto/ResumeRequest.java +++ b/src/main/java/com/example/eumserver/domain/resume/dto/ResumeRequest.java @@ -6,11 +6,11 @@ public record ResumeRequest( @NotBlank String title, + @NotBlank String description, @NotBlank String jobCategory, @NotBlank String jobSubcategory, Double gpa, Double totalScore, - @NotBlank String introduction, Boolean isPublic, List careers, List certificates, diff --git a/src/main/java/com/example/eumserver/domain/resume/entity/Resume.java b/src/main/java/com/example/eumserver/domain/resume/entity/Resume.java index 0363b72..c0f3c78 100644 --- a/src/main/java/com/example/eumserver/domain/resume/entity/Resume.java +++ b/src/main/java/com/example/eumserver/domain/resume/entity/Resume.java @@ -1,5 +1,7 @@ package com.example.eumserver.domain.resume.entity; +import com.example.eumserver.domain.resume.dto.ResumeCareerRequest; +import com.example.eumserver.domain.resume.dto.ResumeRequest; import com.example.eumserver.domain.user.User; import com.example.eumserver.global.dto.TimeStamp; import com.fasterxml.jackson.annotation.JsonIgnore; @@ -62,11 +64,7 @@ public class Resume { private List homepages = new ArrayList<>(); @Column(columnDefinition = "TEXT", nullable = false) - private String introduction; - - @Builder.Default - @Column(name = "is_public", nullable = false) - private Boolean isPublic = true; + private String description; @Embedded private TimeStamp timeStamp; @@ -76,24 +74,22 @@ public void setUser(User user) { user.addResume(this); } - public void updateResume(String title, String jobCategory, String jobSubcategory, Double gpa, Double totalScore, - List careers, List activities, List certificates, - List projects, List homepages, Boolean isPublic) { - this.title = title; - this.jobCategory = jobCategory; - this.jobSubcategory = jobSubcategory; - this.gpa = gpa; - this.totalScore = totalScore; + public void updateResume(Resume resume) { + this.title = resume.getTitle(); + this.description = resume.getDescription(); + this.jobCategory = resume.getJobCategory(); + this.jobSubcategory = resume.getJobSubcategory(); + this.gpa = resume.getGpa(); + this.totalScore = resume.getTotalScore(); this.careers.clear(); - this.careers.addAll(careers); + this.careers.addAll(resume.getCareers()); this.activities.clear(); - this.activities.addAll(activities); + this.activities.addAll(resume.getActivities()); this.certificates.clear(); - this.certificates.addAll(certificates); + this.certificates.addAll(resume.getCertificates()); this.projects.clear(); - this.projects.addAll(projects); + this.projects.addAll(resume.getProjects()); this.homepages.clear(); - this.homepages.addAll(homepages); - this.isPublic = isPublic; + this.homepages.addAll(resume.getHomepages()); } } From 8015da6f5145489e860a8e60ba1d11fd83c4f523 Mon Sep 17 00:00:00 2001 From: Sukju Hong Date: Tue, 7 May 2024 11:13:56 +0900 Subject: [PATCH 14/22] =?UTF-8?q?feat:=20=EC=9D=B4=EB=A0=A5=EC=84=9C=20?= =?UTF-8?q?=EA=B3=B5=EA=B3=A0=20Service=20=EB=A0=88=EC=9D=B4=EC=96=B4?= =?UTF-8?q?=EA=B9=8C=EC=A7=80=20=EA=B5=AC=ED=98=84=20(#56)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/resume/ResumeRepository.java | 2 + .../domain/ResumeAnnouncement.java | 26 +++++++++++ .../dto/ResumeAnnouncementRequest.java | 6 +++ .../mapper/ResumeAnnouncementMapper.java | 17 +++++++ .../ResumeAnnouncementRepository.java | 6 +++ .../service/ResumeAnnouncementService.java | 45 +++++++++++++++++++ .../domain/resume/entity/Resume.java | 25 +++++++++-- 7 files changed, 123 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/example/eumserver/domain/resume/announcement/domain/ResumeAnnouncement.java create mode 100644 src/main/java/com/example/eumserver/domain/resume/announcement/dto/ResumeAnnouncementRequest.java create mode 100644 src/main/java/com/example/eumserver/domain/resume/announcement/mapper/ResumeAnnouncementMapper.java create mode 100644 src/main/java/com/example/eumserver/domain/resume/announcement/repository/ResumeAnnouncementRepository.java create mode 100644 src/main/java/com/example/eumserver/domain/resume/announcement/service/ResumeAnnouncementService.java diff --git a/src/main/java/com/example/eumserver/domain/resume/ResumeRepository.java b/src/main/java/com/example/eumserver/domain/resume/ResumeRepository.java index 1f4c35d..9a1d01c 100644 --- a/src/main/java/com/example/eumserver/domain/resume/ResumeRepository.java +++ b/src/main/java/com/example/eumserver/domain/resume/ResumeRepository.java @@ -4,7 +4,9 @@ import org.springframework.data.jpa.repository.JpaRepository; import java.util.List; +import java.util.Optional; public interface ResumeRepository extends JpaRepository { + Optional findById(Long resumeId); List findByUserId(Long userId); } diff --git a/src/main/java/com/example/eumserver/domain/resume/announcement/domain/ResumeAnnouncement.java b/src/main/java/com/example/eumserver/domain/resume/announcement/domain/ResumeAnnouncement.java new file mode 100644 index 0000000..7b69960 --- /dev/null +++ b/src/main/java/com/example/eumserver/domain/resume/announcement/domain/ResumeAnnouncement.java @@ -0,0 +1,26 @@ +package com.example.eumserver.domain.resume.announcement.domain; + +import com.example.eumserver.domain.resume.entity.Resume; +import jakarta.persistence.*; +import lombok.*; + +@Entity +@Table(name = "resume_announcements") +@Getter +@Builder +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor +public class ResumeAnnouncement { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "resume_announcement_id") + private Long id; + + @Column(nullable = false) + private String introduction; + + @Setter + @OneToOne(mappedBy = "resumeAnnouncement") + private Resume resume; +} diff --git a/src/main/java/com/example/eumserver/domain/resume/announcement/dto/ResumeAnnouncementRequest.java b/src/main/java/com/example/eumserver/domain/resume/announcement/dto/ResumeAnnouncementRequest.java new file mode 100644 index 0000000..4f6d42b --- /dev/null +++ b/src/main/java/com/example/eumserver/domain/resume/announcement/dto/ResumeAnnouncementRequest.java @@ -0,0 +1,6 @@ +package com.example.eumserver.domain.resume.announcement.dto; + +public record ResumeAnnouncementRequest( + String introduction +) { +} diff --git a/src/main/java/com/example/eumserver/domain/resume/announcement/mapper/ResumeAnnouncementMapper.java b/src/main/java/com/example/eumserver/domain/resume/announcement/mapper/ResumeAnnouncementMapper.java new file mode 100644 index 0000000..eff57e8 --- /dev/null +++ b/src/main/java/com/example/eumserver/domain/resume/announcement/mapper/ResumeAnnouncementMapper.java @@ -0,0 +1,17 @@ +package com.example.eumserver.domain.resume.announcement.mapper; + +import com.example.eumserver.domain.resume.announcement.domain.ResumeAnnouncement; +import com.example.eumserver.domain.resume.announcement.dto.ResumeAnnouncementRequest; +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +import org.mapstruct.factory.Mappers; + +@Mapper +public interface ResumeAnnouncementMapper { + + ResumeAnnouncementMapper INSTANCE = Mappers.getMapper(ResumeAnnouncementMapper.class); + + @Mapping(target = "id", ignore = true) + @Mapping(target = "resume", ignore = true) + ResumeAnnouncement requestToEntity(ResumeAnnouncementRequest resumeAnnouncementRequest); +} diff --git a/src/main/java/com/example/eumserver/domain/resume/announcement/repository/ResumeAnnouncementRepository.java b/src/main/java/com/example/eumserver/domain/resume/announcement/repository/ResumeAnnouncementRepository.java new file mode 100644 index 0000000..b470160 --- /dev/null +++ b/src/main/java/com/example/eumserver/domain/resume/announcement/repository/ResumeAnnouncementRepository.java @@ -0,0 +1,6 @@ +package com.example.eumserver.domain.resume.announcement.repository; + +import com.example.eumserver.domain.resume.announcement.domain.ResumeAnnouncement; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface ResumeAnnouncementRepository extends JpaRepository { } diff --git a/src/main/java/com/example/eumserver/domain/resume/announcement/service/ResumeAnnouncementService.java b/src/main/java/com/example/eumserver/domain/resume/announcement/service/ResumeAnnouncementService.java new file mode 100644 index 0000000..6b0a06b --- /dev/null +++ b/src/main/java/com/example/eumserver/domain/resume/announcement/service/ResumeAnnouncementService.java @@ -0,0 +1,45 @@ +package com.example.eumserver.domain.resume.announcement.service; + +import com.example.eumserver.domain.resume.ResumeRepository; +import com.example.eumserver.domain.resume.announcement.domain.ResumeAnnouncement; +import com.example.eumserver.domain.resume.announcement.dto.ResumeAnnouncementRequest; +import com.example.eumserver.domain.resume.announcement.mapper.ResumeAnnouncementMapper; +import com.example.eumserver.domain.resume.announcement.repository.ResumeAnnouncementRepository; +import com.example.eumserver.domain.resume.entity.Resume; +import com.example.eumserver.global.error.exception.CustomException; +import com.example.eumserver.global.error.exception.ErrorCode; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@RequiredArgsConstructor +@Transactional(readOnly = true) +public class ResumeAnnouncementService { + + private final ResumeRepository resumeRepository; + private final ResumeAnnouncementRepository resumeAnnouncementRepository; + + public ResumeAnnouncement publishResume(Long resumeId, ResumeAnnouncementRequest resumeAnnouncementRequest) { + Resume resume = resumeRepository.findById(resumeId) + .orElseThrow(() -> new CustomException(ErrorCode.RESUME_NOT_FOUND)); + + ResumeAnnouncement resumeAnnouncement = ResumeAnnouncementMapper.INSTANCE + .requestToEntity(resumeAnnouncementRequest); + + resume.publishResume(resumeAnnouncement); + resumeRepository.save(resume); + return resumeAnnouncementRepository.save(resumeAnnouncement); + } + + public void unpublishResume(Long resumeId) { + Resume resume = resumeRepository.findById(resumeId) + .orElseThrow(() -> new CustomException(ErrorCode.RESUME_NOT_FOUND)); + ResumeAnnouncement resumeAnnouncement = resume.getResumeAnnouncement(); + + resume.unpublishResume(); + resumeRepository.save(resume); + resumeAnnouncementRepository.delete(resumeAnnouncement); + } + +} diff --git a/src/main/java/com/example/eumserver/domain/resume/entity/Resume.java b/src/main/java/com/example/eumserver/domain/resume/entity/Resume.java index c0f3c78..68988d0 100644 --- a/src/main/java/com/example/eumserver/domain/resume/entity/Resume.java +++ b/src/main/java/com/example/eumserver/domain/resume/entity/Resume.java @@ -1,7 +1,6 @@ package com.example.eumserver.domain.resume.entity; -import com.example.eumserver.domain.resume.dto.ResumeCareerRequest; -import com.example.eumserver.domain.resume.dto.ResumeRequest; +import com.example.eumserver.domain.resume.announcement.domain.ResumeAnnouncement; import com.example.eumserver.domain.user.User; import com.example.eumserver.global.dto.TimeStamp; import com.fasterxml.jackson.annotation.JsonIgnore; @@ -31,6 +30,9 @@ public class Resume { @Column private String title; + @Column(columnDefinition = "TEXT", nullable = false) + private String description; + @Column(name = "job_category", nullable = false) private String jobCategory; @@ -63,8 +65,12 @@ public class Resume { @OneToMany(mappedBy = "resume", cascade = CascadeType.ALL, orphanRemoval = true) private List homepages = new ArrayList<>(); - @Column(columnDefinition = "TEXT", nullable = false) - private String description; + @OneToOne(fetch = FetchType.LAZY, orphanRemoval = true) + @JoinColumn(name = "resume_announcement_id") + private ResumeAnnouncement resumeAnnouncement; + + @Builder.Default + private Boolean isPublished = false; @Embedded private TimeStamp timeStamp; @@ -92,4 +98,15 @@ public void updateResume(Resume resume) { this.homepages.clear(); this.homepages.addAll(resume.getHomepages()); } + + public void publishResume(ResumeAnnouncement resumeAnnouncement) { + this.resumeAnnouncement = resumeAnnouncement; + resumeAnnouncement.setResume(this); + this.isPublished = true; + } + + public void unpublishResume() { + this.resumeAnnouncement = null; + this.isPublished = false; + } } From 2a985e9d7040c7affa47bcfd4b6f28388a230665 Mon Sep 17 00:00:00 2001 From: Sukju Hong Date: Tue, 7 May 2024 11:15:04 +0900 Subject: [PATCH 15/22] =?UTF-8?q?feat:=20ResumeMapper=20target=20=EB=88=84?= =?UTF-8?q?=EB=9D=BD=20(#56)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/example/eumserver/domain/resume/ResumeMapper.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/example/eumserver/domain/resume/ResumeMapper.java b/src/main/java/com/example/eumserver/domain/resume/ResumeMapper.java index ab46be1..4f8ba27 100644 --- a/src/main/java/com/example/eumserver/domain/resume/ResumeMapper.java +++ b/src/main/java/com/example/eumserver/domain/resume/ResumeMapper.java @@ -15,6 +15,8 @@ public interface ResumeMapper { @Mapping(target = "id", ignore = true) @Mapping(target = "timeStamp", ignore = true) @Mapping(target = "user", ignore = true) + @Mapping(target = "resumeAnnouncement", ignore = true) + @Mapping(target = "isPublished", ignore = true) Resume resumeRequestToResume(ResumeRequest resumeRequest); @AfterMapping From 13e14ff28eb9ad17b0aaf2858db26bf38fa0d262 Mon Sep 17 00:00:00 2001 From: Sukju Hong Date: Tue, 7 May 2024 15:08:31 +0900 Subject: [PATCH 16/22] =?UTF-8?q?refactor:=20announcement=20=EB=B6=84?= =?UTF-8?q?=EB=A6=AC=20(#56)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resume}/domain/ResumeAnnouncement.java | 2 +- .../resume}/dto/ResumeAnnouncementRequest.java | 2 +- .../resume}/mapper/ResumeAnnouncementMapper.java | 6 +++--- .../repository/ResumeAnnouncementRepository.java | 4 ++-- .../service/ResumeAnnouncementService.java | 10 +++++----- .../controller/TeamAnnouncementController.java | 16 ++++++++-------- .../team}/domain/OccupationClassification.java | 2 +- .../team}/domain/RecruitmentTypes.java | 2 +- .../team}/domain/TeamAnnouncement.java | 4 ++-- .../team}/dto/TeamAnnouncementFilter.java | 4 ++-- .../team}/dto/TeamAnnouncementRequest.java | 4 ++-- .../team}/dto/TeamAnnouncementResponse.java | 2 +- .../team}/dto/TeamAnnouncementUpdateRequest.java | 4 ++-- .../team}/mapper/TeamAnnouncementMapper.java | 8 ++++---- .../TeamAnnouncementCustomRepository.java | 8 ++++---- .../TeamAnnouncementCustomRepositoryImpl.java | 12 ++++++------ .../repository/TeamAnnouncementRepository.java | 4 ++-- .../team}/service/TeamAnnouncementService.java | 16 ++++++++-------- .../eumserver/domain/resume/entity/Resume.java | 2 +- .../com/example/eumserver/domain/team/Team.java | 2 +- .../controller/AnnouncementControllerTest.java | 10 +++++----- 21 files changed, 62 insertions(+), 62 deletions(-) rename src/main/java/com/example/eumserver/domain/{resume/announcement => announcement/resume}/domain/ResumeAnnouncement.java (89%) rename src/main/java/com/example/eumserver/domain/{resume/announcement => announcement/resume}/dto/ResumeAnnouncementRequest.java (55%) rename src/main/java/com/example/eumserver/domain/{resume/announcement => announcement/resume}/mapper/ResumeAnnouncementMapper.java (71%) rename src/main/java/com/example/eumserver/domain/{resume/announcement => announcement/resume}/repository/ResumeAnnouncementRepository.java (59%) rename src/main/java/com/example/eumserver/domain/{resume/announcement => announcement/resume}/service/ResumeAnnouncementService.java (84%) rename src/main/java/com/example/eumserver/domain/{team/announcement => announcement/team}/controller/TeamAnnouncementController.java (86%) rename src/main/java/com/example/eumserver/domain/{team/announcement => announcement/team}/domain/OccupationClassification.java (97%) rename src/main/java/com/example/eumserver/domain/{team/announcement => announcement/team}/domain/RecruitmentTypes.java (75%) rename src/main/java/com/example/eumserver/domain/{team/announcement => announcement/team}/domain/TeamAnnouncement.java (94%) rename src/main/java/com/example/eumserver/domain/{team/announcement => announcement/team}/dto/TeamAnnouncementFilter.java (59%) rename src/main/java/com/example/eumserver/domain/{team/announcement => announcement/team}/dto/TeamAnnouncementRequest.java (78%) rename src/main/java/com/example/eumserver/domain/{team/announcement => announcement/team}/dto/TeamAnnouncementResponse.java (61%) rename src/main/java/com/example/eumserver/domain/{team/announcement => announcement/team}/dto/TeamAnnouncementUpdateRequest.java (78%) rename src/main/java/com/example/eumserver/domain/{team/announcement => announcement/team}/mapper/TeamAnnouncementMapper.java (71%) rename src/main/java/com/example/eumserver/domain/{team/announcement => announcement/team}/repository/TeamAnnouncementCustomRepository.java (74%) rename src/main/java/com/example/eumserver/domain/{team/announcement => announcement/team}/repository/TeamAnnouncementCustomRepositoryImpl.java (85%) rename src/main/java/com/example/eumserver/domain/{team/announcement => announcement/team}/repository/TeamAnnouncementRepository.java (62%) rename src/main/java/com/example/eumserver/domain/{team/announcement => announcement/team}/service/TeamAnnouncementService.java (85%) diff --git a/src/main/java/com/example/eumserver/domain/resume/announcement/domain/ResumeAnnouncement.java b/src/main/java/com/example/eumserver/domain/announcement/resume/domain/ResumeAnnouncement.java similarity index 89% rename from src/main/java/com/example/eumserver/domain/resume/announcement/domain/ResumeAnnouncement.java rename to src/main/java/com/example/eumserver/domain/announcement/resume/domain/ResumeAnnouncement.java index 7b69960..53107de 100644 --- a/src/main/java/com/example/eumserver/domain/resume/announcement/domain/ResumeAnnouncement.java +++ b/src/main/java/com/example/eumserver/domain/announcement/resume/domain/ResumeAnnouncement.java @@ -1,4 +1,4 @@ -package com.example.eumserver.domain.resume.announcement.domain; +package com.example.eumserver.domain.announcement.resume.domain; import com.example.eumserver.domain.resume.entity.Resume; import jakarta.persistence.*; diff --git a/src/main/java/com/example/eumserver/domain/resume/announcement/dto/ResumeAnnouncementRequest.java b/src/main/java/com/example/eumserver/domain/announcement/resume/dto/ResumeAnnouncementRequest.java similarity index 55% rename from src/main/java/com/example/eumserver/domain/resume/announcement/dto/ResumeAnnouncementRequest.java rename to src/main/java/com/example/eumserver/domain/announcement/resume/dto/ResumeAnnouncementRequest.java index 4f6d42b..880406f 100644 --- a/src/main/java/com/example/eumserver/domain/resume/announcement/dto/ResumeAnnouncementRequest.java +++ b/src/main/java/com/example/eumserver/domain/announcement/resume/dto/ResumeAnnouncementRequest.java @@ -1,4 +1,4 @@ -package com.example.eumserver.domain.resume.announcement.dto; +package com.example.eumserver.domain.announcement.resume.dto; public record ResumeAnnouncementRequest( String introduction diff --git a/src/main/java/com/example/eumserver/domain/resume/announcement/mapper/ResumeAnnouncementMapper.java b/src/main/java/com/example/eumserver/domain/announcement/resume/mapper/ResumeAnnouncementMapper.java similarity index 71% rename from src/main/java/com/example/eumserver/domain/resume/announcement/mapper/ResumeAnnouncementMapper.java rename to src/main/java/com/example/eumserver/domain/announcement/resume/mapper/ResumeAnnouncementMapper.java index eff57e8..bddc6ae 100644 --- a/src/main/java/com/example/eumserver/domain/resume/announcement/mapper/ResumeAnnouncementMapper.java +++ b/src/main/java/com/example/eumserver/domain/announcement/resume/mapper/ResumeAnnouncementMapper.java @@ -1,7 +1,7 @@ -package com.example.eumserver.domain.resume.announcement.mapper; +package com.example.eumserver.domain.announcement.resume.mapper; -import com.example.eumserver.domain.resume.announcement.domain.ResumeAnnouncement; -import com.example.eumserver.domain.resume.announcement.dto.ResumeAnnouncementRequest; +import com.example.eumserver.domain.announcement.resume.domain.ResumeAnnouncement; +import com.example.eumserver.domain.announcement.resume.dto.ResumeAnnouncementRequest; import org.mapstruct.Mapper; import org.mapstruct.Mapping; import org.mapstruct.factory.Mappers; diff --git a/src/main/java/com/example/eumserver/domain/resume/announcement/repository/ResumeAnnouncementRepository.java b/src/main/java/com/example/eumserver/domain/announcement/resume/repository/ResumeAnnouncementRepository.java similarity index 59% rename from src/main/java/com/example/eumserver/domain/resume/announcement/repository/ResumeAnnouncementRepository.java rename to src/main/java/com/example/eumserver/domain/announcement/resume/repository/ResumeAnnouncementRepository.java index b470160..f43fd0e 100644 --- a/src/main/java/com/example/eumserver/domain/resume/announcement/repository/ResumeAnnouncementRepository.java +++ b/src/main/java/com/example/eumserver/domain/announcement/resume/repository/ResumeAnnouncementRepository.java @@ -1,6 +1,6 @@ -package com.example.eumserver.domain.resume.announcement.repository; +package com.example.eumserver.domain.announcement.resume.repository; -import com.example.eumserver.domain.resume.announcement.domain.ResumeAnnouncement; +import com.example.eumserver.domain.announcement.resume.domain.ResumeAnnouncement; import org.springframework.data.jpa.repository.JpaRepository; public interface ResumeAnnouncementRepository extends JpaRepository { } diff --git a/src/main/java/com/example/eumserver/domain/resume/announcement/service/ResumeAnnouncementService.java b/src/main/java/com/example/eumserver/domain/announcement/resume/service/ResumeAnnouncementService.java similarity index 84% rename from src/main/java/com/example/eumserver/domain/resume/announcement/service/ResumeAnnouncementService.java rename to src/main/java/com/example/eumserver/domain/announcement/resume/service/ResumeAnnouncementService.java index 6b0a06b..d82ec79 100644 --- a/src/main/java/com/example/eumserver/domain/resume/announcement/service/ResumeAnnouncementService.java +++ b/src/main/java/com/example/eumserver/domain/announcement/resume/service/ResumeAnnouncementService.java @@ -1,10 +1,10 @@ -package com.example.eumserver.domain.resume.announcement.service; +package com.example.eumserver.domain.announcement.resume.service; +import com.example.eumserver.domain.announcement.resume.mapper.ResumeAnnouncementMapper; +import com.example.eumserver.domain.announcement.resume.repository.ResumeAnnouncementRepository; import com.example.eumserver.domain.resume.ResumeRepository; -import com.example.eumserver.domain.resume.announcement.domain.ResumeAnnouncement; -import com.example.eumserver.domain.resume.announcement.dto.ResumeAnnouncementRequest; -import com.example.eumserver.domain.resume.announcement.mapper.ResumeAnnouncementMapper; -import com.example.eumserver.domain.resume.announcement.repository.ResumeAnnouncementRepository; +import com.example.eumserver.domain.announcement.resume.domain.ResumeAnnouncement; +import com.example.eumserver.domain.announcement.resume.dto.ResumeAnnouncementRequest; import com.example.eumserver.domain.resume.entity.Resume; import com.example.eumserver.global.error.exception.CustomException; import com.example.eumserver.global.error.exception.ErrorCode; diff --git a/src/main/java/com/example/eumserver/domain/team/announcement/controller/TeamAnnouncementController.java b/src/main/java/com/example/eumserver/domain/announcement/team/controller/TeamAnnouncementController.java similarity index 86% rename from src/main/java/com/example/eumserver/domain/team/announcement/controller/TeamAnnouncementController.java rename to src/main/java/com/example/eumserver/domain/announcement/team/controller/TeamAnnouncementController.java index 4039331..825adc8 100644 --- a/src/main/java/com/example/eumserver/domain/team/announcement/controller/TeamAnnouncementController.java +++ b/src/main/java/com/example/eumserver/domain/announcement/team/controller/TeamAnnouncementController.java @@ -1,12 +1,12 @@ -package com.example.eumserver.domain.team.announcement.controller; +package com.example.eumserver.domain.announcement.team.controller; -import com.example.eumserver.domain.team.announcement.domain.TeamAnnouncement; -import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementFilter; -import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementRequest; -import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementResponse; -import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementUpdateRequest; -import com.example.eumserver.domain.team.announcement.mapper.TeamAnnouncementMapper; -import com.example.eumserver.domain.team.announcement.service.TeamAnnouncementService; +import com.example.eumserver.domain.announcement.team.domain.TeamAnnouncement; +import com.example.eumserver.domain.announcement.team.dto.TeamAnnouncementFilter; +import com.example.eumserver.domain.announcement.team.dto.TeamAnnouncementRequest; +import com.example.eumserver.domain.announcement.team.dto.TeamAnnouncementResponse; +import com.example.eumserver.domain.announcement.team.dto.TeamAnnouncementUpdateRequest; +import com.example.eumserver.domain.announcement.team.mapper.TeamAnnouncementMapper; +import com.example.eumserver.domain.announcement.team.service.TeamAnnouncementService; import com.example.eumserver.global.dto.ApiResult; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; diff --git a/src/main/java/com/example/eumserver/domain/team/announcement/domain/OccupationClassification.java b/src/main/java/com/example/eumserver/domain/announcement/team/domain/OccupationClassification.java similarity index 97% rename from src/main/java/com/example/eumserver/domain/team/announcement/domain/OccupationClassification.java rename to src/main/java/com/example/eumserver/domain/announcement/team/domain/OccupationClassification.java index 15b819e..48ed6d8 100644 --- a/src/main/java/com/example/eumserver/domain/team/announcement/domain/OccupationClassification.java +++ b/src/main/java/com/example/eumserver/domain/announcement/team/domain/OccupationClassification.java @@ -1,4 +1,4 @@ -package com.example.eumserver.domain.team.announcement.domain; +package com.example.eumserver.domain.announcement.team.domain; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; diff --git a/src/main/java/com/example/eumserver/domain/team/announcement/domain/RecruitmentTypes.java b/src/main/java/com/example/eumserver/domain/announcement/team/domain/RecruitmentTypes.java similarity index 75% rename from src/main/java/com/example/eumserver/domain/team/announcement/domain/RecruitmentTypes.java rename to src/main/java/com/example/eumserver/domain/announcement/team/domain/RecruitmentTypes.java index 3d4919e..ca2efe8 100644 --- a/src/main/java/com/example/eumserver/domain/team/announcement/domain/RecruitmentTypes.java +++ b/src/main/java/com/example/eumserver/domain/announcement/team/domain/RecruitmentTypes.java @@ -1,4 +1,4 @@ -package com.example.eumserver.domain.team.announcement.domain; +package com.example.eumserver.domain.announcement.team.domain; /** * 모집 공고의 모집 유형을 나타낸 Enum Class 입니다. diff --git a/src/main/java/com/example/eumserver/domain/team/announcement/domain/TeamAnnouncement.java b/src/main/java/com/example/eumserver/domain/announcement/team/domain/TeamAnnouncement.java similarity index 94% rename from src/main/java/com/example/eumserver/domain/team/announcement/domain/TeamAnnouncement.java rename to src/main/java/com/example/eumserver/domain/announcement/team/domain/TeamAnnouncement.java index 5e33a8e..e2e4e99 100644 --- a/src/main/java/com/example/eumserver/domain/team/announcement/domain/TeamAnnouncement.java +++ b/src/main/java/com/example/eumserver/domain/announcement/team/domain/TeamAnnouncement.java @@ -1,7 +1,7 @@ -package com.example.eumserver.domain.team.announcement.domain; +package com.example.eumserver.domain.announcement.team.domain; +import com.example.eumserver.domain.announcement.team.dto.TeamAnnouncementUpdateRequest; import com.example.eumserver.domain.team.Team; -import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementUpdateRequest; import com.example.eumserver.global.dto.TimeStamp; import jakarta.persistence.*; import lombok.*; diff --git a/src/main/java/com/example/eumserver/domain/team/announcement/dto/TeamAnnouncementFilter.java b/src/main/java/com/example/eumserver/domain/announcement/team/dto/TeamAnnouncementFilter.java similarity index 59% rename from src/main/java/com/example/eumserver/domain/team/announcement/dto/TeamAnnouncementFilter.java rename to src/main/java/com/example/eumserver/domain/announcement/team/dto/TeamAnnouncementFilter.java index 87a325b..98a1906 100644 --- a/src/main/java/com/example/eumserver/domain/team/announcement/dto/TeamAnnouncementFilter.java +++ b/src/main/java/com/example/eumserver/domain/announcement/team/dto/TeamAnnouncementFilter.java @@ -1,6 +1,6 @@ -package com.example.eumserver.domain.team.announcement.dto; +package com.example.eumserver.domain.announcement.team.dto; -import com.example.eumserver.domain.team.announcement.domain.OccupationClassification; +import com.example.eumserver.domain.announcement.team.domain.OccupationClassification; import java.util.List; diff --git a/src/main/java/com/example/eumserver/domain/team/announcement/dto/TeamAnnouncementRequest.java b/src/main/java/com/example/eumserver/domain/announcement/team/dto/TeamAnnouncementRequest.java similarity index 78% rename from src/main/java/com/example/eumserver/domain/team/announcement/dto/TeamAnnouncementRequest.java rename to src/main/java/com/example/eumserver/domain/announcement/team/dto/TeamAnnouncementRequest.java index a3db462..65a87b1 100644 --- a/src/main/java/com/example/eumserver/domain/team/announcement/dto/TeamAnnouncementRequest.java +++ b/src/main/java/com/example/eumserver/domain/announcement/team/dto/TeamAnnouncementRequest.java @@ -1,6 +1,6 @@ -package com.example.eumserver.domain.team.announcement.dto; +package com.example.eumserver.domain.announcement.team.dto; -import com.example.eumserver.domain.team.announcement.domain.OccupationClassification; +import com.example.eumserver.domain.announcement.team.domain.OccupationClassification; import org.springframework.format.annotation.DateTimeFormat; import java.time.LocalDateTime; diff --git a/src/main/java/com/example/eumserver/domain/team/announcement/dto/TeamAnnouncementResponse.java b/src/main/java/com/example/eumserver/domain/announcement/team/dto/TeamAnnouncementResponse.java similarity index 61% rename from src/main/java/com/example/eumserver/domain/team/announcement/dto/TeamAnnouncementResponse.java rename to src/main/java/com/example/eumserver/domain/announcement/team/dto/TeamAnnouncementResponse.java index 50f7543..5702ec1 100644 --- a/src/main/java/com/example/eumserver/domain/team/announcement/dto/TeamAnnouncementResponse.java +++ b/src/main/java/com/example/eumserver/domain/announcement/team/dto/TeamAnnouncementResponse.java @@ -1,4 +1,4 @@ -package com.example.eumserver.domain.team.announcement.dto; +package com.example.eumserver.domain.announcement.team.dto; public record TeamAnnouncementResponse( String title, diff --git a/src/main/java/com/example/eumserver/domain/team/announcement/dto/TeamAnnouncementUpdateRequest.java b/src/main/java/com/example/eumserver/domain/announcement/team/dto/TeamAnnouncementUpdateRequest.java similarity index 78% rename from src/main/java/com/example/eumserver/domain/team/announcement/dto/TeamAnnouncementUpdateRequest.java rename to src/main/java/com/example/eumserver/domain/announcement/team/dto/TeamAnnouncementUpdateRequest.java index f6b7953..b400f6c 100644 --- a/src/main/java/com/example/eumserver/domain/team/announcement/dto/TeamAnnouncementUpdateRequest.java +++ b/src/main/java/com/example/eumserver/domain/announcement/team/dto/TeamAnnouncementUpdateRequest.java @@ -1,6 +1,6 @@ -package com.example.eumserver.domain.team.announcement.dto; +package com.example.eumserver.domain.announcement.team.dto; -import com.example.eumserver.domain.team.announcement.domain.OccupationClassification; +import com.example.eumserver.domain.announcement.team.domain.OccupationClassification; import org.springframework.format.annotation.DateTimeFormat; import java.time.LocalDateTime; diff --git a/src/main/java/com/example/eumserver/domain/team/announcement/mapper/TeamAnnouncementMapper.java b/src/main/java/com/example/eumserver/domain/announcement/team/mapper/TeamAnnouncementMapper.java similarity index 71% rename from src/main/java/com/example/eumserver/domain/team/announcement/mapper/TeamAnnouncementMapper.java rename to src/main/java/com/example/eumserver/domain/announcement/team/mapper/TeamAnnouncementMapper.java index 53966dc..1476835 100644 --- a/src/main/java/com/example/eumserver/domain/team/announcement/mapper/TeamAnnouncementMapper.java +++ b/src/main/java/com/example/eumserver/domain/announcement/team/mapper/TeamAnnouncementMapper.java @@ -1,8 +1,8 @@ -package com.example.eumserver.domain.team.announcement.mapper; +package com.example.eumserver.domain.announcement.team.mapper; -import com.example.eumserver.domain.team.announcement.domain.TeamAnnouncement; -import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementRequest; -import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementResponse; +import com.example.eumserver.domain.announcement.team.dto.TeamAnnouncementResponse; +import com.example.eumserver.domain.announcement.team.domain.TeamAnnouncement; +import com.example.eumserver.domain.announcement.team.dto.TeamAnnouncementRequest; import org.mapstruct.Mapper; import org.mapstruct.Mapping; import org.mapstruct.factory.Mappers; diff --git a/src/main/java/com/example/eumserver/domain/team/announcement/repository/TeamAnnouncementCustomRepository.java b/src/main/java/com/example/eumserver/domain/announcement/team/repository/TeamAnnouncementCustomRepository.java similarity index 74% rename from src/main/java/com/example/eumserver/domain/team/announcement/repository/TeamAnnouncementCustomRepository.java rename to src/main/java/com/example/eumserver/domain/announcement/team/repository/TeamAnnouncementCustomRepository.java index d1a7b27..43be412 100644 --- a/src/main/java/com/example/eumserver/domain/team/announcement/repository/TeamAnnouncementCustomRepository.java +++ b/src/main/java/com/example/eumserver/domain/announcement/team/repository/TeamAnnouncementCustomRepository.java @@ -1,8 +1,8 @@ -package com.example.eumserver.domain.team.announcement.repository; +package com.example.eumserver.domain.announcement.team.repository; -import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementFilter; -import com.example.eumserver.domain.team.announcement.domain.TeamAnnouncement; -import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementResponse; +import com.example.eumserver.domain.announcement.team.dto.TeamAnnouncementFilter; +import com.example.eumserver.domain.announcement.team.dto.TeamAnnouncementResponse; +import com.example.eumserver.domain.announcement.team.domain.TeamAnnouncement; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; diff --git a/src/main/java/com/example/eumserver/domain/team/announcement/repository/TeamAnnouncementCustomRepositoryImpl.java b/src/main/java/com/example/eumserver/domain/announcement/team/repository/TeamAnnouncementCustomRepositoryImpl.java similarity index 85% rename from src/main/java/com/example/eumserver/domain/team/announcement/repository/TeamAnnouncementCustomRepositoryImpl.java rename to src/main/java/com/example/eumserver/domain/announcement/team/repository/TeamAnnouncementCustomRepositoryImpl.java index 4bc44b3..1f99959 100644 --- a/src/main/java/com/example/eumserver/domain/team/announcement/repository/TeamAnnouncementCustomRepositoryImpl.java +++ b/src/main/java/com/example/eumserver/domain/announcement/team/repository/TeamAnnouncementCustomRepositoryImpl.java @@ -1,11 +1,11 @@ -package com.example.eumserver.domain.team.announcement.repository; +package com.example.eumserver.domain.announcement.team.repository; -import com.example.eumserver.domain.team.announcement.domain.OccupationClassification; +import com.example.eumserver.domain.announcement.team.dto.TeamAnnouncementFilter; +import com.example.eumserver.domain.announcement.team.dto.TeamAnnouncementResponse; +import com.example.eumserver.domain.announcement.team.mapper.TeamAnnouncementMapper; +import com.example.eumserver.domain.announcement.team.domain.OccupationClassification; import com.example.eumserver.domain.team.announcement.domain.QTeamAnnouncement; -import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementFilter; -import com.example.eumserver.domain.team.announcement.domain.TeamAnnouncement; -import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementResponse; -import com.example.eumserver.domain.team.announcement.mapper.TeamAnnouncementMapper; +import com.example.eumserver.domain.announcement.team.domain.TeamAnnouncement; import com.querydsl.core.types.dsl.BooleanExpression; import com.querydsl.jpa.impl.JPAQuery; import com.querydsl.jpa.impl.JPAQueryFactory; diff --git a/src/main/java/com/example/eumserver/domain/team/announcement/repository/TeamAnnouncementRepository.java b/src/main/java/com/example/eumserver/domain/announcement/team/repository/TeamAnnouncementRepository.java similarity index 62% rename from src/main/java/com/example/eumserver/domain/team/announcement/repository/TeamAnnouncementRepository.java rename to src/main/java/com/example/eumserver/domain/announcement/team/repository/TeamAnnouncementRepository.java index 7899d7f..dbee457 100644 --- a/src/main/java/com/example/eumserver/domain/team/announcement/repository/TeamAnnouncementRepository.java +++ b/src/main/java/com/example/eumserver/domain/announcement/team/repository/TeamAnnouncementRepository.java @@ -1,6 +1,6 @@ -package com.example.eumserver.domain.team.announcement.repository; +package com.example.eumserver.domain.announcement.team.repository; -import com.example.eumserver.domain.team.announcement.domain.TeamAnnouncement; +import com.example.eumserver.domain.announcement.team.domain.TeamAnnouncement; import org.springframework.data.jpa.repository.JpaRepository; public interface TeamAnnouncementRepository extends JpaRepository, TeamAnnouncementCustomRepository { diff --git a/src/main/java/com/example/eumserver/domain/team/announcement/service/TeamAnnouncementService.java b/src/main/java/com/example/eumserver/domain/announcement/team/service/TeamAnnouncementService.java similarity index 85% rename from src/main/java/com/example/eumserver/domain/team/announcement/service/TeamAnnouncementService.java rename to src/main/java/com/example/eumserver/domain/announcement/team/service/TeamAnnouncementService.java index 0e30e7a..84bba4d 100644 --- a/src/main/java/com/example/eumserver/domain/team/announcement/service/TeamAnnouncementService.java +++ b/src/main/java/com/example/eumserver/domain/announcement/team/service/TeamAnnouncementService.java @@ -1,14 +1,14 @@ -package com.example.eumserver.domain.team.announcement.service; +package com.example.eumserver.domain.announcement.team.service; import com.example.eumserver.domain.team.Team; import com.example.eumserver.domain.team.TeamService; -import com.example.eumserver.domain.team.announcement.domain.TeamAnnouncement; -import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementFilter; -import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementRequest; -import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementResponse; -import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementUpdateRequest; -import com.example.eumserver.domain.team.announcement.mapper.TeamAnnouncementMapper; -import com.example.eumserver.domain.team.announcement.repository.TeamAnnouncementRepository; +import com.example.eumserver.domain.announcement.team.domain.TeamAnnouncement; +import com.example.eumserver.domain.announcement.team.dto.TeamAnnouncementFilter; +import com.example.eumserver.domain.announcement.team.dto.TeamAnnouncementRequest; +import com.example.eumserver.domain.announcement.team.dto.TeamAnnouncementResponse; +import com.example.eumserver.domain.announcement.team.dto.TeamAnnouncementUpdateRequest; +import com.example.eumserver.domain.announcement.team.mapper.TeamAnnouncementMapper; +import com.example.eumserver.domain.announcement.team.repository.TeamAnnouncementRepository; import com.example.eumserver.global.error.exception.CustomException; import com.example.eumserver.global.error.exception.ErrorCode; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/example/eumserver/domain/resume/entity/Resume.java b/src/main/java/com/example/eumserver/domain/resume/entity/Resume.java index 68988d0..82b0717 100644 --- a/src/main/java/com/example/eumserver/domain/resume/entity/Resume.java +++ b/src/main/java/com/example/eumserver/domain/resume/entity/Resume.java @@ -1,6 +1,6 @@ package com.example.eumserver.domain.resume.entity; -import com.example.eumserver.domain.resume.announcement.domain.ResumeAnnouncement; +import com.example.eumserver.domain.announcement.resume.domain.ResumeAnnouncement; import com.example.eumserver.domain.user.User; import com.example.eumserver.global.dto.TimeStamp; import com.fasterxml.jackson.annotation.JsonIgnore; diff --git a/src/main/java/com/example/eumserver/domain/team/Team.java b/src/main/java/com/example/eumserver/domain/team/Team.java index 2333eba..41a4bad 100644 --- a/src/main/java/com/example/eumserver/domain/team/Team.java +++ b/src/main/java/com/example/eumserver/domain/team/Team.java @@ -1,6 +1,6 @@ package com.example.eumserver.domain.team; -import com.example.eumserver.domain.team.announcement.domain.TeamAnnouncement; +import com.example.eumserver.domain.announcement.team.domain.TeamAnnouncement; import com.example.eumserver.domain.team.participant.Participant; import com.fasterxml.jackson.annotation.JsonIgnore; import jakarta.persistence.*; diff --git a/src/test/java/com/example/eumserver/domain/team/announcement/controller/AnnouncementControllerTest.java b/src/test/java/com/example/eumserver/domain/team/announcement/controller/AnnouncementControllerTest.java index aa2e37b..852e232 100644 --- a/src/test/java/com/example/eumserver/domain/team/announcement/controller/AnnouncementControllerTest.java +++ b/src/test/java/com/example/eumserver/domain/team/announcement/controller/AnnouncementControllerTest.java @@ -2,11 +2,11 @@ import com.example.eumserver.BaseIntegrationTest; import com.example.eumserver.domain.team.Team; -import com.example.eumserver.domain.team.announcement.domain.TeamAnnouncement; -import com.example.eumserver.domain.team.announcement.domain.OccupationClassification; -import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementFilter; -import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementRequest; -import com.example.eumserver.domain.team.announcement.dto.TeamAnnouncementUpdateRequest; +import com.example.eumserver.domain.announcement.team.domain.TeamAnnouncement; +import com.example.eumserver.domain.announcement.team.domain.OccupationClassification; +import com.example.eumserver.domain.announcement.team.dto.TeamAnnouncementFilter; +import com.example.eumserver.domain.announcement.team.dto.TeamAnnouncementRequest; +import com.example.eumserver.domain.announcement.team.dto.TeamAnnouncementUpdateRequest; import jakarta.persistence.EntityManager; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; From 5e4396d30d2471e5d310be2418d6f5e3e26d35bc Mon Sep 17 00:00:00 2001 From: Sukju Hong Date: Tue, 7 May 2024 15:43:17 +0900 Subject: [PATCH 17/22] =?UTF-8?q?refactor:=20=EA=B3=B5=EA=B3=A0=20?= =?UTF-8?q?=ED=95=84=ED=84=B0=20=EB=AA=A8=EB=93=88=ED=99=94=20(#56)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/OccupationClassification.java | 2 +- .../domain/RecruitmentTypes.java | 2 +- .../ResumeAnnouncementController.java | 22 +++++++++++++++++++ .../team/domain/TeamAnnouncement.java | 1 + .../team/dto/TeamAnnouncementFilter.java | 2 +- .../team/dto/TeamAnnouncementRequest.java | 2 +- .../dto/TeamAnnouncementUpdateRequest.java | 2 +- .../TeamAnnouncementCustomRepositoryImpl.java | 2 +- .../AnnouncementControllerTest.java | 2 +- 9 files changed, 30 insertions(+), 7 deletions(-) rename src/main/java/com/example/eumserver/domain/announcement/{team => filter}/domain/OccupationClassification.java (97%) rename src/main/java/com/example/eumserver/domain/announcement/{team => filter}/domain/RecruitmentTypes.java (75%) create mode 100644 src/main/java/com/example/eumserver/domain/announcement/resume/controller/ResumeAnnouncementController.java diff --git a/src/main/java/com/example/eumserver/domain/announcement/team/domain/OccupationClassification.java b/src/main/java/com/example/eumserver/domain/announcement/filter/domain/OccupationClassification.java similarity index 97% rename from src/main/java/com/example/eumserver/domain/announcement/team/domain/OccupationClassification.java rename to src/main/java/com/example/eumserver/domain/announcement/filter/domain/OccupationClassification.java index 48ed6d8..2c42502 100644 --- a/src/main/java/com/example/eumserver/domain/announcement/team/domain/OccupationClassification.java +++ b/src/main/java/com/example/eumserver/domain/announcement/filter/domain/OccupationClassification.java @@ -1,4 +1,4 @@ -package com.example.eumserver.domain.announcement.team.domain; +package com.example.eumserver.domain.announcement.filter.domain; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; diff --git a/src/main/java/com/example/eumserver/domain/announcement/team/domain/RecruitmentTypes.java b/src/main/java/com/example/eumserver/domain/announcement/filter/domain/RecruitmentTypes.java similarity index 75% rename from src/main/java/com/example/eumserver/domain/announcement/team/domain/RecruitmentTypes.java rename to src/main/java/com/example/eumserver/domain/announcement/filter/domain/RecruitmentTypes.java index ca2efe8..deb122a 100644 --- a/src/main/java/com/example/eumserver/domain/announcement/team/domain/RecruitmentTypes.java +++ b/src/main/java/com/example/eumserver/domain/announcement/filter/domain/RecruitmentTypes.java @@ -1,4 +1,4 @@ -package com.example.eumserver.domain.announcement.team.domain; +package com.example.eumserver.domain.announcement.filter.domain; /** * 모집 공고의 모집 유형을 나타낸 Enum Class 입니다. diff --git a/src/main/java/com/example/eumserver/domain/announcement/resume/controller/ResumeAnnouncementController.java b/src/main/java/com/example/eumserver/domain/announcement/resume/controller/ResumeAnnouncementController.java new file mode 100644 index 0000000..eccef8e --- /dev/null +++ b/src/main/java/com/example/eumserver/domain/announcement/resume/controller/ResumeAnnouncementController.java @@ -0,0 +1,22 @@ +package com.example.eumserver.domain.announcement.resume.controller; + +import com.example.eumserver.domain.announcement.resume.domain.ResumeAnnouncement; +import com.example.eumserver.domain.announcement.resume.service.ResumeAnnouncementService; +import com.example.eumserver.domain.resume.entity.Resume; +import com.example.eumserver.global.dto.ApiResult; +import lombok.RequiredArgsConstructor; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/api/resume/{resumeId}/announcement") +@RequiredArgsConstructor +public class ResumeAnnouncementController { + + private final ResumeAnnouncementService resumeAnnouncementService; + + @PostMapping("") + public ResponseEntity> +} diff --git a/src/main/java/com/example/eumserver/domain/announcement/team/domain/TeamAnnouncement.java b/src/main/java/com/example/eumserver/domain/announcement/team/domain/TeamAnnouncement.java index e2e4e99..d1e49ea 100644 --- a/src/main/java/com/example/eumserver/domain/announcement/team/domain/TeamAnnouncement.java +++ b/src/main/java/com/example/eumserver/domain/announcement/team/domain/TeamAnnouncement.java @@ -1,5 +1,6 @@ package com.example.eumserver.domain.announcement.team.domain; +import com.example.eumserver.domain.announcement.filter.domain.OccupationClassification; import com.example.eumserver.domain.announcement.team.dto.TeamAnnouncementUpdateRequest; import com.example.eumserver.domain.team.Team; import com.example.eumserver.global.dto.TimeStamp; diff --git a/src/main/java/com/example/eumserver/domain/announcement/team/dto/TeamAnnouncementFilter.java b/src/main/java/com/example/eumserver/domain/announcement/team/dto/TeamAnnouncementFilter.java index 98a1906..b76ad9d 100644 --- a/src/main/java/com/example/eumserver/domain/announcement/team/dto/TeamAnnouncementFilter.java +++ b/src/main/java/com/example/eumserver/domain/announcement/team/dto/TeamAnnouncementFilter.java @@ -1,6 +1,6 @@ package com.example.eumserver.domain.announcement.team.dto; -import com.example.eumserver.domain.announcement.team.domain.OccupationClassification; +import com.example.eumserver.domain.announcement.filter.domain.OccupationClassification; import java.util.List; diff --git a/src/main/java/com/example/eumserver/domain/announcement/team/dto/TeamAnnouncementRequest.java b/src/main/java/com/example/eumserver/domain/announcement/team/dto/TeamAnnouncementRequest.java index 65a87b1..d923435 100644 --- a/src/main/java/com/example/eumserver/domain/announcement/team/dto/TeamAnnouncementRequest.java +++ b/src/main/java/com/example/eumserver/domain/announcement/team/dto/TeamAnnouncementRequest.java @@ -1,6 +1,6 @@ package com.example.eumserver.domain.announcement.team.dto; -import com.example.eumserver.domain.announcement.team.domain.OccupationClassification; +import com.example.eumserver.domain.announcement.filter.domain.OccupationClassification; import org.springframework.format.annotation.DateTimeFormat; import java.time.LocalDateTime; diff --git a/src/main/java/com/example/eumserver/domain/announcement/team/dto/TeamAnnouncementUpdateRequest.java b/src/main/java/com/example/eumserver/domain/announcement/team/dto/TeamAnnouncementUpdateRequest.java index b400f6c..ea5dbf8 100644 --- a/src/main/java/com/example/eumserver/domain/announcement/team/dto/TeamAnnouncementUpdateRequest.java +++ b/src/main/java/com/example/eumserver/domain/announcement/team/dto/TeamAnnouncementUpdateRequest.java @@ -1,6 +1,6 @@ package com.example.eumserver.domain.announcement.team.dto; -import com.example.eumserver.domain.announcement.team.domain.OccupationClassification; +import com.example.eumserver.domain.announcement.filter.domain.OccupationClassification; import org.springframework.format.annotation.DateTimeFormat; import java.time.LocalDateTime; diff --git a/src/main/java/com/example/eumserver/domain/announcement/team/repository/TeamAnnouncementCustomRepositoryImpl.java b/src/main/java/com/example/eumserver/domain/announcement/team/repository/TeamAnnouncementCustomRepositoryImpl.java index 1f99959..769c29f 100644 --- a/src/main/java/com/example/eumserver/domain/announcement/team/repository/TeamAnnouncementCustomRepositoryImpl.java +++ b/src/main/java/com/example/eumserver/domain/announcement/team/repository/TeamAnnouncementCustomRepositoryImpl.java @@ -3,7 +3,7 @@ import com.example.eumserver.domain.announcement.team.dto.TeamAnnouncementFilter; import com.example.eumserver.domain.announcement.team.dto.TeamAnnouncementResponse; import com.example.eumserver.domain.announcement.team.mapper.TeamAnnouncementMapper; -import com.example.eumserver.domain.announcement.team.domain.OccupationClassification; +import com.example.eumserver.domain.announcement.filter.domain.OccupationClassification; import com.example.eumserver.domain.team.announcement.domain.QTeamAnnouncement; import com.example.eumserver.domain.announcement.team.domain.TeamAnnouncement; import com.querydsl.core.types.dsl.BooleanExpression; diff --git a/src/test/java/com/example/eumserver/domain/team/announcement/controller/AnnouncementControllerTest.java b/src/test/java/com/example/eumserver/domain/team/announcement/controller/AnnouncementControllerTest.java index 852e232..ddd1607 100644 --- a/src/test/java/com/example/eumserver/domain/team/announcement/controller/AnnouncementControllerTest.java +++ b/src/test/java/com/example/eumserver/domain/team/announcement/controller/AnnouncementControllerTest.java @@ -3,7 +3,7 @@ import com.example.eumserver.BaseIntegrationTest; import com.example.eumserver.domain.team.Team; import com.example.eumserver.domain.announcement.team.domain.TeamAnnouncement; -import com.example.eumserver.domain.announcement.team.domain.OccupationClassification; +import com.example.eumserver.domain.announcement.filter.domain.OccupationClassification; import com.example.eumserver.domain.announcement.team.dto.TeamAnnouncementFilter; import com.example.eumserver.domain.announcement.team.dto.TeamAnnouncementRequest; import com.example.eumserver.domain.announcement.team.dto.TeamAnnouncementUpdateRequest; From d8a11bda4172f35cbb37360fd0df836dd49062f4 Mon Sep 17 00:00:00 2001 From: Sukju Hong Date: Tue, 7 May 2024 15:51:39 +0900 Subject: [PATCH 18/22] =?UTF-8?q?feat:=20=EC=9D=B4=EB=A0=A5=EC=84=9C=20?= =?UTF-8?q?=EA=B3=B5=EA=B3=A0=20endpoint=20=EC=83=9D=EC=84=B1=20(#56)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ResumeAnnouncementController.java | 28 +++++++++++++++---- .../service/ResumeAnnouncementService.java | 5 ++-- .../team/service/TeamAnnouncementService.java | 2 +- .../global/error/exception/ErrorCode.java | 4 ++- 4 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/example/eumserver/domain/announcement/resume/controller/ResumeAnnouncementController.java b/src/main/java/com/example/eumserver/domain/announcement/resume/controller/ResumeAnnouncementController.java index eccef8e..f553f88 100644 --- a/src/main/java/com/example/eumserver/domain/announcement/resume/controller/ResumeAnnouncementController.java +++ b/src/main/java/com/example/eumserver/domain/announcement/resume/controller/ResumeAnnouncementController.java @@ -1,14 +1,12 @@ package com.example.eumserver.domain.announcement.resume.controller; -import com.example.eumserver.domain.announcement.resume.domain.ResumeAnnouncement; +import com.example.eumserver.domain.announcement.resume.dto.ResumeAnnouncementRequest; import com.example.eumserver.domain.announcement.resume.service.ResumeAnnouncementService; -import com.example.eumserver.domain.resume.entity.Resume; import com.example.eumserver.global.dto.ApiResult; import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; @RestController @RequestMapping("/api/resume/{resumeId}/announcement") @@ -18,5 +16,23 @@ public class ResumeAnnouncementController { private final ResumeAnnouncementService resumeAnnouncementService; @PostMapping("") - public ResponseEntity> + @ResponseStatus(HttpStatus.CREATED) + public ResponseEntity> createResumeAnnouncement( + @PathVariable Long resumeId, + @RequestBody ResumeAnnouncementRequest request) { + resumeAnnouncementService.publishResume(resumeId, request); + return ResponseEntity + .status(HttpStatus.CREATED) + .body(new ApiResult<>("이력서 공고 생성")); + } + + @DeleteMapping("/{resumeAnnouncementId}") + public ResponseEntity> deleteResumeAnnouncement( + @PathVariable Long resumeId, + @PathVariable Long resumeAnnouncementId) { + resumeAnnouncementService.unpublishResume(resumeId, resumeAnnouncementId); + return ResponseEntity + .status(HttpStatus.CREATED) + .body(new ApiResult<>("이력서 공고 생성")); + } } diff --git a/src/main/java/com/example/eumserver/domain/announcement/resume/service/ResumeAnnouncementService.java b/src/main/java/com/example/eumserver/domain/announcement/resume/service/ResumeAnnouncementService.java index d82ec79..037932a 100644 --- a/src/main/java/com/example/eumserver/domain/announcement/resume/service/ResumeAnnouncementService.java +++ b/src/main/java/com/example/eumserver/domain/announcement/resume/service/ResumeAnnouncementService.java @@ -32,10 +32,11 @@ public ResumeAnnouncement publishResume(Long resumeId, ResumeAnnouncementRequest return resumeAnnouncementRepository.save(resumeAnnouncement); } - public void unpublishResume(Long resumeId) { + public void unpublishResume(Long resumeId, Long resumeAnnouncementId) { Resume resume = resumeRepository.findById(resumeId) .orElseThrow(() -> new CustomException(ErrorCode.RESUME_NOT_FOUND)); - ResumeAnnouncement resumeAnnouncement = resume.getResumeAnnouncement(); + ResumeAnnouncement resumeAnnouncement = resumeAnnouncementRepository.findById(resumeAnnouncementId) + .orElseThrow(() -> new CustomException(ErrorCode.RESUME_ANNOUNCEMENT_NOT_FOUND)); resume.unpublishResume(); resumeRepository.save(resume); diff --git a/src/main/java/com/example/eumserver/domain/announcement/team/service/TeamAnnouncementService.java b/src/main/java/com/example/eumserver/domain/announcement/team/service/TeamAnnouncementService.java index 84bba4d..3b4c720 100644 --- a/src/main/java/com/example/eumserver/domain/announcement/team/service/TeamAnnouncementService.java +++ b/src/main/java/com/example/eumserver/domain/announcement/team/service/TeamAnnouncementService.java @@ -74,6 +74,6 @@ public void deleteAnnouncement(Long announcementId) { public TeamAnnouncement findAnnouncementById(Long announcementId) { return announcementRepository.findById(announcementId) - .orElseThrow(() -> new CustomException(ErrorCode.ANNOUNCEMENT_NOT_FOUND)); + .orElseThrow(() -> new CustomException(ErrorCode.TEAM_ANNOUNCEMENT_NOT_FOUND)); } } diff --git a/src/main/java/com/example/eumserver/global/error/exception/ErrorCode.java b/src/main/java/com/example/eumserver/global/error/exception/ErrorCode.java index 225f7d1..115e9b7 100644 --- a/src/main/java/com/example/eumserver/global/error/exception/ErrorCode.java +++ b/src/main/java/com/example/eumserver/global/error/exception/ErrorCode.java @@ -30,7 +30,9 @@ public enum ErrorCode { INVITE_NOT_FOUND(400, "INVITE-001", "초대를 찾을 수 없음"), EXPIRED_INVITE(400, "INVITE-002", "해당 초대가 만료됨"), - ANNOUNCEMENT_NOT_FOUND(400, "ANNOUNCEMENT-001", "팀 공고를 찾을 수 없음"); + TEAM_ANNOUNCEMENT_NOT_FOUND(400, "TEAM-ANNOUNCEMENT-001", "팀 공고를 찾을 수 없음"), + + RESUME_ANNOUNCEMENT_NOT_FOUND(400, "RESUME-ANNOUNCEMENT-001", "이력서 공고를 찾을 수 없음."); private final int status; private final String code; From 1e347e9302a9a359594f0148bd5d1d7356e0c3da Mon Sep 17 00:00:00 2001 From: Sukju Hong Date: Tue, 7 May 2024 15:52:26 +0900 Subject: [PATCH 19/22] =?UTF-8?q?chore:=20publishResume=20return=20?= =?UTF-8?q?=EA=B0=92=20=EB=B3=80=EA=B2=BD=20(#56)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resume/service/ResumeAnnouncementService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/example/eumserver/domain/announcement/resume/service/ResumeAnnouncementService.java b/src/main/java/com/example/eumserver/domain/announcement/resume/service/ResumeAnnouncementService.java index 037932a..06966ed 100644 --- a/src/main/java/com/example/eumserver/domain/announcement/resume/service/ResumeAnnouncementService.java +++ b/src/main/java/com/example/eumserver/domain/announcement/resume/service/ResumeAnnouncementService.java @@ -20,7 +20,7 @@ public class ResumeAnnouncementService { private final ResumeRepository resumeRepository; private final ResumeAnnouncementRepository resumeAnnouncementRepository; - public ResumeAnnouncement publishResume(Long resumeId, ResumeAnnouncementRequest resumeAnnouncementRequest) { + public void publishResume(Long resumeId, ResumeAnnouncementRequest resumeAnnouncementRequest) { Resume resume = resumeRepository.findById(resumeId) .orElseThrow(() -> new CustomException(ErrorCode.RESUME_NOT_FOUND)); @@ -29,7 +29,7 @@ public ResumeAnnouncement publishResume(Long resumeId, ResumeAnnouncementRequest resume.publishResume(resumeAnnouncement); resumeRepository.save(resume); - return resumeAnnouncementRepository.save(resumeAnnouncement); + resumeAnnouncementRepository.save(resumeAnnouncement); } public void unpublishResume(Long resumeId, Long resumeAnnouncementId) { From 75a74398cae217103c2f49e50ba12be83b6a37b3 Mon Sep 17 00:00:00 2001 From: Sukju Hong Date: Tue, 7 May 2024 15:56:56 +0900 Subject: [PATCH 20/22] =?UTF-8?q?fix:=20=ED=8C=80=20=EA=B3=B5=EA=B3=A0=20i?= =?UTF-8?q?mport=20=EC=98=A4=EB=A5=98=20(#56)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../team/repository/TeamAnnouncementCustomRepositoryImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/example/eumserver/domain/announcement/team/repository/TeamAnnouncementCustomRepositoryImpl.java b/src/main/java/com/example/eumserver/domain/announcement/team/repository/TeamAnnouncementCustomRepositoryImpl.java index 769c29f..dff1904 100644 --- a/src/main/java/com/example/eumserver/domain/announcement/team/repository/TeamAnnouncementCustomRepositoryImpl.java +++ b/src/main/java/com/example/eumserver/domain/announcement/team/repository/TeamAnnouncementCustomRepositoryImpl.java @@ -1,10 +1,10 @@ package com.example.eumserver.domain.announcement.team.repository; +import com.example.eumserver.domain.announcement.team.domain.QTeamAnnouncement; import com.example.eumserver.domain.announcement.team.dto.TeamAnnouncementFilter; import com.example.eumserver.domain.announcement.team.dto.TeamAnnouncementResponse; import com.example.eumserver.domain.announcement.team.mapper.TeamAnnouncementMapper; import com.example.eumserver.domain.announcement.filter.domain.OccupationClassification; -import com.example.eumserver.domain.team.announcement.domain.QTeamAnnouncement; import com.example.eumserver.domain.announcement.team.domain.TeamAnnouncement; import com.querydsl.core.types.dsl.BooleanExpression; import com.querydsl.jpa.impl.JPAQuery; From 7e41c232951bf4e52469e3235fa0f2e28962584b Mon Sep 17 00:00:00 2001 From: Sukju Hong Date: Tue, 7 May 2024 16:01:07 +0900 Subject: [PATCH 21/22] =?UTF-8?q?refactor:=20TeamAnnouncementControllerTes?= =?UTF-8?q?t=EB=A1=9C=20=EB=B3=80=EA=B2=BD=20(#56)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../team/controller/TeamAnnouncementControllerTest.java} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename src/test/java/com/example/eumserver/domain/{team/announcement/controller/AnnouncementControllerTest.java => announcement/team/controller/TeamAnnouncementControllerTest.java} (98%) diff --git a/src/test/java/com/example/eumserver/domain/team/announcement/controller/AnnouncementControllerTest.java b/src/test/java/com/example/eumserver/domain/announcement/team/controller/TeamAnnouncementControllerTest.java similarity index 98% rename from src/test/java/com/example/eumserver/domain/team/announcement/controller/AnnouncementControllerTest.java rename to src/test/java/com/example/eumserver/domain/announcement/team/controller/TeamAnnouncementControllerTest.java index ddd1607..074220d 100644 --- a/src/test/java/com/example/eumserver/domain/team/announcement/controller/AnnouncementControllerTest.java +++ b/src/test/java/com/example/eumserver/domain/announcement/team/controller/TeamAnnouncementControllerTest.java @@ -1,4 +1,4 @@ -package com.example.eumserver.domain.team.announcement.controller; +package com.example.eumserver.domain.announcement.team.controller; import com.example.eumserver.BaseIntegrationTest; import com.example.eumserver.domain.team.Team; @@ -25,7 +25,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -class AnnouncementControllerTest extends BaseIntegrationTest { +class TeamAnnouncementControllerTest extends BaseIntegrationTest { final String BASE_URI = "/api/team/{teamId}/announcement"; From fd4e813b7498b00651ca572feebd9ab58a1bff47 Mon Sep 17 00:00:00 2001 From: Sukju Hong Date: Tue, 7 May 2024 16:34:13 +0900 Subject: [PATCH 22/22] =?UTF-8?q?feat:=20=EC=9D=B4=EB=A0=A5=EC=84=9C=20?= =?UTF-8?q?=EA=B3=B5=EA=B3=A0=20=ED=95=84=ED=84=B0=EB=A7=81=20=EB=B0=8F=20?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=A7=95=20(#56)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ResumeAnnouncementController.java | 20 +++++-- .../resume/domain/ResumeAnnouncement.java | 14 ++++- .../resume/dto/ResumeAnnouncementFilter.java | 10 ++++ .../resume/dto/ResumeAnnouncementRequest.java | 1 + .../dto/ResumeAnnouncementResponse.java | 13 ++++ .../ResumeAnnouncementCustomRepository.java | 11 ++++ ...esumeAnnouncementCustomRepositoryImpl.java | 59 +++++++++++++++++++ .../ResumeAnnouncementRepository.java | 2 +- .../service/ResumeAnnouncementService.java | 30 ++++++---- .../eumserver/domain/resume/ResumeMapper.java | 2 - .../domain/resume/ResumeRepository.java | 3 +- .../domain/resume/entity/Resume.java | 17 ------ 12 files changed, 144 insertions(+), 38 deletions(-) create mode 100644 src/main/java/com/example/eumserver/domain/announcement/resume/dto/ResumeAnnouncementFilter.java create mode 100644 src/main/java/com/example/eumserver/domain/announcement/resume/dto/ResumeAnnouncementResponse.java create mode 100644 src/main/java/com/example/eumserver/domain/announcement/resume/repository/ResumeAnnouncementCustomRepository.java create mode 100644 src/main/java/com/example/eumserver/domain/announcement/resume/repository/ResumeAnnouncementCustomRepositoryImpl.java diff --git a/src/main/java/com/example/eumserver/domain/announcement/resume/controller/ResumeAnnouncementController.java b/src/main/java/com/example/eumserver/domain/announcement/resume/controller/ResumeAnnouncementController.java index f553f88..121de60 100644 --- a/src/main/java/com/example/eumserver/domain/announcement/resume/controller/ResumeAnnouncementController.java +++ b/src/main/java/com/example/eumserver/domain/announcement/resume/controller/ResumeAnnouncementController.java @@ -1,15 +1,18 @@ package com.example.eumserver.domain.announcement.resume.controller; +import com.example.eumserver.domain.announcement.resume.dto.ResumeAnnouncementFilter; import com.example.eumserver.domain.announcement.resume.dto.ResumeAnnouncementRequest; +import com.example.eumserver.domain.announcement.resume.dto.ResumeAnnouncementResponse; import com.example.eumserver.domain.announcement.resume.service.ResumeAnnouncementService; import com.example.eumserver.global.dto.ApiResult; import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Page; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; @RestController -@RequestMapping("/api/resume/{resumeId}/announcement") +@RequestMapping("/api/resume-announcement") @RequiredArgsConstructor public class ResumeAnnouncementController { @@ -18,9 +21,8 @@ public class ResumeAnnouncementController { @PostMapping("") @ResponseStatus(HttpStatus.CREATED) public ResponseEntity> createResumeAnnouncement( - @PathVariable Long resumeId, @RequestBody ResumeAnnouncementRequest request) { - resumeAnnouncementService.publishResume(resumeId, request); + resumeAnnouncementService.publishResume(request); return ResponseEntity .status(HttpStatus.CREATED) .body(new ApiResult<>("이력서 공고 생성")); @@ -28,11 +30,19 @@ public ResponseEntity> createResumeAnnouncement( @DeleteMapping("/{resumeAnnouncementId}") public ResponseEntity> deleteResumeAnnouncement( - @PathVariable Long resumeId, @PathVariable Long resumeAnnouncementId) { - resumeAnnouncementService.unpublishResume(resumeId, resumeAnnouncementId); + resumeAnnouncementService.unpublishResume(resumeAnnouncementId); return ResponseEntity .status(HttpStatus.CREATED) .body(new ApiResult<>("이력서 공고 생성")); } + + @GetMapping("") + public ResponseEntity>> getResumeAnnouncements( + @RequestBody ResumeAnnouncementFilter filter, + @RequestParam(name = "page", defaultValue = "0") int page + ) { + Page resumeAnnouncementResponses = resumeAnnouncementService.getResumeAnnouncements(filter, page); + return ResponseEntity.ok(new ApiResult<>("이력서 공고 필터링 및 페이징 조회 성공", resumeAnnouncementResponses)); + } } diff --git a/src/main/java/com/example/eumserver/domain/announcement/resume/domain/ResumeAnnouncement.java b/src/main/java/com/example/eumserver/domain/announcement/resume/domain/ResumeAnnouncement.java index 53107de..f38e06c 100644 --- a/src/main/java/com/example/eumserver/domain/announcement/resume/domain/ResumeAnnouncement.java +++ b/src/main/java/com/example/eumserver/domain/announcement/resume/domain/ResumeAnnouncement.java @@ -1,9 +1,13 @@ package com.example.eumserver.domain.announcement.resume.domain; +import com.example.eumserver.domain.announcement.filter.domain.OccupationClassification; import com.example.eumserver.domain.resume.entity.Resume; +import com.example.eumserver.global.dto.TimeStamp; import jakarta.persistence.*; import lombok.*; +import java.util.List; + @Entity @Table(name = "resume_announcements") @Getter @@ -20,7 +24,15 @@ public class ResumeAnnouncement { @Column(nullable = false) private String introduction; + @ElementCollection(targetClass = OccupationClassification.class) + @Enumerated(EnumType.STRING) + private List occupationClassifications; + @Setter - @OneToOne(mappedBy = "resumeAnnouncement") + @OneToOne(fetch = FetchType.LAZY, orphanRemoval = true) + @JoinColumn(name = "resume_id") private Resume resume; + + @Embedded + private TimeStamp timeStamp; } diff --git a/src/main/java/com/example/eumserver/domain/announcement/resume/dto/ResumeAnnouncementFilter.java b/src/main/java/com/example/eumserver/domain/announcement/resume/dto/ResumeAnnouncementFilter.java new file mode 100644 index 0000000..0148a49 --- /dev/null +++ b/src/main/java/com/example/eumserver/domain/announcement/resume/dto/ResumeAnnouncementFilter.java @@ -0,0 +1,10 @@ +package com.example.eumserver.domain.announcement.resume.dto; + +import com.example.eumserver.domain.announcement.filter.domain.OccupationClassification; + +import java.util.List; + +public record ResumeAnnouncementFilter( + List occupationClassifications +) { +} diff --git a/src/main/java/com/example/eumserver/domain/announcement/resume/dto/ResumeAnnouncementRequest.java b/src/main/java/com/example/eumserver/domain/announcement/resume/dto/ResumeAnnouncementRequest.java index 880406f..2347466 100644 --- a/src/main/java/com/example/eumserver/domain/announcement/resume/dto/ResumeAnnouncementRequest.java +++ b/src/main/java/com/example/eumserver/domain/announcement/resume/dto/ResumeAnnouncementRequest.java @@ -1,6 +1,7 @@ package com.example.eumserver.domain.announcement.resume.dto; public record ResumeAnnouncementRequest( + Long resumeId, String introduction ) { } diff --git a/src/main/java/com/example/eumserver/domain/announcement/resume/dto/ResumeAnnouncementResponse.java b/src/main/java/com/example/eumserver/domain/announcement/resume/dto/ResumeAnnouncementResponse.java new file mode 100644 index 0000000..dfc57c1 --- /dev/null +++ b/src/main/java/com/example/eumserver/domain/announcement/resume/dto/ResumeAnnouncementResponse.java @@ -0,0 +1,13 @@ +package com.example.eumserver.domain.announcement.resume.dto; + +import com.example.eumserver.domain.announcement.filter.domain.OccupationClassification; + +import java.util.List; + +public record ResumeAnnouncementResponse( + Long id, + Long resumeId, + String introduction, + List occupationClassifications +) { +} diff --git a/src/main/java/com/example/eumserver/domain/announcement/resume/repository/ResumeAnnouncementCustomRepository.java b/src/main/java/com/example/eumserver/domain/announcement/resume/repository/ResumeAnnouncementCustomRepository.java new file mode 100644 index 0000000..033315e --- /dev/null +++ b/src/main/java/com/example/eumserver/domain/announcement/resume/repository/ResumeAnnouncementCustomRepository.java @@ -0,0 +1,11 @@ +package com.example.eumserver.domain.announcement.resume.repository; + +import com.example.eumserver.domain.announcement.resume.dto.ResumeAnnouncementFilter; +import com.example.eumserver.domain.announcement.resume.dto.ResumeAnnouncementResponse; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; + +public interface ResumeAnnouncementCustomRepository { + + Page findResumeAnnouncementsWithFilteredAndPagination(ResumeAnnouncementFilter filter, Pageable pageable); +} diff --git a/src/main/java/com/example/eumserver/domain/announcement/resume/repository/ResumeAnnouncementCustomRepositoryImpl.java b/src/main/java/com/example/eumserver/domain/announcement/resume/repository/ResumeAnnouncementCustomRepositoryImpl.java new file mode 100644 index 0000000..3c8512e --- /dev/null +++ b/src/main/java/com/example/eumserver/domain/announcement/resume/repository/ResumeAnnouncementCustomRepositoryImpl.java @@ -0,0 +1,59 @@ +package com.example.eumserver.domain.announcement.resume.repository; + +import com.example.eumserver.domain.announcement.filter.domain.OccupationClassification; +import com.example.eumserver.domain.announcement.resume.domain.QResumeAnnouncement; +import com.example.eumserver.domain.announcement.resume.domain.ResumeAnnouncement; +import com.example.eumserver.domain.announcement.resume.dto.ResumeAnnouncementFilter; +import com.example.eumserver.domain.announcement.resume.dto.ResumeAnnouncementResponse; +import com.querydsl.core.types.dsl.BooleanExpression; +import com.querydsl.jpa.impl.JPAQuery; +import com.querydsl.jpa.impl.JPAQueryFactory; +import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.support.PageableExecutionUtils; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +@RequiredArgsConstructor +public class ResumeAnnouncementCustomRepositoryImpl implements ResumeAnnouncementCustomRepository { + + private final JPAQueryFactory queryFactory; + + @Override + public Page findResumeAnnouncementsWithFilteredAndPagination(ResumeAnnouncementFilter filter, Pageable pageable) { + + QResumeAnnouncement resumeAnnouncement = QResumeAnnouncement.resumeAnnouncement; + BooleanExpression predicate = resumeAnnouncement.isNotNull(); + + List occupationClassifications = filter.occupationClassifications(); + if (occupationClassifications != null && !occupationClassifications.isEmpty()) { + predicate = predicate.and(resumeAnnouncement.occupationClassifications.any().in(occupationClassifications)); + } + + List announcements = queryFactory + .select(resumeAnnouncement) + .where(predicate) + .offset(pageable.getOffset()) + .limit(pageable.getPageSize()) + .fetch(); + + List resumeAnnouncementResponses = announcements.stream() + .map(announcement -> + new ResumeAnnouncementResponse( + announcement.getId(), + announcement.getResume().getId(), + announcement.getIntroduction(), + announcement.getOccupationClassifications())).toList(); + + JPAQuery count = queryFactory + .select(resumeAnnouncement.count()) + .from(resumeAnnouncement) + .where(predicate); + + return PageableExecutionUtils.getPage(resumeAnnouncementResponses, pageable, count::fetchOne); + } + +} diff --git a/src/main/java/com/example/eumserver/domain/announcement/resume/repository/ResumeAnnouncementRepository.java b/src/main/java/com/example/eumserver/domain/announcement/resume/repository/ResumeAnnouncementRepository.java index f43fd0e..2904ea5 100644 --- a/src/main/java/com/example/eumserver/domain/announcement/resume/repository/ResumeAnnouncementRepository.java +++ b/src/main/java/com/example/eumserver/domain/announcement/resume/repository/ResumeAnnouncementRepository.java @@ -3,4 +3,4 @@ import com.example.eumserver.domain.announcement.resume.domain.ResumeAnnouncement; import org.springframework.data.jpa.repository.JpaRepository; -public interface ResumeAnnouncementRepository extends JpaRepository { } +public interface ResumeAnnouncementRepository extends JpaRepository, ResumeAnnouncementCustomRepository { } diff --git a/src/main/java/com/example/eumserver/domain/announcement/resume/service/ResumeAnnouncementService.java b/src/main/java/com/example/eumserver/domain/announcement/resume/service/ResumeAnnouncementService.java index 06966ed..79049ad 100644 --- a/src/main/java/com/example/eumserver/domain/announcement/resume/service/ResumeAnnouncementService.java +++ b/src/main/java/com/example/eumserver/domain/announcement/resume/service/ResumeAnnouncementService.java @@ -1,5 +1,7 @@ package com.example.eumserver.domain.announcement.resume.service; +import com.example.eumserver.domain.announcement.resume.dto.ResumeAnnouncementFilter; +import com.example.eumserver.domain.announcement.resume.dto.ResumeAnnouncementResponse; import com.example.eumserver.domain.announcement.resume.mapper.ResumeAnnouncementMapper; import com.example.eumserver.domain.announcement.resume.repository.ResumeAnnouncementRepository; import com.example.eumserver.domain.resume.ResumeRepository; @@ -9,9 +11,16 @@ import com.example.eumserver.global.error.exception.CustomException; import com.example.eumserver.global.error.exception.ErrorCode; import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.util.ArrayList; +import java.util.List; + @Service @RequiredArgsConstructor @Transactional(readOnly = true) @@ -20,27 +29,26 @@ public class ResumeAnnouncementService { private final ResumeRepository resumeRepository; private final ResumeAnnouncementRepository resumeAnnouncementRepository; - public void publishResume(Long resumeId, ResumeAnnouncementRequest resumeAnnouncementRequest) { - Resume resume = resumeRepository.findById(resumeId) + public void publishResume(ResumeAnnouncementRequest resumeAnnouncementRequest) { + Resume resume = resumeRepository.findById(resumeAnnouncementRequest.resumeId()) .orElseThrow(() -> new CustomException(ErrorCode.RESUME_NOT_FOUND)); ResumeAnnouncement resumeAnnouncement = ResumeAnnouncementMapper.INSTANCE .requestToEntity(resumeAnnouncementRequest); - - resume.publishResume(resumeAnnouncement); - resumeRepository.save(resume); + resumeAnnouncement.setResume(resume); resumeAnnouncementRepository.save(resumeAnnouncement); } - public void unpublishResume(Long resumeId, Long resumeAnnouncementId) { - Resume resume = resumeRepository.findById(resumeId) - .orElseThrow(() -> new CustomException(ErrorCode.RESUME_NOT_FOUND)); + public void unpublishResume(Long resumeAnnouncementId) { ResumeAnnouncement resumeAnnouncement = resumeAnnouncementRepository.findById(resumeAnnouncementId) .orElseThrow(() -> new CustomException(ErrorCode.RESUME_ANNOUNCEMENT_NOT_FOUND)); - - resume.unpublishResume(); - resumeRepository.save(resume); resumeAnnouncementRepository.delete(resumeAnnouncement); } + public Page getResumeAnnouncements(ResumeAnnouncementFilter filter, int page) { + List sorts = new ArrayList<>(); + sorts.add(Sort.Order.desc("date_created")); + Pageable pageable = PageRequest.of(page, 12, Sort.by(sorts)); + return resumeRepository.findResumeAnnouncementsWithFilteredAndPagination(filter, pageable); + } } diff --git a/src/main/java/com/example/eumserver/domain/resume/ResumeMapper.java b/src/main/java/com/example/eumserver/domain/resume/ResumeMapper.java index 4f8ba27..ab46be1 100644 --- a/src/main/java/com/example/eumserver/domain/resume/ResumeMapper.java +++ b/src/main/java/com/example/eumserver/domain/resume/ResumeMapper.java @@ -15,8 +15,6 @@ public interface ResumeMapper { @Mapping(target = "id", ignore = true) @Mapping(target = "timeStamp", ignore = true) @Mapping(target = "user", ignore = true) - @Mapping(target = "resumeAnnouncement", ignore = true) - @Mapping(target = "isPublished", ignore = true) Resume resumeRequestToResume(ResumeRequest resumeRequest); @AfterMapping diff --git a/src/main/java/com/example/eumserver/domain/resume/ResumeRepository.java b/src/main/java/com/example/eumserver/domain/resume/ResumeRepository.java index 9a1d01c..7b488a4 100644 --- a/src/main/java/com/example/eumserver/domain/resume/ResumeRepository.java +++ b/src/main/java/com/example/eumserver/domain/resume/ResumeRepository.java @@ -1,12 +1,13 @@ package com.example.eumserver.domain.resume; +import com.example.eumserver.domain.announcement.resume.repository.ResumeAnnouncementCustomRepository; import com.example.eumserver.domain.resume.entity.Resume; import org.springframework.data.jpa.repository.JpaRepository; import java.util.List; import java.util.Optional; -public interface ResumeRepository extends JpaRepository { +public interface ResumeRepository extends JpaRepository, ResumeAnnouncementCustomRepository { Optional findById(Long resumeId); List findByUserId(Long userId); } diff --git a/src/main/java/com/example/eumserver/domain/resume/entity/Resume.java b/src/main/java/com/example/eumserver/domain/resume/entity/Resume.java index 82b0717..944aa83 100644 --- a/src/main/java/com/example/eumserver/domain/resume/entity/Resume.java +++ b/src/main/java/com/example/eumserver/domain/resume/entity/Resume.java @@ -1,6 +1,5 @@ package com.example.eumserver.domain.resume.entity; -import com.example.eumserver.domain.announcement.resume.domain.ResumeAnnouncement; import com.example.eumserver.domain.user.User; import com.example.eumserver.global.dto.TimeStamp; import com.fasterxml.jackson.annotation.JsonIgnore; @@ -65,12 +64,6 @@ public class Resume { @OneToMany(mappedBy = "resume", cascade = CascadeType.ALL, orphanRemoval = true) private List homepages = new ArrayList<>(); - @OneToOne(fetch = FetchType.LAZY, orphanRemoval = true) - @JoinColumn(name = "resume_announcement_id") - private ResumeAnnouncement resumeAnnouncement; - - @Builder.Default - private Boolean isPublished = false; @Embedded private TimeStamp timeStamp; @@ -99,14 +92,4 @@ public void updateResume(Resume resume) { this.homepages.addAll(resume.getHomepages()); } - public void publishResume(ResumeAnnouncement resumeAnnouncement) { - this.resumeAnnouncement = resumeAnnouncement; - resumeAnnouncement.setResume(this); - this.isPublished = true; - } - - public void unpublishResume() { - this.resumeAnnouncement = null; - this.isPublished = false; - } }