-
Notifications
You must be signed in to change notification settings - Fork 0
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
[Refactor]: 커뮤니티 게시글 생성 API 코드 리팩토링 #560
Changes from 21 commits
9940a6f
8c01153
19045a1
29e84f4
023e5a7
e56b2aa
97b719a
ce89e5a
573a9ce
ca94af5
4a1aac2
4559e1c
7904d59
4d67c92
450ea1e
3d2c71e
7aafe6d
0b3449f
491c716
cab2bd9
3dae0af
6e527e1
e22f3d8
4f9c01b
a6d9eeb
bfc1908
84f4195
e2e317f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,31 @@ | ||||||
package org.sopt.makers.internal.community.controller.dto.request; | ||||||
|
||||||
import io.swagger.v3.oas.annotations.media.Schema; | ||||||
|
||||||
import javax.validation.constraints.NotBlank; | ||||||
import javax.validation.constraints.NotNull; | ||||||
|
||||||
public record PostSaveRequest( | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Spring Validator 쓸 때 메시지도 같이 작성해주면 좋을 것 같아요!! fyi. 다른 도메인의 Request Dto Lines 16 to 17 in 2d3bd79
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 좋은 의견 감사합니다! 바로 반영하겠습니다. |
||||||
@Schema(required = true) | ||||||
@NotNull | ||||||
Long categoryId, | ||||||
|
||||||
String title, | ||||||
|
||||||
@Schema(required = true) | ||||||
@NotBlank | ||||||
String content, | ||||||
|
||||||
@Schema(required = true) | ||||||
@NotNull | ||||||
Boolean isQuestion, | ||||||
|
||||||
@Schema(required = true) | ||||||
@NotNull | ||||||
Boolean isBlindWriter, | ||||||
|
||||||
@Schema(required = true) | ||||||
@NotNull | ||||||
String[] images | ||||||
) { | ||||||
} |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 현재 prod 테이블에도 not null 컬럼들 반영이 필요할 것 같아요! (혹시 null인 데이터가 있다면 백필이 필요할 것 같구요) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이 부분은 해당 PR에 달린 코드리뷰 반영이 다 되고 같이 진행하면 좋을 것 같습니다! |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,22 @@ | ||
package org.sopt.makers.internal.domain.community; | ||
package org.sopt.makers.internal.community.domain.anonymous; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.GenerationType; | ||
import javax.persistence.Id; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.*; | ||
|
||
@Entity | ||
@Getter | ||
@Builder | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Builder는 클래스 전역에 선언했을 때, id값의 변경도 허용되기 때문에 클래스 내부에서 최소한의 변경되는 범위에만 사용하는 게 좋을 것 같습니다! AnonymousNickname.builder().id(id).build(); >> 가 가능해짐 그래서 되도록이면 @AllArgsConstructor 도 private으로 제한하거나 아예 사용하지 않고, 필요한 필드들만 생성자 정의를 해주는 게 좋아보입니다! (e.g. MemberBlock 처럼 통일하면 좋을 것 같습니닷 ㅎㅎ) |
||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@AllArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class AnonymousNickname { | ||
|
||
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "anonymous_nickname_id") | ||
private Long id; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
package org.sopt.makers.internal.community.domain; | ||
package org.sopt.makers.internal.community.domain.anonymous; | ||
|
||
import lombok.Getter; | ||
import lombok.*; | ||
|
||
import javax.persistence.*; | ||
|
||
@Entity | ||
@Getter | ||
@Builder | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@AllArgsConstructor(access = AccessLevel.PROTECTED) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 여기도 위와 동일합니다!! (현재 이런 구조가 많은데 유지보수를 위해 하나로 통일하는 게 좋을 것 같아서요!) |
||
public class AnonymousProfileImage { | ||
|
||
@Id | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package org.sopt.makers.internal.community.repository.anonymous; | ||
|
||
import org.sopt.makers.internal.community.domain.anonymous.AnonymousPostProfile; | ||
|
||
import java.util.List; | ||
|
||
public interface AnonymousPostProfileRepositoryCustom { | ||
|
||
List<AnonymousPostProfile> findTopByOrderByIdDescWithLimit(int limit); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. param으로 받게 하는 거 너무 좋네요 !! 👍 |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.sopt.makers.internal.community.repository.anonymous; | ||
|
||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
import lombok.RequiredArgsConstructor; | ||
import org.sopt.makers.internal.community.domain.anonymous.AnonymousPostProfile; | ||
import org.sopt.makers.internal.community.domain.anonymous.QAnonymousPostProfile; | ||
|
||
import java.util.List; | ||
|
||
@RequiredArgsConstructor | ||
public class AnonymousPostProfileRepositoryCustomImpl implements AnonymousPostProfileRepositoryCustom { | ||
|
||
private final JPAQueryFactory queryFactory; | ||
|
||
@Override | ||
public List<AnonymousPostProfile> findTopByOrderByIdDescWithLimit(int limit) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 요기 메서드명 수정이 필요해보입니다. order by 기준이 createdAt인데, 메서드에서는 id로 되어 있어서요! |
||
|
||
QAnonymousPostProfile anonymousPostProfile = QAnonymousPostProfile.anonymousPostProfile; | ||
|
||
return queryFactory | ||
.selectFrom(anonymousPostProfile) | ||
.orderBy(anonymousPostProfile.createdAt.desc()) | ||
.limit(limit) | ||
.fetch(); | ||
} | ||
} |
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
요거 @Valid가 앞쪽에 와야 제대로 동작할 것 같습니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
제가 알기로는 @Valid 위치는 상관없이 동작하는 것으로 알고 있습니다.
해당 어노테이션 테스트도 해본 상태입니다!