-
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 all 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(message = "카테고리 id는 필수 입력값입니다.") | ||||||
Long categoryId, | ||||||
|
||||||
String title, | ||||||
|
||||||
@Schema(required = true) | ||||||
@NotBlank(message = "게시글 본문은 공백일 수 없습니다.") | ||||||
String content, | ||||||
|
||||||
@Schema(required = true) | ||||||
@NotNull(message = "질문글 여부 필드는 필수 입력값입니다.") | ||||||
Boolean isQuestion, | ||||||
|
||||||
@Schema(required = true) | ||||||
@NotNull(message = "익명글 여부 필드는 필수 입력값입니다.") | ||||||
Boolean isBlindWriter, | ||||||
|
||||||
@Schema(required = true) | ||||||
@NotNull(message = "이미지 필드는 필수 필드입니다.") | ||||||
String[] images | ||||||
) { | ||||||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,29 @@ | ||
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 | ||
@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; | ||
|
||
@Column(nullable = false) | ||
String nickname; | ||
|
||
@Builder | ||
private AnonymousNickname(Long id, String nickname) { | ||
this.id = id; | ||
this.nickname = nickname; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.sopt.makers.internal.community.domain.anonymous; | ||
|
||
import lombok.*; | ||
|
||
import javax.persistence.*; | ||
|
||
@Entity | ||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class AnonymousProfileImage { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@Column(nullable = false) | ||
private String imageUrl; | ||
|
||
@Builder | ||
private AnonymousProfileImage(Long id, String imageUrl) { | ||
this.id = id; | ||
this.imageUrl = imageUrl; | ||
} | ||
} |
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.
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 위치는 상관없이 동작하는 것으로 알고 있습니다.
해당 어노테이션 테스트도 해본 상태입니다!