-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Refactor]: 커뮤니티 게시글 생성 API 코드 리팩토링 (#560)
* [Refactor]: 커뮤니티 게시글 생성 API 리팩토링 PostSaveRequest로 받는 데이터 validation 추가 Related to: #559 * [Refactor]: CommunityPostRepository 파일 이동 repository/community -> community/repository 폴더로 이동 Related to: #559 * [Refactor]: CommunityPost.java 수정 및 패키지 이동 community domain 패키지로 이동 validation 필요한 필드 추가 Related to: #559 * [Refactor]: AnonymousPostProfileRepository 파일 이동 Related to: #559 * [Refactor]: AnonymousProfileImageRepository 패키지 변경 Related to: #559 * [Refactor]: AnonymousProfileImageRepository 패키지 변경 Related to: #559 * [Refactor]: repository 파일 이동 및 querydsl 메서드 구현 Related to: #559 * [Refactor]: request body validation 추가 Related to: #559 * [Refactor]: 리팩토링 관련 파일 이동 import문 변경있음 Related to: #559 * [Refactor]: 커뮤니티 게시글 생성 로직 코드 분리 Service 계층에 밀집된 비즈니스 로직 분리 하위 도메인 정의 및 코드 분리 Related to: #559 * [Refactor]: 커뮤니티 게시글 생성 단위 테스트 코드 생성 Related to: #559 * [Refactor]: 도메인 정의에 맞게 패키지 변경 Related to: #559 * [Refactor]: val 사용 지양 CommunityController.java에 있는 val 삭제 Related to: #559 * [Refactor]: 사용되지 않는 파일 삭제 Related to: #559 * [Refactor]: Qclass 경로 변경 Related to: #559 * [Refactor]: 익명 프로필 이미지 Map 초기화 확인 테스트 코드 작성 Related to: #559 * [Refactor]: 익명 프로필 이미지 1~5 사이의 id값 확인 테스트 코드 Related to: #559 * [Refactor]: 익명 프로필 이미지 1~5 사이의 id값 확인 테스트 코드 Related to: #559 * [Refactor]: 익명 프로필 이미지 랜덤 생성 테스트 코드 Related to: #559 * [Refactor]: 익명 프로필 닉네임 랜덤 생성 테스트 코드 작성 Related to: #559 * [Refactor]: 게시물 익명으로 생성 시 익명 프로필 생성 테스트 코드 Related to: #559 * [Refactor]: PostSaveRequest.java @Valid message 필드 추가 Related to: #559 * [Refactor]: Domain 객체 생성방식 통일 Related to: #559 * [Refactor]: 익명글에 따른 분기 처리 로직 service 계층에서 담당 Related to: #559 * [Refactor]: 익명 프로필 최신 데이터 조회 limit 상수 선언 Related to: #559 * [Refactor]: 익명 프로필 최신 데이터 조회 limit 상수 선언 Related to: #559 * [Refactor]: 서비스 레이어에 @transactional 어노테이션 추가 Related to: #559 * [Refactor]: 테스트 코드 더미데이터 생성 함수 분리 Related to: #559
- Loading branch information
1 parent
8529719
commit c5da3f0
Showing
42 changed files
with
765 additions
and
250 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/main/java/org/sopt/makers/internal/community/controller/dto/request/PostSaveRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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( | ||
@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 | ||
) { | ||
} |
17 changes: 0 additions & 17 deletions
17
src/main/java/org/sopt/makers/internal/community/domain/AnonymousProfileImage.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 10 additions & 7 deletions
17
...l/domain/community/AnonymousNickname.java → ...y/domain/anonymous/AnonymousNickname.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/main/java/org/sopt/makers/internal/community/domain/anonymous/AnonymousProfileImage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
5 changes: 2 additions & 3 deletions
5
...ry/community/CommunityPostRepository.java → ...y/repository/CommunityPostRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...ommunity/AnonymousNicknameRepository.java → ...nonymous/AnonymousNicknameRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 4 additions & 10 deletions
14
...unity/AnonymousPostProfileRepository.java → ...ymous/AnonymousPostProfileRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
.../makers/internal/community/repository/anonymous/AnonymousPostProfileRepositoryCustom.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
26 changes: 26 additions & 0 deletions
26
...ers/internal/community/repository/anonymous/AnonymousPostProfileRepositoryCustomImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { | ||
|
||
QAnonymousPostProfile anonymousPostProfile = QAnonymousPostProfile.anonymousPostProfile; | ||
|
||
return queryFactory | ||
.selectFrom(anonymousPostProfile) | ||
.orderBy(anonymousPostProfile.createdAt.desc()) | ||
.limit(limit) | ||
.fetch(); | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
...tory/AnonymousProfileImageRepository.java → ...mous/AnonymousProfileImageRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 0 additions & 17 deletions
17
src/main/java/org/sopt/makers/internal/community/service/AnonymousNicknameServiceUtil.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.