Skip to content

Commit

Permalink
FeedQueryList 비즈니스 로직 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
tlsgmltjd committed Mar 21, 2024
1 parent 6a18a93 commit 8c08bb3
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@ import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController
import team.themoment.gsmNetworking.common.exception.ExpectedException
import team.themoment.gsmNetworking.domain.feed.dto.FeedInfoDto
import team.themoment.gsmNetworking.domain.feed.dto.FeedSaveDto
import team.themoment.gsmNetworking.domain.feed.service.GenerateFeedUseCase
import team.themoment.gsmNetworking.domain.feed.service.QueryFeedListUseCase

@RestController
@RequestMapping("/api/v1/feed")
class FeedController(
private val generateFeedUseCase: GenerateFeedUseCase
private val generateFeedUseCase: GenerateFeedUseCase,
private val queryFeedListUseCase: QueryFeedListUseCase
) {

@PostMapping
Expand All @@ -24,9 +27,16 @@ class FeedController(
return ResponseEntity.status(HttpStatus.CREATED).build()
}

// @GetMapping
// fun queryFeedList(@RequestParam cursorId: Long,
// @RequestParam pageSize: Long) : ResponseEntity<List<FeedInfoDto>> {
// }
@GetMapping
fun queryFeedList(@RequestParam cursorId: Long,
@RequestParam pageSize: Long) : ResponseEntity<List<FeedInfoDto>> {

if (cursorId < 0L || pageSize < 0L)
throw ExpectedException("0이상부터 가능합니다.", HttpStatus.BAD_REQUEST)
if (pageSize > 20L)
throw ExpectedException("페이지 크기는 20이하까지 가능합니다.", HttpStatus.BAD_REQUEST)

return ResponseEntity.ok(queryFeedListUseCase.queryFeedList(cursorId, pageSize))
}

}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package team.themoment.gsmNetworking.domain.feed.service

import team.themoment.gsmNetworking.domain.feed.dto.FeedInfoDto

interface QueryFeedListUseCase {
fun queryFeedList(cursorId: Long, pageSize: Long): List<FeedInfoDto>
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@ import org.springframework.transaction.annotation.Transactional
import team.themoment.gsmNetworking.common.exception.ExpectedException
import team.themoment.gsmNetworking.common.manager.AuthenticatedUserManager
import team.themoment.gsmNetworking.domain.feed.domain.Feed
import team.themoment.gsmNetworking.domain.feed.dto.FeedInfoDto
import team.themoment.gsmNetworking.domain.feed.dto.FeedSaveDto
import team.themoment.gsmNetworking.domain.feed.repository.FeedRepository
import team.themoment.gsmNetworking.domain.feed.service.GenerateFeedUseCase
import team.themoment.gsmNetworking.domain.feed.service.QueryFeedListUseCase
import team.themoment.gsmNetworking.domain.user.repository.UserRepository

@Service
class FeedService (
private val feedRepository: FeedRepository,
private val userRepository: UserRepository,
private val authenticatedUserManager: AuthenticatedUserManager
) : GenerateFeedUseCase {
) : GenerateFeedUseCase, QueryFeedListUseCase {

@Transactional
override fun generateFeed(feedSaveDto: FeedSaveDto) {
Expand All @@ -35,4 +37,10 @@ class FeedService (

}

}
override fun queryFeedList(cursorId: Long, pageSize: Long): List<FeedInfoDto> =
if (cursorId == 0L)
feedRepository.findPageWithRecentFeed(pageSize)
else
feedRepository.findPageByCursorId(cursorId, pageSize)

}

0 comments on commit 8c08bb3

Please sign in to comment.