diff --git a/.gitignore b/.gitignore index 404f76b..5761f22 100644 --- a/.gitignore +++ b/.gitignore @@ -36,4 +36,4 @@ out/ ### VS Code ### .vscode/ -firebase_service_key.json \ No newline at end of file +firebase_service_key.json diff --git a/README.md b/README.md index 77b50df..7c7f108 100644 --- a/README.md +++ b/README.md @@ -29,13 +29,13 @@ API 개발 | API 개발 | API 개발 | +

+## 📝 Coding Convention, Git flow +> [Convention and flow](https://www.notion.so/efe35fa22c0044b4bd4c0dd5ff014d04?pvs=4) -
- -## 📝 Coding Convention, Git flow -- [Convention and flow](https://www.notion.so/efe35fa22c0044b4bd4c0dd5ff014d04?pvs=4) +

## 📒 Foldering @@ -48,14 +48,13 @@ API 개발 | API 개발 | API 개발 | │  │  └─ 🐞-bug.md │  ├─ PULL_REQUEST_TEMPLATE.md │  └─ workflows -│     ├─ CD-dev.yml -│     ├─ CD-prod.yml -│     ├─ CI-dev.yml -│     └─ CI-prod.yml +│     ├─ api-cd-dev.yml +│     ├─ api-ci-dev.yml +│     ├─ notification-cd-dev.yml +│     └─ notification-ci-dev.yml ├─ .gitignore ├─ .gitmessage.txt ├─ README.md -├─ appspec.yml ├─ build.gradle ├─ docker-compose.yml ├─ gradle @@ -75,14 +74,121 @@ API 개발 | API 개발 | API 개발 | │        │           └─ api │        │              ├─ ApiApplication.java │        │              ├─ config +│        │              │  ├─ WebConfig.java +│        │              │  ├─ interceptor +│        │              │  │  ├─ admin +│        │              │  │  │  ├─ Admin.java +│        │              │  │  │  ├─ AdminCheckHandler.java +│        │              │  │  │  └─ AdminInterceptor.java +│        │              │  │  └─ auth +│        │              │  │     ├─ Auth.java +│        │              │  │     ├─ AuthInterceptor.java +│        │              │  │     └─ LoginCheckHandler.java +│        │              │  ├─ redis +│        │              │  │  └─ RedisConfig.java +│        │              │  ├─ resolver +│        │              │  │  ├─ MemberId.java +│        │              │  │  └─ MemberIdResolver.java +│        │              │  ├─ sqs +│        │              │  │  ├─ SqsConfig.java +│        │              │  │  └─ producer +│        │              │  │     └─ SqsProducer.java │        │              │  └─ swagger │        │              │     └─ SwaggerConfig.java -│        │              └─ controller -│        │                 └─ advice -│        │                    └─ ControllerAdvice.java +│        │              ├─ controller +│        │              │  ├─ advice +│        │              │  │  └─ ControllerAdvice.java +│        │              │  ├─ article +│        │              │  │  └─ ArticleRetrieveController.java +│        │              │  ├─ articlebookmark +│        │              │  │  ├─ ArticleBookmarkController.java +│        │              │  │  └─ ArticleBookmarkRetrieveController.java +│        │              │  ├─ auth +│        │              │  │  └─ AuthController.java +│        │              │  ├─ challenge +│        │              │  │  └─ ChallengeRetrieveController.java +│        │              │  ├─ curriculum +│        │              │  │  └─ CurriculumRetrieveController.java +│        │              │  ├─ member +│        │              │  │  ├─ MemberController.java +│        │              │  │  └─ MemberRetrieveController.java +│        │              │  └─ notification +│        │              │     ├─ NotificationController.java +│        │              │     └─ dto +│        │              │        └─ request +│        │              │           ├─ CustomNotificationRequest.java +│        │              │           └─ SlackNotificationRequest.java +│        │              └─ service +│        │                 ├─ article +│        │                 │  ├─ ArticleRetrieveService.java +│        │                 │  ├─ ArticleServiceUtils.java +│        │                 │  ├─ articleContent +│        │                 │  │  └─ ArticleContentServiceUtils.java +│        │                 │  ├─ articleTag +│        │                 │  │  └─ ArticleTagServiceUtils.java +│        │                 │  └─ dto +│        │                 │     └─ response +│        │                 │        ├─ ArticleBookmarkSummaryDto.java +│        │                 │        ├─ ArticleContentDto.java +│        │                 │        ├─ ArticleDetailResponse.java +│        │                 │        ├─ ArticleSummaryDto.java +│        │                 │        ├─ ArticleSummaryResponse.java +│        │                 │        ├─ TodayArticleResponse.java +│        │                 │        └─ WeekArticleSummaryResponse.java +│        │                 ├─ articlebookmark +│        │                 │  ├─ ArticleBookmarkRetrieveService.java +│        │                 │  ├─ ArticleBookmarkService.java +│        │                 │  ├─ ArticleBookmarkServiceUtils.java +│        │                 │  └─ dto +│        │                 │     ├─ request +│        │                 │     │  └─ UpdateArticleBookmarkRequest.java +│        │                 │     └─ response +│        │                 │        ├─ ArticleBookmarkResponse.java +│        │                 │        └─ ArticleSummaryDto.java +│        │                 ├─ auth +│        │                 │  ├─ AuthService.java +│        │                 │  ├─ AuthServiceProvider.java +│        │                 │  ├─ CommonAuthService.java +│        │                 │  ├─ CreateTokenService.java +│        │                 │  ├─ dto +│        │                 │  │  ├─ request +│        │                 │  │  │  ├─ LoginRequest.java +│        │                 │  │  │  ├─ SignUpRequest.java +│        │                 │  │  │  └─ TokenRequest.java +│        │                 │  │  └─ response +│        │                 │  │     └─ TokenResponse.java +│        │                 │  └─ impl +│        │                 │     └─ KakaoAuthService.java +│        │                 ├─ challenge +│        │                 │  ├─ ChallengeRetrieveService.java +│        │                 │  ├─ ChallengeService.java +│        │                 │  ├─ ChallengeServiceUtils.java +│        │                 │  └─ dto +│        │                 │     └─ response +│        │                 │        └─ ChallengeProgressResponse.java +│        │                 ├─ curriculum +│        │                 │  ├─ CurriculumRetrieveService.java +│        │                 │  └─ dto +│        │                 │     └─ response +│        │                 │        └─ CurriculumProgressResponse.java +│        │                 ├─ member +│        │                 │  ├─ MemberRetrieveService.java +│        │                 │  ├─ MemberService.java +│        │                 │  ├─ MemberServiceUtils.java +│        │                 │  └─ dto +│        │                 │     ├─ request +│        │                 │     │  └─ CreateMemberRequest.java +│        │                 │     └─ response +│        │                 │        └─ ProfileResponse.java +│        │                 └─ notification +│        │                    └─ NotificationService.java │        └─ resources +│           ├─ application-dev.yml │           ├─ application-local.yml │           ├─ application.yml +│           ├─ bootstrap.yml +│           ├─ messages +│           │  └─ validation.properties │           └─ sql │              ├─ data.sql │              └─ schema.sql @@ -91,20 +197,48 @@ API 개발 | API 개발 | API 개발 | │  └─ src │     └─ main │        └─ java -│           └─ com.chiwawa.lionheart.common -│              ├─ LionHeartCommonRoot.java -│              ├─ dto -│              │  └─ ApiResponse.java -│              └─ exception -│                 ├─ BadGatewayException.java -│                 ├─ ConflictException.java -│                 ├─ ErrorCode.java -│                 ├─ ForbiddenException.java -│                 ├─ InternalServerException.java -│                 ├─ LionHeartException.java -│                 ├─ NotFoundException.java -│                 ├─ UnAuthorizedException.java -│                 └─ ValidationException.java +│           └─ com +│              └─ chiwawa +│                 └─ lionheart +│                    └─ common +│                       ├─ LionHeartCommonRoot.java +│                       ├─ constant +│                       │  ├─ Constraint.java +│                       │  ├─ JwtKey.java +│                       │  ├─ MessageType.java +│                       │  ├─ ProfileType.java +│                       │  ├─ RedisKey.java +│                       │  └─ message +│                       │     ├─ ArticleBookmarkErrorMessage.java +│                       │     ├─ ArticleErrorMessage.java +│                       │     ├─ AuthErrorMessage.java +│                       │     ├─ CategoryErrorMessage.java +│                       │     ├─ ChallengeErrorMessage.java +│                       │     ├─ FirebaseErrorMessage.java +│                       │     └─ MemberErrorMessage.java +│                       ├─ dto +│                       │  ├─ ApiResponse.java +│                       │  ├─ WeekAndDay.java +│                       │  └─ sqs +│                       │     ├─ FirebaseDto.java +│                       │     ├─ MessageDto.java +│                       │     └─ SlackDto.java +│                       ├─ exception +│                       │  ├─ ErrorCode.java +│                       │  └─ model +│                       │     ├─ BadGatewayException.java +│                       │     ├─ ConflictException.java +│                       │     ├─ ForbiddenException.java +│                       │     ├─ InternalServerException.java +│                       │     ├─ LionHeartException.java +│                       │     ├─ NotFoundException.java +│                       │     ├─ UnAuthorizedException.java +│                       │     └─ ValidationException.java +│                       └─ util +│                          ├─ DateUtils.java +│                          ├─ JwtUtils.java +│                          ├─ MessageUtils.java +│                          └─ UuidUtils.java ├─ lionheart-domain │  ├─ build.gradle │  └─ src @@ -123,29 +257,59 @@ API 개발 | API 개발 | API 개발 | │                       └─ domain │                          ├─ article │                          │  ├─ Article.java -│                          │  ├─ ArticleCategory.java -│                          │  ├─ ArticleContent.java -│                          │  ├─ ArticleContentType.java -│                          │  ├─ ArticleImage.java -│                          │  └─ Category.java +│                          │  ├─ ArticleType.java +│                          │  ├─ Category.java +│                          │  ├─ articleContent +│                          │  │  ├─ ArticleContent.java +│                          │  │  └─ ArticleContentType.java +│                          │  ├─ articleTag +│                          │  │  └─ ArticleTag.java +│                          │  └─ repository +│                          │     ├─ ArticleRepository.java +│                          │     ├─ ArticleRepositoryCustom.java +│                          │     └─ ArticleRepositoryImpl.java │                          ├─ articlebookmark -│                          │  └─ ArticleBookmark.java +│                          │  ├─ ArticleBookmark.java +│                          │  └─ repository +│                          │     ├─ ArticleBookmarkRepository.java +│                          │     ├─ ArticleBookmarkRepositoryCustom.java +│                          │     └─ ArticleBookmarkRepositoryImpl.java │                          ├─ challenge │                          │  ├─ Attendance.java │                          │  ├─ Challenge.java │                          │  ├─ ChallengeLevelType.java -│                          │  └─ ChallengePopupType.java +│                          │  └─ repository +│                          │     ├─ AttendanceRepository.java +│                          │     ├─ AttendanceRepositoryCustom.java +│                          │     ├─ AttendanceRepositoryImpl.java +│                          │     ├─ ChallengeRepository.java +│                          │     ├─ ChallengeRepositoryCustom.java +│                          │     └─ ChallengeRepositoryImpl.java │                          ├─ common │                          │  └─ BaseEntity.java -│                          └─ member -│                             ├─ Member.java -│                             ├─ MemberSocialType.java -│                             ├─ Onboarding.java -│                             ├─ SocialInfo.java +│                          ├─ member +│                          │  ├─ Member.java +│                          │  ├─ MemberRole.java +│                          │  ├─ MemberSocialType.java +│                          │  ├─ NotificationStatus.java +│                          │  ├─ Onboarding.java +│                          │  ├─ Setting.java +│                          │  ├─ SocialInfo.java +│                          │  └─ repository +│                          │     ├─ MemberRepository.java +│                          │     ├─ MemberRepositoryCustom.java +│                          │     ├─ MemberRepositoryImpl.java +│                          │     ├─ OnboardingRepository.java +│                          │     ├─ OnboardingRepositoryCustom.java +│                          │     ├─ OnboardingRepositoryImpl.java +│                          │     ├─ SettingRepository.java +│                          │     └─ SettingRepositoryCustom.java +│                          └─ notification +│                             ├─ TodayArticleNotification.java │                             └─ repository -│                                ├─ MemberRepository.java -│                                ├─ MemberRepositoryCustom.java -│                                └─ MemberRepositoryImpl.java +│                                ├─ TodayArticleNotificationRepository.java +│                                ├─ TodayArticleNotificationRepositoryCustom.java +│                                └─ TodayArticleNotificationRepositoryImpl.java ├─ lionheart-external │  ├─ build.gradle │  └─ src @@ -155,11 +319,63 @@ API 개발 | API 개발 | API 개발 | │              └─ chiwawa │                 └─ lionheart │                    └─ external -│                       └─ LionHeartExternalRoot.java +│                       ├─ LionHeartExternalRoot.java +│                       ├─ client +│                       │  ├─ auth +│                       │  │  └─ kakao +│                       │  │     ├─ KakaoApiCaller.java +│                       │  │     ├─ WebClientKakaoCaller.java +│                       │  │     └─ dto +│                       │  │        └─ response +│                       │  │           └─ KakaoProfileResponse.java +│                       │  └─ firebase +│                       │     ├─ FirebaseApiCaller.java +│                       │     └─ WebClientFirebaseCaller.java +│                       └─ config +│                          └─ webclient +│                             └─ WebClientConfig.java +├─ lionheart-notification +│  ├─ build.gradle +│  └─ src +│     └─ main +│        ├─ java +│        │  └─ com +│        │     └─ chiwawa +│        │        └─ lionheart +│        │           └─ notification +│        │              ├─ NotificationApplication.java +│        │              ├─ config +│        │              │  ├─ scheduler +│        │              │  │  ├─ SchedulerConfig.java +│        │              │  │  └─ SchedulerErrorHandler.java +│        │              │  └─ sqs +│        │              │     ├─ SqsConfig.java +│        │              │     └─ consumer +│        │              │        └─ SqsConsumer.java +│        │              └─ service +│        │                 ├─ firebase +│        │                 │  ├─ FirebaseCloudMessageService.java +│        │                 │  └─ dto +│        │                 │     └─ request +│        │                 │        └─ FcmMessageRequest.java +│        │                 ├─ scheduler +│        │                 │  └─ SchedulerService.java +│        │                 └─ slack +│        │                    └─ SlackMessageService.java +│        └─ resources +│           ├─ application-dev.yml +│           ├─ application-local.yml +│           ├─ application.yml +│           └─ bootstrap.yml ├─ naver-intellij-formatter.xml ├─ scripts -│  ├─ deploy.sh -│  └─ switch.sh +│  ├─ lionheart-api +│  │  ├─ appspec.yml +│  │  ├─ health_check.sh +│  │  ├─ run_new_was.sh +│  │  └─ switch.sh +│  └─ lionheart-notification +│     ├─ appspec.yml +│     └─ deploy.sh └─ settings.gradle ``` - diff --git a/lionheart-api/src/main/java/com/chiwawa/lionheart/api/config/interceptor/admin/AdminCheckHandler.java b/lionheart-api/src/main/java/com/chiwawa/lionheart/api/config/interceptor/admin/AdminCheckHandler.java index 0594b58..c5ef9b8 100644 --- a/lionheart-api/src/main/java/com/chiwawa/lionheart/api/config/interceptor/admin/AdminCheckHandler.java +++ b/lionheart-api/src/main/java/com/chiwawa/lionheart/api/config/interceptor/admin/AdminCheckHandler.java @@ -24,13 +24,11 @@ public class AdminCheckHandler { private final JwtUtils jwtUtils; private final MemberRepository memberRepository; - public void validateMemberRole(HttpServletRequest request) { + public boolean hasRole(HttpServletRequest request) { String bearerToken = request.getHeader("Authorization"); if (StringUtils.hasText(bearerToken) && bearerToken.startsWith("Bearer ")) { String accessToken = bearerToken.substring("Bearer ".length()); - if (hasAdminAuthority(accessToken)) { - return; - } + return hasAdminAuthority(accessToken); } throw new ForbiddenException(ADMIN_ERROR_MESSAGE, FORBIDDEN_ADMIN_EXCEPTION); } diff --git a/lionheart-api/src/main/java/com/chiwawa/lionheart/api/config/interceptor/admin/AdminInterceptor.java b/lionheart-api/src/main/java/com/chiwawa/lionheart/api/config/interceptor/admin/AdminInterceptor.java index c699f63..d80b14c 100644 --- a/lionheart-api/src/main/java/com/chiwawa/lionheart/api/config/interceptor/admin/AdminInterceptor.java +++ b/lionheart-api/src/main/java/com/chiwawa/lionheart/api/config/interceptor/admin/AdminInterceptor.java @@ -27,7 +27,7 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons if (admin.isEmpty()) { return true; } - adminCheckHandler.validateMemberRole(request); - return true; + + return adminCheckHandler.hasRole(request); } } \ No newline at end of file diff --git a/lionheart-common/src/main/resources/logback-spring.xml b/lionheart-common/src/main/resources/logback-spring.xml new file mode 100644 index 0000000..9ebf1ce --- /dev/null +++ b/lionheart-common/src/main/resources/logback-spring.xml @@ -0,0 +1,69 @@ + + + + + + + + + + ${CONSOLE_LOG_PATTERN} + + + + + + ${FILE_LOG_PATTERN} + + + /home/ubuntu/api-server/logs/%d{yyyy-MM-dd}.%i.log + 100MB + 30 + + + + + + ${FILE_LOG_PATTERN} + + + /home/ubuntu/notification-server/logs/%d{yyyy-MM-dd}.%i.log + 100MB + 30 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +