Skip to content
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

Merged
merged 3 commits into from
Jan 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Facade 패턴 익숙해져보겠습니다!


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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[질문] 여기 NoteService에서 NoteRepository 1개만 주입받는데 왜 굳이 Facade를 만들어서 코드를 작성했는지 궁금합니다 🤔

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

추후에 CommonFacade에서 NoteService와 BookService를 모두 주입받아야해서 만들어 놓은 것입니다!
현재 상황에서는 필요 없긴 합니다!


//TODO 되는지 검증 필요
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

추후에 API 개발 완료된 이후에 테스트 해봐야할 것 같네요

public Long getAllNoteCount() {
return noteRepository.count();
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ public enum SuccessType {
LOGOUT_SUCCESS(HttpStatus.OK, "로그아웃에 성공했습니다."),
KAKAO_ACCESS_TOKEN_SUCCESS(HttpStatus.OK, "카카오 엑세스 토큰을 가져오는데 성공했습니다."),

STICKER_PACK_LIST_SUCCESS(HttpStatus.OK, "스티커팩 목록 조회에 성공했습니다.");
STICKER_PACK_LIST_SUCCESS(HttpStatus.OK, "스티커팩 목록 조회에 성공했습니다."),
GET_SPLASH_SUCCESS(HttpStatus.OK, "전체 노트의 수를 성공적으로 조회했습니다."),
;

private final HttpStatus httpStatus;
private final String message;
Expand Down
Loading