-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #60 from sukjuhong/feature/sukjuhong/resume-announ…
…cement feature: 이력서 공고 기능 구현
- Loading branch information
Showing
38 changed files
with
495 additions
and
247 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...ment/domain/OccupationClassification.java → ...lter/domain/OccupationClassification.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...announcement/domain/RecruitmentTypes.java → ...ement/filter/domain/RecruitmentTypes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...example/eumserver/domain/announcement/resume/controller/ResumeAnnouncementController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
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-announcement") | ||
@RequiredArgsConstructor | ||
public class ResumeAnnouncementController { | ||
|
||
private final ResumeAnnouncementService resumeAnnouncementService; | ||
|
||
@PostMapping("") | ||
@ResponseStatus(HttpStatus.CREATED) | ||
public ResponseEntity<ApiResult<?>> createResumeAnnouncement( | ||
@RequestBody ResumeAnnouncementRequest request) { | ||
resumeAnnouncementService.publishResume(request); | ||
return ResponseEntity | ||
.status(HttpStatus.CREATED) | ||
.body(new ApiResult<>("이력서 공고 생성")); | ||
} | ||
|
||
@DeleteMapping("/{resumeAnnouncementId}") | ||
public ResponseEntity<ApiResult<?>> deleteResumeAnnouncement( | ||
@PathVariable Long resumeAnnouncementId) { | ||
resumeAnnouncementService.unpublishResume(resumeAnnouncementId); | ||
return ResponseEntity | ||
.status(HttpStatus.CREATED) | ||
.body(new ApiResult<>("이력서 공고 생성")); | ||
} | ||
|
||
@GetMapping("") | ||
public ResponseEntity<ApiResult<Page<ResumeAnnouncementResponse>>> getResumeAnnouncements( | ||
@RequestBody ResumeAnnouncementFilter filter, | ||
@RequestParam(name = "page", defaultValue = "0") int page | ||
) { | ||
Page<ResumeAnnouncementResponse> resumeAnnouncementResponses = resumeAnnouncementService.getResumeAnnouncements(filter, page); | ||
return ResponseEntity.ok(new ApiResult<>("이력서 공고 필터링 및 페이징 조회 성공", resumeAnnouncementResponses)); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
...main/java/com/example/eumserver/domain/announcement/resume/domain/ResumeAnnouncement.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
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 | ||
@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; | ||
|
||
@ElementCollection(targetClass = OccupationClassification.class) | ||
@Enumerated(EnumType.STRING) | ||
private List<OccupationClassification> occupationClassifications; | ||
|
||
@Setter | ||
@OneToOne(fetch = FetchType.LAZY, orphanRemoval = true) | ||
@JoinColumn(name = "resume_id") | ||
private Resume resume; | ||
|
||
@Embedded | ||
private TimeStamp timeStamp; | ||
} |
10 changes: 10 additions & 0 deletions
10
...n/java/com/example/eumserver/domain/announcement/resume/dto/ResumeAnnouncementFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<OccupationClassification> occupationClassifications | ||
) { | ||
} |
7 changes: 7 additions & 0 deletions
7
.../java/com/example/eumserver/domain/announcement/resume/dto/ResumeAnnouncementRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.example.eumserver.domain.announcement.resume.dto; | ||
|
||
public record ResumeAnnouncementRequest( | ||
Long resumeId, | ||
String introduction | ||
) { | ||
} |
13 changes: 13 additions & 0 deletions
13
...java/com/example/eumserver/domain/announcement/resume/dto/ResumeAnnouncementResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<OccupationClassification> occupationClassifications | ||
) { | ||
} |
17 changes: 17 additions & 0 deletions
17
...ava/com/example/eumserver/domain/announcement/resume/mapper/ResumeAnnouncementMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.example.eumserver.domain.announcement.resume.mapper; | ||
|
||
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; | ||
|
||
@Mapper | ||
public interface ResumeAnnouncementMapper { | ||
|
||
ResumeAnnouncementMapper INSTANCE = Mappers.getMapper(ResumeAnnouncementMapper.class); | ||
|
||
@Mapping(target = "id", ignore = true) | ||
@Mapping(target = "resume", ignore = true) | ||
ResumeAnnouncement requestToEntity(ResumeAnnouncementRequest resumeAnnouncementRequest); | ||
} |
11 changes: 11 additions & 0 deletions
11
...e/eumserver/domain/announcement/resume/repository/ResumeAnnouncementCustomRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<ResumeAnnouncementResponse> findResumeAnnouncementsWithFilteredAndPagination(ResumeAnnouncementFilter filter, Pageable pageable); | ||
} |
59 changes: 59 additions & 0 deletions
59
...mserver/domain/announcement/resume/repository/ResumeAnnouncementCustomRepositoryImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<ResumeAnnouncementResponse> findResumeAnnouncementsWithFilteredAndPagination(ResumeAnnouncementFilter filter, Pageable pageable) { | ||
|
||
QResumeAnnouncement resumeAnnouncement = QResumeAnnouncement.resumeAnnouncement; | ||
BooleanExpression predicate = resumeAnnouncement.isNotNull(); | ||
|
||
List<OccupationClassification> occupationClassifications = filter.occupationClassifications(); | ||
if (occupationClassifications != null && !occupationClassifications.isEmpty()) { | ||
predicate = predicate.and(resumeAnnouncement.occupationClassifications.any().in(occupationClassifications)); | ||
} | ||
|
||
List<ResumeAnnouncement> announcements = queryFactory | ||
.select(resumeAnnouncement) | ||
.where(predicate) | ||
.offset(pageable.getOffset()) | ||
.limit(pageable.getPageSize()) | ||
.fetch(); | ||
|
||
List<ResumeAnnouncementResponse> resumeAnnouncementResponses = announcements.stream() | ||
.map(announcement -> | ||
new ResumeAnnouncementResponse( | ||
announcement.getId(), | ||
announcement.getResume().getId(), | ||
announcement.getIntroduction(), | ||
announcement.getOccupationClassifications())).toList(); | ||
|
||
JPAQuery<Long> count = queryFactory | ||
.select(resumeAnnouncement.count()) | ||
.from(resumeAnnouncement) | ||
.where(predicate); | ||
|
||
return PageableExecutionUtils.getPage(resumeAnnouncementResponses, pageable, count::fetchOne); | ||
} | ||
|
||
} |
6 changes: 6 additions & 0 deletions
6
...example/eumserver/domain/announcement/resume/repository/ResumeAnnouncementRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.example.eumserver.domain.announcement.resume.repository; | ||
|
||
import com.example.eumserver.domain.announcement.resume.domain.ResumeAnnouncement; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface ResumeAnnouncementRepository extends JpaRepository<ResumeAnnouncement, Long>, ResumeAnnouncementCustomRepository { } |
54 changes: 54 additions & 0 deletions
54
...a/com/example/eumserver/domain/announcement/resume/service/ResumeAnnouncementService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
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; | ||
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; | ||
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) | ||
public class ResumeAnnouncementService { | ||
|
||
private final ResumeRepository resumeRepository; | ||
private final ResumeAnnouncementRepository resumeAnnouncementRepository; | ||
|
||
public void publishResume(ResumeAnnouncementRequest resumeAnnouncementRequest) { | ||
Resume resume = resumeRepository.findById(resumeAnnouncementRequest.resumeId()) | ||
.orElseThrow(() -> new CustomException(ErrorCode.RESUME_NOT_FOUND)); | ||
|
||
ResumeAnnouncement resumeAnnouncement = ResumeAnnouncementMapper.INSTANCE | ||
.requestToEntity(resumeAnnouncementRequest); | ||
resumeAnnouncement.setResume(resume); | ||
resumeAnnouncementRepository.save(resumeAnnouncement); | ||
} | ||
|
||
public void unpublishResume(Long resumeAnnouncementId) { | ||
ResumeAnnouncement resumeAnnouncement = resumeAnnouncementRepository.findById(resumeAnnouncementId) | ||
.orElseThrow(() -> new CustomException(ErrorCode.RESUME_ANNOUNCEMENT_NOT_FOUND)); | ||
resumeAnnouncementRepository.delete(resumeAnnouncement); | ||
} | ||
|
||
public Page<ResumeAnnouncementResponse> getResumeAnnouncements(ResumeAnnouncementFilter filter, int page) { | ||
List<Sort.Order> sorts = new ArrayList<>(); | ||
sorts.add(Sort.Order.desc("date_created")); | ||
Pageable pageable = PageRequest.of(page, 12, Sort.by(sorts)); | ||
return resumeRepository.findResumeAnnouncementsWithFilteredAndPagination(filter, pageable); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.