forked from InhaBas/Inhabas.com-api
-
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.
[feature/Inhabas#252] [내 정보] 내가 쓴 게시글, 댓글, 예산신청 목록 조회 기능 구현
[feature/Inhabas#252] [내 정보] 내가 쓴 게시글, 댓글, 예산신청 목록 조회 기능 구현
- Loading branch information
Showing
19 changed files
with
963 additions
and
6 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
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
43 changes: 43 additions & 0 deletions
43
resource-server/src/main/java/com/inhabas/api/domain/myInfo/dto/MyBoardDto.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,43 @@ | ||
package com.inhabas.api.domain.myInfo.dto; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
import javax.validation.constraints.NotBlank; | ||
import javax.validation.constraints.NotNull; | ||
import javax.validation.constraints.Positive; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import com.fasterxml.jackson.annotation.JsonFormat; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
|
||
@NoArgsConstructor | ||
@Getter | ||
public class MyBoardDto { | ||
|
||
// 게시글 id | ||
@NotNull @Positive private Long id; | ||
|
||
@NotNull private Integer menuId; | ||
|
||
@NotNull private String menuName; | ||
|
||
@NotBlank private String title; | ||
|
||
@NotNull | ||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss") | ||
@Schema(type = "string", example = "2024-11-01T00:00:00") | ||
private LocalDateTime dateCreated; | ||
|
||
@Builder | ||
public MyBoardDto( | ||
Long id, Integer menuId, String menuName, String title, LocalDateTime dateCreated) { | ||
this.id = id; | ||
this.menuId = menuId; | ||
this.menuName = menuName; | ||
this.title = title; | ||
this.dateCreated = dateCreated; | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
...server/src/main/java/com/inhabas/api/domain/myInfo/dto/MyBudgetSupportApplicationDto.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,54 @@ | ||
package com.inhabas.api.domain.myInfo.dto; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
import javax.validation.constraints.NotBlank; | ||
import javax.validation.constraints.NotNull; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import com.fasterxml.jackson.annotation.JsonFormat; | ||
import com.inhabas.api.auth.domain.oauth2.member.domain.valueObject.RequestStatus; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
public class MyBudgetSupportApplicationDto { | ||
|
||
@NotNull private Long id; | ||
|
||
@NotNull private RequestStatus status; | ||
|
||
@NotBlank private String title; | ||
|
||
@NotNull | ||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss") | ||
@Schema(type = "string", example = "2024-11-01T00:00:00") | ||
private LocalDateTime dateCreated; | ||
|
||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss") | ||
@Schema(type = "string", example = "2024-11-01T00:00:00") | ||
private LocalDateTime dateChecked; | ||
|
||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss") | ||
@Schema(type = "string", example = "2024-11-01T00:00:00") | ||
private LocalDateTime dateDeposited; | ||
|
||
@Builder | ||
public MyBudgetSupportApplicationDto( | ||
Long id, | ||
RequestStatus status, | ||
String title, | ||
LocalDateTime dateCreated, | ||
LocalDateTime dateChecked, | ||
LocalDateTime dateDeposited) { | ||
this.id = id; | ||
this.status = status; | ||
this.title = title; | ||
this.dateCreated = dateCreated; | ||
this.dateChecked = dateChecked; | ||
this.dateDeposited = dateDeposited; | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
resource-server/src/main/java/com/inhabas/api/domain/myInfo/dto/MyCommentDto.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,46 @@ | ||
package com.inhabas.api.domain.myInfo.dto; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
import javax.validation.constraints.NotBlank; | ||
import javax.validation.constraints.NotNull; | ||
import javax.validation.constraints.Positive; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import com.fasterxml.jackson.annotation.JsonFormat; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
|
||
@NoArgsConstructor | ||
@Getter | ||
public class MyCommentDto { | ||
|
||
// ParentsBoard의 게시판 id | ||
@NotNull @Positive private Long id; | ||
|
||
// ParentsBoard의 menuId | ||
@NotNull private Integer menuId; | ||
|
||
// ParentsBoard의 메뉴 이름 | ||
@NotNull private String menuName; | ||
|
||
// 댓글의 내용 | ||
@NotBlank private String content; | ||
|
||
@NotNull | ||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss") | ||
@Schema(type = "string", example = "2024-11-01T00:00:00") | ||
private LocalDateTime dateCreated; | ||
|
||
@Builder | ||
public MyCommentDto( | ||
Long id, Integer menuId, String menuName, String content, LocalDateTime dateCreated) { | ||
this.id = id; | ||
this.menuId = menuId; | ||
this.menuName = menuName; | ||
this.content = content; | ||
this.dateCreated = dateCreated; | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
resource-server/src/main/java/com/inhabas/api/domain/myInfo/repository/MyInfoRepository.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,8 @@ | ||
package com.inhabas.api.domain.myInfo.repository; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import com.inhabas.api.domain.normalBoard.domain.NormalBoard; | ||
|
||
public interface MyInfoRepository | ||
extends JpaRepository<NormalBoard, Long>, MyInfoRepositoryCustom {} |
16 changes: 16 additions & 0 deletions
16
...server/src/main/java/com/inhabas/api/domain/myInfo/repository/MyInfoRepositoryCustom.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,16 @@ | ||
package com.inhabas.api.domain.myInfo.repository; | ||
|
||
import java.util.List; | ||
|
||
import com.inhabas.api.domain.myInfo.dto.MyBoardDto; | ||
import com.inhabas.api.domain.myInfo.dto.MyBudgetSupportApplicationDto; | ||
import com.inhabas.api.domain.myInfo.dto.MyCommentDto; | ||
|
||
public interface MyInfoRepositoryCustom { | ||
|
||
List<MyBoardDto> findAllBoardsByMemberId(Long memberId); | ||
|
||
List<MyCommentDto> findAllCommentsByMemberId(Long memberId); | ||
|
||
List<MyBudgetSupportApplicationDto> findAllBudgetSupportApplicationsByMemberId(Long memberId); | ||
} |
87 changes: 87 additions & 0 deletions
87
...e-server/src/main/java/com/inhabas/api/domain/myInfo/repository/MyInfoRepositoryImpl.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,87 @@ | ||
package com.inhabas.api.domain.myInfo.repository; | ||
|
||
import static com.inhabas.api.domain.board.domain.QBaseBoard.baseBoard; | ||
import static com.inhabas.api.domain.budget.domain.QBudgetSupportApplication.budgetSupportApplication; | ||
import static com.inhabas.api.domain.comment.domain.QComment.comment; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
import com.inhabas.api.domain.budget.domain.BudgetSupportApplication; | ||
import com.inhabas.api.domain.comment.domain.Comment; | ||
import com.inhabas.api.domain.myInfo.dto.MyBoardDto; | ||
import com.inhabas.api.domain.myInfo.dto.MyBudgetSupportApplicationDto; | ||
import com.inhabas.api.domain.myInfo.dto.MyCommentDto; | ||
import com.querydsl.core.types.Projections; | ||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
|
||
@RequiredArgsConstructor | ||
public class MyInfoRepositoryImpl implements MyInfoRepositoryCustom { | ||
|
||
private final JPAQueryFactory queryFactory; | ||
|
||
@Override | ||
public List<MyBoardDto> findAllBoardsByMemberId(Long memberId) { | ||
return queryFactory | ||
.select( | ||
Projections.constructor( | ||
MyBoardDto.class, | ||
baseBoard.id, | ||
baseBoard.menu.id, | ||
baseBoard.menu.name.value, | ||
baseBoard.title.value, | ||
baseBoard.dateCreated)) | ||
.from(baseBoard) | ||
.where( | ||
baseBoard | ||
.writer | ||
.id | ||
.eq(memberId) | ||
// budgetSupportApplication은 예산신청 조회가 따로 있으므로, 게시판 조회 범주에서 제외 | ||
.and(baseBoard.instanceOf(BudgetSupportApplication.class).not())) | ||
.orderBy(baseBoard.dateCreated.desc()) | ||
.fetch(); | ||
} | ||
|
||
@Override | ||
public List<MyCommentDto> findAllCommentsByMemberId(Long memberId) { | ||
List<Comment> comments = | ||
queryFactory | ||
.selectFrom(comment) | ||
.where(comment.writer.id.eq(memberId)) | ||
.orderBy(comment.dateCreated.desc()) | ||
.fetch(); | ||
|
||
return comments.stream() | ||
.map( | ||
comment -> | ||
new MyCommentDto( | ||
comment.getParentBoard().getId(), | ||
comment.getParentBoard().getMenu().getId(), | ||
comment.getParentBoard().getMenu().getName(), | ||
comment.getContent(), | ||
comment.getDateCreated())) | ||
.collect(Collectors.toList()); | ||
} | ||
|
||
@Override | ||
public List<MyBudgetSupportApplicationDto> findAllBudgetSupportApplicationsByMemberId( | ||
Long memberId) { | ||
return queryFactory | ||
.select( | ||
Projections.constructor( | ||
MyBudgetSupportApplicationDto.class, | ||
budgetSupportApplication.id, | ||
budgetSupportApplication.status, | ||
budgetSupportApplication.title.value, | ||
budgetSupportApplication.dateCreated, | ||
budgetSupportApplication.dateChecked, | ||
budgetSupportApplication.dateDeposited)) | ||
.from(budgetSupportApplication) | ||
.where(budgetSupportApplication.applicant.id.eq(memberId)) | ||
.orderBy(budgetSupportApplication.dateCreated.desc()) | ||
.fetch(); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
resource-server/src/main/java/com/inhabas/api/domain/myInfo/usecase/MyInfoService.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,15 @@ | ||
package com.inhabas.api.domain.myInfo.usecase; | ||
|
||
import java.util.List; | ||
|
||
import com.inhabas.api.domain.myInfo.dto.MyBoardDto; | ||
import com.inhabas.api.domain.myInfo.dto.MyBudgetSupportApplicationDto; | ||
import com.inhabas.api.domain.myInfo.dto.MyCommentDto; | ||
|
||
public interface MyInfoService { | ||
List<MyBoardDto> getMyBoards(Long memberId); | ||
|
||
List<MyCommentDto> getMyComments(Long memberId); | ||
|
||
List<MyBudgetSupportApplicationDto> getMyBudgetSupportApplications(Long memberId); | ||
} |
60 changes: 60 additions & 0 deletions
60
resource-server/src/main/java/com/inhabas/api/domain/myInfo/usecase/MyInfoServiceImpl.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,60 @@ | ||
package com.inhabas.api.domain.myInfo.usecase; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import com.inhabas.api.domain.myInfo.dto.MyBoardDto; | ||
import com.inhabas.api.domain.myInfo.dto.MyBudgetSupportApplicationDto; | ||
import com.inhabas.api.domain.myInfo.dto.MyCommentDto; | ||
import com.inhabas.api.domain.myInfo.repository.MyInfoRepository; | ||
|
||
@Service | ||
@Slf4j | ||
@RequiredArgsConstructor | ||
public class MyInfoServiceImpl implements MyInfoService { | ||
|
||
private final MyInfoRepository myInfoRepository; | ||
|
||
// 현재 로그인한 유저의 모든 게시글을 불러온다. | ||
@Override | ||
@Transactional(readOnly = true) | ||
public List<MyBoardDto> getMyBoards(Long memberId) { | ||
|
||
List<MyBoardDto> myBoardDtoList = new ArrayList<>(); | ||
|
||
myBoardDtoList.addAll(myInfoRepository.findAllBoardsByMemberId(memberId)); | ||
|
||
return myBoardDtoList; | ||
} | ||
|
||
// 현재 로그인한 유저의 모든 댓글을 불러온다. | ||
@Override | ||
@Transactional(readOnly = true) | ||
public List<MyCommentDto> getMyComments(Long memberId) { | ||
|
||
List<MyCommentDto> myCommentDtoList = new ArrayList<>(); | ||
|
||
myCommentDtoList.addAll(myInfoRepository.findAllCommentsByMemberId(memberId)); | ||
|
||
return myCommentDtoList; | ||
} | ||
|
||
// 현재 로그인한 유저의 모든 예산 신청 내역을 불러온다. | ||
@Override | ||
@Transactional(readOnly = true) | ||
public List<MyBudgetSupportApplicationDto> getMyBudgetSupportApplications(Long memberId) { | ||
|
||
List<MyBudgetSupportApplicationDto> budgetSupportApplicationDtoList = new ArrayList<>(); | ||
|
||
budgetSupportApplicationDtoList.addAll( | ||
myInfoRepository.findAllBudgetSupportApplicationsByMemberId(memberId)); | ||
|
||
return budgetSupportApplicationDtoList; | ||
} | ||
} |
Oops, something went wrong.