Skip to content

Commit

Permalink
Merge pull request #77 from KNU-HAEDAL-Website/feat-post-to-end-date-…
Browse files Browse the repository at this point in the history
…issue-65

feat: 게시글 활동 종료일 추가 (#65)
  • Loading branch information
tfer2442 authored Aug 13, 2024
2 parents 53c062c + 46d0769 commit a363af4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
7 changes: 5 additions & 2 deletions src/main/java/com/haedal/haedalweb/domain/Post.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,11 @@ public class Post {
@NonNull
private PostType postType;

@Column(name = "post_activity_date")
private LocalDate activityDate;
@Column(name = "post_activity_start_date")
private LocalDate activityStartDate;

@Column(name = "post_activity_end_date")
private LocalDate activityEndDate;

@Column(name = "post_create_date")
@NonNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ public class CreatePostDTO {
@Schema(description = "게시글 대표 이미지 파일 Url", example = "posts/abc.jpg")
private String postImageUrl;

@Schema(description = "활동일", example = "yyyy-MM-dd (2024-07-24)")
private String postActivityDate;
@Schema(description = "활동 시작일", example = "yyyy-MM-dd (2024-07-24)")
private String postActivityStartDate;

@Schema(description = "활동 종료일", example = "yyyy-MM-dd (2024-07-24)")
private String postActivityEndDate;

@Schema(description = "게시글 타입", example = "(ACTIVITY, NOTICE, EVENT)")
private String postType;
Expand Down
12 changes: 8 additions & 4 deletions src/main/java/com/haedal/haedalweb/service/PostService.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ public void createPost(Long boardId, CreatePostDTO createPostDTO) { // createPos
throw new BusinessException(ErrorCode.NOT_FOUND_POST_TYPE);
}

LocalDate activityDate = LocalDate.parse(createPostDTO.getPostActivityDate(), DateTimeFormatter.ISO_DATE);
LocalDate activityStartDate = LocalDate.parse(createPostDTO.getPostActivityStartDate(), DateTimeFormatter.ISO_DATE);
LocalDate activityEndDate = LocalDate.parse(createPostDTO.getPostActivityEndDate(), DateTimeFormatter.ISO_DATE);
LocalDateTime createDate = LocalDateTime.now();
User creator = userService.getLoggedInUser();

Expand All @@ -48,7 +49,8 @@ public void createPost(Long boardId, CreatePostDTO createPostDTO) { // createPos
.imageUrl(createPostDTO.getPostImageUrl()) // 이미지 생성 Controller 만들기
.views(0L)
.postType(postType)
.activityDate(activityDate)
.activityStartDate(activityStartDate)
.activityEndDate(activityEndDate)
.createDate(createDate)
.user(creator)
.board(board)
Expand All @@ -69,7 +71,8 @@ public void createPost(CreatePostDTO createPostDTO) {
throw new BusinessException(ErrorCode.NOT_FOUND_POST_TYPE);
}

LocalDate activityDate = LocalDate.parse(createPostDTO.getPostActivityDate(), DateTimeFormatter.ISO_DATE);
LocalDate activityStartDate = LocalDate.parse(createPostDTO.getPostActivityStartDate(), DateTimeFormatter.ISO_DATE);
LocalDate activityEndDate = LocalDate.parse(createPostDTO.getPostActivityEndDate(), DateTimeFormatter.ISO_DATE);
LocalDateTime createDate = LocalDateTime.now();
User creator = userService.getLoggedInUser();

Expand All @@ -79,7 +82,8 @@ public void createPost(CreatePostDTO createPostDTO) {
.imageUrl(createPostDTO.getPostImageUrl()) // 이미지 생성 Controller 만들기
.views(0L)
.postType(postType)
.activityDate(activityDate)
.activityStartDate(activityStartDate)
.activityEndDate(activityEndDate)
.createDate(createDate)
.user(creator)
.build();
Expand Down

0 comments on commit a363af4

Please sign in to comment.