-
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.
Merge pull request #146 from sharemindteam/feature/139-post-get
feat: 일대다 상담 질문 조회 구현
- Loading branch information
Showing
13 changed files
with
305 additions
and
5 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
19 changes: 19 additions & 0 deletions
19
src/main/java/com/example/sharemind/global/config/QueryDslConfig.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,19 @@ | ||
package com.example.sharemind.global.config; | ||
|
||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
import jakarta.persistence.EntityManager; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
@RequiredArgsConstructor | ||
public class QueryDslConfig { | ||
|
||
private final EntityManager entityManager; | ||
|
||
@Bean | ||
public JPAQueryFactory jpaQueryFactory() { | ||
return new JPAQueryFactory(entityManager); | ||
} | ||
} |
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
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
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
36 changes: 36 additions & 0 deletions
36
src/main/java/com/example/sharemind/post/dto/response/PostGetIsSavedResponse.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,36 @@ | ||
package com.example.sharemind.post.dto.response; | ||
|
||
import com.example.sharemind.post.domain.Post; | ||
import com.fasterxml.jackson.annotation.JsonFormat; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import java.time.LocalDateTime; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class PostGetIsSavedResponse { | ||
|
||
@Schema(description = "임시저장 메시지 존재하면 true, 아니면 false", example = "true") | ||
private final Boolean isSaved; | ||
|
||
@Schema(description = "마지막 수정일시, isSaved false면 null", example = "2023년 12월 25일 오후 12시 34분", type = "string") | ||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy년 MM월 dd일 a HH시 mm분") | ||
private final LocalDateTime updatedAt; | ||
|
||
@Builder | ||
public PostGetIsSavedResponse(Boolean isSaved, LocalDateTime updatedAt) { | ||
this.isSaved = isSaved; | ||
this.updatedAt = updatedAt; | ||
} | ||
|
||
public static PostGetIsSavedResponse of(Post post) { | ||
return PostGetIsSavedResponse.builder() | ||
.isSaved(true) | ||
.updatedAt(post.getUpdatedAt()) | ||
.build(); | ||
} | ||
|
||
public static PostGetIsSavedResponse of() { | ||
return PostGetIsSavedResponse.builder().build(); | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
src/main/java/com/example/sharemind/post/dto/response/PostGetResponse.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,77 @@ | ||
package com.example.sharemind.post.dto.response; | ||
|
||
import com.example.sharemind.global.utils.TimeUtil; | ||
import com.example.sharemind.post.domain.Post; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class PostGetResponse { | ||
|
||
@Schema(description = "일대다 질문 아이디") | ||
private final Long postId; | ||
|
||
@Schema(description = "상담 카테고리", example = "연애갈등") | ||
private final String consultCategory; | ||
|
||
@Schema(description = "제목") | ||
private final String title; | ||
|
||
@Schema(description = "상담 내용") | ||
private final String content; | ||
|
||
@Schema(description = "공개/비공개 여부") | ||
private final Boolean isPublic; | ||
|
||
@Schema(description = "좋아요 수") | ||
private final Long totalLike; | ||
|
||
@Schema(description = "스크랩 수") | ||
private final Long totalScrap; | ||
|
||
@Schema(description = "마지막 업데이트 일시", example = "8분 전") | ||
private final String updatedAt; | ||
|
||
@Builder | ||
public PostGetResponse(Long postId, String consultCategory, String title, String content, | ||
Boolean isPublic, Long totalLike, Long totalScrap, String updatedAt) { | ||
this.postId = postId; | ||
this.consultCategory = consultCategory; | ||
this.title = title; | ||
this.content = content; | ||
this.isPublic = isPublic; | ||
this.totalLike = totalLike; | ||
this.totalScrap = totalScrap; | ||
this.updatedAt = updatedAt; | ||
} | ||
|
||
public static PostGetResponse of(Post post) { | ||
String consultCategory = post.getConsultCategory() == null ? null | ||
: post.getConsultCategory().getDisplayName(); | ||
|
||
return PostGetResponse.builder() | ||
.postId(post.getPostId()) | ||
.consultCategory(consultCategory) | ||
.title(post.getTitle()) | ||
.content(post.getContent()) | ||
.isPublic(post.getIsPublic()) | ||
.totalLike(post.getTotalLike()) | ||
.totalScrap(post.getTotalScrap()) | ||
.updatedAt(TimeUtil.getUpdatedAt(post.getUpdatedAt())) | ||
.build(); | ||
} | ||
|
||
public static PostGetResponse ofIsNotCompleted(Post post) { | ||
return PostGetResponse.builder() | ||
.postId(post.getPostId()) | ||
.consultCategory(null) | ||
.title(null) | ||
.content(null) | ||
.isPublic(post.getIsPublic()) | ||
.totalLike(post.getTotalLike()) | ||
.totalScrap(post.getTotalScrap()) | ||
.updatedAt(TimeUtil.getUpdatedAt(post.getUpdatedAt())) | ||
.build(); | ||
} | ||
} |
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
11 changes: 11 additions & 0 deletions
11
src/main/java/com/example/sharemind/post/repository/PostCustomRepository.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,11 @@ | ||
package com.example.sharemind.post.repository; | ||
|
||
import com.example.sharemind.customer.domain.Customer; | ||
import com.example.sharemind.post.domain.Post; | ||
import java.util.List; | ||
|
||
public interface PostCustomRepository { | ||
|
||
List<Post> findAllByCustomerAndIsActivatedIsTrue(Customer customer, Boolean filter, | ||
Long postId, int size); | ||
} |
Oops, something went wrong.