-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Feature/#43 Recruit card API 개발
- Loading branch information
Showing
13 changed files
with
452 additions
and
43 deletions.
There are no files selected for viewing
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
49 changes: 49 additions & 0 deletions
49
src/main/java/com/server/bbo_gak/domain/card/controller/CardInRecruitController.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,49 @@ | ||
package com.server.bbo_gak.domain.card.controller; | ||
|
||
import com.server.bbo_gak.domain.card.dto.response.CardCreateResponse; | ||
import com.server.bbo_gak.domain.card.dto.response.CardListGetResponse; | ||
import com.server.bbo_gak.domain.card.dto.response.CardTypeCountInRecruitGetResponse; | ||
import com.server.bbo_gak.domain.card.service.CardInRecruitService; | ||
import com.server.bbo_gak.domain.user.entity.User; | ||
import com.server.bbo_gak.global.annotation.AuthUser; | ||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequestMapping("/api/v1") | ||
@RequiredArgsConstructor | ||
public class CardInRecruitController { | ||
|
||
private final CardInRecruitService cardInRecruitService; | ||
|
||
@GetMapping("/recruits/{recruit-id}/cards/type-count") | ||
public ResponseEntity<CardTypeCountInRecruitGetResponse> getCardTypeCounts(@AuthUser User user) { | ||
return ResponseEntity.ok(cardInRecruitService.getCardTypeCountsInRecruit(user)); | ||
} | ||
|
||
@GetMapping("/recruits/{recruit-id}/cards") | ||
public ResponseEntity<List<CardListGetResponse>> getCardDetail( | ||
@AuthUser User user, | ||
@PathVariable("recruit-id") Long recruitId, | ||
@RequestParam("type") String type) { | ||
|
||
return ResponseEntity.ok(cardInRecruitService.getCardListInRecruit(user, recruitId, type)); | ||
} | ||
|
||
@PostMapping("/recruits/{recruit-id}/cards/{card-id}") | ||
public ResponseEntity<CardCreateResponse> createCard( | ||
@AuthUser User user, | ||
@PathVariable("recruit-id") Long recruitId, | ||
@PathVariable("card-id") Long cardId) { | ||
|
||
return ResponseEntity.ok(cardInRecruitService.copyCardFromMyInfo(user, cardId, recruitId)); | ||
} | ||
|
||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/com/server/bbo_gak/domain/card/dao/CardCopyInfoRepository.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,8 @@ | ||
package com.server.bbo_gak.domain.card.dao; | ||
|
||
import com.server.bbo_gak.domain.card.entity.CardCopyInfo; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface CardCopyInfoRepository extends JpaRepository<CardCopyInfo, Long> { | ||
|
||
} |
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
32 changes: 32 additions & 0 deletions
32
...n/java/com/server/bbo_gak/domain/card/dto/response/CardTypeCountInRecruitGetResponse.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,32 @@ | ||
package com.server.bbo_gak.domain.card.dto.response; | ||
|
||
import com.server.bbo_gak.domain.card.entity.Card; | ||
import com.server.bbo_gak.domain.card.entity.CardType; | ||
import com.server.bbo_gak.domain.card.entity.CardTypeValue; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.stream.Collectors; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
|
||
@Builder(access = AccessLevel.PRIVATE) | ||
public record CardTypeCountInRecruitGetResponse( | ||
Long 서류_준비, | ||
Long 과제_준비, | ||
Long 인터뷰_준비 | ||
) { | ||
|
||
public static CardTypeCountInRecruitGetResponse from(List<Card> cards) { | ||
|
||
Map<CardTypeValue, Long> cardTypeValueCountMap = cards.stream() | ||
.flatMap(card -> card.getCardTypeList().stream()) | ||
.collect(Collectors.groupingBy(CardType::getCardTypeValue, Collectors.counting())); | ||
|
||
return CardTypeCountInRecruitGetResponse.builder() | ||
.서류_준비(cardTypeValueCountMap.getOrDefault(CardTypeValue.DOCUMENT_PREPARING, 0L)) | ||
.과제_준비(cardTypeValueCountMap.getOrDefault(CardTypeValue.ASSIGNMENT_PREPARING, 0L)) | ||
.인터뷰_준비(cardTypeValueCountMap.getOrDefault(CardTypeValue.INTERVIEW_PREPARING, 0L)) | ||
.build(); | ||
} | ||
|
||
} |
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
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.