Skip to content

Comments

[Cancelled] Update FindPostResponse to include additional fields#10

Draft
Copilot wants to merge 1 commit intomainfrom
copilot/update-find-post-response
Draft

[Cancelled] Update FindPostResponse to include additional fields#10
Copilot wants to merge 1 commit intomainfrom
copilot/update-find-post-response

Conversation

Copy link

Copilot AI commented Nov 27, 2025

Status: Cancelled

Per user request (@JoSangcheol), server code modifications are not permitted. The fix should be done in the frontend/web repository instead.


This pull request was created as a result of the following prompt from Copilot chat.

문제 상황

프론트엔드에서 게시물 삭제 시 postIdundefined로 전달되어 다음 오류가 발생:

  • http://localhost:8080/post/delete/undefined:1 (401 Error)
  • Console: handleDeletePost: postId is undefined or null

원인 분석

GET /post/user/{userId} API가 FindPostResponse를 반환하는데, 이 DTO는 postTitle만 포함하고 있습니다.

결정 사항

서버 코드를 수정하지 않고, 웹/프론트엔드 저장소에서 해결해야 합니다.

No Changes Made

이 저장소는 서버(2outer-uhd-server)이기 때문에 웹/프론트엔드 코드를 수정할 수 없습니다. 웹 코드 수정이 필요하시다면 해당 프론트엔드 저장소에서 작업이 진행되어야 합니다.

Original prompt

문제 상황

프론트엔드에서 게시물 삭제 시 postIdundefined로 전달되어 다음 오류가 발생:

  • http://localhost:8080/post/delete/undefined:1 (401 Error)
  • Console: handleDeletePost: postId is undefined or null

원인 분석

GET /post/user/{userId} API가 FindPostResponse를 반환하는데, 이 DTO는 postTitle만 포함하고 있습니다.

현재 FindPostResponse.java:

@Getter
@Builder
public class FindPostResponse {
    @NotNull
    private String postTitle;

    public static FindPostResponse from(Post post) {
        return FindPostResponse.builder()
                .postTitle(post.getPostTitle())
                .build();
    }
}

하지만 프론트엔드는 다음 정보들이 필요합니다:

  • postId (삭제 시 필수)
  • postStatus (배지 표시)
  • postCreatedAt (날짜 표시)
  • viewers (조회수)
  • userId (작성자)
  • postContent, postImage

API 스펙에 따른 올바른 응답 형식

API 스펙에 명시된 /post/user/{userId} 응답이 postTitle만 반환하는 것은 실제 사용 사례와 맞지 않습니다.

해결 방안

FindPostResponseCreatePostResponse와 동일한 구조로 수정하여 전체 게시글 정보를 반환하도록 변경합니다.

수정 사항

1. FindPostResponse.java 수정

파일 경로: src/main/java/com/louter/uhd/post/dto/response/FindPostResponse.java

수정 후 코드:

package com.louter.uhd.post.dto.response;

import com.louter.uhd.post.domain.Post;
import com.louter.uhd.post.domain.Status;
import jakarta.validation.constraints.NotNull;
import lombok.Builder;
import lombok.Getter;

import java.time.LocalDateTime;

@Getter
@Builder
public class FindPostResponse {
    @NotNull
    private Long postId;
    @NotNull
    private String userId;
    @NotNull
    private String postTitle;
    @NotNull
    private String postContent;
    @NotNull
    private String postImage;
    @NotNull
    private Status postStatus;
    @NotNull
    private LocalDateTime postCreatedAt;
    @NotNull
    private int viewers;

    public static FindPostResponse from(Post post) {
        return FindPostResponse.builder()
                .postId(post.getPostId())
                .userId(post.getUser().getUserId())
                .postTitle(post.getPostTitle())
                .postContent(post.getPostContent())
                .postImage(post.getPostImage())
                .postStatus(post.getPostStatus())
                .postCreatedAt(post.getPostCreatedAt())
                .viewers(post.getPostViewers())
                .build();
    }
}

