diff --git a/src/main/java/com/gongjakso/server/domain/apply/dto/response/ApplyRes.java b/src/main/java/com/gongjakso/server/domain/apply/dto/response/ApplyRes.java index 406f67c..4cbf196 100644 --- a/src/main/java/com/gongjakso/server/domain/apply/dto/response/ApplyRes.java +++ b/src/main/java/com/gongjakso/server/domain/apply/dto/response/ApplyRes.java @@ -4,6 +4,8 @@ import com.fasterxml.jackson.databind.PropertyNamingStrategies; import com.fasterxml.jackson.databind.annotation.JsonNaming; import com.gongjakso.server.domain.apply.entity.Apply; +import com.gongjakso.server.domain.team.vo.RecruitPart; +import io.swagger.v3.oas.annotations.media.Schema; import jakarta.annotation.Nullable; import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.Size; @@ -12,6 +14,7 @@ import java.time.LocalDate; import java.time.LocalDateTime; import java.time.Period; +import java.util.List; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) @@ -49,6 +52,8 @@ public record ApplyRes( @NotNull String status, + List recruitPart, + @Size(max = 20) @NotNull String applyPart, @@ -70,7 +75,35 @@ public record ApplyRes( LocalDateTime deleteAt ) { + + @Builder + @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) + public record RecruitPartRes( + @Schema(description = "지원 파트", example = "기획") + String position, + + @Schema(description = "모집 인원", example = "3") + Integer recruitCount, + + @Schema(description = "합격 인원", example = "2") + Integer passCount + ) { + + public static RecruitPartRes of(RecruitPart recruitPart) { + return RecruitPartRes.builder() + .position(recruitPart.position().getKoreanName()) + .recruitCount(recruitPart.recruitCount()) + .passCount(recruitPart.passCount()) + .build(); + } + + } + public static ApplyRes of(Apply apply) { + List recruitPartRes = (apply.getTeam().getRecruitPart() != null) ? apply.getTeam().getRecruitPart().stream() + .map(RecruitPartRes::of) + .toList() : null; + return ApplyRes.builder() .id(apply.getId()) .teamId(apply.getTeam().getId()) @@ -85,6 +118,7 @@ public static ApplyRes of(Apply apply) { .isPrivate(apply.getPortfolioInfo().isPrivate()) .body(apply.getBody()) .status(apply.getStatus().getDescription()) + .recruitPart(recruitPartRes) .applyPart(apply.getPart()) .isViewed(apply.isViewed()) .deleteAt(apply.getDeletedAt())