-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…eadnews Refactor/#166 ReadNews와 News 도메인 분리
- Loading branch information
Showing
14 changed files
with
125 additions
and
60 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
2 changes: 1 addition & 1 deletion
2
...core/src/main/java/com/rollthedice/backend/domain/news/repository/ReadNewsRepository.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
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
22 changes: 22 additions & 0 deletions
22
backend/core/src/main/java/com/rollthedice/backend/domain/readNews/api/ReadNewsApi.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,22 @@ | ||
package com.rollthedice.backend.domain.readNews.api; | ||
|
||
import com.rollthedice.backend.domain.news.dto.response.ReadNewsResponse; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
import io.swagger.v3.oas.annotations.security.SecurityRequirement; | ||
|
||
import java.util.List; | ||
|
||
public interface ReadNewsApi { | ||
@Operation( | ||
summary = "최근 읽은 뉴스 조회", | ||
description = "가장 최근에 읽은 3개의 뉴스를 조회합니다.", | ||
security = {@SecurityRequirement(name = "access_token")}, | ||
tags = {"news"} | ||
) | ||
@ApiResponse( | ||
responseCode = "200", | ||
description = "요청에 성공하였습니다." | ||
) | ||
List<ReadNewsResponse> getReadNews(); | ||
} |
27 changes: 27 additions & 0 deletions
27
...nd/core/src/main/java/com/rollthedice/backend/domain/readNews/api/ReadNewsController.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,27 @@ | ||
package com.rollthedice.backend.domain.readNews.api; | ||
|
||
import com.rollthedice.backend.domain.news.dto.response.ReadNewsResponse; | ||
import com.rollthedice.backend.domain.readNews.service.ReadNewsService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.ResponseStatus; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.util.List; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("read-news") | ||
public class ReadNewsController implements ReadNewsApi { | ||
|
||
private final ReadNewsService readNewsService; | ||
|
||
@ResponseStatus(HttpStatus.OK) | ||
@GetMapping("/viewed-history") | ||
@Override | ||
public List<ReadNewsResponse> getReadNews() { | ||
return readNewsService.getReadNews(); | ||
} | ||
} |
3 changes: 2 additions & 1 deletion
3
.../backend/domain/news/entity/ReadNews.java → ...kend/domain/readNews/entity/ReadNews.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
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
23 changes: 23 additions & 0 deletions
23
backend/core/src/test/java/com/rollthedice/backend/domain/readNews/ReadNewsFixture.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,23 @@ | ||
package com.rollthedice.backend.domain.readNews; | ||
|
||
import com.rollthedice.backend.domain.member.entity.Member; | ||
import com.rollthedice.backend.domain.news.dto.response.ReadNewsResponse; | ||
import com.rollthedice.backend.domain.readNews.entity.ReadNews; | ||
|
||
import static com.rollthedice.backend.domain.news.NewsFixture.NEWS; | ||
|
||
public class ReadNewsFixture { | ||
public static ReadNews READ_NEWS(Member member) { | ||
return ReadNews.builder() | ||
.member(member) | ||
.news(NEWS(member)) | ||
.build(); | ||
} | ||
|
||
public static ReadNewsResponse READ_NEWS_RESPONSE() { | ||
return ReadNewsResponse.builder() | ||
.id(1L) | ||
.title("임연지 대통령 되다.") | ||
.build(); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...ore/src/test/java/com/rollthedice/backend/domain/readNews/api/ReadNewsControllerTest.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,35 @@ | ||
package com.rollthedice.backend.domain.readNews.api; | ||
|
||
import com.rollthedice.backend.domain.readNews.service.ReadNewsService; | ||
import com.rollthedice.backend.global.BaseControllerTest; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; | ||
import org.springframework.boot.test.mock.mockito.MockBean; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.test.web.servlet.ResultActions; | ||
|
||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | ||
|
||
@DisplayName("ReadNewsController의 ") | ||
@WebMvcTest(ReadNewsController.class) | ||
class ReadNewsControllerTest extends BaseControllerTest { | ||
@MockBean | ||
private ReadNewsService readNewsService; | ||
|
||
@Test | ||
@DisplayName("조회한 News 전체 조회 API가 수행되는가") | ||
void getReadNews() throws Exception{ | ||
//when | ||
final ResultActions perform = mockMvc.perform( | ||
get("/read-news/viewed-history") | ||
.contentType(MediaType.APPLICATION_JSON) | ||
.header("Authorization", "Bearer " + accessToken) | ||
).andDo(print()); | ||
|
||
//then | ||
perform.andExpect(status().isOk()); | ||
} | ||
} |
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