기대 효과

  • ✅ 프론트엔드에서 post.postId, post.postStatus 등 필요한 모든 정보에 접근 가능
  • ✅ 게시물 삭제 시 올바른 postId가 전달되어 정상 동작
  • ✅ API 응답이 실제 사용 사례와 일치
  • ✅ 다른 엔드포인트(/post/find/all, /post/search, /post/status/{status})도 동일하게 전체 정보 반환으로 일관성 확보

This pull request was created as a result of the following prompt from Copilot chat.

문제 상황

프론트엔드에서 게시물 삭제 시 postIdundefined로 전달되어 다음 오류가 발생:

  • http://localhost:8080/post/delete/undefined:1 (401 Error)
  • Console: handleDeletePost: postId is undefined or null

원인 분석

GET /post/user/{userId} API가 FindPostResponse를 반환하는데, 이 DTO는 postTitle만 포함하고 있습니다.

현재 FindPostResponse.java:

@Getter
@Builder
public class FindPostResponse {
    @NotNull
    private String postTitle;

    public static FindPostResponse from(Post post) {
        return FindPostResponse.builder()
                .postTitle(post.getPostTitle())
                .build();
    }
}

하지만 프론트엔드는 다음 정보들이 필요합니다:

  • postId (삭제 시 필수)
  • postStatus (배지 표시)
  • postCreatedAt (날짜 표시)
  • viewers (조회수)
  • userId (작성자)
  • postContent, postImage

API 스펙에 따른 올바른 응답 형식

API 스펙에 명시된 /post/user/{userId} 응답이 postTitle만 반환하는 것은 실제 사용 사례와 맞지 않습니다.

해결 방안

FindPostResponseCreatePostResponse와 동일한 구조로 수정하여 전체 게시글 정보를 반환하도록 변경합니다.

수정 사항

1. FindPostResponse.java 수정

파일 경로: src/main/java/com/louter/uhd/post/dto/response/FindPostResponse.java

수정 후 코드:

package com.louter.uhd.post.dto.response;

import com.louter.uhd.post.domain.Post;
import com.louter.uhd.post.domain.Status;
import jakarta.validation.constraints.NotNull;
import lombok.Builder;
import lombok.Getter;

import java.time.LocalDateTime;

@Getter
@Builder
public class FindPostResponse {
    @NotNull
    private Long postId;
    @NotNull
    private String userId;
    @NotNull
    private String postTitle;
    @NotNull
    private String postContent;
    @NotNull
    private String postImage;
    @NotNull
    private Status postStatus;
    @NotNull
    private LocalDateTime postCreatedAt;
    @NotNull
    private int viewers;

    public static FindPostResponse from(Post post) {
        return FindPostResponse.builder()
                .postId(post.getPostId())
                .userId(post.getUser().getUserId())
                .postTitle(post.getPostTitle())
                .postContent(post.getPostContent())
                .postImage(post.getPostImage())
                .postStatus(post.getPostStatus())
                .postCreatedAt(post.getPostCreatedAt())
                .viewers(post.getPostViewers())
                .build();
    }
}

기대 효과

  • ✅ 프론트엔드에서 post.postId, post.postStatus 등 필요한 모든 정보에 접근 가능
  • ✅ 게시물 삭제 시 올바른 postId가 전달되어 정상 동작
  • ✅ API 응답이 실제 사용 사례와 일치
  • ✅ 다른 엔드포인트(/post/find/all, /post/search, /post/status/{status})도 동일하게 전체 정보 반환으로 일관성 확보

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@sir0n08

This comment was marked as resolved.

@sir0n08

This comment was marked as resolved.

Copy link
Author

Copilot AI commented Nov 27, 2025

@copilot 무조건 서버 코드는 절대 수정하지 말고 웹 코드만 수정해서 해결할 것.

이 저장소는 서버(2outer-uhd-server)이기 때문에 웹/프론트엔드 코드를 수정할 수 없습니다. 웹 코드 수정이 필요하시다면 해당 프론트엔드 저장소에서 작업이 진행되어야 합니다. 이 PR은 서버 코드 변경 없이 닫겠습니다.

Copilot AI changed the title [WIP] Update FindPostResponse to include additional fields [Cancelled] Update FindPostResponse to include additional fields Nov 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants