-
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
…ad-news Feat/#116 최근 조회한 뉴스 관련 기능 구현
- Loading branch information
Showing
46 changed files
with
1,502 additions
and
572 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...s/repository/DebateMessageRepository.java → ...e/repository/DebateMessageRepository.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
15 changes: 15 additions & 0 deletions
15
...core/src/main/java/com/rollthedice/backend/domain/news/dto/response/ReadNewsResponse.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.rollthedice.backend.domain.news.dto.response; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class ReadNewsResponse { | ||
private Long id; | ||
private String title; | ||
} |
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
14 changes: 14 additions & 0 deletions
14
...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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.rollthedice.backend.domain.news.repository; | ||
|
||
import com.rollthedice.backend.domain.member.entity.Member; | ||
import com.rollthedice.backend.domain.news.entity.ReadNews; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.List; | ||
|
||
@Repository | ||
public interface ReadNewsRepository extends JpaRepository<ReadNews, Long> { | ||
List<ReadNews> getTop3ByMemberOrderByCreatedAtDesc(Member member); | ||
|
||
} |
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
26 changes: 26 additions & 0 deletions
26
backend/core/src/main/java/com/rollthedice/backend/domain/news/service/ReadNewsService.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,26 @@ | ||
package com.rollthedice.backend.domain.news.service; | ||
|
||
import com.rollthedice.backend.domain.member.entity.Member; | ||
import com.rollthedice.backend.domain.news.dto.response.ReadNewsResponse; | ||
import com.rollthedice.backend.domain.news.entity.ReadNews; | ||
import com.rollthedice.backend.domain.news.repository.ReadNewsRepository; | ||
import com.rollthedice.backend.global.oauth2.service.AuthService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class ReadNewsService { | ||
private final AuthService authService; | ||
private final ReadNewsRepository readNewsReository; | ||
private final NewsService newsService; | ||
|
||
public List<ReadNewsResponse> getReadNews() { | ||
Member member = authService.getMember(); | ||
List<ReadNews> readNews = readNewsReository.getTop3ByMemberOrderByCreatedAtDesc(member); | ||
return newsService.getNewsByReadNews(readNews.stream().map(r -> r.getNews()).collect(Collectors.toList())); | ||
} | ||
} |
Oops, something went wrong.