Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
0263572
Article Repository Jpa / Query 전용 구분
qowl880 May 28, 2025
6394b4c
Article Custom Error Exception 구현
qowl880 May 28, 2025
092f5f9
Auditing 설정 추가
qowl880 May 28, 2025
0a84823
Article Create Controller 구현
qowl880 May 28, 2025
63e0b3f
Article Delete Controller 구현
qowl880 May 28, 2025
8db6bab
Article Controller CUD 구현
qowl880 May 28, 2025
688931c
Comment Repository Jpa / Query 전용 구분
qowl880 May 28, 2025
9a7c27f
Comment Controller Create 구현
qowl880 May 28, 2025
f5c340a
application yml파일 배포/로컬 분리
qowl880 May 28, 2025
e5ff962
Article Create Controller 구현
qowl880 May 28, 2025
cefeeaf
Article Delete Controller 구현
qowl880 May 28, 2025
d8589b1
Article Controller CUD 구현
qowl880 May 28, 2025
360b85d
application.yml 통합
qowl880 May 28, 2025
3fb8784
Article Repository 설정
qowl880 Jun 3, 2025
5ca9b42
Comment Error Exception 생성
qowl880 Jun 4, 2025
a699862
구조 변경
qowl880 Jun 4, 2025
598192c
Comment Read 전용 Dao 생성
qowl880 Jun 4, 2025
552d962
application yml파일 배포/로컬 분리
qowl880 May 28, 2025
62b8539
Article Repository Jpa / Query 전용 구분
qowl880 May 28, 2025
dea83bd
Article Create Controller 구현
qowl880 May 28, 2025
50fd1d4
Article Delete Controller 구현
qowl880 May 28, 2025
9b15db5
Article Controller CUD 구현
qowl880 May 28, 2025
c5911c1
application.yml 통합
qowl880 May 28, 2025
a8d8355
Article Repository 설정
qowl880 Jun 3, 2025
920c7ae
개행 추가
qowl880 Jun 6, 2025
b88d056
ErrorException 통합
qowl880 Jun 8, 2025
3e1cdc9
Dao -> QueryResult 파일명 변경
qowl880 Jun 8, 2025
2f7ba08
Update IdolApplication.java
qowl880 Jun 10, 2025
ce3b509
유저 인증 검사 추가
qowl880 Jun 14, 2025
0c15894
Article Entity 구현
qowl880 May 28, 2025
757ab0b
Article Repository Jpa / Query 전용 구분
qowl880 May 28, 2025
cb03367
Article Custom Error Exception 구현
qowl880 May 28, 2025
f876eb4
Auditing 설정 추가
qowl880 May 28, 2025
e5ca6ca
Article Create Controller 구현
qowl880 May 28, 2025
5f55539
Article Delete Controller 구현
qowl880 May 28, 2025
1684e25
Article Controller CUD 구현
qowl880 May 28, 2025
5523de7
S3 관련 이미지 업로드 및 호출 기능 구현
qowl880 May 28, 2025
ea6b433
Comment Repository Jpa / Query 전용 구분
qowl880 May 28, 2025
2ca71b5
Comment Controller Create 구현
qowl880 May 28, 2025
e2dd00f
application yml파일 배포/로컬 분리
qowl880 May 28, 2025
549aae8
Article Create Controller 구현
qowl880 May 28, 2025
4687dff
Article Delete Controller 구현
qowl880 May 28, 2025
6061a9d
Article Controller CUD 구현
qowl880 May 28, 2025
26d45cb
application.yml 통합
qowl880 May 28, 2025
2c4f8bd
Article Repository 설정
qowl880 Jun 3, 2025
f3e3013
Comment Error Exception 생성
qowl880 Jun 4, 2025
b92293c
구조 변경
qowl880 Jun 4, 2025
33db692
Comment Read 전용 Dao 생성
qowl880 Jun 4, 2025
af4c5f5
application yml파일 배포/로컬 분리
qowl880 May 28, 2025
78233c5
Article Repository Jpa / Query 전용 구분
qowl880 May 28, 2025
124c68c
Article Create Controller 구현
qowl880 May 28, 2025
81fa9ee
Article Delete Controller 구현
qowl880 May 28, 2025
defeccc
Article Controller CUD 구현
qowl880 May 28, 2025
e5f4e72
application.yml 통합
qowl880 May 28, 2025
0638da4
SoftDelete 추가
qowl880 Jun 3, 2025
141227a
Article Repository 설정
qowl880 Jun 3, 2025
dad8f99
개행 추가
qowl880 Jun 6, 2025
cbf3ce6
ErrorException 통합
qowl880 Jun 8, 2025
0bc9a57
Dao -> QueryResult 파일명 변경
qowl880 Jun 8, 2025
2796734
S3 의존성 변경에 따른 구조 변경
qowl880 Jun 8, 2025
594cc53
Update IdolApplication.java
qowl880 Jun 10, 2025
fe960e3
유저 인증 검사 추가
qowl880 Jun 14, 2025
5a48983
@Where 삭제
qowl880 Jun 17, 2025
8912f03
오류로 인한 주석처리
qowl880 Jun 18, 2025
67f7546
aws 관련 설정 추가
qowl880 Jun 19, 2025
67a7907
나의 답변 기능 구현
qowl880 Jun 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import com.idol.board.dto.response.article.ArticleListResponseDto;
import com.idol.board.dto.response.comment.CommentResponseDto;
import com.idol.board.dto.response.mypage.MyPageQuestionResponseDto;
import com.idol.board.dto.response.mypage.UserAnswerResponseDto;
import com.idol.board.dto.response.mypage.UserAnswerTotalResponseDto;
import com.idol.board.dto.response.mypage.UserDataResponseDto;
import com.idol.board.service.article.query.ReadArticleService;
import com.idol.board.usecase.article.query.ReadArticleUseCase;
Expand Down Expand Up @@ -54,21 +56,6 @@ public ApiResponse<List<ArticleListResponseDto>> readAllCreateMyPage(
return ApiResponse.ok(dto, "나가 만든 펜팔 리스트 조회 성공");
}


