|
1 | 1 | package com.clubber.ClubberServer.domain.calendar.dto; |
2 | 2 |
|
3 | 3 | import com.clubber.ClubberServer.domain.calendar.entity.Calendar; |
| 4 | +import com.clubber.ClubberServer.domain.club.domain.Club; |
4 | 5 | import com.clubber.ClubberServer.domain.recruit.domain.Recruit; |
5 | 6 | import com.clubber.ClubberServer.domain.recruit.domain.RecruitType; |
6 | 7 | import com.clubber.ClubberServer.domain.user.domain.AccountRole; |
7 | 8 | import com.fasterxml.jackson.annotation.JsonFormat; |
8 | 9 | import io.swagger.v3.oas.annotations.media.Schema; |
9 | 10 | import jakarta.validation.constraints.NotBlank; |
10 | | -import lombok.Builder; |
11 | | - |
12 | 11 | import java.time.LocalDateTime; |
| 12 | +import lombok.Builder; |
13 | 13 |
|
14 | 14 | @Builder |
15 | 15 | public record CreateCalendarRequest( |
16 | | - @NotBlank(message = "제목을 입력해주세요") |
17 | | - String title, |
18 | | - @NotBlank(message = "모집 종류를 입력해주세요") |
19 | | - RecruitType recruitType, |
20 | | - @Schema(description = "기간 시작일", example = "2025-08-30 00:00", type = "string") |
21 | | - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm", timezone = "Asia/Seoul") |
22 | | - @NotBlank(message = "시작 일자를 입력해주세요") |
23 | | - LocalDateTime startAt, |
24 | | - @Schema(description = "기간 마감일", example = "2025-09-02 23:59", type = "string") |
25 | | - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm", timezone = "Asia/Seoul") |
26 | | - @NotBlank(message = "마감 일정을 입력해주세요") |
27 | | - LocalDateTime endAt, |
28 | | - String url |
| 16 | + @NotBlank(message = "제목을 입력해주세요") |
| 17 | + String title, |
| 18 | + @NotBlank(message = "모집 종류를 입력해주세요") |
| 19 | + RecruitType recruitType, |
| 20 | + @Schema(description = "기간 시작일", example = "2025-08-30 00:00", type = "string") |
| 21 | + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm", timezone = "Asia/Seoul") |
| 22 | + @NotBlank(message = "시작 일자를 입력해주세요") |
| 23 | + LocalDateTime startAt, |
| 24 | + @Schema(description = "기간 마감일", example = "2025-09-02 23:59", type = "string") |
| 25 | + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm", timezone = "Asia/Seoul") |
| 26 | + @NotBlank(message = "마감 일정을 입력해주세요") |
| 27 | + LocalDateTime endAt, |
| 28 | + String url |
| 29 | + |
29 | 30 | ) { |
30 | | - public Calendar toEntity() { |
| 31 | + |
| 32 | + public Calendar toEntity(Club club) { |
31 | 33 | return Calendar.builder() |
32 | | - .title(title) |
33 | | - .recruitType(recruitType) |
34 | | - .startAt(startAt) |
35 | | - .endAt(endAt) |
36 | | - .url(url) |
37 | | - .writerRole(AccountRole.ADMIN) |
38 | | - .build(); |
| 34 | + .title(title) |
| 35 | + .recruitType(recruitType) |
| 36 | + .startAt(startAt) |
| 37 | + .endAt(endAt) |
| 38 | + .url(url) |
| 39 | + .writerRole(AccountRole.ADMIN) |
| 40 | + .club(club) |
| 41 | + .build(); |
39 | 42 | } |
40 | 43 |
|
41 | 44 | public static CreateCalendarRequest from(Recruit recruit, String recruitUrl) { |
42 | 45 | return CreateCalendarRequest.builder() |
43 | | - .title(recruit.getTitle()) |
44 | | - .recruitType(recruit.getRecruitType()) |
45 | | - .startAt(recruit.getStartAt()) |
46 | | - .endAt(recruit.getEndAt()) |
47 | | - .url(recruitUrl) |
48 | | - .build(); |
| 46 | + .title(recruit.getTitle()) |
| 47 | + .recruitType(recruit.getRecruitType()) |
| 48 | + .startAt(recruit.getStartAt()) |
| 49 | + .endAt(recruit.getEndAt()) |
| 50 | + .url(recruitUrl) |
| 51 | + .build(); |
49 | 52 | } |
50 | 53 | } |
0 commit comments