-
Notifications
You must be signed in to change notification settings - Fork 0
[CMAT-33] feat: 채용 공고 스크랩 CRD 구현 #24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
54e9ebf
[CMAT-33] feat: 채용 공고 스크랩 CRD API를 구현한다
momuzzi ec4068f
[CMAT-33] feat: 추천 채용 공고 조회 반환값에 isScraped(스크랩 여부)를 추가한다
momuzzi 27659d6
[CMAT-33] fix: 채용 공고 미사용 정렬 기준을 삭제한다
momuzzi 565eca6
[CMAT-33] fix: 채용 공고 조회 관련 response 갑들을 수정한다
momuzzi e49a646
[CMAT-33] fix: CommonErrorCode를 수정한다
momuzzi 17235e0
[CMAT-33] docs: RecruitController swagger를 업데이트한다
momuzzi fed666e
[CMAT-33] docs: RecruitController swagger를 업데이트한다
momuzzi 43c9579
[CMAT-33] docs: RecruitScrapController swagger를 업데이트한다
momuzzi dbecb6f
[CMAT-33] docs: RecruitController swagger를 업데이트한다
momuzzi dec5f53
[CMAT-33] fix: imageUrl을 반환하는 로직을 삭제한다
momuzzi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
8 changes: 1 addition & 7 deletions
8
src/main/java/UMC/career_mate/domain/recruit/dto/response/RecruitInfoDTO.java
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
65 changes: 65 additions & 0 deletions
65
src/main/java/UMC/career_mate/domain/recruitScrap/controller/RecruitScrapController.java
This file contains hidden or 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,65 @@ | ||
| package UMC.career_mate.domain.recruitScrap.controller; | ||
|
|
||
| import UMC.career_mate.domain.member.Member; | ||
| import UMC.career_mate.domain.recruitScrap.dto.response.RecruitScrapResponseDTO; | ||
| import UMC.career_mate.domain.recruitScrap.service.RecruitScrapCommandService; | ||
| import UMC.career_mate.domain.recruitScrap.service.RecruitScrapQueryService; | ||
| import UMC.career_mate.global.annotation.LoginMember; | ||
| import UMC.career_mate.global.response.ApiResponse; | ||
| import io.swagger.v3.oas.annotations.Operation; | ||
| import java.util.List; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.web.bind.annotation.DeleteMapping; | ||
| import org.springframework.web.bind.annotation.GetMapping; | ||
| import org.springframework.web.bind.annotation.PathVariable; | ||
| import org.springframework.web.bind.annotation.PostMapping; | ||
| import org.springframework.web.bind.annotation.RequestMapping; | ||
| import org.springframework.web.bind.annotation.RestController; | ||
|
|
||
| @RestController | ||
| @RequiredArgsConstructor | ||
| @RequestMapping("/scrap/recruits") | ||
| public class RecruitScrapController { | ||
|
|
||
| private final RecruitScrapCommandService recruitScrapCommandService; | ||
| private final RecruitScrapQueryService recruitScrapQueryService; | ||
|
|
||
| @Operation( | ||
| summary = "채용 공고 스크랩 API", | ||
| description = """ | ||
| 채용 공고를 스크랩하는 API입니다.\n\n | ||
| recruitId : 스크랩하려는 채용 공고 pk 값 | ||
| """) | ||
| @PostMapping("/{recruitId}") | ||
| public ApiResponse<String> createRecruitScrap(@LoginMember Member member, | ||
| @PathVariable Long recruitId) { | ||
| recruitScrapCommandService.saveRecruitScrap(member, recruitId); | ||
| return ApiResponse.onSuccess("스크랩 완료"); | ||
| } | ||
|
|
||
| @Operation( | ||
| summary = "채용 공고 스크랩 삭제 API", | ||
| description = """ | ||
| 스크랩을 삭제하는 API입니다.\n\n | ||
| recruitId : 삭제하려는 스크랩의 채용 공고 pk 값 | ||
| """) | ||
| @DeleteMapping("/{recruitId}") | ||
| public ApiResponse<String> deleteRecruitScrap(@LoginMember Member member, | ||
| @PathVariable Long recruitId) { | ||
| recruitScrapCommandService.deleteRecruitScrap(member, recruitId); | ||
| return ApiResponse.onSuccess("스크랩 삭제 완료"); | ||
| } | ||
|
|
||
| @Operation( | ||
| summary = "채용 공고 스크랩 목록 조회 API", | ||
| description = """ | ||
| 스크랩한 채용 공고 목록을 조회하는 API입니다.\n\n | ||
| 로그인 인증만을 요구합니다. | ||
| """) | ||
| @GetMapping | ||
| public ApiResponse<List<RecruitScrapResponseDTO>> getRecruitScrapList( | ||
| @LoginMember Member member) { | ||
| return ApiResponse.onSuccess(recruitScrapQueryService.findRecruitScrapList(member)); | ||
| } | ||
|
|
||
| } |
44 changes: 44 additions & 0 deletions
44
src/main/java/UMC/career_mate/domain/recruitScrap/converter/RecruitScrapConverter.java
This file contains hidden or 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,44 @@ | ||
| package UMC.career_mate.domain.recruitScrap.converter; | ||
|
|
||
| import UMC.career_mate.domain.member.Member; | ||
| import UMC.career_mate.domain.recruit.Recruit; | ||
| import UMC.career_mate.domain.recruitScrap.RecruitScrap; | ||
| import UMC.career_mate.domain.recruitScrap.dto.response.RecruitScrapResponseDTO; | ||
| import java.time.LocalDate; | ||
| import java.time.temporal.ChronoUnit; | ||
|
|
||
| public class RecruitScrapConverter { | ||
|
|
||
| public static RecruitScrap toEntity(Member member, Recruit recruit) { | ||
| return RecruitScrap.builder() | ||
| .member(member) | ||
| .recruit(recruit) | ||
| .build(); | ||
| } | ||
|
|
||
| public static RecruitScrapResponseDTO toRecruitScrapResponseDTO(Recruit recruit) { | ||
| return RecruitScrapResponseDTO.builder() | ||
| .recruitId(recruit.getId()) | ||
| .companyName(recruit.getCompanyName()) | ||
| .title(recruit.getTitle()) | ||
| .deadLine(formatDeadLine(recruit)) | ||
| .isScraped(true) | ||
| .build(); | ||
| } | ||
|
|
||
| private static String formatDeadLine(Recruit recruit) { | ||
| LocalDate today = LocalDate.now(); | ||
| LocalDate targetDate = recruit.getDeadLine().toLocalDate(); | ||
| long daysBetween = ChronoUnit.DAYS.between(today, targetDate); | ||
|
|
||
| if (daysBetween == 0) { | ||
| return "오늘 마감"; | ||
| } | ||
|
|
||
| if (daysBetween > 0) { | ||
| return "D-" + daysBetween; | ||
| } | ||
|
|
||
| return "마감"; | ||
| } | ||
| } |
15 changes: 15 additions & 0 deletions
15
src/main/java/UMC/career_mate/domain/recruitScrap/dto/response/RecruitScrapResponseDTO.java
This file contains hidden or 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,15 @@ | ||
| package UMC.career_mate.domain.recruitScrap.dto.response; | ||
|
|
||
| import java.time.LocalDateTime; | ||
| import lombok.Builder; | ||
|
|
||
| @Builder | ||
| public record RecruitScrapResponseDTO( | ||
| Long recruitId, | ||
| String companyName, | ||
| String title, | ||
| String deadLine, | ||
| boolean isScraped | ||
| ) { | ||
|
|
||
| } |
24 changes: 24 additions & 0 deletions
24
src/main/java/UMC/career_mate/domain/recruitScrap/repository/RecruitScrapRepository.java
This file contains hidden or 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,24 @@ | ||
| package UMC.career_mate.domain.recruitScrap.repository; | ||
|
|
||
| import UMC.career_mate.domain.member.Member; | ||
| import UMC.career_mate.domain.recruit.Recruit; | ||
| import UMC.career_mate.domain.recruitScrap.RecruitScrap; | ||
| import java.util.List; | ||
| import java.util.Optional; | ||
| import java.util.Set; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
| import org.springframework.data.jpa.repository.Query; | ||
| import org.springframework.data.repository.query.Param; | ||
|
|
||
| public interface RecruitScrapRepository extends JpaRepository<RecruitScrap, Long> { | ||
|
|
||
| boolean existsByMemberAndRecruit(Member member, Recruit recruit); | ||
|
|
||
| Optional<RecruitScrap> findByMemberAndRecruitId(Member member, Long recruitId); | ||
|
|
||
| @Query("select rs from RecruitScrap rs join fetch rs.recruit where rs.member = :member") | ||
| List<RecruitScrap> findByMember(@Param("member") Member member); | ||
|
|
||
| @Query("select rs.recruit.id from RecruitScrap rs where rs.member = :member") | ||
| Set<Long> findRecruitIdsByMember(@Param("member") Member member); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
여기에서는 기한이 지난 공고는 다루지 않아도 괜찮나요?