// @Operation(summary = "나의 질문 출력", description = "나의 질문 출력")
// @GetMapping("/self")
// public ApiResponse<MyPageQuestionResponseDto> readAllQuestionMyPage(
// @RequestParam(value = "lastParentCommentId", required = false) Long lastParentCommentId,
// @RequestParam(value = "lastCommentId", required = false) Long lastCommentId,
// @RequestParam(value = "pageSize") Long limit,
// @MemberId Long userId
// ){
// MyPageQuestionResponseDto dto = readMypageUseCase.readMyQuestion(userId, lastParentCommentId,lastCommentId,limit);
//
// return ApiResponse.ok(dto, "나의 질문 조회 성공");
// }


@Operation(summary = "유저 정보 전달", description = "유저 정보 전달을 진행합니다.")
@GetMapping("/user")
public ApiResponse<UserDataResponseDto> readUserInformation(
Expand All @@ -77,4 +64,15 @@ public ApiResponse<UserDataResponseDto> readUserInformation(
UserDataResponseDto response = readMypageUseCase.readUserInformation(userId);
return ApiResponse.ok(response, "유저 정보 전달 성공");
}


@Operation(summary = "나의 답변 리스트 출력", description = "나의 답변 리스트 출력")
@GetMapping("/answer")
public ApiResponse<UserAnswerTotalResponseDto> readAllAnswers(
@RequestParam(value = "lastArticleId", required = false) Long lastArticleId,
@MemberId Long userId
) {
UserAnswerTotalResponseDto response= readMypageUseCase.readAllAnswers(lastArticleId,userId);
return ApiResponse.ok(response, "나의 답변 리스트 출력 성공");
}
}
2 changes: 0 additions & 2 deletions src/main/java/com/idol/board/domain/entity/Comment.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ public class Comment extends BaseEntity {
@Column(name = "secret", nullable = false)
private boolean secret;

// @Column(name = "parent_check")
// private boolean parentCheck;

@Builder
public Comment(Long commentId, Long articleId, Long writerId, String content, Long parentCommentId, boolean secret) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.idol.board.dto.response.mypage;

import java.sql.Timestamp;
import java.time.LocalDateTime;

public record UserAnswerResponseDto(
Long articleId,
String title,
String location,
Long createdAt,
String comment,
boolean answer
) {
public static Long changeToUnixTime(Timestamp ts) {
// 2. 밀리초 단위 UNIX timestamp 얻기
long unixMillis = ts.getTime(); // 1750288750000

// 3. 초 단위 UNIX timestamp 얻기
long unixSeconds = unixMillis / 1000; // 1750288750

return unixSeconds;
}

public static UserAnswerResponseDto from( Long articleId,
String title,
String location,
LocalDateTime createdAt,
String comment,
boolean answer){



return new UserAnswerResponseDto(articleId, title, location, changeToUnixTime(Timestamp.valueOf(createdAt)), comment, answer);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.idol.board.dto.response.mypage;

import java.util.List;

public record UserAnswerTotalResponseDto(
int totalCount,
List<UserAnswerResponseDto> data
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
import com.idol.board.domain.entity.Article;
import com.idol.board.dto.response.article.ArticleListResponseDto;
import com.idol.board.repository.mapper.ArticleListReadQueryResult;
import org.springframework.data.domain.Page;

import com.idol.board.repository.mapper.ArticleReadAnswerQueryResult;
import java.sql.Timestamp;
import java.util.List;
import java.util.Optional;
Expand All @@ -23,4 +22,6 @@ List<ArticleListReadQueryResult> findArticleList(

List<ArticleListReadQueryResult> findJoinMyPageArticle(List<Long> articleIds, Long limit, Long offset);

List<ArticleReadAnswerQueryResult> findAllByWriterIdInfiniteScrollFromArticle(Long userId);
List<ArticleReadAnswerQueryResult> findAllByWriterIdInfiniteScrollFromArticle(Long lastArticleId, Long userId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
import com.idol.board.domain.entity.QArticle;
import com.idol.board.dto.response.article.ArticleListResponseDto;
import com.idol.board.repository.mapper.ArticleListReadQueryResult;
import com.idol.board.repository.mapper.ArticleReadAnswerQueryResult;
import com.idol.board.repository.mapper.CommentReadQueryResult;
import com.querydsl.core.BooleanBuilder;
import com.querydsl.core.types.Order;
import com.querydsl.core.types.OrderSpecifier;
import com.querydsl.core.types.Projections;
Expand Down Expand Up @@ -124,6 +126,42 @@ public List<ArticleListReadQueryResult> findJoinMyPageArticle(List<Long> article
.fetch();
}

@Override
public List<ArticleReadAnswerQueryResult> findAllByWriterIdInfiniteScrollFromArticle( Long userId) {
return queryFactory
.select(Projections.constructor(ArticleReadAnswerQueryResult.class,
article.articleId,
article.title,
article.locationAddress))
.from(article)
.where(
article.isDeleted.eq(false),
article.writerId.in(userId)
)
.fetch();
}

@Override
public List<ArticleReadAnswerQueryResult> findAllByWriterIdInfiniteScrollFromArticle(
Long lastArticleId, Long userId) {
return queryFactory
.select(Projections.constructor(ArticleReadAnswerQueryResult.class,
article.articleId,
article.title,
article.locationAddress))
.from(article)
.where(
article.isDeleted.eq(false),
article.writerId.in(userId),
new BooleanBuilder()
.or(article.articleId.eq(lastArticleId))
)
.orderBy(
article.articleId.asc()
)
.fetch();
}

private BooleanExpression eqWriterId(Long userId) {
return userId != null ? article.writerId.eq(userId) : null;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.idol.board.repository.comment;

import com.idol.board.domain.entity.Comment;
import com.idol.board.repository.mapper.CommentReadAnswerQueryResult;
import com.idol.board.repository.mapper.CommentReadQueryResult;
import com.idol.board.repository.mapper.CommentReadQuestionQueryResult;

Expand All @@ -19,7 +20,7 @@ public interface CommentRepositoryCustom {

Optional<Comment> findByParentCommentId(Long parentCommentId);

List<CommentReadAnswerQueryResult> findAllByArticleId(Long articleId);

// List<CommentReadQuestionQueryResult> findQuestionAllInfiniteScroll(Long userId, Long limit);
// List<CommentReadQueryResult> findQuestionAllInfiniteScroll(Long userId, Long lastParentCommentId, Long lastCommentId, Long limit);
Long parentIdCountBy(Long parentCommentId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.idol.board.domain.entity.Comment;
import com.idol.board.domain.entity.QComment;
import com.idol.board.repository.mapper.CommentReadAnswerQueryResult;
import com.idol.board.repository.mapper.CommentReadQueryResult;
import com.idol.board.repository.mapper.CommentReadQuestionQueryResult;
import com.querydsl.core.BooleanBuilder;
Expand Down Expand Up @@ -136,44 +137,38 @@ public List<CommentReadQueryResult> findAllInfiniteScroll(Long articleId, Long l
}


// @Override
// public List<CommentReadQuestionQueryResult> findQuestionAllInfiniteScroll(Long userId, Long limit) {
//
// return queryFactory
// .select(Projections.constructor(CommentReadQuestionQueryResult.class,
// comment.commentId,
// comment.articleId,
// comment.content,
// comment.parentCommentId,
// comment.writerId,
// comment.isDeleted,
// comment.createdAt,
// comment.secret))
// .from(comment)
// .where(
// comment.isDeleted.eq(false),
// comment.writerId.eq(userId).and(comment.parentCheck.eq(true)) // 부모 댓글
// .or(
// comment.parentCommentId.in(
// JPAExpressions
// .select(comment.commentId)
// .from(comment)
// .where(
// comment.isDeleted.eq(false),
// comment.writerId.eq(userId),
// comment.parentCheck.eq(true)
// )
// ) // 자식 댓글
// )
// )
// .orderBy(
// comment.parentCommentId.asc().nullsFirst(), // 부모 댓글 먼저
// comment.parentCheck.desc(), // 부모 댓글 먼저
// comment.createdAt.asc()
// )
//// .limit(limit * 10)
//// .offset(offset)
// .fetch();
// }

@Override
public List<CommentReadAnswerQueryResult> findAllByArticleId(Long articleId) {

return queryFactory
.select(Projections.constructor(CommentReadAnswerQueryResult.class,
comment.content,
comment.createdAt,
comment.commentId,
comment.parentCommentId))
.from(comment)
.where(
comment.isDeleted.eq(false),
comment.articleId.eq(articleId)
)
.orderBy(
comment.parentCommentId.asc(),
comment.commentId.asc()
)
.fetch();
}


@Override
public Long parentIdCountBy(Long parentCommentId) {
return queryFactory
.select(comment.count())
.from(comment)
.where(
comment.isDeleted.eq(false),
comment.parentCommentId.eq(parentCommentId)
)
.fetchOne();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.idol.board.repository.mapper;


public record ArticleReadAnswerQueryResult(
Long articleId,
String title,
String locationAddress
) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.idol.board.repository.mapper;

import java.time.LocalDateTime;

public record CommentReadAnswerQueryResult(
String content,
LocalDateTime createdAt,
Long commentId,
Long parentCommentId
) {
}
Loading