Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature : 커뮤니티 댓글 API 구현 #45

Merged
merged 18 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
feat : 커뮤니티 게시글 상세조회 (댓글) api #39
  • Loading branch information
dhun0103 committed Jan 5, 2025
commit 4855223b59e82e1c78c177143575a06c99874806
6 changes: 4 additions & 2 deletions src/main/java/itstime/reflog/comment/dto/CommentDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class CommentDto {
@AllArgsConstructor
public static class CommentSaveOrUpdateRequest {

@NotBlank(message = "content는 비어 있을 수 없습니다.")
@NotBlank(message = "댓글은 비어 있을 수 없습니다.")
private String content;

private Long parentId;
Expand All @@ -21,8 +21,10 @@ public static class CommentSaveOrUpdateRequest {
@Getter
@AllArgsConstructor
public static class CommentResponse {

private Long commentId;
private String name;
private String content;
private Long parentId;
private LocalDateTime createdAt;
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
package itstime.reflog.comment.repository;

import itstime.reflog.comment.domain.Comment;
import itstime.reflog.community.domain.Community;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.List;

public interface CommentRepository extends JpaRepository<Comment, Long> {

// 커뮤니티 모든 댓글 조회
List<Comment> findAllByCommunityOrderByCreatedAtDesc(Community community);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,7 @@
import java.util.UUID;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import io.swagger.v3.oas.annotations.Operation;
Expand Down Expand Up @@ -82,6 +74,33 @@ public ResponseEntity<CommonApiResponse<Void>> createCommunity(
return ResponseEntity.ok(CommonApiResponse.onSuccess(null));
}

@Operation(
summary = "커뮤니티 상세조회 API",
description = "커뮤니티 게시글 상세조회 API입니다. AccessToken 필요.",
responses = {
@ApiResponse(
responseCode = "200",
description = "커뮤니티 게시글 상세조회 성공"
),
@ApiResponse(
responseCode = "404",
description = "해당 회원을 찾을 수 없음"
),
@ApiResponse(
responseCode = "500",
description = "서버 에러"
)
}
)
@GetMapping("/{communityId}")
public ResponseEntity<CommonApiResponse<CommunityDto.CommunityResponse>> getCommunity(
@PathVariable Long communityId) {
CommunityDto.CommunityResponse communityResponse = communityService.getCommunity(communityId);
return ResponseEntity.ok(CommonApiResponse.onSuccess(communityResponse));
}



@Operation(
summary = "커뮤니티 수정 API",
description = "커뮤니티 게시글 수정 API입니다. 마찬가지로 게시글 수정할 때 파일을 업로드하게 되면 커뮤니티 파일 임시 생성 API에서 받은 url값을 fileUrls에 전달해주시면 돼요. AccessToken 필요.",
Expand Down Expand Up @@ -161,6 +180,4 @@ public ResponseEntity<CommonApiResponse<List<CommunityDto.CombinedCategoryRespon
List<CommunityDto.CombinedCategoryResponse> responses = communityService.getFilteredCommunity(postTypes, learningTypes);
return ResponseEntity.ok(CommonApiResponse.onSuccess(responses));
}


}
10 changes: 7 additions & 3 deletions src/main/java/itstime/reflog/community/dto/CommunityDto.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package itstime.reflog.community.dto;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
import java.util.stream.Collectors;

import itstime.reflog.comment.dto.CommentDto;
import itstime.reflog.community.domain.Community;
import itstime.reflog.member.domain.Member;
import itstime.reflog.retrospect.domain.Retrospect;
import itstime.reflog.retrospect.domain.StudyType;
import lombok.*;

public class CommunityDto {
Expand All @@ -23,6 +21,12 @@ public static class CommunitySaveOrUpdateRequest {
private List<String> fileUrls;
}

@Getter
@AllArgsConstructor
public static class CommunityResponse {
private List<CommentDto.CommentResponse> commentList;
}

//카테고리 별 필터링 api dto
@Getter
@Builder
Expand Down
Loading