-
Notifications
You must be signed in to change notification settings - Fork 2
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 #3 from 지원 공고 CRUD 기초
지원 공고 CRUD 기초
- Loading branch information
Showing
20 changed files
with
634 additions
and
10 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
src/main/java/umc/kkijuk/server/common/controller/ExceptionControllerAdvice.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,20 @@ | ||
package umc.kkijuk.server.common.controller; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.web.bind.annotation.ExceptionHandler; | ||
import org.springframework.web.bind.annotation.ResponseStatus; | ||
import org.springframework.web.bind.annotation.RestControllerAdvice; | ||
import umc.kkijuk.server.common.domian.exception.ResourceNotFoundException; | ||
import umc.kkijuk.server.common.domian.response.ErrorResponse; | ||
|
||
@RestControllerAdvice | ||
@RequiredArgsConstructor | ||
public class ExceptionControllerAdvice { | ||
|
||
@ResponseStatus(HttpStatus.NOT_FOUND) | ||
@ExceptionHandler(ResourceNotFoundException.class) | ||
public ErrorResponse resourceNotFoundException(ResourceNotFoundException exception) { | ||
return new ErrorResponse(exception.getMessage()); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/umc/kkijuk/server/common/domian/exception/ResourceNotFoundException.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 umc.kkijuk.server.common.domian.exception; | ||
|
||
public class ResourceNotFoundException extends RuntimeException{ | ||
public ResourceNotFoundException(String dataSource, long id) { | ||
super(dataSource + "에서 ID " + id + "를 찾을 수 없습니다."); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/umc/kkijuk/server/common/domian/response/ErrorResponse.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,12 @@ | ||
package umc.kkijuk.server.common.domian.response; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public class ErrorResponse { | ||
private final String message; | ||
|
||
public ErrorResponse(String message) { | ||
this.message = message; | ||
} | ||
} |
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
47 changes: 47 additions & 0 deletions
47
src/main/java/umc/kkijuk/server/recruit/controller/response/RecruitInfoResponse.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,47 @@ | ||
package umc.kkijuk.server.recruit.controller.response; | ||
|
||
import com.fasterxml.jackson.annotation.JsonFormat; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import umc.kkijuk.server.recruit.domain.Recruit; | ||
import umc.kkijuk.server.recruit.domain.Review; | ||
|
||
import java.time.LocalDate; | ||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
|
||
@Getter | ||
@Builder | ||
public class RecruitInfoResponse { | ||
private final String title; | ||
|
||
@Schema(description = "공고 모집 시작 날짜", example = "2022-09-18 10:11", pattern = "yyyy-MM-dd HH:mm", type = "string") | ||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm", timezone = "Asia/Seoul") | ||
private final LocalDateTime startTime; | ||
|
||
@Schema(description = "공고 모집 마감 날짜", example = "2022-09-25 10:11", pattern = "yyyy-MM-dd HH:mm", type = "string" ) | ||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm", timezone = "Asia/Seoul") | ||
private final LocalDateTime endTime; | ||
|
||
@Schema(description = "공고 지원 날짜", example = "2024-07-19") | ||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "Asia/Seoul") | ||
private final LocalDate applyDate; | ||
private final List<String> tags; | ||
private final int reviewCount; | ||
private final String link; | ||
private final List<ReviewResponse> reviews; | ||
|
||
public static RecruitInfoResponse from(Recruit recruit, List<Review> reviews) { | ||
return RecruitInfoResponse.builder() | ||
.title(recruit.getTitle()) | ||
.startTime(recruit.getStartTime()) | ||
.endTime(recruit.getEndTime()) | ||
.applyDate(recruit.getApplyDate()) | ||
.tags(recruit.getTags()) | ||
.link(recruit.getLink()) | ||
.reviewCount(reviews.size()) | ||
.reviews(reviews.stream().map(ReviewResponse::from).toList()) | ||
.build(); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/umc/kkijuk/server/recruit/controller/response/ReviewResponse.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,30 @@ | ||
package umc.kkijuk.server.recruit.controller.response; | ||
|
||
import com.fasterxml.jackson.annotation.JsonFormat; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import umc.kkijuk.server.recruit.domain.Review; | ||
|
||
import java.time.LocalDate; | ||
|
||
@Getter | ||
@Builder | ||
public class ReviewResponse { | ||
private final Long reviewId; | ||
private final String title; | ||
private final String content; | ||
|
||
@Schema(description = "날짜", example = "2024-07-19") | ||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "Asia/Seoul") | ||
private final LocalDate date; | ||
|
||
public static ReviewResponse from(Review review) { | ||
return ReviewResponse.builder() | ||
.reviewId(review.getId()) | ||
.title(review.getTitle()) | ||
.content(review.getContent()) | ||
.date(review.getDate()) | ||
.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
15 changes: 15 additions & 0 deletions
15
src/main/java/umc/kkijuk/server/recruit/domain/RecruitStatusUpdate.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,15 @@ | ||
package umc.kkijuk.server.recruit.domain; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import jakarta.validation.constraints.NotNull; | ||
import lombok.*; | ||
|
||
@Getter | ||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class RecruitStatusUpdate { | ||
@NotNull | ||
@Schema(description = "변경될 공고 상태", example = "REJECTED", type = "string") | ||
private RecruitStatus status; | ||
} |
45 changes: 45 additions & 0 deletions
45
src/main/java/umc/kkijuk/server/recruit/domain/RecruitUpdate.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,45 @@ | ||
package umc.kkijuk.server.recruit.domain; | ||
|
||
import com.fasterxml.jackson.annotation.JsonFormat; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import jakarta.validation.constraints.NotBlank; | ||
import jakarta.validation.constraints.NotNull; | ||
import lombok.*; | ||
|
||
import java.time.LocalDate; | ||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
|
||
@Getter | ||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class RecruitUpdate { | ||
@NotBlank(message = "공고 제목은 필수 입력 항목입니다.") | ||
@Schema(description = "수정될 공고 제목", example = "[00] 공고제목", type = "string") | ||
private String title; | ||
|
||
@NotNull(message = "공고 모집 시작 날짜는 필수 입력 항목입니다.") | ||
@Schema(description = "수정될 공고 모집 시작 날짜", example = "2022-09-18 10:11", pattern = "yyyy-MM-dd HH:mm", type = "string") | ||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm", timezone = "Asia/Seoul") | ||
private LocalDateTime startTime; | ||
|
||
@NotNull(message = "공고 모집 마감 날짜는 필수 입력 항목입니다.") | ||
@Schema(description = "수정될 공고 모집 마감 날짜", example = "2022-09-18 10:11", pattern = "yyyy-MM-dd HH:mm", type = "string") | ||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm", timezone = "Asia/Seoul") | ||
private LocalDateTime endTime; | ||
|
||
@NotNull(message = "유효하지 않은 지원 상태가 입력 되었습니다.") | ||
@Schema(description = "수정될 공고 지원 상태", example = "PLANNED", type = "string") | ||
private RecruitStatus status; | ||
|
||
@Schema(description = "수정될 공고 지원 날짜", pattern = "yyyy-MM-dd") | ||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "Asia/Seoul") | ||
private LocalDate applyDate; | ||
|
||
// @Schema(description = "태그", example = "[\"코딩 테스트\", \"인턴\", \"대외 활동\"]", type = "string") | ||
private List<String> tags; | ||
|
||
@Schema(description = "수정될 공고 링크", example = "https://www.naver.com", type = "string") | ||
private String link; | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/umc/kkijuk/server/recruit/domain/Review.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,15 @@ | ||
package umc.kkijuk.server.recruit.domain; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
import java.time.LocalDate; | ||
|
||
@Getter | ||
@Builder | ||
public class Review { | ||
private final Long id; | ||
private final String title; | ||
private final String content; | ||
private final LocalDate date; | ||
} |
Oops, something went wrong.