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

톡픽 생성 요청 DTO와 수정 요청 DTO를 분리합니다. #704

Closed
Hanjaemo opened this issue Nov 11, 2024 · 0 comments · Fixed by #709
Closed

톡픽 생성 요청 DTO와 수정 요청 DTO를 분리합니다. #704

Hanjaemo opened this issue Nov 11, 2024 · 0 comments · Fixed by #709
Assignees
Labels
🪄 refactor 리팩토링

Comments

@Hanjaemo
Copy link
Member

💡 구현 기능

톡픽 생성 요청과 수정 요청을 동일한 DTO로 매핑하기 때문에, 수정 요청 시 북마크수와 조회수가 0으로 초기화됩니다.
따라서 아래 코드를 톡픽 생성 요청 DTO와 수정 요청 DTO 2개의 클래스로 분리합니다.

public class TalkPickDto {

    @Schema(description = "톡픽 생성/수정 요청")
    @Data
    @AllArgsConstructor
    public static class CreateOrUpdateTalkPickRequest {

        private BaseTalkPickFields baseFields;

        @Schema(description = "첨부한 이미지 파일 ID 목록", example = "[12, 41]")
        private List<Long> fileIds;

        public TalkPick toEntity(Member member) {
            return TalkPick.builder()
                    .member(member)
                    .title(baseFields.getTitle())
                    .content(baseFields.getContent())
                    .optionA(baseFields.getOptionA())
                    .optionB(baseFields.getOptionB())
                    .sourceUrl(baseFields.getSourceUrl())
                    .views(0L)
                    .bookmarks(0L)
                    .viewStatus(NORMAL)
                    .editedAt(LocalDateTime.now())
                    .build();
        }

        public boolean containsFileIds() {
            return fileIds != null;
        }
    }

    ...
@Hanjaemo Hanjaemo added the 🪄 refactor 리팩토링 label Nov 11, 2024
@Hanjaemo Hanjaemo self-assigned this Nov 11, 2024
@Hanjaemo Hanjaemo added this to PICK-O Nov 11, 2024
@github-project-automation github-project-automation bot moved this to Todo in PICK-O Nov 11, 2024
@Hanjaemo Hanjaemo linked a pull request Nov 12, 2024 that will close this issue
8 tasks
@github-project-automation github-project-automation bot moved this from Todo to Done in PICK-O Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🪄 refactor 리팩토링
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant