Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.example.helloworldmvc.domain.Community;
import com.example.helloworldmvc.domain.User;
import com.example.helloworldmvc.web.dto.CommentRequestDTO;
import com.example.helloworldmvc.web.dto.CommentResponseDTO;

public class CommentConverter {

Expand All @@ -15,4 +16,11 @@ public static Comment toComment(CommentRequestDTO.commentCreateReq request, Comm
.content(request.getContent())
.build();
}

public static CommentResponseDTO.commentCreateRes toCommentCreateRes(Long commentId, Long communityId) {
return CommentResponseDTO.commentCreateRes.builder()
.commentId(commentId)
.communityId(communityId)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ public static CommunityResponseDTO.ModifyPostDTO toModifyPostDTO(Community commu
return CommunityResponseDTO.ModifyPostDTO.builder()
.title(community.getTitle())
.content(community.getContent())
.communityCategory(community.getCommunityCategory())
.communityWriterEmail(community.getUser().getEmail())
.created_at(community.getCreatedAt())
.isOwner(isOwner)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,7 @@ public void setTitle(String title) {
public void setContent(String content) {
this.content = content;
}

public void setCommunityCategory(CommunityCategory communityCategory) {
this.communityCategory = communityCategory;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public CommentResponseDTO.commentCreateRes createComment(String userId, Long com
Comment comment = CommentConverter.toComment(requestBody, community, user, anonymousNumber);
Comment savedComment = commentRepository.save(comment);

return new CommentResponseDTO.commentCreateRes(savedComment.getId());
return CommentConverter.toCommentCreateRes(savedComment.getId(), communityId);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,20 @@ public CommunityResponseDTO.ModifyPostDTO modifyCommunityPost(String userId, Lon
if(community.getUser().getEmail().equals(user.getEmail())) {
isOwner = true;
}
switch (modifyPostDTO.getCommunityCategoryId()){
case 1 :
community.setCommunityCategory(CommunityCategory.WORRY);
break;
case 2 :
community.setCommunityCategory(CommunityCategory.MEDICAL);
break;
case 3 :
community.setCommunityCategory(CommunityCategory.QUALIFICATION);
break;
default :
community.setCommunityCategory(CommunityCategory.ETC);
break;
}
communityRepository.save(community);
return CommunityConverter.toModifyPostDTO(community, isOwner);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class CommentResponseDTO {
@AllArgsConstructor
public static class commentCreateRes{
Long commentId;
Long communityId;
}

@Builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,7 @@ public static class ModifyPostDTO {

@NotBlank
String content;

Integer communityCategoryId;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.example.helloworldmvc.web.dto;

import com.example.helloworldmvc.domain.enums.CommunityCategory;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
Expand Down Expand Up @@ -80,6 +81,7 @@ public static class DeletedPostDTO{
public static class ModifyPostDTO{
String title;
String content;
CommunityCategory communityCategory;
String communityWriterEmail;
LocalDateTime created_at;
Boolean isOwner;
Expand Down
Loading