-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEAT] 스플래시 조회 기능 구현 #30
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package org.sopt.lequuServer.domain.common.controller; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.sopt.lequuServer.domain.common.facade.CommonFacade; | ||
import org.sopt.lequuServer.global.common.dto.ApiResponse; | ||
import org.sopt.lequuServer.global.exception.enums.SuccessType; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController("/api/common") | ||
@RequiredArgsConstructor | ||
public class CommonController { | ||
|
||
private final CommonFacade commonFacade; | ||
|
||
@GetMapping("/splash") | ||
public ApiResponse<Long> getSplash() { | ||
return ApiResponse.success(SuccessType.GET_SPLASH_SUCCESS, commonFacade.getSplash()); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package org.sopt.lequuServer.domain.common.facade; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.sopt.lequuServer.domain.note.service.NoteService; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class CommonFacade { | ||
|
||
private final NoteService noteService; | ||
|
||
public Long getSplash() { | ||
return noteService.getAllNoteCount(); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package org.sopt.lequuServer.domain.note.repository; | ||
|
||
import org.sopt.lequuServer.domain.note.model.Note; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface NoteRepository extends JpaRepository<Note, Long> { | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.sopt.lequuServer.domain.note.service; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.sopt.lequuServer.domain.note.repository.NoteRepository; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class NoteService { | ||
|
||
private final NoteRepository noteRepository; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [질문] 여기 NoteService에서 NoteRepository 1개만 주입받는데 왜 굳이 Facade를 만들어서 코드를 작성했는지 궁금합니다 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 추후에 CommonFacade에서 NoteService와 BookService를 모두 주입받아야해서 만들어 놓은 것입니다! |
||
|
||
//TODO 되는지 검증 필요 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 추후에 API 개발 완료된 이후에 테스트 해봐야할 것 같네요 |
||
public Long getAllNoteCount() { | ||
return noteRepository.count(); | ||
} | ||
|
||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Facade 패턴 익숙해져보겠습니다!