diff --git a/resource-server/src/main/java/com/inhabas/api/domain/myInfo/dto/MyPostsDto.java b/resource-server/src/main/java/com/inhabas/api/domain/myInfo/dto/MyBoardsDto.java similarity index 88% rename from resource-server/src/main/java/com/inhabas/api/domain/myInfo/dto/MyPostsDto.java rename to resource-server/src/main/java/com/inhabas/api/domain/myInfo/dto/MyBoardsDto.java index b1510818..c03f0290 100644 --- a/resource-server/src/main/java/com/inhabas/api/domain/myInfo/dto/MyPostsDto.java +++ b/resource-server/src/main/java/com/inhabas/api/domain/myInfo/dto/MyBoardsDto.java @@ -13,7 +13,7 @@ @NoArgsConstructor @Getter -public class MyPostsDto { +public class MyBoardsDto { // 게시글 id @NotNull @Positive private Long id; @@ -28,7 +28,7 @@ public class MyPostsDto { String dateCreated; @Builder - MyPostsDto(Long id, String menuName, String title, String dateCreated) { + MyBoardsDto(Long id, String menuName, String title, String dateCreated) { this.id = id; this.menuName = menuName; this.title = title; diff --git a/resource-server/src/main/java/com/inhabas/api/domain/myInfo/repository/MyInfoRepositoryCustom.java b/resource-server/src/main/java/com/inhabas/api/domain/myInfo/repository/MyInfoRepositoryCustom.java index 987cdbc0..498df8ea 100644 --- a/resource-server/src/main/java/com/inhabas/api/domain/myInfo/repository/MyInfoRepositoryCustom.java +++ b/resource-server/src/main/java/com/inhabas/api/domain/myInfo/repository/MyInfoRepositoryCustom.java @@ -2,13 +2,13 @@ import java.util.List; +import com.inhabas.api.domain.myInfo.dto.MyBoardsDto; import com.inhabas.api.domain.myInfo.dto.MyBudgetSupportApplicationDto; import com.inhabas.api.domain.myInfo.dto.MyCommentsDto; -import com.inhabas.api.domain.myInfo.dto.MyPostsDto; public interface MyInfoRepositoryCustom { - List findAllBoardsByMemberId(Long memberId); + List findAllBoardsByMemberId(Long memberId); List findAllCommentsByMemberId(Long memberId); diff --git a/resource-server/src/main/java/com/inhabas/api/domain/myInfo/repository/MyInfoRepositoryImpl.java b/resource-server/src/main/java/com/inhabas/api/domain/myInfo/repository/MyInfoRepositoryImpl.java index b764f734..b55e469e 100644 --- a/resource-server/src/main/java/com/inhabas/api/domain/myInfo/repository/MyInfoRepositoryImpl.java +++ b/resource-server/src/main/java/com/inhabas/api/domain/myInfo/repository/MyInfoRepositoryImpl.java @@ -8,9 +8,9 @@ import lombok.RequiredArgsConstructor; +import com.inhabas.api.domain.myInfo.dto.MyBoardsDto; import com.inhabas.api.domain.myInfo.dto.MyBudgetSupportApplicationDto; import com.inhabas.api.domain.myInfo.dto.MyCommentsDto; -import com.inhabas.api.domain.myInfo.dto.MyPostsDto; import com.querydsl.core.types.Projections; import com.querydsl.jpa.impl.JPAQueryFactory; @@ -20,11 +20,11 @@ public class MyInfoRepositoryImpl implements MyInfoRepositoryCustom { private final JPAQueryFactory queryFactory; @Override - public List findAllBoardsByMemberId(Long memberId) { + public List findAllBoardsByMemberId(Long memberId) { return queryFactory .select( Projections.constructor( - MyPostsDto.class, + MyBoardsDto.class, baseBoard.id, baseBoard.menu.id, baseBoard.menu.name.value, @@ -60,6 +60,7 @@ public List findAllBudgetSupportAllpicationByMemb .select( Projections.constructor( MyBudgetSupportApplicationDto.class, + budgetSupportApplication.id, budgetSupportApplication.status, budgetSupportApplication.title.value, budgetSupportApplication.dateCreated, diff --git a/resource-server/src/main/java/com/inhabas/api/domain/myInfo/usecase/MyInfoService.java b/resource-server/src/main/java/com/inhabas/api/domain/myInfo/usecase/MyInfoService.java index a6d7a3fa..0c7f2219 100644 --- a/resource-server/src/main/java/com/inhabas/api/domain/myInfo/usecase/MyInfoService.java +++ b/resource-server/src/main/java/com/inhabas/api/domain/myInfo/usecase/MyInfoService.java @@ -2,14 +2,14 @@ import java.util.List; +import com.inhabas.api.domain.myInfo.dto.MyBoardsDto; import com.inhabas.api.domain.myInfo.dto.MyBudgetSupportApplicationDto; import com.inhabas.api.domain.myInfo.dto.MyCommentsDto; -import com.inhabas.api.domain.myInfo.dto.MyPostsDto; public interface MyInfoService { - List getMyBoards(); + List getMyBoards(); List getMyComments(); - List getMyBudgetApplicationSupports(); + List getMyBudgetSupportApplications(); } diff --git a/resource-server/src/main/java/com/inhabas/api/domain/myInfo/usecase/MyInfoServiceImpl.java b/resource-server/src/main/java/com/inhabas/api/domain/myInfo/usecase/MyInfoServiceImpl.java index f43646f2..724e0c1a 100644 --- a/resource-server/src/main/java/com/inhabas/api/domain/myInfo/usecase/MyInfoServiceImpl.java +++ b/resource-server/src/main/java/com/inhabas/api/domain/myInfo/usecase/MyInfoServiceImpl.java @@ -11,9 +11,9 @@ import org.springframework.transaction.annotation.Transactional; import com.inhabas.api.auth.domain.error.authException.InvalidAuthorityException; +import com.inhabas.api.domain.myInfo.dto.MyBoardsDto; import com.inhabas.api.domain.myInfo.dto.MyBudgetSupportApplicationDto; import com.inhabas.api.domain.myInfo.dto.MyCommentsDto; -import com.inhabas.api.domain.myInfo.dto.MyPostsDto; import com.inhabas.api.domain.myInfo.repository.MyInfoRepository; @Service @@ -26,21 +26,21 @@ public class MyInfoServiceImpl implements MyInfoService { // 현재 로그인한 유저의 모든 게시글을 불러온다. @Override @Transactional(readOnly = true) - public List getMyBoards() { + public List getMyBoards() { - List myPostsDtoList = new ArrayList<>(); + List myBoardsDtoList = new ArrayList<>(); if (SecurityContextHolder.getContext() == null) { throw new InvalidAuthorityException(); } Long memberId = (Long) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); - myPostsDtoList.addAll(myInfoRepository.findAllBoardsByMemberId(memberId)); + myBoardsDtoList.addAll(myInfoRepository.findAllBoardsByMemberId(memberId)); if (SecurityContextHolder.getContext() == null) { throw new InvalidAuthorityException(); } - return myPostsDtoList; + return myBoardsDtoList; } // 현재 로그인한 유저의 모든 댓글을 불러온다. @@ -66,7 +66,7 @@ public List getMyComments() { // 현재 로그인한 유저의 모든 예산 신청 내역을 불러온다. @Override @Transactional(readOnly = true) - public List getMyBudgetApplicationSupports() { + public List getMyBudgetSupportApplications() { List budgetSupportApplicationDtoList = new ArrayList<>(); diff --git a/resource-server/src/main/java/com/inhabas/api/web/MyProfileController.java b/resource-server/src/main/java/com/inhabas/api/web/MyProfileController.java index cf331b19..fb43d54c 100644 --- a/resource-server/src/main/java/com/inhabas/api/web/MyProfileController.java +++ b/resource-server/src/main/java/com/inhabas/api/web/MyProfileController.java @@ -18,6 +18,10 @@ import com.inhabas.api.auth.domain.error.ErrorResponse; import com.inhabas.api.auth.domain.oauth2.member.dto.*; import com.inhabas.api.domain.member.usecase.MemberProfileService; +import com.inhabas.api.domain.myInfo.dto.MyBoardsDto; +import com.inhabas.api.domain.myInfo.dto.MyBudgetSupportApplicationDto; +import com.inhabas.api.domain.myInfo.dto.MyCommentsDto; +import com.inhabas.api.domain.myInfo.usecase.MyInfoService; import com.inhabas.api.global.dto.PageInfoDto; import com.inhabas.api.global.dto.PagedResponseDto; import com.inhabas.api.global.util.PageUtil; @@ -38,6 +42,7 @@ public class MyProfileController { private final MemberProfileService memberProfileService; + private final MyInfoService myInfoService; @Operation(summary = "내 정보 조회", description = "사용자 자신의 정보만 조회 가능") @ApiResponses( @@ -227,4 +232,82 @@ public ResponseEntity handleMyInfoRequest( // [모임, 글, 댓글, 예산신청 조회] 추후 개발 예정 + @Operation(summary = "내가 쓴 게시글 목록 조회") + @ApiResponses( + value = { + @ApiResponse( + responseCode = "200", + content = {@Content(schema = @Schema(implementation = UpdateNameRequestDto.class))}), + }) + @GetMapping("/myInfo/boards") + public ResponseEntity> getBoardList( + @Parameter(description = "페이지", example = "0") + @RequestParam(name = "page", defaultValue = "0") + int page, + @Parameter(description = "페이지당 개수", example = "10") + @RequestParam(name = "size", defaultValue = "10") + int size, + @Authenticated Long memberId) { + + Pageable pageable = PageRequest.of(page, size); + List allDtoList = myInfoService.getMyBoards(); + List pagedDtoList = PageUtil.getPagedDtoList(pageable, allDtoList); + + PageImpl myBoardsDtoPage = + new PageImpl<>(pagedDtoList, pageable, allDtoList.size()); + PageInfoDto pageInfoDto = new PageInfoDto(myBoardsDtoPage); + + return ResponseEntity.ok(new PagedResponseDto<>(pageInfoDto, pagedDtoList)); + } + + @Operation(summary = "내가 쓴 댓글 목록 조회") + @ApiResponses( + value = { + @ApiResponse( + responseCode = "200", + content = {@Content(schema = @Schema(implementation = UpdateNameRequestDto.class))}), + }) + @GetMapping("/myInfo/comments") + public ResponseEntity> getCommentsList( + @Parameter(description = "페이지", example = "0") + @RequestParam(name = "page", defaultValue = "0") + int page, + @Parameter(description = "페이지당 개수", example = "10") + @RequestParam(name = "size", defaultValue = "10") + int size, + @Authenticated Long memberId) { + + Pageable pageable = PageRequest.of(page, size); + List allDtoList = myInfoService.getMyComments(); + List pagedDtoList = PageUtil.getPagedDtoList(pageable, allDtoList); + + PageImpl myCommentsDtoPage = + new PageImpl<>(pagedDtoList, pageable, allDtoList.size()); + PageInfoDto pageInfoDto = new PageInfoDto(myCommentsDtoPage); + + return ResponseEntity.ok(new PagedResponseDto<>(pageInfoDto, pagedDtoList)); + } + + @GetMapping("/myInfo/budgetSupportApplications") + public ResponseEntity> + getBudgetSupportApplicationsList( + @Parameter(description = "페이지", example = "0") + @RequestParam(name = "page", defaultValue = "0") + int page, + @Parameter(description = "페이지당 개수", example = "10") + @RequestParam(name = "size", defaultValue = "10") + int size, + @Authenticated Long memberId) { + + Pageable pageable = PageRequest.of(page, size); + List allDtoList = myInfoService.getMyBudgetSupportApplications(); + List pagedDtoList = + PageUtil.getPagedDtoList(pageable, allDtoList); + + PageImpl myBudgetSupportApplicationDtoPage = + new PageImpl<>(pagedDtoList, pageable, allDtoList.size()); + PageInfoDto pageInfoDto = new PageInfoDto(myBudgetSupportApplicationDtoPage); + + return ResponseEntity.ok(new PagedResponseDto<>(pageInfoDto, pagedDtoList)); + } }