diff --git a/Briefing-Api/build.gradle b/Briefing-Api/build.gradle new file mode 100644 index 0000000..19e57e8 --- /dev/null +++ b/Briefing-Api/build.gradle @@ -0,0 +1,60 @@ + +tasks.named('bootJar') { //빌드할 때 bootjar 파일로 하겠다는 의미 + enabled = true +} + +tasks.named('jar') { //빌드할 때 jar 파일로 하겠다는 의미 + enabled = false +} + +dependencies { + + implementation project(':core:Briefing-Common') + implementation project(':core:Briefing-Infra') + implementation 'org.springframework.boot:spring-boot-starter-data-jpa' + // querydsl + // == 스프링 부트 3.0 이상 == + implementation 'com.querydsl:querydsl-jpa:5.0.0:jakarta' + annotationProcessor "com.querydsl:querydsl-apt:${dependencyManagement.importedProperties['querydsl.version']}:jakarta" + annotationProcessor "jakarta.annotation:jakarta.annotation-api" + annotationProcessor "jakarta.persistence:jakarta.persistence-api" + + implementation 'org.springframework.boot:spring-boot-starter-validation' + implementation 'org.springframework.boot:spring-boot-starter-web' + implementation 'org.springframework.boot:spring-boot-starter-data-redis:2.3.1.RELEASE' + implementation 'org.springframework.boot:spring-boot-starter-security' + + implementation 'io.springfox:springfox-swagger2:2.9.2' + implementation 'io.springfox:springfox-swagger-ui:2.9.2' + implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.2' + implementation 'org.springframework.cloud:spring-cloud-starter-openfeign' + implementation 'com.googlecode.json-simple:json-simple:1.1.1' + implementation 'mysql:mysql-connector-java' // 추가 작성 + + implementation platform("org.springframework.cloud:spring-cloud-dependencies:2022.0.3") + compileOnly 'org.projectlombok:lombok' + runtimeOnly 'com.h2database:h2' +// runtimeOnly 'org.postgresql:postgresql' +// runtimeOnly 'com.mysql:mysql-connector-j' + + // jwt 의존성 + runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.11.5' + runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.11.5' + implementation 'io.jsonwebtoken:jjwt-api:0.11.5' + annotationProcessor 'org.projectlombok:lombok' + testImplementation 'org.springframework.boot:spring-boot-starter-test' + + // fcm 의존성 + implementation 'com.google.firebase:firebase-admin:9.1.1' + + //spring batch 의존성 + implementation 'org.springframework.boot:spring-boot-starter-batch' +} + +tasks.named('test') { + useJUnitPlatform() +} + +tasks.named('test') { + useJUnitPlatform() +} diff --git a/Briefing-Api/gradle/wrapper/gradle-wrapper.jar b/Briefing-Api/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..d64cd49 Binary files /dev/null and b/Briefing-Api/gradle/wrapper/gradle-wrapper.jar differ diff --git a/Briefing-Api/gradle/wrapper/gradle-wrapper.properties b/Briefing-Api/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..1af9e09 --- /dev/null +++ b/Briefing-Api/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/Briefing-Api/src/main/java/com/example/briefingapi/BriefingApiApplication.java b/Briefing-Api/src/main/java/com/example/briefingapi/BriefingApiApplication.java new file mode 100644 index 0000000..b4c9fe0 --- /dev/null +++ b/Briefing-Api/src/main/java/com/example/briefingapi/BriefingApiApplication.java @@ -0,0 +1,34 @@ +package com.example.briefingapi; + +import io.swagger.v3.oas.annotations.OpenAPIDefinition; +import io.swagger.v3.oas.annotations.servers.Server; +import lombok.RequiredArgsConstructor; +import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.ImportAutoConfiguration; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cache.annotation.EnableCaching; +import org.springframework.cloud.openfeign.EnableFeignClients; +import org.springframework.cloud.openfeign.FeignAutoConfiguration; +import org.springframework.data.redis.repository.configuration.EnableRedisRepositories; + + +@OpenAPIDefinition( + servers = { + @Server(url = "http://localhost:8080", description = "local server"), + @Server(url = "https://dev.briefing.store", description = "dev server"), + @Server(url = "https://api.newsbreifing.store", description = "release server") + }) +@SpringBootApplication(scanBasePackages = {"com.example.briefingapi","com.example.briefingcommon","com.example.briefinginfra"}) +@RequiredArgsConstructor +@EnableCaching +@EnableFeignClients(basePackages = "com.example.briefinginfra") +@EnableRedisRepositories +@ImportAutoConfiguration({FeignAutoConfiguration.class}) +public class BriefingApiApplication { + + public static void main(String[] args) { + SpringApplication.run(BriefingApiApplication.class, args); + } + +} diff --git a/src/main/java/briefing/common/aop/annotation/CacheEvictByBriefingId.java b/Briefing-Api/src/main/java/com/example/briefingapi/aop/annotation/CacheEvictByBriefingId.java similarity index 88% rename from src/main/java/briefing/common/aop/annotation/CacheEvictByBriefingId.java rename to Briefing-Api/src/main/java/com/example/briefingapi/aop/annotation/CacheEvictByBriefingId.java index 22d7db4..2229df6 100644 --- a/src/main/java/briefing/common/aop/annotation/CacheEvictByBriefingId.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/aop/annotation/CacheEvictByBriefingId.java @@ -1,4 +1,4 @@ -package briefing.common.aop.annotation; +package com.example.briefingapi.aop.annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/src/main/java/briefing/common/aop/aspect/CacheEvictByBriefingIdAspect.java b/Briefing-Api/src/main/java/com/example/briefingapi/aop/aspect/CacheEvictByBriefingIdAspect.java similarity index 91% rename from src/main/java/briefing/common/aop/aspect/CacheEvictByBriefingIdAspect.java rename to Briefing-Api/src/main/java/com/example/briefingapi/aop/aspect/CacheEvictByBriefingIdAspect.java index e76350d..73624af 100644 --- a/src/main/java/briefing/common/aop/aspect/CacheEvictByBriefingIdAspect.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/aop/aspect/CacheEvictByBriefingIdAspect.java @@ -1,7 +1,10 @@ -package briefing.common.aop.aspect; +package com.example.briefingapi.aop.aspect; import java.util.Optional; +import com.example.briefingapi.aop.annotation.CacheEvictByBriefingId; +import com.example.briefingcommon.domain.repository.article.BriefingRepository; +import com.example.briefingcommon.entity.Briefing; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.annotation.After; import org.aspectj.lang.annotation.Aspect; @@ -13,9 +16,7 @@ import org.springframework.expression.spel.support.StandardEvaluationContext; import org.springframework.stereotype.Component; -import briefing.briefing.domain.Briefing; -import briefing.briefing.domain.repository.BriefingRepository; -import briefing.common.aop.annotation.CacheEvictByBriefingId; + import lombok.RequiredArgsConstructor; @Aspect diff --git a/Briefing-Api/src/main/java/com/example/briefingapi/batch/job/DailyPushJobConfig.java b/Briefing-Api/src/main/java/com/example/briefingapi/batch/job/DailyPushJobConfig.java new file mode 100644 index 0000000..c28f86f --- /dev/null +++ b/Briefing-Api/src/main/java/com/example/briefingapi/batch/job/DailyPushJobConfig.java @@ -0,0 +1,49 @@ +package com.example.briefingapi.batch.job; + +import com.example.briefingapi.fcm.implementation.FcmCommandService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.batch.core.Job; +import org.springframework.batch.core.Step; +import org.springframework.batch.core.job.builder.JobBuilder; +import org.springframework.batch.core.repository.JobRepository; +import org.springframework.batch.core.step.builder.StepBuilder; +import org.springframework.batch.core.step.tasklet.Tasklet; +import org.springframework.batch.repeat.RepeatStatus; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.transaction.PlatformTransactionManager; + +@Slf4j +@Configuration +@RequiredArgsConstructor +public class DailyPushJobConfig { + + private final FcmCommandService fcmCommandService; + + @Value("${fcm.topic.daily-push}") + private String dailyPushTopic; + + @Bean + public Job dailyPushJob(JobRepository jobRepository, Step simpleStep1) { + return new JobBuilder("daily Push", jobRepository) + .start(simpleStep1) + .build(); + } + + @Bean + public Step dailyPushStep(JobRepository jobRepository, Tasklet testTasklet, PlatformTransactionManager platformTransactionManager){ + return new StepBuilder("dailyPushStep", jobRepository) + .tasklet(testTasklet, platformTransactionManager).build(); + } + @Bean + public Tasklet dailyPushTasklet(){ + return ((contribution, chunkContext) -> { + log.info("request FCM!!"); + fcmCommandService.sendMessage(dailyPushTopic); + return RepeatStatus.FINISHED; + }); + } +} + diff --git a/Briefing-Api/src/main/java/com/example/briefingapi/batch/scheduler/DailyPush.java b/Briefing-Api/src/main/java/com/example/briefingapi/batch/scheduler/DailyPush.java new file mode 100644 index 0000000..e529904 --- /dev/null +++ b/Briefing-Api/src/main/java/com/example/briefingapi/batch/scheduler/DailyPush.java @@ -0,0 +1,39 @@ +package com.example.briefingapi.batch.scheduler; + +import com.example.briefingapi.fcm.implementation.FcmCommandService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.batch.core.Job; +import org.springframework.batch.core.JobExecutionException; +import org.springframework.batch.core.JobParameters; +import org.springframework.batch.core.JobParametersBuilder; +import org.springframework.batch.core.launch.JobLauncher; +import org.springframework.scheduling.annotation.EnableScheduling; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +@Slf4j +@Component +@RequiredArgsConstructor +@EnableScheduling +public class DailyPush { + + private final JobLauncher jobLauncher; + + private final Job job; + + // 초 분 시 일 월 요일 + @Scheduled(cron = "0 0 8,17 * * *") + public void requestDailyTopicFcmJob(){ + log.info("daily alarm launched"); + try { + JobParameters jobParameters = new JobParametersBuilder() + .addLong("executedTime", System.currentTimeMillis()) + .toJobParameters(); + + jobLauncher.run(job, jobParameters); + } catch (JobExecutionException e) { + log.error("SeatReleaseScheduler error : ", e); + } + } +} diff --git a/src/main/java/briefing/briefing/business/BriefingConverter.java b/Briefing-Api/src/main/java/com/example/briefingapi/briefing/business/BriefingConverter.java similarity index 95% rename from src/main/java/briefing/briefing/business/BriefingConverter.java rename to Briefing-Api/src/main/java/com/example/briefingapi/briefing/business/BriefingConverter.java index 0b95a97..7ce474e 100644 --- a/src/main/java/briefing/briefing/business/BriefingConverter.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/briefing/business/BriefingConverter.java @@ -1,14 +1,14 @@ -package briefing.briefing.business; +package com.example.briefingapi.briefing.business; import java.time.LocalDate; import java.time.LocalDateTime; import java.util.List; -import briefing.briefing.domain.Article; -import briefing.briefing.domain.Briefing; -import briefing.briefing.presentation.dto.BriefingRequestDTO; -import briefing.briefing.presentation.dto.BriefingResponseDTO; -import briefing.common.enums.BriefingType; +import com.example.briefingapi.briefing.presentation.dto.BriefingRequestDTO; +import com.example.briefingapi.briefing.presentation.dto.BriefingResponseDTO; +import com.example.briefingcommon.entity.Article; +import com.example.briefingcommon.entity.Briefing; +import com.example.briefingcommon.entity.enums.BriefingType; public class BriefingConverter { diff --git a/src/main/java/briefing/briefing/business/BriefingFacade.java b/Briefing-Api/src/main/java/com/example/briefingapi/briefing/business/BriefingFacade.java similarity index 75% rename from src/main/java/briefing/briefing/business/BriefingFacade.java rename to Briefing-Api/src/main/java/com/example/briefingapi/briefing/business/BriefingFacade.java index 87a7e87..7506647 100644 --- a/src/main/java/briefing/briefing/business/BriefingFacade.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/briefing/business/BriefingFacade.java @@ -1,24 +1,25 @@ -package briefing.briefing.business; +package com.example.briefingapi.briefing.business; import java.util.List; import java.util.Optional; +import com.example.briefingapi.briefing.implement.service.ArticleCommandService; +import com.example.briefingapi.briefing.implement.service.BriefingArticleCommandService; +import com.example.briefingapi.briefing.implement.service.BriefingCommandService; +import com.example.briefingapi.briefing.implement.service.BriefingQueryService; +import com.example.briefingapi.briefing.presentation.dto.BriefingRequestDTO; +import com.example.briefingapi.briefing.presentation.dto.BriefingRequestParam; +import com.example.briefingapi.briefing.presentation.dto.BriefingResponseDTO; +import com.example.briefingapi.scrap.implement.ScrapQueryService; +import com.example.briefingcommon.entity.Article; +import com.example.briefingcommon.entity.Briefing; +import com.example.briefingcommon.entity.BriefingArticle; +import com.example.briefingcommon.entity.Member; +import com.example.briefingcommon.entity.enums.APIVersion; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; -import briefing.briefing.domain.Article; -import briefing.briefing.domain.Briefing; -import briefing.briefing.domain.BriefingArticle; -import briefing.briefing.implement.service.ArticleCommandService; -import briefing.briefing.implement.service.BriefingArticleCommandService; -import briefing.briefing.implement.service.BriefingCommandService; -import briefing.briefing.implement.service.BriefingQueryService; -import briefing.briefing.presentation.dto.BriefingRequestDTO; -import briefing.briefing.presentation.dto.BriefingRequestParam; -import briefing.briefing.presentation.dto.BriefingResponseDTO; -import briefing.common.enums.APIVersion; -import briefing.member.domain.Member; -import briefing.scrap.implement.ScrapQueryService; + import lombok.RequiredArgsConstructor; @Component diff --git a/src/main/java/briefing/briefing/business/BriefingV2Facade.java b/Briefing-Api/src/main/java/com/example/briefingapi/briefing/business/BriefingV2Facade.java similarity index 73% rename from src/main/java/briefing/briefing/business/BriefingV2Facade.java rename to Briefing-Api/src/main/java/com/example/briefingapi/briefing/business/BriefingV2Facade.java index 8bf5957..af41716 100644 --- a/src/main/java/briefing/briefing/business/BriefingV2Facade.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/briefing/business/BriefingV2Facade.java @@ -1,18 +1,18 @@ -package briefing.briefing.business; +package com.example.briefingapi.briefing.business; import java.util.List; import java.util.Optional; +import com.example.briefingapi.briefing.implement.service.BriefingQueryService; +import com.example.briefingapi.briefing.presentation.dto.BriefingRequestParam; +import com.example.briefingapi.briefing.presentation.dto.BriefingResponseDTO; +import com.example.briefingapi.scrap.implement.ScrapQueryService; +import com.example.briefingcommon.entity.Briefing; +import com.example.briefingcommon.entity.Member; +import com.example.briefingcommon.entity.enums.APIVersion; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; -import briefing.briefing.domain.Briefing; -import briefing.briefing.implement.service.BriefingQueryService; -import briefing.briefing.presentation.dto.BriefingRequestParam; -import briefing.briefing.presentation.dto.BriefingResponseDTO; -import briefing.common.enums.APIVersion; -import briefing.member.domain.Member; -import briefing.scrap.implement.ScrapQueryService; import lombok.RequiredArgsConstructor; @Component diff --git a/src/main/java/briefing/briefing/implement/context/BriefingQueryContext.java b/Briefing-Api/src/main/java/com/example/briefingapi/briefing/implement/context/BriefingQueryContext.java similarity index 64% rename from src/main/java/briefing/briefing/implement/context/BriefingQueryContext.java rename to Briefing-Api/src/main/java/com/example/briefingapi/briefing/implement/context/BriefingQueryContext.java index d9ab7fc..3690294 100644 --- a/src/main/java/briefing/briefing/implement/context/BriefingQueryContext.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/briefing/implement/context/BriefingQueryContext.java @@ -1,11 +1,13 @@ -package briefing.briefing.implement.context; +package com.example.briefingapi.briefing.implement.context; import java.util.List; import java.util.Optional; -import briefing.briefing.domain.Briefing; -import briefing.briefing.implement.strategy.BriefingQueryStrategy; -import briefing.briefing.presentation.dto.BriefingRequestParam; + + +import com.example.briefingapi.briefing.implement.strategy.BriefingQueryStrategy; +import com.example.briefingapi.briefing.presentation.dto.BriefingRequestParam; +import com.example.briefingcommon.entity.Briefing; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor diff --git a/src/main/java/briefing/briefing/implement/context/BriefingQueryContextFactory.java b/Briefing-Api/src/main/java/com/example/briefingapi/briefing/implement/context/BriefingQueryContextFactory.java similarity index 82% rename from src/main/java/briefing/briefing/implement/context/BriefingQueryContextFactory.java rename to Briefing-Api/src/main/java/com/example/briefingapi/briefing/implement/context/BriefingQueryContextFactory.java index c2c7934..8f393a1 100644 --- a/src/main/java/briefing/briefing/implement/context/BriefingQueryContextFactory.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/briefing/implement/context/BriefingQueryContextFactory.java @@ -1,14 +1,14 @@ -package briefing.briefing.implement.context; +package com.example.briefingapi.briefing.implement.context; import java.util.EnumMap; import java.util.List; import java.util.Map; +import com.example.briefingapi.briefing.implement.strategy.BriefingQueryStrategy; +import com.example.briefingcommon.entity.enums.APIVersion; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import briefing.briefing.implement.strategy.BriefingQueryStrategy; -import briefing.common.enums.APIVersion; @Component public class BriefingQueryContextFactory { diff --git a/src/main/java/briefing/briefing/implement/service/ArticleCommandService.java b/Briefing-Api/src/main/java/com/example/briefingapi/briefing/implement/service/ArticleCommandService.java similarity index 65% rename from src/main/java/briefing/briefing/implement/service/ArticleCommandService.java rename to Briefing-Api/src/main/java/com/example/briefingapi/briefing/implement/service/ArticleCommandService.java index e413d4b..810ba1d 100644 --- a/src/main/java/briefing/briefing/implement/service/ArticleCommandService.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/briefing/implement/service/ArticleCommandService.java @@ -1,11 +1,12 @@ -package briefing.briefing.implement.service; +package com.example.briefingapi.briefing.implement.service; import java.util.List; +import com.example.briefingcommon.domain.repository.article.ArticleRepository; +import com.example.briefingcommon.entity.Article; import org.springframework.stereotype.Service; -import briefing.briefing.domain.Article; -import briefing.briefing.domain.repository.ArticleRepository; + import lombok.RequiredArgsConstructor; @Service diff --git a/src/main/java/briefing/briefing/implement/service/BriefingArticleCommandService.java b/Briefing-Api/src/main/java/com/example/briefingapi/briefing/implement/service/BriefingArticleCommandService.java similarity index 67% rename from src/main/java/briefing/briefing/implement/service/BriefingArticleCommandService.java rename to Briefing-Api/src/main/java/com/example/briefingapi/briefing/implement/service/BriefingArticleCommandService.java index 1366b06..20e3686 100644 --- a/src/main/java/briefing/briefing/implement/service/BriefingArticleCommandService.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/briefing/implement/service/BriefingArticleCommandService.java @@ -1,11 +1,12 @@ -package briefing.briefing.implement.service; +package com.example.briefingapi.briefing.implement.service; import java.util.List; +import com.example.briefingcommon.domain.repository.article.BriefingArticleRepository; +import com.example.briefingcommon.entity.BriefingArticle; import org.springframework.stereotype.Service; -import briefing.briefing.domain.BriefingArticle; -import briefing.briefing.domain.repository.BriefingArticleRepository; + import lombok.RequiredArgsConstructor; @Service diff --git a/src/main/java/briefing/briefing/implement/service/BriefingCommandService.java b/Briefing-Api/src/main/java/com/example/briefingapi/briefing/implement/service/BriefingCommandService.java similarity index 74% rename from src/main/java/briefing/briefing/implement/service/BriefingCommandService.java rename to Briefing-Api/src/main/java/com/example/briefingapi/briefing/implement/service/BriefingCommandService.java index e3af12a..c61d1f6 100644 --- a/src/main/java/briefing/briefing/implement/service/BriefingCommandService.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/briefing/implement/service/BriefingCommandService.java @@ -1,9 +1,9 @@ -package briefing.briefing.implement.service; +package com.example.briefingapi.briefing.implement.service; +import com.example.briefingcommon.domain.repository.article.BriefingRepository; +import com.example.briefingcommon.entity.Briefing; import org.springframework.stereotype.Service; -import briefing.briefing.domain.Briefing; -import briefing.briefing.domain.repository.BriefingRepository; import lombok.RequiredArgsConstructor; @Service diff --git a/src/main/java/briefing/briefing/implement/service/BriefingQueryService.java b/Briefing-Api/src/main/java/com/example/briefingapi/briefing/implement/service/BriefingQueryService.java similarity index 63% rename from src/main/java/briefing/briefing/implement/service/BriefingQueryService.java rename to Briefing-Api/src/main/java/com/example/briefingapi/briefing/implement/service/BriefingQueryService.java index f4737a6..201903b 100644 --- a/src/main/java/briefing/briefing/implement/service/BriefingQueryService.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/briefing/implement/service/BriefingQueryService.java @@ -1,16 +1,15 @@ -package briefing.briefing.implement.service; +package com.example.briefingapi.briefing.implement.service; import java.util.List; +import com.example.briefingapi.briefing.implement.context.BriefingQueryContext; +import com.example.briefingapi.briefing.implement.context.BriefingQueryContextFactory; +import com.example.briefingapi.briefing.presentation.dto.BriefingRequestParam; +import com.example.briefingcommon.common.exception.BriefingException; +import com.example.briefingcommon.common.exception.common.ErrorCode; +import com.example.briefingcommon.entity.Briefing; +import com.example.briefingcommon.entity.enums.APIVersion; import org.springframework.stereotype.Service; - -import briefing.briefing.domain.Briefing; -import briefing.briefing.exception.BriefingException; -import briefing.briefing.implement.context.BriefingQueryContext; -import briefing.briefing.implement.context.BriefingQueryContextFactory; -import briefing.briefing.presentation.dto.BriefingRequestParam; -import briefing.common.enums.APIVersion; -import briefing.common.exception.common.ErrorCode; import lombok.RequiredArgsConstructor; @Service diff --git a/src/main/java/briefing/briefing/implement/strategy/BriefingQueryStrategy.java b/Briefing-Api/src/main/java/com/example/briefingapi/briefing/implement/strategy/BriefingQueryStrategy.java similarity index 50% rename from src/main/java/briefing/briefing/implement/strategy/BriefingQueryStrategy.java rename to Briefing-Api/src/main/java/com/example/briefingapi/briefing/implement/strategy/BriefingQueryStrategy.java index a325dfa..c2d73bb 100644 --- a/src/main/java/briefing/briefing/implement/strategy/BriefingQueryStrategy.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/briefing/implement/strategy/BriefingQueryStrategy.java @@ -1,11 +1,12 @@ -package briefing.briefing.implement.strategy; +package com.example.briefingapi.briefing.implement.strategy; import java.util.List; import java.util.Optional; -import briefing.briefing.domain.Briefing; -import briefing.briefing.presentation.dto.BriefingRequestParam; -import briefing.common.enums.APIVersion; + +import com.example.briefingapi.briefing.presentation.dto.BriefingRequestParam; +import com.example.briefingcommon.entity.Briefing; +import com.example.briefingcommon.entity.enums.APIVersion; public interface BriefingQueryStrategy { List findBriefings(BriefingRequestParam.BriefingPreviewListParam params); diff --git a/src/main/java/briefing/briefing/implement/strategy/BriefingV1QueryStrategy.java b/Briefing-Api/src/main/java/com/example/briefingapi/briefing/implement/strategy/BriefingV1QueryStrategy.java similarity index 69% rename from src/main/java/briefing/briefing/implement/strategy/BriefingV1QueryStrategy.java rename to Briefing-Api/src/main/java/com/example/briefingapi/briefing/implement/strategy/BriefingV1QueryStrategy.java index 04b79eb..86a8433 100644 --- a/src/main/java/briefing/briefing/implement/strategy/BriefingV1QueryStrategy.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/briefing/implement/strategy/BriefingV1QueryStrategy.java @@ -1,17 +1,19 @@ -package briefing.briefing.implement.strategy; +package com.example.briefingapi.briefing.implement.strategy; import java.time.LocalDateTime; import java.time.LocalTime; import java.util.List; import java.util.Optional; +import com.example.briefingcommon.domain.repository.article.BriefingRepository; +import com.example.briefingapi.briefing.presentation.dto.BriefingRequestParam; +import com.example.briefingcommon.entity.Briefing; +import com.example.briefingcommon.entity.enums.APIVersion; +import com.example.briefingcommon.entity.enums.BriefingType; import org.springframework.stereotype.Component; -import briefing.briefing.domain.Briefing; -import briefing.briefing.domain.repository.BriefingRepository; -import briefing.briefing.presentation.dto.BriefingRequestParam; -import briefing.common.enums.APIVersion; -import briefing.common.enums.BriefingType; + + import lombok.RequiredArgsConstructor; @Component @@ -29,8 +31,7 @@ public List findBriefings(BriefingRequestParam.BriefingPreviewListPara briefingRepository.findAllByTypeAndCreatedAtBetweenOrderByRanks( params.getType(), startDateTime, endDateTime); if (briefingList.isEmpty()) { - briefingList = - briefingRepository.findTop10ByTypeOrderByCreatedAtDesc(BriefingType.SOCIAL); + briefingList = briefingRepository.findTop10ByTypeOrderByCreatedAtDesc(BriefingType.SOCIAL); } return briefingList; } diff --git a/src/main/java/briefing/briefing/implement/strategy/BriefingV2QueryStrategy.java b/Briefing-Api/src/main/java/com/example/briefingapi/briefing/implement/strategy/BriefingV2QueryStrategy.java similarity index 80% rename from src/main/java/briefing/briefing/implement/strategy/BriefingV2QueryStrategy.java rename to Briefing-Api/src/main/java/com/example/briefingapi/briefing/implement/strategy/BriefingV2QueryStrategy.java index 9ccf3c4..c69a3a5 100644 --- a/src/main/java/briefing/briefing/implement/strategy/BriefingV2QueryStrategy.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/briefing/implement/strategy/BriefingV2QueryStrategy.java @@ -1,16 +1,17 @@ -package briefing.briefing.implement.strategy; +package com.example.briefingapi.briefing.implement.strategy; import java.time.LocalDateTime; import java.time.LocalTime; import java.util.List; import java.util.Optional; +import com.example.briefingcommon.domain.repository.article.BriefingRepository; +import com.example.briefingapi.briefing.presentation.dto.BriefingRequestParam; +import com.example.briefingcommon.entity.Briefing; +import com.example.briefingcommon.entity.enums.APIVersion; import org.springframework.stereotype.Component; -import briefing.briefing.domain.Briefing; -import briefing.briefing.domain.repository.BriefingRepository; -import briefing.briefing.presentation.dto.BriefingRequestParam; -import briefing.common.enums.APIVersion; + import lombok.RequiredArgsConstructor; @Component diff --git a/src/main/java/briefing/briefing/presentation/BriefingApi.java b/Briefing-Api/src/main/java/com/example/briefingapi/briefing/presentation/BriefingApi.java similarity index 82% rename from src/main/java/briefing/briefing/presentation/BriefingApi.java rename to Briefing-Api/src/main/java/com/example/briefingapi/briefing/presentation/BriefingApi.java index 02d46c7..dedd814 100644 --- a/src/main/java/briefing/briefing/presentation/BriefingApi.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/briefing/presentation/BriefingApi.java @@ -1,5 +1,12 @@ -package briefing.briefing.presentation; +package com.example.briefingapi.briefing.presentation; +import com.example.briefingapi.briefing.business.BriefingFacade; +import com.example.briefingapi.briefing.presentation.dto.BriefingRequestDTO; +import com.example.briefingapi.briefing.presentation.dto.BriefingRequestParam; +import com.example.briefingapi.briefing.presentation.dto.BriefingResponseDTO; +import com.example.briefingapi.security.handler.annotation.AuthMember; +import com.example.briefingcommon.common.presentation.response.CommonResponse; +import com.example.briefingcommon.entity.Member; import jakarta.validation.Valid; import org.springdoc.core.annotations.ParameterObject; @@ -7,14 +14,8 @@ import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.*; -import briefing.briefing.business.BriefingFacade; -import briefing.briefing.presentation.dto.BriefingRequestDTO; -import briefing.briefing.presentation.dto.BriefingRequestParam; -import briefing.briefing.presentation.dto.BriefingResponseDTO; -import briefing.common.aop.annotation.CacheEvictByBriefingId; -import briefing.common.presentation.response.CommonResponse; -import briefing.member.domain.Member; -import briefing.security.handler.annotation.AuthMember; + +import com.example.briefingapi.aop.annotation.CacheEvictByBriefingId; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; diff --git a/src/main/java/briefing/briefing/presentation/BriefingV2Api.java b/Briefing-Api/src/main/java/com/example/briefingapi/briefing/presentation/BriefingV2Api.java similarity index 75% rename from src/main/java/briefing/briefing/presentation/BriefingV2Api.java rename to Briefing-Api/src/main/java/com/example/briefingapi/briefing/presentation/BriefingV2Api.java index 7e01ccf..ffed107 100644 --- a/src/main/java/briefing/briefing/presentation/BriefingV2Api.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/briefing/presentation/BriefingV2Api.java @@ -1,15 +1,15 @@ -package briefing.briefing.presentation; +package com.example.briefingapi.briefing.presentation; +import com.example.briefingapi.briefing.business.BriefingV2Facade; +import com.example.briefingapi.briefing.presentation.dto.BriefingRequestParam; +import com.example.briefingapi.briefing.presentation.dto.BriefingResponseDTO; +import com.example.briefingapi.security.handler.annotation.AuthMember; +import com.example.briefingcommon.common.presentation.response.CommonResponse; +import com.example.briefingcommon.entity.Member; import org.springdoc.core.annotations.ParameterObject; import org.springframework.cache.annotation.Cacheable; import org.springframework.web.bind.annotation.*; -import briefing.briefing.business.BriefingV2Facade; -import briefing.briefing.presentation.dto.BriefingRequestParam; -import briefing.briefing.presentation.dto.BriefingResponseDTO; -import briefing.common.presentation.response.CommonResponse; -import briefing.member.domain.Member; -import briefing.security.handler.annotation.AuthMember; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; diff --git a/src/main/java/briefing/briefing/presentation/dto/BriefingRequestDTO.java b/Briefing-Api/src/main/java/com/example/briefingapi/briefing/presentation/dto/BriefingRequestDTO.java similarity index 78% rename from src/main/java/briefing/briefing/presentation/dto/BriefingRequestDTO.java rename to Briefing-Api/src/main/java/com/example/briefingapi/briefing/presentation/dto/BriefingRequestDTO.java index 2a0ebbb..c8068db 100644 --- a/src/main/java/briefing/briefing/presentation/dto/BriefingRequestDTO.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/briefing/presentation/dto/BriefingRequestDTO.java @@ -1,12 +1,13 @@ -package briefing.briefing.presentation.dto; +package com.example.briefingapi.briefing.presentation.dto; import java.util.List; +import com.example.briefingcommon.entity.enums.BriefingType; +import com.example.briefingcommon.entity.enums.GptModel; +import com.example.briefingcommon.entity.enums.TimeOfDay; import com.fasterxml.jackson.annotation.JsonProperty; -import briefing.common.enums.BriefingType; -import briefing.common.enums.GptModel; -import briefing.common.enums.TimeOfDay; + import lombok.Getter; public class BriefingRequestDTO { diff --git a/src/main/java/briefing/briefing/presentation/dto/BriefingRequestParam.java b/Briefing-Api/src/main/java/com/example/briefingapi/briefing/presentation/dto/BriefingRequestParam.java similarity index 75% rename from src/main/java/briefing/briefing/presentation/dto/BriefingRequestParam.java rename to Briefing-Api/src/main/java/com/example/briefingapi/briefing/presentation/dto/BriefingRequestParam.java index a2def3f..9b4b7b8 100644 --- a/src/main/java/briefing/briefing/presentation/dto/BriefingRequestParam.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/briefing/presentation/dto/BriefingRequestParam.java @@ -1,11 +1,11 @@ -package briefing.briefing.presentation.dto; +package com.example.briefingapi.briefing.presentation.dto; import java.time.LocalDate; +import com.example.briefingcommon.entity.enums.BriefingType; +import com.example.briefingcommon.entity.enums.TimeOfDay; import jakarta.validation.constraints.NotNull; -import briefing.common.enums.BriefingType; -import briefing.common.enums.TimeOfDay; import lombok.*; @NoArgsConstructor(access = AccessLevel.PRIVATE) diff --git a/src/main/java/briefing/briefing/presentation/dto/BriefingResponseDTO.java b/Briefing-Api/src/main/java/com/example/briefingapi/briefing/presentation/dto/BriefingResponseDTO.java similarity index 86% rename from src/main/java/briefing/briefing/presentation/dto/BriefingResponseDTO.java rename to Briefing-Api/src/main/java/com/example/briefingapi/briefing/presentation/dto/BriefingResponseDTO.java index cbb56e0..18f4e19 100644 --- a/src/main/java/briefing/briefing/presentation/dto/BriefingResponseDTO.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/briefing/presentation/dto/BriefingResponseDTO.java @@ -1,12 +1,12 @@ -package briefing.briefing.presentation.dto; +package com.example.briefingapi.briefing.presentation.dto; import java.time.LocalDate; import java.time.LocalDateTime; import java.util.List; -import briefing.common.enums.BriefingType; -import briefing.common.enums.GptModel; -import briefing.common.enums.TimeOfDay; +import com.example.briefingcommon.entity.enums.BriefingType; +import com.example.briefingcommon.entity.enums.GptModel; +import com.example.briefingcommon.entity.enums.TimeOfDay; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; @@ -81,9 +81,12 @@ public static class BriefingDetailDTOV2 { Boolean isBriefingOpen; Boolean isWarning; @Builder.Default Integer scrapCount = 0; - @Builder.Default GptModel gptModel = GptModel.GPT_3_5_TURBO; - @Builder.Default TimeOfDay timeOfDay = TimeOfDay.MORNING; - @Builder.Default BriefingType type = BriefingType.KOREA; + @Builder.Default + GptModel gptModel = GptModel.GPT_3_5_TURBO; + @Builder.Default + TimeOfDay timeOfDay = TimeOfDay.MORNING; + @Builder.Default + BriefingType type = BriefingType.KOREA; } @Builder diff --git a/src/main/java/briefing/config/CacheConfig.java b/Briefing-Api/src/main/java/com/example/briefingapi/config/CacheConfig.java similarity index 98% rename from src/main/java/briefing/config/CacheConfig.java rename to Briefing-Api/src/main/java/com/example/briefingapi/config/CacheConfig.java index a368f66..96bcdc9 100644 --- a/src/main/java/briefing/config/CacheConfig.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/config/CacheConfig.java @@ -1,4 +1,4 @@ -package briefing.config; +package com.example.briefingapi.config; import java.time.Duration; diff --git a/src/main/java/briefing/config/GlobalWebConfig.java b/Briefing-Api/src/main/java/com/example/briefingapi/config/GlobalWebConfig.java similarity index 88% rename from src/main/java/briefing/config/GlobalWebConfig.java rename to Briefing-Api/src/main/java/com/example/briefingapi/config/GlobalWebConfig.java index cefd846..72302b9 100644 --- a/src/main/java/briefing/config/GlobalWebConfig.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/config/GlobalWebConfig.java @@ -1,15 +1,15 @@ -package briefing.config; +package com.example.briefingapi.config; import java.util.List; +import com.example.briefingapi.security.handler.annotation.AuthUserArgumentResolver; +import com.example.briefingcommon.common.presentation.converter.*; import org.springframework.context.annotation.Configuration; import org.springframework.format.FormatterRegistry; import org.springframework.web.method.support.HandlerMethodArgumentResolver; import org.springframework.web.servlet.config.annotation.CorsRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; -import briefing.common.presentation.converter.*; -import briefing.security.handler.annotation.AuthUserArgumentResolver; import lombok.RequiredArgsConstructor; @Configuration diff --git a/src/main/java/briefing/config/RestTemplateConfig.java b/Briefing-Api/src/main/java/com/example/briefingapi/config/RestTemplateConfig.java similarity index 88% rename from src/main/java/briefing/config/RestTemplateConfig.java rename to Briefing-Api/src/main/java/com/example/briefingapi/config/RestTemplateConfig.java index c99f07b..5e293da 100644 --- a/src/main/java/briefing/config/RestTemplateConfig.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/config/RestTemplateConfig.java @@ -1,4 +1,4 @@ -package briefing.config; +package com.example.briefingapi.config; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/src/main/java/briefing/config/SwaggerConfig.java b/Briefing-Api/src/main/java/com/example/briefingapi/config/SwaggerConfig.java similarity index 97% rename from src/main/java/briefing/config/SwaggerConfig.java rename to Briefing-Api/src/main/java/com/example/briefingapi/config/SwaggerConfig.java index cc9d7d5..0ad94d5 100644 --- a/src/main/java/briefing/config/SwaggerConfig.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/config/SwaggerConfig.java @@ -1,4 +1,4 @@ -package briefing.config; +package com.example.briefingapi.config; import org.springdoc.core.models.GroupedOpenApi; import org.springframework.context.annotation.Bean; diff --git a/Briefing-Api/src/main/java/com/example/briefingapi/config/firebaseConfig.java b/Briefing-Api/src/main/java/com/example/briefingapi/config/firebaseConfig.java new file mode 100644 index 0000000..0ab3c24 --- /dev/null +++ b/Briefing-Api/src/main/java/com/example/briefingapi/config/firebaseConfig.java @@ -0,0 +1,37 @@ +package com.example.briefingapi.config; + +import com.google.auth.oauth2.GoogleCredentials; +import com.google.firebase.FirebaseApp; +import com.google.firebase.FirebaseOptions; +import jakarta.annotation.PostConstruct; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.util.Base64; + +@Configuration +public class firebaseConfig { + + @Value("${fcm.key}") + private String fcmJson; + + @PostConstruct + public void initFirebase(){ + + String base64String = fcmJson; + + byte[] decodedBytes = Base64.getDecoder().decode(base64String); + + InputStream credentialStream = new ByteArrayInputStream(decodedBytes); + try { + FirebaseOptions options = FirebaseOptions.builder() + .setCredentials(GoogleCredentials.fromStream(credentialStream)) + .build(); + FirebaseApp.initializeApp(options); + }catch (Exception e){ + e.printStackTrace(); + } + } +} diff --git a/src/main/java/briefing/common/exception/JwtAuthenticationException.java b/Briefing-Api/src/main/java/com/example/briefingapi/exception/JwtAuthenticationException.java similarity index 67% rename from src/main/java/briefing/common/exception/JwtAuthenticationException.java rename to Briefing-Api/src/main/java/com/example/briefingapi/exception/JwtAuthenticationException.java index ed9c0e4..d5ccf81 100644 --- a/src/main/java/briefing/common/exception/JwtAuthenticationException.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/exception/JwtAuthenticationException.java @@ -1,8 +1,8 @@ -package briefing.common.exception; +package com.example.briefingapi.exception; -import org.springframework.security.core.AuthenticationException; -import briefing.common.exception.common.ErrorCode; +import com.example.briefingcommon.common.exception.common.ErrorCode; +import org.springframework.security.core.AuthenticationException; public class JwtAuthenticationException extends AuthenticationException { diff --git a/src/main/java/briefing/common/exception/handler/ExceptionAdvice.java b/Briefing-Api/src/main/java/com/example/briefingapi/exception/handler/ExceptionAdvice.java similarity index 95% rename from src/main/java/briefing/common/exception/handler/ExceptionAdvice.java rename to Briefing-Api/src/main/java/com/example/briefingapi/exception/handler/ExceptionAdvice.java index dd7c5c6..42ea315 100644 --- a/src/main/java/briefing/common/exception/handler/ExceptionAdvice.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/exception/handler/ExceptionAdvice.java @@ -1,4 +1,4 @@ -package briefing.common.exception.handler; +package com.example.briefingapi.exception.handler; import java.io.PrintWriter; import java.io.StringWriter; @@ -6,9 +6,14 @@ import java.util.Map; import java.util.Optional; + +import com.example.briefingcommon.common.exception.common.ErrorCode; +import com.example.briefingcommon.common.exception.common.GeneralException; +import com.example.briefingcommon.common.presentation.response.CommonResponse; import jakarta.servlet.http.HttpServletRequest; import jakarta.validation.ConstraintViolationException; import jakarta.validation.constraints.NotNull; +import lombok.extern.slf4j.Slf4j; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; @@ -24,11 +29,6 @@ import org.springframework.web.context.request.WebRequest; import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; -import briefing.common.exception.common.ErrorCode; -import briefing.common.exception.common.GeneralException; -import briefing.common.presentation.response.CommonResponse; -import lombok.extern.slf4j.Slf4j; - @Slf4j @RestControllerAdvice(annotations = {RestController.class}) public class ExceptionAdvice extends ResponseEntityExceptionHandler { diff --git a/src/main/java/briefing/common/exception/handler/GlobalControllerAdvice.java b/Briefing-Api/src/main/java/com/example/briefingapi/exception/handler/GlobalControllerAdvice.java similarity index 79% rename from src/main/java/briefing/common/exception/handler/GlobalControllerAdvice.java rename to Briefing-Api/src/main/java/com/example/briefingapi/exception/handler/GlobalControllerAdvice.java index 994ead9..b4f8ddc 100644 --- a/src/main/java/briefing/common/exception/handler/GlobalControllerAdvice.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/exception/handler/GlobalControllerAdvice.java @@ -1,10 +1,10 @@ -package briefing.common.exception.handler; +package com.example.briefingapi.exception.handler; +import com.example.briefingcommon.common.exception.common.BaseException; +import com.example.briefingcommon.common.exception.common.BaseExceptionType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ExceptionHandler; -import briefing.common.exception.common.BaseException; -import briefing.common.exception.common.BaseExceptionType; import lombok.extern.slf4j.Slf4j; @Slf4j diff --git a/Briefing-Api/src/main/java/com/example/briefingapi/fcm/implementation/FcmCommandService.java b/Briefing-Api/src/main/java/com/example/briefingapi/fcm/implementation/FcmCommandService.java new file mode 100644 index 0000000..4c1a4a7 --- /dev/null +++ b/Briefing-Api/src/main/java/com/example/briefingapi/fcm/implementation/FcmCommandService.java @@ -0,0 +1,71 @@ +package com.example.briefingapi.fcm.implementation; + +import com.example.briefingcommon.domain.repository.article.BriefingRepository; +import com.example.briefingcommon.entity.Briefing; +import com.example.briefingcommon.entity.enums.BriefingType; +import com.google.firebase.messaging.*; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; +import java.util.Optional; + +@Service +@RequiredArgsConstructor +@Transactional +@Slf4j +public class FcmCommandService { + + private final BriefingRepository briefingRepository; + + public void subScribe(String topicName, String memberTokenList) + { + try { + TopicManagementResponse topicManagementResponse = FirebaseMessaging.getInstance().subscribeToTopic(List.of(memberTokenList), topicName); + List errors = topicManagementResponse.getErrors(); + log.info("subscribe response : {}", topicManagementResponse.getSuccessCount()); + log.info("subscribe fail : {}", topicManagementResponse.getFailureCount()); + }catch (FirebaseMessagingException e){ + e.printStackTrace(); + } + } + + public void unSubScribe(String topicName, String memberTokenList){ + try { + TopicManagementResponse topicManagementResponse = FirebaseMessaging.getInstance().unsubscribeFromTopic(List.of(memberTokenList), topicName); + List errors = topicManagementResponse.getErrors(); + log.info("unSubscribe response : {}", topicManagementResponse.getSuccessCount()); + log.info("unSubscribe fail : {}", topicManagementResponse.getFailureCount()); + }catch (FirebaseMessagingException e){ + e.printStackTrace(); + } + } + + public void sendMessage(String topicName){ + + Optional briefingOptional = briefingRepository + .getBestTodayBriefing(BriefingType.SOCIAL, PageRequest.of(0, 1)) + .getContent().stream().findFirst(); + Message message = Message.builder() + .setNotification( + Notification.builder() + .setTitle(String.format("현재 소셜 키워드 #1 '%s'",briefingOptional.map(Briefing::getTitle) + .orElse("Briefing Social1"))) + .setBody(String.format("내용 : '%s' 읽어보러 가기",briefingOptional.map(Briefing::getSubtitle) + .orElse("Briefing App"))) + .build()) + .setTopic(topicName) + .build(); + + try { + String response = FirebaseMessaging.getInstance().send(message); + log.info("the response of request FCM : {}",response); + }catch (FirebaseMessagingException e){ + e.printStackTrace(); + } + } +} diff --git a/Briefing-Api/src/main/java/com/example/briefingapi/fcm/implementation/FcmQueryService.java b/Briefing-Api/src/main/java/com/example/briefingapi/fcm/implementation/FcmQueryService.java new file mode 100644 index 0000000..2b233c4 --- /dev/null +++ b/Briefing-Api/src/main/java/com/example/briefingapi/fcm/implementation/FcmQueryService.java @@ -0,0 +1,4 @@ +package com.example.briefingapi.fcm.implementation; + +public class FcmQueryService { +} diff --git a/Briefing-Api/src/main/java/com/example/briefingapi/fcm/presentation/FcmApi.java b/Briefing-Api/src/main/java/com/example/briefingapi/fcm/presentation/FcmApi.java new file mode 100644 index 0000000..cb1ad5a --- /dev/null +++ b/Briefing-Api/src/main/java/com/example/briefingapi/fcm/presentation/FcmApi.java @@ -0,0 +1,41 @@ +package com.example.briefingapi.fcm.presentation; + +import com.example.briefingapi.fcm.implementation.FcmCommandService; +import com.example.briefingapi.fcm.presentation.dto.FcmRequest; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@Tag(name = "06-Push-alarm 🚀", description = "푸쉬 알림 관련 API") +@RestController +@RequiredArgsConstructor +@RequestMapping("/pushs") +public class FcmApi { + + private final FcmCommandService fcmCommandService; + + @Operation(summary = "06-02 🚀[테스트] FCM 구독 테스트용 API") + @PostMapping("/subscribe") + public String testFcmSubscribe(@RequestBody FcmRequest.FcmTokenDTO body){ + fcmCommandService.subScribe("dailyPush",body.getToken()); + return "response"; + } + + @Operation(summary = "06-03 🚀[테스트] FCM 구독 취소 테스트용 API") + @PostMapping("/unsubscribe") + public String testFcmUnSubscribe(@RequestBody FcmRequest.FcmTokenDTO body){ + fcmCommandService.unSubScribe("dailyPush",body.getToken()); + return "response"; + } + + @Operation(summary = "06-01 🚀[테스트] FCM 전송 테스트용 API") + @PostMapping("/") + public String testSendMessage(){ + fcmCommandService.sendMessage("dailyPush"); + return "response"; + } +} diff --git a/Briefing-Api/src/main/java/com/example/briefingapi/fcm/presentation/dto/FcmRequest.java b/Briefing-Api/src/main/java/com/example/briefingapi/fcm/presentation/dto/FcmRequest.java new file mode 100644 index 0000000..59de872 --- /dev/null +++ b/Briefing-Api/src/main/java/com/example/briefingapi/fcm/presentation/dto/FcmRequest.java @@ -0,0 +1,11 @@ +package com.example.briefingapi.fcm.presentation.dto; + +import lombok.Getter; + +public class FcmRequest { + + @Getter + public static class FcmTokenDTO{ + String token; + } +} diff --git a/src/main/java/briefing/member/business/MemberConverter.java b/Briefing-Api/src/main/java/com/example/briefingapi/member/business/MemberConverter.java similarity index 81% rename from src/main/java/briefing/member/business/MemberConverter.java rename to Briefing-Api/src/main/java/com/example/briefingapi/member/business/MemberConverter.java index 6903cd5..3eca6d3 100644 --- a/src/main/java/briefing/member/business/MemberConverter.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/member/business/MemberConverter.java @@ -1,15 +1,16 @@ -package briefing.member.business; +package com.example.briefingapi.member.business; import java.time.LocalDateTime; +import com.example.briefingapi.member.presentation.dto.MemberResponse; +import com.example.briefingcommon.entity.Member; +import com.example.briefingcommon.entity.enums.MemberRole; +import com.example.briefingcommon.entity.enums.MemberStatus; +import com.example.briefingcommon.entity.enums.SocialType; +import com.example.briefinginfra.feign.oauth.google.dto.GoogleUserInfo; import org.springframework.stereotype.Component; -import briefing.common.enums.MemberRole; -import briefing.common.enums.MemberStatus; -import briefing.common.enums.SocialType; -import briefing.infra.feign.oauth.google.dto.GoogleUserInfo; -import briefing.member.domain.Member; -import briefing.member.presentation.dto.MemberResponse; + import lombok.RequiredArgsConstructor; @RequiredArgsConstructor diff --git a/src/main/java/briefing/member/business/MemberFacade.java b/Briefing-Api/src/main/java/com/example/briefingapi/member/business/MemberFacade.java similarity index 56% rename from src/main/java/briefing/member/business/MemberFacade.java rename to Briefing-Api/src/main/java/com/example/briefingapi/member/business/MemberFacade.java index e0386b1..bd230dd 100644 --- a/src/main/java/briefing/member/business/MemberFacade.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/member/business/MemberFacade.java @@ -1,24 +1,28 @@ -package briefing.member.business; +package com.example.briefingapi.member.business; import java.util.List; +import com.example.briefingapi.fcm.implementation.FcmCommandService; +import com.example.briefingapi.member.implement.MemberCommandService; +import com.example.briefingapi.member.implement.MemberQueryService; +import com.example.briefingapi.member.presentation.dto.MemberRequest; +import com.example.briefingapi.member.presentation.dto.MemberResponse; +import com.example.briefingapi.security.provider.TokenProvider; +import com.example.briefingcommon.entity.Member; +import com.example.briefingcommon.entity.enums.MemberRole; +import com.example.briefingcommon.entity.enums.SocialType; +import com.example.briefingcommon.entity.redis.RefreshToken; +import com.example.briefinginfra.feign.oauth.apple.client.AppleOauth2Client; +import com.example.briefinginfra.feign.oauth.google.client.GoogleOauth2Client; +import com.example.briefinginfra.feign.oauth.google.dto.GoogleUserInfo; +import org.springframework.beans.factory.annotation.Value; import org.springframework.security.core.authority.SimpleGrantedAuthority; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; -import briefing.common.enums.MemberRole; -import briefing.common.enums.SocialType; -import briefing.infra.feign.oauth.apple.client.AppleOauth2Client; -import briefing.infra.feign.oauth.google.client.GoogleOauth2Client; -import briefing.infra.feign.oauth.google.dto.GoogleUserInfo; -import briefing.infra.redis.domain.RefreshToken; -import briefing.infra.redis.service.RedisService; -import briefing.member.domain.Member; -import briefing.member.implement.MemberCommandService; -import briefing.member.implement.MemberQueryService; -import briefing.member.presentation.dto.MemberRequest; -import briefing.member.presentation.dto.MemberResponse; -import briefing.security.provider.TokenProvider; + +import com.example.briefingapi.redis.service.RedisService; + import lombok.RequiredArgsConstructor; @Component @@ -27,10 +31,17 @@ public class MemberFacade { private final MemberQueryService memberQueryService; private final MemberCommandService memberCommandService; private final TokenProvider tokenProvider; + private final FcmCommandService fcmCommandService; private final RedisService redisService; private final GoogleOauth2Client googleOauth2Client; private final AppleOauth2Client appleOauth2Client; + @Value("${fcm.topic.daily-push}") + private String dailyPushTopic; + + @Value(("${fcm.permit-flag}")) + private Integer permitFlag; + private Member loginWithGoogle(String identityToken) { GoogleUserInfo googleUserInfo = googleOauth2Client.verifyToken(identityToken); Member member = @@ -61,6 +72,20 @@ public MemberResponse.LoginDTO login( return MemberConverter.toLoginDTO(member, accessToken, refreshToken); } + public MemberResponse.TestTokenDTO getTestToken(){ + Member member = memberQueryService.findById(63L); + + return MemberResponse.TestTokenDTO.builder() + .token( + tokenProvider.createAccessToken( + member.getId(), + member.getSocialType().toString(), + member.getSocialId(), + List.of(new SimpleGrantedAuthority(MemberRole.ROLE_USER.name())))) + .build(); + + } + public MemberResponse.ReIssueTokenDTO reIssueToken(final MemberRequest.ReissueDTO request) { RefreshToken refreshToken = redisService.reGenerateRefreshToken(request); Member parsedMember = memberQueryService.parseRefreshToken(refreshToken); @@ -78,4 +103,16 @@ public MemberResponse.QuitDTO quit(final Long memberId) { memberCommandService.deleteMember(memberId); return MemberConverter.toQuitDTO(); } + + public void subScribeDailyPush(MemberRequest.ToggleDailyPushAlarmDTO request, Member member){ + + if(request.getPermit().equals(permitFlag)){ + memberCommandService.storeFcmToken(request.getFcmToken(),member); + fcmCommandService.subScribe(dailyPushTopic, request.getFcmToken()); + } + else { + memberCommandService.abortFcmToken(request.getFcmToken(), member); + fcmCommandService.unSubScribe(dailyPushTopic,request.getFcmToken()); + } + } } diff --git a/src/main/java/briefing/member/implement/MemberCommandService.java b/Briefing-Api/src/main/java/com/example/briefingapi/member/implement/MemberCommandService.java similarity index 65% rename from src/main/java/briefing/member/implement/MemberCommandService.java rename to Briefing-Api/src/main/java/com/example/briefingapi/member/implement/MemberCommandService.java index 7703f40..d615540 100644 --- a/src/main/java/briefing/member/implement/MemberCommandService.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/member/implement/MemberCommandService.java @@ -1,4 +1,4 @@ -package briefing.member.implement; +package com.example.briefingapi.member.implement; import java.math.BigInteger; import java.security.KeyFactory; @@ -7,6 +7,19 @@ import java.util.Base64; import java.util.Optional; +import com.example.briefingapi.member.business.MemberConverter; +import com.example.briefingcommon.domain.repository.FcmTokenRepository; +import com.example.briefingcommon.domain.repository.member.MemberRepository; +import com.example.briefingapi.member.presentation.dto.MemberRequest; +import com.example.briefingcommon.common.exception.AppleOAuthException; +import com.example.briefingcommon.common.exception.common.ErrorCode; +import com.example.briefingcommon.entity.FcmToken; +import com.example.briefingcommon.entity.Member; +import com.example.briefingcommon.entity.enums.SocialType; +import com.example.briefinginfra.feign.oauth.apple.client.AppleOauth2Client; +import com.example.briefinginfra.feign.oauth.apple.dto.ApplePublicKey; +import com.example.briefinginfra.feign.oauth.apple.dto.ApplePublicKeyList; +import com.example.briefinginfra.feign.oauth.google.client.GoogleOauth2Client; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; @@ -14,16 +27,7 @@ import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; -import briefing.common.enums.SocialType; -import briefing.common.exception.AppleOAuthException; -import briefing.common.exception.common.ErrorCode; -import briefing.infra.feign.oauth.apple.client.AppleOauth2Client; -import briefing.infra.feign.oauth.apple.dto.ApplePublicKey; -import briefing.infra.feign.oauth.apple.dto.ApplePublicKeyList; -import briefing.member.business.MemberConverter; -import briefing.member.domain.Member; -import briefing.member.domain.repository.MemberRepository; -import briefing.member.presentation.dto.MemberRequest; + import io.jsonwebtoken.Claims; import io.jsonwebtoken.Jwts; import lombok.RequiredArgsConstructor; @@ -35,6 +39,8 @@ public class MemberCommandService { private final MemberRepository memberRepository; private final AppleOauth2Client appleOauth2Client; + private final FcmTokenRepository fcmTokenRepository; + Logger logger = LoggerFactory.getLogger(MemberCommandService.class); public Member login(MemberRequest.LoginDTO request) { @@ -110,4 +116,28 @@ private PublicKey getPublicKey(ApplePublicKey applePublicKeyDTO) { public void deleteMember(Long memberId) { memberRepository.deleteById(memberId); } + + + public void storeFcmToken(String token, Member member){ + + Optional optionalFcmToken = fcmTokenRepository.findByMemberAndToken(member, token); + + optionalFcmToken.ifPresentOrElse( + fcmToken -> {}, + () -> fcmTokenRepository.save(FcmToken.builder() + .token(token) + .member(member) + .build()) + ); + } + + public void abortFcmToken(String token, Member member){ + + Optional optionalFcmToken = fcmTokenRepository.findByMemberAndToken(member, token); + + optionalFcmToken.ifPresentOrElse( + fcmTokenRepository::delete, + () -> {} + ); + } } diff --git a/src/main/java/briefing/member/implement/MemberQueryService.java b/Briefing-Api/src/main/java/com/example/briefingapi/member/implement/MemberQueryService.java similarity index 75% rename from src/main/java/briefing/member/implement/MemberQueryService.java rename to Briefing-Api/src/main/java/com/example/briefingapi/member/implement/MemberQueryService.java index 9789e51..3e71533 100644 --- a/src/main/java/briefing/member/implement/MemberQueryService.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/member/implement/MemberQueryService.java @@ -1,16 +1,17 @@ -package briefing.member.implement; +package com.example.briefingapi.member.implement; import java.util.Optional; +import com.example.briefingcommon.domain.repository.member.MemberRepository; +import com.example.briefingcommon.common.exception.MemberException; +import com.example.briefingcommon.common.exception.common.ErrorCode; +import com.example.briefingcommon.entity.Member; +import com.example.briefingcommon.entity.enums.MemberRole; +import com.example.briefingcommon.entity.enums.SocialType; +import com.example.briefingcommon.entity.redis.RefreshToken; import org.springframework.stereotype.Service; -import briefing.common.enums.MemberRole; -import briefing.common.enums.SocialType; -import briefing.common.exception.common.ErrorCode; -import briefing.infra.redis.domain.RefreshToken; -import briefing.member.domain.Member; -import briefing.member.domain.repository.MemberRepository; -import briefing.member.exception.MemberException; + import lombok.RequiredArgsConstructor; @Service diff --git a/src/main/java/briefing/member/presentation/MemberApi.java b/Briefing-Api/src/main/java/com/example/briefingapi/member/presentation/MemberApi.java similarity index 64% rename from src/main/java/briefing/member/presentation/MemberApi.java rename to Briefing-Api/src/main/java/com/example/briefingapi/member/presentation/MemberApi.java index 1e6d37e..33fa2d7 100644 --- a/src/main/java/briefing/member/presentation/MemberApi.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/member/presentation/MemberApi.java @@ -1,18 +1,18 @@ -package briefing.member.presentation; +package com.example.briefingapi.member.presentation; +import com.example.briefingapi.member.business.MemberFacade; +import com.example.briefingapi.member.presentation.dto.MemberRequest; +import com.example.briefingapi.member.presentation.dto.MemberResponse; +import com.example.briefingapi.security.handler.annotation.AuthMember; +import com.example.briefingapi.validation.annotation.CheckSameMember; +import com.example.briefingcommon.common.presentation.response.CommonResponse; +import com.example.briefingcommon.entity.Member; +import com.example.briefingcommon.entity.enums.SocialType; import jakarta.validation.Valid; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; -import briefing.common.enums.SocialType; -import briefing.common.presentation.response.CommonResponse; -import briefing.member.business.MemberFacade; -import briefing.member.domain.Member; -import briefing.member.presentation.dto.MemberRequest; -import briefing.member.presentation.dto.MemberResponse; -import briefing.security.handler.annotation.AuthMember; -import briefing.validation.annotation.CheckSameMember; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameters; @@ -36,23 +36,12 @@ public class MemberApi { private final MemberFacade memberFacade; - /* - @Operation(summary = "Member\uD83D\uDC64 토큰 잘 발급되나 테스트용API", description = "테스트 용") + + @Operation(summary = "02-05 Member\uD83D\uDC64 [테스트] 테스트를 위한 토큰 발급 API", description = "테스트 용") @GetMapping("/members/auth/test") - public CommonResponse testGenerateToken() { - Member member = memberQueryService.testForTokenApi(); - String accessToken = - tokenProvider.createAccessToken( - member.getId(), - member.getSocialType().toString(), - member.getSocialId(), - Arrays.asList(new SimpleGrantedAuthority(member.getRole().name()))); - RefreshToken refreshToken = - redisService.generateRefreshToken(member.getSocialId(), member.getSocialType()); - return CommonResponse.onSuccess( - MemberConverter.toLoginDTO(member, accessToken, refreshToken.getToken())); + public CommonResponse testGenerateToken() { + return CommonResponse.onSuccess(memberFacade.getTestToken()); } - */ @Operation(summary = "02-01 Member\uD83D\uDC64 소셜 로그인 V1", description = "구글, 애플 소셜로그인 API입니다.") @PostMapping("/members/auth/{socialType}") @@ -64,7 +53,7 @@ public CommonResponse login( } @Operation( - summary = "02-01 Member\uD83D\uDC64 accessToken 재발급 받기 V1", + summary = "02-02 Member\uD83D\uDC64 accessToken 재발급 받기 V1", description = "accessToken 만료 시 refreshToken으로 재발급을 받는 API 입니다.") @ApiResponses({ @ApiResponse(responseCode = "1000", description = "OK, 성공"), @@ -87,7 +76,7 @@ public CommonResponse reissueToken( return CommonResponse.onSuccess(memberFacade.reIssueToken(request)); } - @Operation(summary = "02-01 Member\uD83D\uDC64 회원 탈퇴 V1", description = "회원 탈퇴 API 입니다.") + @Operation(summary = "02-03 Member\uD83D\uDC64 회원 탈퇴 V1", description = "회원 탈퇴 API 입니다.") @DeleteMapping("/members/{memberId}") @Parameters({ @Parameter(name = "member", hidden = true), @@ -120,4 +109,34 @@ public CommonResponse quitMember( @AuthMember Member member, @CheckSameMember @PathVariable Long memberId) { return CommonResponse.onSuccess(memberFacade.quit(memberId)); } + + @Operation(summary = "02-04 Member\uD83D\uDC64 푸쉬 알람 허용/거부 설정 ", description = "푸쉬 알람 허용/거부 설정입니다.") + @PostMapping("/members/alarms") + @ApiResponses({ + @ApiResponse(responseCode = "1000", description = "OK, 성공"), + @ApiResponse( + responseCode = "AUTH003", + description = "access 토큰을 주세요!", + content = @Content(schema = @Schema(implementation = CommonResponse.class))), + @ApiResponse( + responseCode = "AUTH004", + description = "acess 토큰 만료", + content = @Content(schema = @Schema(implementation = CommonResponse.class))), + @ApiResponse( + responseCode = "AUTH006", + description = "acess 토큰 모양이 이상함", + content = @Content(schema = @Schema(implementation = CommonResponse.class))), + @ApiResponse( + responseCode = "MEMBER_001", + description = "사용자가 존재하지 않습니다.", + content = @Content(schema = @Schema(implementation = CommonResponse.class))), + }) + public CommonResponse subscribeDailyPush( + @Valid @RequestBody MemberRequest.ToggleDailyPushAlarmDTO request, + @Parameter(hidden = true) @AuthMember Member member + ){ + + memberFacade.subScribeDailyPush(request,member); + return CommonResponse.onSuccess(); + } } diff --git a/src/main/java/briefing/member/presentation/MemberV2Api.java b/Briefing-Api/src/main/java/com/example/briefingapi/member/presentation/MemberV2Api.java similarity index 89% rename from src/main/java/briefing/member/presentation/MemberV2Api.java rename to Briefing-Api/src/main/java/com/example/briefingapi/member/presentation/MemberV2Api.java index 6382b8a..9714ecd 100644 --- a/src/main/java/briefing/member/presentation/MemberV2Api.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/member/presentation/MemberV2Api.java @@ -1,18 +1,19 @@ -package briefing.member.presentation; +package com.example.briefingapi.member.presentation; +import com.example.briefingapi.member.business.MemberFacade; +import com.example.briefingapi.member.presentation.dto.MemberRequest; +import com.example.briefingapi.member.presentation.dto.MemberResponse; +import com.example.briefingapi.security.handler.annotation.AuthMember; +import com.example.briefingapi.validation.annotation.CheckSameMember; +import com.example.briefingcommon.common.presentation.response.CommonResponse; +import com.example.briefingcommon.entity.Member; +import com.example.briefingcommon.entity.enums.SocialType; import jakarta.validation.Valid; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; -import briefing.common.enums.SocialType; -import briefing.common.presentation.response.CommonResponse; -import briefing.member.business.MemberFacade; -import briefing.member.domain.Member; -import briefing.member.presentation.dto.MemberRequest; -import briefing.member.presentation.dto.MemberResponse; -import briefing.security.handler.annotation.AuthMember; -import briefing.validation.annotation.CheckSameMember; + import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameters; diff --git a/src/main/java/briefing/member/presentation/dto/MemberRequest.java b/Briefing-Api/src/main/java/com/example/briefingapi/member/presentation/dto/MemberRequest.java similarity index 53% rename from src/main/java/briefing/member/presentation/dto/MemberRequest.java rename to Briefing-Api/src/main/java/com/example/briefingapi/member/presentation/dto/MemberRequest.java index 030f33b..1fe5803 100644 --- a/src/main/java/briefing/member/presentation/dto/MemberRequest.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/member/presentation/dto/MemberRequest.java @@ -1,7 +1,8 @@ -package briefing.member.presentation.dto; +package com.example.briefingapi.member.presentation.dto; import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; import lombok.Getter; public class MemberRequest { @@ -15,4 +16,12 @@ public static class LoginDTO { public static class ReissueDTO { @NotBlank private String refreshToken; } + + @Getter + public static class ToggleDailyPushAlarmDTO{ + + @NotNull private Integer permit; + @NotBlank private String fcmToken; + } + } diff --git a/src/main/java/briefing/member/presentation/dto/MemberResponse.java b/Briefing-Api/src/main/java/com/example/briefingapi/member/presentation/dto/MemberResponse.java similarity index 83% rename from src/main/java/briefing/member/presentation/dto/MemberResponse.java rename to Briefing-Api/src/main/java/com/example/briefingapi/member/presentation/dto/MemberResponse.java index 3578e26..7c7ff2e 100644 --- a/src/main/java/briefing/member/presentation/dto/MemberResponse.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/member/presentation/dto/MemberResponse.java @@ -1,4 +1,4 @@ -package briefing.member.presentation.dto; +package com.example.briefingapi.member.presentation.dto; import java.time.LocalDateTime; import java.util.List; @@ -20,6 +20,14 @@ public static class LoginDTO { private String refreshToken; } + @Builder + @Getter + @NoArgsConstructor + @AllArgsConstructor + public static class TestTokenDTO{ + String token; + } + @Builder @Getter @NoArgsConstructor diff --git a/src/main/java/briefing/infra/redis/repository/RefreshTokenRepository.java b/Briefing-Api/src/main/java/com/example/briefingapi/redis/repository/RefreshTokenRepository.java similarity index 57% rename from src/main/java/briefing/infra/redis/repository/RefreshTokenRepository.java rename to Briefing-Api/src/main/java/com/example/briefingapi/redis/repository/RefreshTokenRepository.java index 9abf7d4..93ff659 100644 --- a/src/main/java/briefing/infra/redis/repository/RefreshTokenRepository.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/redis/repository/RefreshTokenRepository.java @@ -1,7 +1,7 @@ -package briefing.infra.redis.repository; +package com.example.briefingapi.redis.repository; +import com.example.briefingcommon.entity.redis.RefreshToken; import org.springframework.data.repository.CrudRepository; -import briefing.infra.redis.domain.RefreshToken; public interface RefreshTokenRepository extends CrudRepository {} diff --git a/src/main/java/briefing/infra/redis/service/RedisService.java b/Briefing-Api/src/main/java/com/example/briefingapi/redis/service/RedisService.java similarity index 55% rename from src/main/java/briefing/infra/redis/service/RedisService.java rename to Briefing-Api/src/main/java/com/example/briefingapi/redis/service/RedisService.java index f1753ab..02f197b 100644 --- a/src/main/java/briefing/infra/redis/service/RedisService.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/redis/service/RedisService.java @@ -1,8 +1,10 @@ -package briefing.infra.redis.service; +package com.example.briefingapi.redis.service; + + +import com.example.briefingapi.member.presentation.dto.MemberRequest; +import com.example.briefingcommon.entity.enums.SocialType; +import com.example.briefingcommon.entity.redis.RefreshToken; -import briefing.common.enums.SocialType; -import briefing.infra.redis.domain.RefreshToken; -import briefing.member.presentation.dto.MemberRequest; public interface RedisService { diff --git a/src/main/java/briefing/infra/redis/service/RedisServiceImpl.java b/Briefing-Api/src/main/java/com/example/briefingapi/redis/service/RedisServiceImpl.java similarity index 84% rename from src/main/java/briefing/infra/redis/service/RedisServiceImpl.java rename to Briefing-Api/src/main/java/com/example/briefingapi/redis/service/RedisServiceImpl.java index f24446a..29ef3ce 100644 --- a/src/main/java/briefing/infra/redis/service/RedisServiceImpl.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/redis/service/RedisServiceImpl.java @@ -1,24 +1,24 @@ -package briefing.infra.redis.service; +package com.example.briefingapi.redis.service; import java.time.LocalDateTime; import java.time.temporal.ChronoUnit; import java.util.Optional; import java.util.UUID; +import com.example.briefingcommon.domain.repository.member.MemberRepository; +import com.example.briefingapi.member.presentation.dto.MemberRequest; +import com.example.briefingapi.redis.repository.RefreshTokenRepository; +import com.example.briefingcommon.common.exception.MemberException; +import com.example.briefingcommon.common.exception.RefreshTokenException; +import com.example.briefingcommon.common.exception.common.ErrorCode; +import com.example.briefingcommon.entity.Member; +import com.example.briefingcommon.entity.enums.SocialType; +import com.example.briefingcommon.entity.redis.RefreshToken; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import briefing.common.enums.SocialType; -import briefing.common.exception.RefreshTokenException; -import briefing.common.exception.common.ErrorCode; -import briefing.infra.redis.domain.RefreshToken; -import briefing.infra.redis.repository.RefreshTokenRepository; -import briefing.member.domain.Member; -import briefing.member.domain.repository.MemberRepository; -import briefing.member.exception.MemberException; -import briefing.member.presentation.dto.MemberRequest; import lombok.RequiredArgsConstructor; @Service diff --git a/src/main/java/briefing/root/presentation/RootApi.java b/Briefing-Api/src/main/java/com/example/briefingapi/root/presentation/RootApi.java similarity index 93% rename from src/main/java/briefing/root/presentation/RootApi.java rename to Briefing-Api/src/main/java/com/example/briefingapi/root/presentation/RootApi.java index 135cf26..c055c32 100644 --- a/src/main/java/briefing/root/presentation/RootApi.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/root/presentation/RootApi.java @@ -1,4 +1,4 @@ -package briefing.root.presentation; +package com.example.briefingapi.root.presentation; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; diff --git a/src/main/java/briefing/scrap/business/ScrapConverter.java b/Briefing-Api/src/main/java/com/example/briefingapi/scrap/business/ScrapConverter.java similarity index 91% rename from src/main/java/briefing/scrap/business/ScrapConverter.java rename to Briefing-Api/src/main/java/com/example/briefingapi/scrap/business/ScrapConverter.java index e0fb5fb..e48b8bd 100644 --- a/src/main/java/briefing/scrap/business/ScrapConverter.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/scrap/business/ScrapConverter.java @@ -1,11 +1,11 @@ -package briefing.scrap.business; +package com.example.briefingapi.scrap.business; import java.time.LocalDateTime; -import briefing.briefing.domain.Briefing; -import briefing.member.domain.Member; -import briefing.scrap.domain.Scrap; -import briefing.scrap.presentation.dto.ScrapResponse; +import com.example.briefingapi.scrap.presentation.dto.ScrapResponse; +import com.example.briefingcommon.entity.Briefing; +import com.example.briefingcommon.entity.Member; +import com.example.briefingcommon.entity.Scrap; public class ScrapConverter { public static ScrapResponse.CreateDTO toCreateDTO(Scrap createdScrap) { diff --git a/src/main/java/briefing/scrap/business/ScrapFacade.java b/Briefing-Api/src/main/java/com/example/briefingapi/scrap/business/ScrapFacade.java similarity index 69% rename from src/main/java/briefing/scrap/business/ScrapFacade.java rename to Briefing-Api/src/main/java/com/example/briefingapi/scrap/business/ScrapFacade.java index 8fc8df2..6f5ef15 100644 --- a/src/main/java/briefing/scrap/business/ScrapFacade.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/scrap/business/ScrapFacade.java @@ -1,22 +1,23 @@ -package briefing.scrap.business; +package com.example.briefingapi.scrap.business; import java.util.List; +import com.example.briefingapi.briefing.implement.service.BriefingQueryService; +import com.example.briefingapi.member.implement.MemberQueryService; +import com.example.briefingapi.scrap.implement.ScrapCommandService; +import com.example.briefingapi.scrap.implement.ScrapQueryService; +import com.example.briefingapi.scrap.presentation.dto.ScrapRequest; +import com.example.briefingapi.scrap.presentation.dto.ScrapResponse; +import com.example.briefingcommon.common.exception.common.ErrorCode; +import com.example.briefingcommon.entity.Briefing; +import com.example.briefingcommon.entity.Member; +import com.example.briefingcommon.entity.Scrap; +import com.example.briefingcommon.entity.enums.APIVersion; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; -import briefing.briefing.domain.Briefing; -import briefing.briefing.implement.service.BriefingQueryService; -import briefing.common.enums.APIVersion; -import briefing.common.exception.common.ErrorCode; -import briefing.member.domain.Member; -import briefing.member.implement.MemberQueryService; -import briefing.scrap.domain.Scrap; -import briefing.scrap.exception.ScrapException; -import briefing.scrap.implement.ScrapCommandService; -import briefing.scrap.implement.ScrapQueryService; -import briefing.scrap.presentation.dto.ScrapRequest; -import briefing.scrap.presentation.dto.ScrapResponse; + +import com.example.briefingcommon.common.exception.ScrapException; import lombok.RequiredArgsConstructor; @Component diff --git a/src/main/java/briefing/scrap/business/ScrapV2Facade.java b/Briefing-Api/src/main/java/com/example/briefingapi/scrap/business/ScrapV2Facade.java similarity index 71% rename from src/main/java/briefing/scrap/business/ScrapV2Facade.java rename to Briefing-Api/src/main/java/com/example/briefingapi/scrap/business/ScrapV2Facade.java index 269f515..d6e2040 100644 --- a/src/main/java/briefing/scrap/business/ScrapV2Facade.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/scrap/business/ScrapV2Facade.java @@ -1,22 +1,22 @@ -package briefing.scrap.business; +package com.example.briefingapi.scrap.business; import java.util.List; +import com.example.briefingapi.briefing.implement.service.BriefingQueryService; +import com.example.briefingapi.member.implement.MemberQueryService; +import com.example.briefingapi.scrap.implement.ScrapCommandService; +import com.example.briefingapi.scrap.implement.ScrapQueryService; +import com.example.briefingapi.scrap.presentation.dto.ScrapRequest; +import com.example.briefingapi.scrap.presentation.dto.ScrapResponse; +import com.example.briefingcommon.common.exception.common.ErrorCode; +import com.example.briefingcommon.entity.Briefing; +import com.example.briefingcommon.entity.Member; +import com.example.briefingcommon.entity.Scrap; +import com.example.briefingcommon.entity.enums.APIVersion; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; -import briefing.briefing.domain.Briefing; -import briefing.briefing.implement.service.BriefingQueryService; -import briefing.common.enums.APIVersion; -import briefing.common.exception.common.ErrorCode; -import briefing.member.domain.Member; -import briefing.member.implement.MemberQueryService; -import briefing.scrap.domain.Scrap; -import briefing.scrap.exception.ScrapException; -import briefing.scrap.implement.ScrapCommandService; -import briefing.scrap.implement.ScrapQueryService; -import briefing.scrap.presentation.dto.ScrapRequest; -import briefing.scrap.presentation.dto.ScrapResponse; +import com.example.briefingcommon.common.exception.ScrapException; import lombok.RequiredArgsConstructor; @Component diff --git a/src/main/java/briefing/scrap/implement/ScrapCommandService.java b/Briefing-Api/src/main/java/com/example/briefingapi/scrap/implement/ScrapCommandService.java similarity index 66% rename from src/main/java/briefing/scrap/implement/ScrapCommandService.java rename to Briefing-Api/src/main/java/com/example/briefingapi/scrap/implement/ScrapCommandService.java index ea3db0d..94cbb6b 100644 --- a/src/main/java/briefing/scrap/implement/ScrapCommandService.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/scrap/implement/ScrapCommandService.java @@ -1,12 +1,12 @@ -package briefing.scrap.implement; +package com.example.briefingapi.scrap.implement; +import com.example.briefingcommon.domain.repository.scrap.ScrapRepository; +import com.example.briefingcommon.common.exception.common.ErrorCode; +import com.example.briefingcommon.entity.Scrap; import org.springframework.dao.DataIntegrityViolationException; import org.springframework.stereotype.Service; -import briefing.common.exception.common.ErrorCode; -import briefing.scrap.domain.Scrap; -import briefing.scrap.domain.repository.ScrapRepository; -import briefing.scrap.exception.ScrapException; +import com.example.briefingcommon.common.exception.ScrapException; import lombok.RequiredArgsConstructor; @Service diff --git a/src/main/java/briefing/scrap/implement/ScrapQueryService.java b/Briefing-Api/src/main/java/com/example/briefingapi/scrap/implement/ScrapQueryService.java similarity index 75% rename from src/main/java/briefing/scrap/implement/ScrapQueryService.java rename to Briefing-Api/src/main/java/com/example/briefingapi/scrap/implement/ScrapQueryService.java index 0575c8a..7665584 100644 --- a/src/main/java/briefing/scrap/implement/ScrapQueryService.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/scrap/implement/ScrapQueryService.java @@ -1,13 +1,13 @@ -package briefing.scrap.implement; +package com.example.briefingapi.scrap.implement; import java.util.List; +import com.example.briefingcommon.domain.repository.scrap.ScrapRepository; +import com.example.briefingcommon.common.exception.common.ErrorCode; +import com.example.briefingcommon.entity.Scrap; import org.springframework.stereotype.Service; -import briefing.common.exception.common.ErrorCode; -import briefing.scrap.domain.Scrap; -import briefing.scrap.domain.repository.ScrapRepository; -import briefing.scrap.exception.ScrapException; +import com.example.briefingcommon.common.exception.ScrapException; import lombok.RequiredArgsConstructor; @Service diff --git a/src/main/java/briefing/scrap/presentation/ScrapApi.java b/Briefing-Api/src/main/java/com/example/briefingapi/scrap/presentation/ScrapApi.java similarity index 82% rename from src/main/java/briefing/scrap/presentation/ScrapApi.java rename to Briefing-Api/src/main/java/com/example/briefingapi/scrap/presentation/ScrapApi.java index 051aee8..c40c435 100644 --- a/src/main/java/briefing/scrap/presentation/ScrapApi.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/scrap/presentation/ScrapApi.java @@ -1,13 +1,12 @@ -package briefing.scrap.presentation; - +package com.example.briefingapi.scrap.presentation; import java.util.List; +import com.example.briefingapi.scrap.business.ScrapFacade; +import com.example.briefingapi.scrap.presentation.dto.ScrapRequest; +import com.example.briefingapi.scrap.presentation.dto.ScrapResponse; +import com.example.briefingcommon.common.presentation.response.CommonResponse; import org.springframework.web.bind.annotation.*; -import briefing.common.presentation.response.CommonResponse; -import briefing.scrap.business.ScrapFacade; -import briefing.scrap.presentation.dto.ScrapRequest; -import briefing.scrap.presentation.dto.ScrapResponse; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/briefing/scrap/presentation/ScrapV2Api.java b/Briefing-Api/src/main/java/com/example/briefingapi/scrap/presentation/ScrapV2Api.java similarity index 81% rename from src/main/java/briefing/scrap/presentation/ScrapV2Api.java rename to Briefing-Api/src/main/java/com/example/briefingapi/scrap/presentation/ScrapV2Api.java index 83ebc60..b1e4f12 100644 --- a/src/main/java/briefing/scrap/presentation/ScrapV2Api.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/scrap/presentation/ScrapV2Api.java @@ -1,14 +1,13 @@ -package briefing.scrap.presentation; - +package com.example.briefingapi.scrap.presentation; import java.util.List; +import com.example.briefingapi.scrap.business.ScrapV2Facade; +import com.example.briefingapi.scrap.presentation.dto.ScrapRequest; +import com.example.briefingapi.scrap.presentation.dto.ScrapResponse; +import com.example.briefingcommon.common.presentation.response.CommonResponse; import org.springframework.web.bind.annotation.*; -import briefing.common.aop.annotation.CacheEvictByBriefingId; -import briefing.common.presentation.response.CommonResponse; -import briefing.scrap.business.ScrapV2Facade; -import briefing.scrap.presentation.dto.ScrapRequest; -import briefing.scrap.presentation.dto.ScrapResponse; +import com.example.briefingapi.aop.annotation.CacheEvictByBriefingId; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/briefing/scrap/presentation/dto/ScrapRequest.java b/Briefing-Api/src/main/java/com/example/briefingapi/scrap/presentation/dto/ScrapRequest.java similarity index 83% rename from src/main/java/briefing/scrap/presentation/dto/ScrapRequest.java rename to Briefing-Api/src/main/java/com/example/briefingapi/scrap/presentation/dto/ScrapRequest.java index d00fd82..fe34bee 100644 --- a/src/main/java/briefing/scrap/presentation/dto/ScrapRequest.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/scrap/presentation/dto/ScrapRequest.java @@ -1,4 +1,4 @@ -package briefing.scrap.presentation.dto; +package com.example.briefingapi.scrap.presentation.dto; import lombok.AccessLevel; import lombok.Getter; diff --git a/src/main/java/briefing/scrap/presentation/dto/ScrapResponse.java b/Briefing-Api/src/main/java/com/example/briefingapi/scrap/presentation/dto/ScrapResponse.java similarity index 91% rename from src/main/java/briefing/scrap/presentation/dto/ScrapResponse.java rename to Briefing-Api/src/main/java/com/example/briefingapi/scrap/presentation/dto/ScrapResponse.java index e5208a1..8c62589 100644 --- a/src/main/java/briefing/scrap/presentation/dto/ScrapResponse.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/scrap/presentation/dto/ScrapResponse.java @@ -1,10 +1,11 @@ -package briefing.scrap.presentation.dto; +package com.example.briefingapi.scrap.presentation.dto; import java.time.LocalDate; import java.time.LocalDateTime; -import briefing.common.enums.GptModel; -import briefing.common.enums.TimeOfDay; + +import com.example.briefingcommon.entity.enums.GptModel; +import com.example.briefingcommon.entity.enums.TimeOfDay; import lombok.*; @NoArgsConstructor(access = AccessLevel.PRIVATE) diff --git a/src/main/java/briefing/security/config/SecurityConfig.java b/Briefing-Api/src/main/java/com/example/briefingapi/security/config/SecurityConfig.java similarity index 93% rename from src/main/java/briefing/security/config/SecurityConfig.java rename to Briefing-Api/src/main/java/com/example/briefingapi/security/config/SecurityConfig.java index cf2b06c..a474b9d 100644 --- a/src/main/java/briefing/security/config/SecurityConfig.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/security/config/SecurityConfig.java @@ -1,9 +1,15 @@ -package briefing.security.config; +package com.example.briefingapi.security.config; import static org.springframework.security.config.Customizer.withDefaults; import java.util.Collections; +import com.example.briefingapi.security.filter.JwtRequestFilter; +import com.example.briefingapi.security.handler.JwtAccessDeniedHandler; +import com.example.briefingapi.security.handler.JwtAuthenticationEntryPoint; +import com.example.briefingapi.security.handler.JwtAuthenticationExceptionHandler; +import com.example.briefingapi.security.handler.SwaggerLoginSuccessHandler; +import com.example.briefingapi.security.provider.TokenProvider; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -26,12 +32,6 @@ import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; import org.springframework.web.cors.CorsConfigurationSource; -import briefing.security.filter.JwtRequestFilter; -import briefing.security.handler.JwtAccessDeniedHandler; -import briefing.security.handler.JwtAuthenticationEntryPoint; -import briefing.security.handler.JwtAuthenticationExceptionHandler; -import briefing.security.handler.SwaggerLoginSuccessHandler; -import briefing.security.provider.TokenProvider; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -82,7 +82,7 @@ public WebSecurityCustomizer webSecurityCustomizer() { "/schedule", "/v3/api-docs", "/v3/api-docs/**", - "/docs/**", + "/docs/**","/fcms/**", "/briefings/temp"); } diff --git a/src/main/java/briefing/security/filter/JwtRequestFilter.java b/Briefing-Api/src/main/java/com/example/briefingapi/security/filter/JwtRequestFilter.java similarity index 92% rename from src/main/java/briefing/security/filter/JwtRequestFilter.java rename to Briefing-Api/src/main/java/com/example/briefingapi/security/filter/JwtRequestFilter.java index 73d712f..0fed31b 100644 --- a/src/main/java/briefing/security/filter/JwtRequestFilter.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/security/filter/JwtRequestFilter.java @@ -1,7 +1,8 @@ -package briefing.security.filter; +package com.example.briefingapi.security.filter; import java.io.IOException; +import com.example.briefingapi.security.provider.TokenProvider; import jakarta.servlet.FilterChain; import jakarta.servlet.ServletException; import jakarta.servlet.http.HttpServletRequest; @@ -12,7 +13,7 @@ import org.springframework.util.StringUtils; import org.springframework.web.filter.OncePerRequestFilter; -import briefing.security.provider.TokenProvider; + import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; diff --git a/src/main/java/briefing/security/handler/JwtAccessDeniedHandler.java b/Briefing-Api/src/main/java/com/example/briefingapi/security/handler/JwtAccessDeniedHandler.java similarity index 89% rename from src/main/java/briefing/security/handler/JwtAccessDeniedHandler.java rename to Briefing-Api/src/main/java/com/example/briefingapi/security/handler/JwtAccessDeniedHandler.java index 3368c5d..36a2f14 100644 --- a/src/main/java/briefing/security/handler/JwtAccessDeniedHandler.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/security/handler/JwtAccessDeniedHandler.java @@ -1,8 +1,10 @@ -package briefing.security.handler; +package com.example.briefingapi.security.handler; import java.io.IOException; import java.io.PrintWriter; +import com.example.briefingcommon.common.exception.common.ApiErrorResult; +import com.example.briefingcommon.common.exception.common.ErrorCode; import jakarta.servlet.ServletException; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; @@ -12,8 +14,6 @@ import org.springframework.security.access.AccessDeniedException; import org.springframework.security.web.access.AccessDeniedHandler; -import briefing.common.exception.common.ApiErrorResult; -import briefing.common.exception.common.ErrorCode; public class JwtAccessDeniedHandler implements AccessDeniedHandler { diff --git a/src/main/java/briefing/security/handler/JwtAuthenticationEntryPoint.java b/Briefing-Api/src/main/java/com/example/briefingapi/security/handler/JwtAuthenticationEntryPoint.java similarity index 89% rename from src/main/java/briefing/security/handler/JwtAuthenticationEntryPoint.java rename to Briefing-Api/src/main/java/com/example/briefingapi/security/handler/JwtAuthenticationEntryPoint.java index 7dcebb0..53fffb5 100644 --- a/src/main/java/briefing/security/handler/JwtAuthenticationEntryPoint.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/security/handler/JwtAuthenticationEntryPoint.java @@ -1,8 +1,10 @@ -package briefing.security.handler; +package com.example.briefingapi.security.handler; import java.io.IOException; import java.io.PrintWriter; +import com.example.briefingcommon.common.exception.common.ApiErrorResult; +import com.example.briefingcommon.common.exception.common.ErrorCode; import jakarta.servlet.ServletException; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; @@ -12,8 +14,6 @@ import org.springframework.security.core.AuthenticationException; import org.springframework.security.web.AuthenticationEntryPoint; -import briefing.common.exception.common.ApiErrorResult; -import briefing.common.exception.common.ErrorCode; public class JwtAuthenticationEntryPoint implements AuthenticationEntryPoint { diff --git a/src/main/java/briefing/security/handler/JwtAuthenticationExceptionHandler.java b/Briefing-Api/src/main/java/com/example/briefingapi/security/handler/JwtAuthenticationExceptionHandler.java similarity index 85% rename from src/main/java/briefing/security/handler/JwtAuthenticationExceptionHandler.java rename to Briefing-Api/src/main/java/com/example/briefingapi/security/handler/JwtAuthenticationExceptionHandler.java index deb0c06..c4330bf 100644 --- a/src/main/java/briefing/security/handler/JwtAuthenticationExceptionHandler.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/security/handler/JwtAuthenticationExceptionHandler.java @@ -1,8 +1,11 @@ -package briefing.security.handler; +package com.example.briefingapi.security.handler; import java.io.IOException; import java.io.PrintWriter; +import com.example.briefingapi.exception.JwtAuthenticationException; +import com.example.briefingcommon.common.exception.common.ApiErrorResult; +import com.example.briefingcommon.common.exception.common.ErrorCode; import jakarta.servlet.FilterChain; import jakarta.servlet.ServletException; import jakarta.servlet.http.HttpServletRequest; @@ -11,9 +14,6 @@ import org.springframework.http.HttpStatus; import org.springframework.web.filter.OncePerRequestFilter; -import briefing.common.exception.JwtAuthenticationException; -import briefing.common.exception.common.ApiErrorResult; -import briefing.common.exception.common.ErrorCode; // @Component public class JwtAuthenticationExceptionHandler extends OncePerRequestFilter { diff --git a/src/main/java/briefing/security/handler/SwaggerLoginSuccessHandler.java b/Briefing-Api/src/main/java/com/example/briefingapi/security/handler/SwaggerLoginSuccessHandler.java similarity index 93% rename from src/main/java/briefing/security/handler/SwaggerLoginSuccessHandler.java rename to Briefing-Api/src/main/java/com/example/briefingapi/security/handler/SwaggerLoginSuccessHandler.java index 39aa9a2..effe35a 100644 --- a/src/main/java/briefing/security/handler/SwaggerLoginSuccessHandler.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/security/handler/SwaggerLoginSuccessHandler.java @@ -1,4 +1,4 @@ -package briefing.security.handler; +package com.example.briefingapi.security.handler; import java.io.IOException; diff --git a/src/main/java/briefing/security/handler/annotation/AuthMember.java b/Briefing-Api/src/main/java/com/example/briefingapi/security/handler/annotation/AuthMember.java similarity index 81% rename from src/main/java/briefing/security/handler/annotation/AuthMember.java rename to Briefing-Api/src/main/java/com/example/briefingapi/security/handler/annotation/AuthMember.java index 7178ca4..432665c 100644 --- a/src/main/java/briefing/security/handler/annotation/AuthMember.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/security/handler/annotation/AuthMember.java @@ -1,4 +1,4 @@ -package briefing.security.handler.annotation; +package com.example.briefingapi.security.handler.annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/src/main/java/briefing/security/handler/annotation/AuthUserArgumentResolver.java b/Briefing-Api/src/main/java/com/example/briefingapi/security/handler/annotation/AuthUserArgumentResolver.java similarity index 91% rename from src/main/java/briefing/security/handler/annotation/AuthUserArgumentResolver.java rename to Briefing-Api/src/main/java/com/example/briefingapi/security/handler/annotation/AuthUserArgumentResolver.java index 4a0a530..1be7254 100644 --- a/src/main/java/briefing/security/handler/annotation/AuthUserArgumentResolver.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/security/handler/annotation/AuthUserArgumentResolver.java @@ -1,5 +1,8 @@ -package briefing.security.handler.annotation; +package com.example.briefingapi.security.handler.annotation; +import com.example.briefingapi.member.implement.MemberQueryService; +import com.example.briefingapi.security.provider.TokenProvider; +import com.example.briefingcommon.entity.Member; import jakarta.servlet.http.HttpServletRequest; import org.springframework.core.MethodParameter; @@ -10,9 +13,6 @@ import org.springframework.web.method.support.HandlerMethodArgumentResolver; import org.springframework.web.method.support.ModelAndViewContainer; -import briefing.member.domain.Member; -import briefing.member.implement.MemberQueryService; -import briefing.security.provider.TokenProvider; import lombok.RequiredArgsConstructor; @Component diff --git a/src/main/java/briefing/security/provider/TokenProvider.java b/Briefing-Api/src/main/java/com/example/briefingapi/security/provider/TokenProvider.java similarity index 96% rename from src/main/java/briefing/security/provider/TokenProvider.java rename to Briefing-Api/src/main/java/com/example/briefingapi/security/provider/TokenProvider.java index 20a0d2a..456e494 100644 --- a/src/main/java/briefing/security/provider/TokenProvider.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/security/provider/TokenProvider.java @@ -1,5 +1,4 @@ -package briefing.security.provider; - +package com.example.briefingapi.security.provider; import java.security.Key; import java.util.Arrays; import java.util.Base64; @@ -7,6 +6,8 @@ import java.util.Date; import java.util.stream.Collectors; +import com.example.briefingapi.exception.JwtAuthenticationException; +import com.example.briefingcommon.common.exception.common.ErrorCode; import jakarta.servlet.http.HttpServletRequest; import org.slf4j.Logger; @@ -21,8 +22,6 @@ import org.springframework.stereotype.Component; import org.springframework.util.StringUtils; -import briefing.common.exception.JwtAuthenticationException; -import briefing.common.exception.common.ErrorCode; import io.jsonwebtoken.*; import io.jsonwebtoken.security.Keys; diff --git a/src/main/java/briefing/validation/annotation/CheckSameMember.java b/Briefing-Api/src/main/java/com/example/briefingapi/validation/annotation/CheckSameMember.java similarity index 79% rename from src/main/java/briefing/validation/annotation/CheckSameMember.java rename to Briefing-Api/src/main/java/com/example/briefingapi/validation/annotation/CheckSameMember.java index 14c2182..f4807f0 100644 --- a/src/main/java/briefing/validation/annotation/CheckSameMember.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/validation/annotation/CheckSameMember.java @@ -1,11 +1,12 @@ -package briefing.validation.annotation; +package com.example.briefingapi.validation.annotation; import java.lang.annotation.*; +import com.example.briefingapi.validation.validator.CheckSameMemberValidator; import jakarta.validation.Constraint; import jakarta.validation.Payload; -import briefing.validation.validator.CheckSameMemberValidator; + @Documented @Constraint(validatedBy = CheckSameMemberValidator.class) diff --git a/src/main/java/briefing/validation/validator/CheckSameMemberValidator.java b/Briefing-Api/src/main/java/com/example/briefingapi/validation/validator/CheckSameMemberValidator.java similarity index 90% rename from src/main/java/briefing/validation/validator/CheckSameMemberValidator.java rename to Briefing-Api/src/main/java/com/example/briefingapi/validation/validator/CheckSameMemberValidator.java index 38112a0..3278487 100644 --- a/src/main/java/briefing/validation/validator/CheckSameMemberValidator.java +++ b/Briefing-Api/src/main/java/com/example/briefingapi/validation/validator/CheckSameMemberValidator.java @@ -1,5 +1,7 @@ -package briefing.validation.validator; +package com.example.briefingapi.validation.validator; +import com.example.briefingcommon.common.exception.common.ErrorCode; +import com.example.briefingapi.validation.annotation.CheckSameMember; import jakarta.validation.ConstraintValidator; import jakarta.validation.ConstraintValidatorContext; @@ -8,8 +10,6 @@ import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.stereotype.Component; -import briefing.common.exception.common.ErrorCode; -import briefing.validation.annotation.CheckSameMember; import lombok.RequiredArgsConstructor; @Component diff --git a/Briefing-Api/src/main/resources/application.yml b/Briefing-Api/src/main/resources/application.yml new file mode 100644 index 0000000..bb1eaee --- /dev/null +++ b/Briefing-Api/src/main/resources/application.yml @@ -0,0 +1,168 @@ +# default profile +spring: + application: + name: briefing-dev + profiles: + active: dev + batch: + jdbc: + initialize-schema: always +springdoc: + swagger-ui: + tags-sorter: alpha # alpha: 알파벳 순 태그 정렬, method: HTTP Method 순 정렬 + operations-sorter: alpha # alpha: 알파벳 순 태그 정렬, method: HTTP Method 순 정렬 + cache: + disabled: true + use-fqn: true +swagger: + login: + id: ${SWAGGER_ID} + password : ${SWAGGER_PASS} +fcm: + key: ${FCM_KEY} + permit-flag : 1 + topic: + daily-push : dailyPush +--- +spring: + config: + activate: + on-profile: local + datasource: + username: ${aws.db.username} + password: ${aws.db.password} + url: ${aws.db.url} + driver-class-name: com.mysql.cj.jdbc.Driver + sql: + init: + mode: never + jpa: + properties: + hibernate: + dialect: org.hibernate.dialect.MySQLDialect + show_sql: true + format_sql: true + use_sql_comments: true + hbm2ddl: + auto: update + default_batch_fetch_size: 1000 + + data: + redis: + host: localhost + port: 6379 +eureka: + client: + service-url: + defaultZone: http://gateway.newsbreifing.store:8761/eureka + instance: + # 표기되는 규칙 변경 + instance-id: dev_briefing_server + hostname: dev.newsbreifing.store + ip-address: dev.newsbreifing.store + +jwt: + header: Authorization + # dev server + secret: ${JWT_SECRET} + authorities-key: authoritiesKey + access-token-validity-in-seconds: 1210000000 # 30 m + refresh-token-validity-in-seconds: 1210000000 # 14 d + +openai: + token: ${OPEN_API_TOKEN} + url: + chat: https://api.openai.com/v1/chat/completions + +--- +spring: + application: + name: dev + config: + activate: + on-profile: dev + datasource: + username: ${aws.db.username} + password: ${aws.db.password} + url: ${aws.db.url} + driver-class-name: com.mysql.cj.jdbc.Driver + sql: + init: + mode: never + jpa: + properties: + hibernate: + dialect: org.hibernate.dialect.MySQLDialect + # show_sql: true + # format_sql: true + use_sql_comments: true + hbm2ddl: + auto: update + default_batch_fetch_size: 1000 + data: + redis: + host: ${REDIS_URL} + port: 6379 +eureka: + instance: + # 표기되는 규칙 변경 + instance-id: dev_briefing_server + hostname: dev.newsbreifing.store + ip-address: dev.newsbreifing.store + client: + service-url: + defaultZone: http://gateway.newsbreifing.store:8761/eureka + +jwt: + header: Authorization + # dev server + secret: ${JWT_SECRET} + # secret : ${JWT_SECRET} + authorities-key: authoritiesKey + access-token-validity-in-seconds: 1210000000 # 30 m + refresh-token-validity-in-seconds: 1210000000 # 14 d + +openai: + token: ${OPEN_API_TOKEN} + url: + chat: https://api.openai.com/v1/chat/completions +--- +spring: + config: + activate: + on-profile: release + datasource: + username: ${aws.db.username} + password: ${aws.db.password} + url: ${aws.db.url} + driver-class-name: com.mysql.cj.jdbc.Driver + sql: + init: + mode: never + jpa: + properties: + hibernate: + dialect: org.hibernate.dialect.MySQLDialect + # show_sql: true + # format_sql: true + use_sql_comments: true + hbm2ddl: + auto: update + default_batch_fetch_size: 1000 + data: + redis: + host: ${release.redis.host} + port: 6379 +jwt: + header: Authorization + # dev server + secret: ${JWT_SECRET} + # secret : ${JWT_SECRET} + authorities-key: authoritiesKey + access-token-validity-in-seconds: 1210000000 # 30 m + refresh-token-validity-in-seconds: 1210000000 # 14 d + +openai: + token: ${OPEN_API_TOKEN} + url: + chat: https://api.openai.com/v1/chat/completions diff --git a/Briefing-Api/src/test/java/com/example/briefingapi/BriefingApiApplicationTests.java b/Briefing-Api/src/test/java/com/example/briefingapi/BriefingApiApplicationTests.java new file mode 100644 index 0000000..1a80c17 --- /dev/null +++ b/Briefing-Api/src/test/java/com/example/briefingapi/BriefingApiApplicationTests.java @@ -0,0 +1,13 @@ +package com.example.briefingapi; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class BriefingApiApplicationTests { + + @Test + void contextLoads() { + } + +} diff --git a/Briefing-Batch/build.gradle b/Briefing-Batch/build.gradle new file mode 100644 index 0000000..4be5d5c --- /dev/null +++ b/Briefing-Batch/build.gradle @@ -0,0 +1,17 @@ +//tasks.named('bootJar') { //빌드할 때 bootjar 파일로 하겠다는 의미 +// enabled = false +//} +// +//tasks.named('jar') { //빌드할 때 jar 파일로 하겠다는 의미 +// enabled = true +//} + +dependencies { + implementation 'org.springframework.boot:spring-boot-starter-batch' + testImplementation 'org.springframework.boot:spring-boot-starter-test' + testImplementation 'org.springframework.batch:spring-batch-test' +} + +tasks.named('test') { + useJUnitPlatform() +} diff --git a/Briefing-Batch/gradle/wrapper/gradle-wrapper.jar b/Briefing-Batch/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..d64cd49 Binary files /dev/null and b/Briefing-Batch/gradle/wrapper/gradle-wrapper.jar differ diff --git a/Briefing-Batch/gradle/wrapper/gradle-wrapper.properties b/Briefing-Batch/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..1af9e09 --- /dev/null +++ b/Briefing-Batch/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/Briefing-Batch/src/main/java/com/example/briefingbatch/BriefingBatchApplication.java b/Briefing-Batch/src/main/java/com/example/briefingbatch/BriefingBatchApplication.java new file mode 100644 index 0000000..2f94d64 --- /dev/null +++ b/Briefing-Batch/src/main/java/com/example/briefingbatch/BriefingBatchApplication.java @@ -0,0 +1,13 @@ +package com.example.briefingbatch; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class BriefingBatchApplication { + + public static void main(String[] args) { + SpringApplication.run(BriefingBatchApplication.class, args); + } + +} diff --git a/Briefing-Batch/src/main/resources/application.properties b/Briefing-Batch/src/main/resources/application.properties new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/Briefing-Batch/src/main/resources/application.properties @@ -0,0 +1 @@ + diff --git a/Briefing-Batch/src/test/java/com/example/briefingbatch/BriefingBatchApplicationTests.java b/Briefing-Batch/src/test/java/com/example/briefingbatch/BriefingBatchApplicationTests.java new file mode 100644 index 0000000..340d465 --- /dev/null +++ b/Briefing-Batch/src/test/java/com/example/briefingbatch/BriefingBatchApplicationTests.java @@ -0,0 +1,13 @@ +package com.example.briefingbatch; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class BriefingBatchApplicationTests { + + @Test + void contextLoads() { + } + +} diff --git a/Briefing-FCM/.gitignore b/Briefing-FCM/.gitignore new file mode 100644 index 0000000..c2065bc --- /dev/null +++ b/Briefing-FCM/.gitignore @@ -0,0 +1,37 @@ +HELP.md +.gradle +build/ +!gradle/wrapper/gradle-wrapper.jar +!**/src/main/**/build/ +!**/src/test/**/build/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache +bin/ +!**/src/main/**/bin/ +!**/src/test/**/bin/ + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr +out/ +!**/src/main/**/out/ +!**/src/test/**/out/ + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ + +### VS Code ### +.vscode/ diff --git a/Briefing-FCM/build.gradle b/Briefing-FCM/build.gradle new file mode 100644 index 0000000..9178dca --- /dev/null +++ b/Briefing-FCM/build.gradle @@ -0,0 +1,25 @@ +plugins { + id 'java' + id 'org.springframework.boot' version '3.2.2' + id 'io.spring.dependency-management' version '1.1.4' +} + +group = 'com.example' +version = '0.0.1-SNAPSHOT' + +java { + sourceCompatibility = '17' +} + +repositories { + mavenCentral() +} + +dependencies { + implementation 'org.springframework.boot:spring-boot-starter' + testImplementation 'org.springframework.boot:spring-boot-starter-test' +} + +tasks.named('test') { + useJUnitPlatform() +} diff --git a/Briefing-FCM/gradle/wrapper/gradle-wrapper.jar b/Briefing-FCM/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..d64cd49 Binary files /dev/null and b/Briefing-FCM/gradle/wrapper/gradle-wrapper.jar differ diff --git a/Briefing-FCM/gradle/wrapper/gradle-wrapper.properties b/Briefing-FCM/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..1af9e09 --- /dev/null +++ b/Briefing-FCM/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/Briefing-FCM/gradlew b/Briefing-FCM/gradlew new file mode 100644 index 0000000..1aa94a4 --- /dev/null +++ b/Briefing-FCM/gradlew @@ -0,0 +1,249 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/Briefing-FCM/gradlew.bat b/Briefing-FCM/gradlew.bat new file mode 100644 index 0000000..93e3f59 --- /dev/null +++ b/Briefing-FCM/gradlew.bat @@ -0,0 +1,92 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/Briefing-FCM/settings.gradle b/Briefing-FCM/settings.gradle new file mode 100644 index 0000000..f53aaa5 --- /dev/null +++ b/Briefing-FCM/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'Briefing-FCM' diff --git a/Briefing-FCM/src/main/java/com/example/briefingfcm/BriefingFcmApplication.java b/Briefing-FCM/src/main/java/com/example/briefingfcm/BriefingFcmApplication.java new file mode 100644 index 0000000..d7cb544 --- /dev/null +++ b/Briefing-FCM/src/main/java/com/example/briefingfcm/BriefingFcmApplication.java @@ -0,0 +1,13 @@ +package com.example.briefingfcm; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class BriefingFcmApplication { + + public static void main(String[] args) { + SpringApplication.run(BriefingFcmApplication.class, args); + } + +} diff --git a/Briefing-FCM/src/main/resources/application.properties b/Briefing-FCM/src/main/resources/application.properties new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/Briefing-FCM/src/main/resources/application.properties @@ -0,0 +1 @@ + diff --git a/Briefing-FCM/src/test/java/com/example/briefingfcm/BriefingFcmApplicationTests.java b/Briefing-FCM/src/test/java/com/example/briefingfcm/BriefingFcmApplicationTests.java new file mode 100644 index 0000000..050f969 --- /dev/null +++ b/Briefing-FCM/src/test/java/com/example/briefingfcm/BriefingFcmApplicationTests.java @@ -0,0 +1,13 @@ +package com.example.briefingfcm; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class BriefingFcmApplicationTests { + + @Test + void contextLoads() { + } + +} diff --git a/build.gradle b/build.gradle index a209aaa..846c845 100644 --- a/build.gradle +++ b/build.gradle @@ -5,11 +5,15 @@ plugins { id 'com.diffplug.spotless' version '6.23.3' // Spotless 플러그인 } -group = 'briefing.info' -version = '0.0.1-SNAPSHOT' - -java { +allprojects { + group = 'com.chooz' + version = '0.0.1-SNAPSHOT' sourceCompatibility = '17' + + repositories { + mavenCentral() + } + } configurations { @@ -18,44 +22,31 @@ configurations { } } -repositories { - mavenCentral() -} +subprojects { // 각 모듈에 적용할 공통 설정 + apply plugin: 'java' + + // build.gradle에서 api() 를 사용하려면 java-library 사용 + apply plugin: 'java-library' + + apply plugin: 'org.springframework.boot' + apply plugin: 'io.spring.dependency-management' + + dependencies { // 롬복은 공통적으로 사용하는 의존성이니 여기서 끌어다 사용 + compileOnly 'org.projectlombok:lombok' + annotationProcessor 'org.projectlombok:lombok' + } + + tasks.named('bootJar') { //빌드할 때 bootjar 파일로 하겠다는 의미 + enabled = false + } + + tasks.named('jar') { //빌드할 때 jar 파일로 하겠다는 의미 + enabled = true + } -dependencies { - implementation 'org.springframework.boot:spring-boot-starter-data-jpa' - - // eureka client 설정 - implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client' - - // querydsl - // == 스프링 부트 3.0 이상 == - implementation 'com.querydsl:querydsl-jpa:5.0.0:jakarta' - annotationProcessor "com.querydsl:querydsl-apt:${dependencyManagement.importedProperties['querydsl.version']}:jakarta" - annotationProcessor "jakarta.annotation:jakarta.annotation-api" - annotationProcessor "jakarta.persistence:jakarta.persistence-api" - - implementation 'org.springframework.boot:spring-boot-starter-validation' - implementation 'org.springframework.boot:spring-boot-starter-web' - implementation 'org.springframework.boot:spring-boot-starter-data-redis:2.3.1.RELEASE' - implementation 'org.springframework.boot:spring-boot-starter-security' - implementation 'io.jsonwebtoken:jjwt-api:0.11.5' - implementation 'io.springfox:springfox-swagger2:2.9.2' - implementation 'io.springfox:springfox-swagger-ui:2.9.2' - implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.2' - implementation 'org.springframework.cloud:spring-cloud-starter-openfeign' - implementation 'com.googlecode.json-simple:json-simple:1.1.1' - implementation 'mysql:mysql-connector-java' // 추가 작성 - - implementation platform("org.springframework.cloud:spring-cloud-dependencies:2022.0.3") - compileOnly 'org.projectlombok:lombok' - runtimeOnly 'com.h2database:h2' -// runtimeOnly 'org.postgresql:postgresql' -// runtimeOnly 'com.mysql:mysql-connector-j' - runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.11.5' - runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.11.5' - annotationProcessor 'org.projectlombok:lombok' - testImplementation 'org.springframework.boot:spring-boot-starter-test' + tasks.named('test') { + useJUnitPlatform() + } } def querydslSrcDir = 'src/main/generated' @@ -68,10 +59,6 @@ tasks.withType(JavaCompile) { options.generatedSourceOutputDirectory = file(querydslSrcDir) } -tasks.named('test') { - useJUnitPlatform() -} - /* compileJava 태스크가 실행되기 전에 spotlessApply 태스크가 먼저 실행되도록 구성 diff --git a/core/Briefing-Common/build.gradle b/core/Briefing-Common/build.gradle new file mode 100644 index 0000000..68b8e7b --- /dev/null +++ b/core/Briefing-Common/build.gradle @@ -0,0 +1,38 @@ +bootJar { + enabled = false +} + +jar { + enabled = true +} + +dependencies { + + // querydsl + // == 스프링 부트 3.0 이상 == + implementation 'com.querydsl:querydsl-jpa:5.0.0:jakarta' + annotationProcessor "com.querydsl:querydsl-apt:${dependencyManagement.importedProperties['querydsl.version']}:jakarta" + annotationProcessor "jakarta.annotation:jakarta.annotation-api" + annotationProcessor "jakarta.persistence:jakarta.persistence-api" + + implementation 'org.springframework.boot:spring-boot-starter' + testImplementation 'org.springframework.boot:spring-boot-starter-test' + implementation 'org.springframework.boot:spring-boot-starter-data-jpa' + implementation 'org.springframework.boot:spring-boot-starter-data-redis:2.3.1.RELEASE' + implementation 'org.springframework.boot:spring-boot-starter-web' + implementation 'org.springframework.boot:spring-boot-starter-validation' +} + +tasks.named('test') { + useJUnitPlatform() +} + +def querydslSrcDir = 'src/main/generated' + +clean { + delete file(querydslSrcDir) +} + +tasks.withType(JavaCompile) { + options.generatedSourceOutputDirectory = file(querydslSrcDir) +} \ No newline at end of file diff --git a/core/Briefing-Common/gradle/wrapper/gradle-wrapper.jar b/core/Briefing-Common/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..d64cd49 Binary files /dev/null and b/core/Briefing-Common/gradle/wrapper/gradle-wrapper.jar differ diff --git a/core/Briefing-Common/gradle/wrapper/gradle-wrapper.properties b/core/Briefing-Common/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..1af9e09 --- /dev/null +++ b/core/Briefing-Common/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/src/main/generated/briefing/briefing/domain/QArticle.java b/core/Briefing-Common/src/main/generated/com/example/briefingcommon/entity/QArticle.java similarity index 84% rename from src/main/generated/briefing/briefing/domain/QArticle.java rename to core/Briefing-Common/src/main/generated/com/example/briefingcommon/entity/QArticle.java index c515f8e..6f97129 100644 --- a/src/main/generated/briefing/briefing/domain/QArticle.java +++ b/core/Briefing-Common/src/main/generated/com/example/briefingcommon/entity/QArticle.java @@ -1,4 +1,4 @@ -package briefing.briefing.domain; +package com.example.briefingcommon.entity; import static com.querydsl.core.types.PathMetadataFactory.*; @@ -15,11 +15,11 @@ @Generated("com.querydsl.codegen.DefaultEntitySerializer") public class QArticle extends EntityPathBase
{ - private static final long serialVersionUID = -598074260L; + private static final long serialVersionUID = 426734549L; public static final QArticle article = new QArticle("article"); - public final briefing.common.domain.QBaseDateTimeEntity _super = new briefing.common.domain.QBaseDateTimeEntity(this); + public final QBaseDateTimeEntity _super = new QBaseDateTimeEntity(this); //inherited public final DateTimePath createdAt = _super.createdAt; diff --git a/src/main/generated/briefing/common/domain/QBaseDateTimeEntity.java b/core/Briefing-Common/src/main/generated/com/example/briefingcommon/entity/QBaseDateTimeEntity.java similarity index 91% rename from src/main/generated/briefing/common/domain/QBaseDateTimeEntity.java rename to core/Briefing-Common/src/main/generated/com/example/briefingcommon/entity/QBaseDateTimeEntity.java index aadba51..0e6bc71 100644 --- a/src/main/generated/briefing/common/domain/QBaseDateTimeEntity.java +++ b/core/Briefing-Common/src/main/generated/com/example/briefingcommon/entity/QBaseDateTimeEntity.java @@ -1,4 +1,4 @@ -package briefing.common.domain; +package com.example.briefingcommon.entity; import static com.querydsl.core.types.PathMetadataFactory.*; @@ -15,7 +15,7 @@ @Generated("com.querydsl.codegen.DefaultSupertypeSerializer") public class QBaseDateTimeEntity extends EntityPathBase { - private static final long serialVersionUID = -1472697380L; + private static final long serialVersionUID = 1973246032L; public static final QBaseDateTimeEntity baseDateTimeEntity = new QBaseDateTimeEntity("baseDateTimeEntity"); diff --git a/src/main/generated/briefing/briefing/domain/QBriefing.java b/core/Briefing-Common/src/main/generated/com/example/briefingcommon/entity/QBriefing.java similarity index 70% rename from src/main/generated/briefing/briefing/domain/QBriefing.java rename to core/Briefing-Common/src/main/generated/com/example/briefingcommon/entity/QBriefing.java index ffcdca6..b63bd7d 100644 --- a/src/main/generated/briefing/briefing/domain/QBriefing.java +++ b/core/Briefing-Common/src/main/generated/com/example/briefingcommon/entity/QBriefing.java @@ -1,4 +1,4 @@ -package briefing.briefing.domain; +package com.example.briefingcommon.entity; import static com.querydsl.core.types.PathMetadataFactory.*; @@ -16,11 +16,11 @@ @Generated("com.querydsl.codegen.DefaultEntitySerializer") public class QBriefing extends EntityPathBase { - private static final long serialVersionUID = 63849586L; + private static final long serialVersionUID = 1768151593L; public static final QBriefing briefing = new QBriefing("briefing"); - public final briefing.common.domain.QBaseDateTimeEntity _super = new briefing.common.domain.QBaseDateTimeEntity(this); + public final QBaseDateTimeEntity _super = new QBaseDateTimeEntity(this); public final ListPath briefingArticles = this.createList("briefingArticles", BriefingArticle.class, QBriefingArticle.class, PathInits.DIRECT2); @@ -29,7 +29,7 @@ public class QBriefing extends EntityPathBase { //inherited public final DateTimePath createdAt = _super.createdAt; - public final EnumPath gptModel = createEnum("gptModel", briefing.common.enums.GptModel.class); + public final EnumPath gptModel = createEnum("gptModel", com.example.briefingcommon.entity.enums.GptModel.class); public final NumberPath id = createNumber("id", Long.class); @@ -37,11 +37,11 @@ public class QBriefing extends EntityPathBase { public final StringPath subtitle = createString("subtitle"); - public final EnumPath timeOfDay = createEnum("timeOfDay", briefing.common.enums.TimeOfDay.class); + public final EnumPath timeOfDay = createEnum("timeOfDay", com.example.briefingcommon.entity.enums.TimeOfDay.class); public final StringPath title = createString("title"); - public final EnumPath type = createEnum("type", briefing.common.enums.BriefingType.class); + public final EnumPath type = createEnum("type", com.example.briefingcommon.entity.enums.BriefingType.class); //inherited public final DateTimePath updatedAt = _super.updatedAt; diff --git a/src/main/generated/briefing/briefing/domain/QBriefingArticle.java b/core/Briefing-Common/src/main/generated/com/example/briefingcommon/entity/QBriefingArticle.java similarity index 89% rename from src/main/generated/briefing/briefing/domain/QBriefingArticle.java rename to core/Briefing-Common/src/main/generated/com/example/briefingcommon/entity/QBriefingArticle.java index c9600b7..9e8782c 100644 --- a/src/main/generated/briefing/briefing/domain/QBriefingArticle.java +++ b/core/Briefing-Common/src/main/generated/com/example/briefingcommon/entity/QBriefingArticle.java @@ -1,4 +1,4 @@ -package briefing.briefing.domain; +package com.example.briefingcommon.entity; import static com.querydsl.core.types.PathMetadataFactory.*; @@ -16,13 +16,13 @@ @Generated("com.querydsl.codegen.DefaultEntitySerializer") public class QBriefingArticle extends EntityPathBase { - private static final long serialVersionUID = 37002276L; + private static final long serialVersionUID = 1813281421L; private static final PathInits INITS = PathInits.DIRECT2; public static final QBriefingArticle briefingArticle = new QBriefingArticle("briefingArticle"); - public final briefing.common.domain.QBaseDateTimeEntity _super = new briefing.common.domain.QBaseDateTimeEntity(this); + public final QBaseDateTimeEntity _super = new QBaseDateTimeEntity(this); public final QArticle article; diff --git a/core/Briefing-Common/src/main/generated/com/example/briefingcommon/entity/QFcmToken.java b/core/Briefing-Common/src/main/generated/com/example/briefingcommon/entity/QFcmToken.java new file mode 100644 index 0000000..f1591c4 --- /dev/null +++ b/core/Briefing-Common/src/main/generated/com/example/briefingcommon/entity/QFcmToken.java @@ -0,0 +1,53 @@ +package com.example.briefingcommon.entity; + +import static com.querydsl.core.types.PathMetadataFactory.*; + +import com.querydsl.core.types.dsl.*; + +import com.querydsl.core.types.PathMetadata; +import javax.annotation.processing.Generated; +import com.querydsl.core.types.Path; +import com.querydsl.core.types.dsl.PathInits; + + +/** + * QFcmToken is a Querydsl query type for FcmToken + */ +@Generated("com.querydsl.codegen.DefaultEntitySerializer") +public class QFcmToken extends EntityPathBase { + + private static final long serialVersionUID = -179108470L; + + private static final PathInits INITS = PathInits.DIRECT2; + + public static final QFcmToken fcmToken = new QFcmToken("fcmToken"); + + public final NumberPath id = createNumber("id", Long.class); + + public final QMember member; + + public final StringPath token = createString("token"); + + public QFcmToken(String variable) { + this(FcmToken.class, forVariable(variable), INITS); + } + + public QFcmToken(Path path) { + this(path.getType(), path.getMetadata(), PathInits.getFor(path.getMetadata(), INITS)); + } + + public QFcmToken(PathMetadata metadata) { + this(metadata, PathInits.getFor(metadata, INITS)); + } + + public QFcmToken(PathMetadata metadata, PathInits inits) { + this(FcmToken.class, metadata, inits); + } + + public QFcmToken(Class type, PathMetadata metadata, PathInits inits) { + super(type, metadata, inits); + this.member = inits.isInitialized("member") ? new QMember(forProperty("member")) : null; + } + +} + diff --git a/src/main/generated/briefing/member/domain/QMember.java b/core/Briefing-Common/src/main/generated/com/example/briefingcommon/entity/QMember.java similarity index 59% rename from src/main/generated/briefing/member/domain/QMember.java rename to core/Briefing-Common/src/main/generated/com/example/briefingcommon/entity/QMember.java index 2113fc3..2a3e6de 100644 --- a/src/main/generated/briefing/member/domain/QMember.java +++ b/core/Briefing-Common/src/main/generated/com/example/briefingcommon/entity/QMember.java @@ -1,4 +1,4 @@ -package briefing.member.domain; +package com.example.briefingcommon.entity; import static com.querydsl.core.types.PathMetadataFactory.*; @@ -16,11 +16,11 @@ @Generated("com.querydsl.codegen.DefaultEntitySerializer") public class QMember extends EntityPathBase { - private static final long serialVersionUID = 2051544022L; + private static final long serialVersionUID = 1037831131L; public static final QMember member = new QMember("member1"); - public final briefing.common.domain.QBaseDateTimeEntity _super = new briefing.common.domain.QBaseDateTimeEntity(this); + public final QBaseDateTimeEntity _super = new QBaseDateTimeEntity(this); //inherited public final DateTimePath createdAt = _super.createdAt; @@ -31,15 +31,15 @@ public class QMember extends EntityPathBase { public final StringPath profileImgUrl = createString("profileImgUrl"); - public final EnumPath role = createEnum("role", briefing.common.enums.MemberRole.class); + public final EnumPath role = createEnum("role", com.example.briefingcommon.entity.enums.MemberRole.class); - public final ListPath scrapList = this.createList("scrapList", briefing.scrap.domain.Scrap.class, briefing.scrap.domain.QScrap.class, PathInits.DIRECT2); + public final ListPath scrapList = this.createList("scrapList", Scrap.class, QScrap.class, PathInits.DIRECT2); public final StringPath socialId = createString("socialId"); - public final EnumPath socialType = createEnum("socialType", briefing.common.enums.SocialType.class); + public final EnumPath socialType = createEnum("socialType", com.example.briefingcommon.entity.enums.SocialType.class); - public final EnumPath status = createEnum("status", briefing.common.enums.MemberStatus.class); + public final EnumPath status = createEnum("status", com.example.briefingcommon.entity.enums.MemberStatus.class); //inherited public final DateTimePath updatedAt = _super.updatedAt; diff --git a/src/main/generated/briefing/scrap/domain/QScrap.java b/core/Briefing-Common/src/main/generated/com/example/briefingcommon/entity/QScrap.java similarity index 71% rename from src/main/generated/briefing/scrap/domain/QScrap.java rename to core/Briefing-Common/src/main/generated/com/example/briefingcommon/entity/QScrap.java index e0c5e17..a8524bc 100644 --- a/src/main/generated/briefing/scrap/domain/QScrap.java +++ b/core/Briefing-Common/src/main/generated/com/example/briefingcommon/entity/QScrap.java @@ -1,4 +1,4 @@ -package briefing.scrap.domain; +package com.example.briefingcommon.entity; import static com.querydsl.core.types.PathMetadataFactory.*; @@ -16,22 +16,22 @@ @Generated("com.querydsl.codegen.DefaultEntitySerializer") public class QScrap extends EntityPathBase { - private static final long serialVersionUID = -881090678L; + private static final long serialVersionUID = -930866576L; private static final PathInits INITS = PathInits.DIRECT2; public static final QScrap scrap = new QScrap("scrap"); - public final briefing.common.domain.QBaseDateTimeEntity _super = new briefing.common.domain.QBaseDateTimeEntity(this); + public final QBaseDateTimeEntity _super = new QBaseDateTimeEntity(this); - public final briefing.briefing.domain.QBriefing briefing; + public final QBriefing briefing; //inherited public final DateTimePath createdAt = _super.createdAt; public final NumberPath id = createNumber("id", Long.class); - public final briefing.member.domain.QMember member; + public final QMember member; //inherited public final DateTimePath updatedAt = _super.updatedAt; @@ -54,8 +54,8 @@ public QScrap(PathMetadata metadata, PathInits inits) { public QScrap(Class type, PathMetadata metadata, PathInits inits) { super(type, metadata, inits); - this.briefing = inits.isInitialized("briefing") ? new briefing.briefing.domain.QBriefing(forProperty("briefing")) : null; - this.member = inits.isInitialized("member") ? new briefing.member.domain.QMember(forProperty("member")) : null; + this.briefing = inits.isInitialized("briefing") ? new QBriefing(forProperty("briefing")) : null; + this.member = inits.isInitialized("member") ? new QMember(forProperty("member")) : null; } } diff --git a/core/Briefing-Common/src/main/java/com/example/briefingcommon/DomainPackageLocation.java b/core/Briefing-Common/src/main/java/com/example/briefingcommon/DomainPackageLocation.java new file mode 100644 index 0000000..2803cf9 --- /dev/null +++ b/core/Briefing-Common/src/main/java/com/example/briefingcommon/DomainPackageLocation.java @@ -0,0 +1,4 @@ +package com.example.briefingcommon; + +public interface DomainPackageLocation { +} diff --git a/core/Briefing-Common/src/main/java/com/example/briefingcommon/JpaConfig.java b/core/Briefing-Common/src/main/java/com/example/briefingcommon/JpaConfig.java new file mode 100644 index 0000000..c950dbb --- /dev/null +++ b/core/Briefing-Common/src/main/java/com/example/briefingcommon/JpaConfig.java @@ -0,0 +1,13 @@ +package com.example.briefingcommon; + +import org.springframework.boot.autoconfigure.domain.EntityScan; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.data.jpa.repository.config.EnableJpaAuditing; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; + +@Configuration +@EnableJpaAuditing +@EntityScan(basePackageClasses = DomainPackageLocation.class) +@EnableJpaRepositories(basePackageClasses = DomainPackageLocation.class) +public class JpaConfig {} diff --git a/src/main/java/briefing/config/QueryDslConfig.java b/core/Briefing-Common/src/main/java/com/example/briefingcommon/QueryDslConfig.java similarity index 81% rename from src/main/java/briefing/config/QueryDslConfig.java rename to core/Briefing-Common/src/main/java/com/example/briefingcommon/QueryDslConfig.java index 4d4db3b..3233f53 100644 --- a/src/main/java/briefing/config/QueryDslConfig.java +++ b/core/Briefing-Common/src/main/java/com/example/briefingcommon/QueryDslConfig.java @@ -1,7 +1,8 @@ -package briefing.config; +package com.example.briefingcommon; import jakarta.persistence.EntityManager; +import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/core/Briefing-Common/src/main/java/com/example/briefingcommon/common/exception/AppleOAuthException.java b/core/Briefing-Common/src/main/java/com/example/briefingcommon/common/exception/AppleOAuthException.java new file mode 100644 index 0000000..a628b92 --- /dev/null +++ b/core/Briefing-Common/src/main/java/com/example/briefingcommon/common/exception/AppleOAuthException.java @@ -0,0 +1,11 @@ +package com.example.briefingcommon.common.exception; + + +import com.example.briefingcommon.common.exception.common.ErrorCode; +import com.example.briefingcommon.common.exception.common.GeneralException; + +public class AppleOAuthException extends GeneralException { + public AppleOAuthException(ErrorCode errorCode) { + super(errorCode); + } +} diff --git a/core/Briefing-Common/src/main/java/com/example/briefingcommon/common/exception/BriefingException.java b/core/Briefing-Common/src/main/java/com/example/briefingcommon/common/exception/BriefingException.java new file mode 100644 index 0000000..17d4335 --- /dev/null +++ b/core/Briefing-Common/src/main/java/com/example/briefingcommon/common/exception/BriefingException.java @@ -0,0 +1,11 @@ +package com.example.briefingcommon.common.exception; + + +import com.example.briefingcommon.common.exception.common.ErrorCode; +import com.example.briefingcommon.common.exception.common.GeneralException; + +public class BriefingException extends GeneralException { + public BriefingException(ErrorCode errorCode) { + super(errorCode); + } +} diff --git a/core/Briefing-Common/src/main/java/com/example/briefingcommon/common/exception/ChattingException.java b/core/Briefing-Common/src/main/java/com/example/briefingcommon/common/exception/ChattingException.java new file mode 100644 index 0000000..288a9ac --- /dev/null +++ b/core/Briefing-Common/src/main/java/com/example/briefingcommon/common/exception/ChattingException.java @@ -0,0 +1,11 @@ +package com.example.briefingcommon.common.exception; + + +import com.example.briefingcommon.common.exception.common.ErrorCode; +import com.example.briefingcommon.common.exception.common.GeneralException; + +public class ChattingException extends GeneralException { + public ChattingException(ErrorCode errorCode) { + super(errorCode); + } +} diff --git a/core/Briefing-Common/src/main/java/com/example/briefingcommon/common/exception/CustomFeignClientException.java b/core/Briefing-Common/src/main/java/com/example/briefingcommon/common/exception/CustomFeignClientException.java new file mode 100644 index 0000000..ba6c2b2 --- /dev/null +++ b/core/Briefing-Common/src/main/java/com/example/briefingcommon/common/exception/CustomFeignClientException.java @@ -0,0 +1,12 @@ +package com.example.briefingcommon.common.exception; + + +import com.example.briefingcommon.common.exception.common.ErrorCode; +import com.example.briefingcommon.common.exception.common.GeneralException; + +public class CustomFeignClientException extends GeneralException { + + public CustomFeignClientException(ErrorCode errorCode) { + super(errorCode); + } +} diff --git a/core/Briefing-Common/src/main/java/com/example/briefingcommon/common/exception/MemberException.java b/core/Briefing-Common/src/main/java/com/example/briefingcommon/common/exception/MemberException.java new file mode 100644 index 0000000..daa0c6c --- /dev/null +++ b/core/Briefing-Common/src/main/java/com/example/briefingcommon/common/exception/MemberException.java @@ -0,0 +1,10 @@ +package com.example.briefingcommon.common.exception; + +import com.example.briefingcommon.common.exception.common.ErrorCode; +import com.example.briefingcommon.common.exception.common.GeneralException; + +public class MemberException extends GeneralException { + public MemberException(ErrorCode errorCode) { + super(errorCode); + } +} diff --git a/core/Briefing-Common/src/main/java/com/example/briefingcommon/common/exception/RefreshTokenException.java b/core/Briefing-Common/src/main/java/com/example/briefingcommon/common/exception/RefreshTokenException.java new file mode 100644 index 0000000..372682c --- /dev/null +++ b/core/Briefing-Common/src/main/java/com/example/briefingcommon/common/exception/RefreshTokenException.java @@ -0,0 +1,10 @@ +package com.example.briefingcommon.common.exception; + +import com.example.briefingcommon.common.exception.common.ErrorCode; +import com.example.briefingcommon.common.exception.common.GeneralException; + +public class RefreshTokenException extends GeneralException { + public RefreshTokenException(ErrorCode errorCode) { + super(errorCode); + } +} diff --git a/core/Briefing-Common/src/main/java/com/example/briefingcommon/common/exception/ScrapException.java b/core/Briefing-Common/src/main/java/com/example/briefingcommon/common/exception/ScrapException.java new file mode 100644 index 0000000..3b4ef83 --- /dev/null +++ b/core/Briefing-Common/src/main/java/com/example/briefingcommon/common/exception/ScrapException.java @@ -0,0 +1,11 @@ +package com.example.briefingcommon.common.exception; + + +import com.example.briefingcommon.common.exception.common.ErrorCode; +import com.example.briefingcommon.common.exception.common.GeneralException; + +public class ScrapException extends GeneralException { + public ScrapException(ErrorCode errorCode) { + super(errorCode); + } +} diff --git a/src/main/java/briefing/common/exception/common/ApiErrorResult.java b/core/Briefing-Common/src/main/java/com/example/briefingcommon/common/exception/common/ApiErrorResult.java similarity index 91% rename from src/main/java/briefing/common/exception/common/ApiErrorResult.java rename to core/Briefing-Common/src/main/java/com/example/briefingcommon/common/exception/common/ApiErrorResult.java index 387f660..8d819c4 100644 --- a/src/main/java/briefing/common/exception/common/ApiErrorResult.java +++ b/core/Briefing-Common/src/main/java/com/example/briefingcommon/common/exception/common/ApiErrorResult.java @@ -1,4 +1,5 @@ -package briefing.common.exception.common; +package com.example.briefingcommon.common.exception.common; + import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; diff --git a/src/main/java/briefing/common/exception/common/BaseException.java b/core/Briefing-Common/src/main/java/com/example/briefingcommon/common/exception/common/BaseException.java similarity index 77% rename from src/main/java/briefing/common/exception/common/BaseException.java rename to core/Briefing-Common/src/main/java/com/example/briefingcommon/common/exception/common/BaseException.java index f919fcb..45a98ac 100644 --- a/src/main/java/briefing/common/exception/common/BaseException.java +++ b/core/Briefing-Common/src/main/java/com/example/briefingcommon/common/exception/common/BaseException.java @@ -1,4 +1,5 @@ -package briefing.common.exception.common; +package com.example.briefingcommon.common.exception.common; + public abstract class BaseException extends RuntimeException { diff --git a/src/main/java/briefing/common/exception/common/BaseExceptionType.java b/core/Briefing-Common/src/main/java/com/example/briefingcommon/common/exception/common/BaseExceptionType.java similarity index 68% rename from src/main/java/briefing/common/exception/common/BaseExceptionType.java rename to core/Briefing-Common/src/main/java/com/example/briefingcommon/common/exception/common/BaseExceptionType.java index d962b9d..958a640 100644 --- a/src/main/java/briefing/common/exception/common/BaseExceptionType.java +++ b/core/Briefing-Common/src/main/java/com/example/briefingcommon/common/exception/common/BaseExceptionType.java @@ -1,4 +1,5 @@ -package briefing.common.exception.common; +package com.example.briefingcommon.common.exception.common; + import org.springframework.http.HttpStatus; diff --git a/core/Briefing-Common/src/main/java/com/example/briefingcommon/common/exception/common/ErrorCode.java b/core/Briefing-Common/src/main/java/com/example/briefingcommon/common/exception/common/ErrorCode.java new file mode 100644 index 0000000..745792e --- /dev/null +++ b/core/Briefing-Common/src/main/java/com/example/briefingcommon/common/exception/common/ErrorCode.java @@ -0,0 +1,108 @@ +package com.example.briefingcommon.common.exception.common; + + +import static org.springframework.http.HttpStatus.*; + +import java.util.Arrays; +import java.util.Optional; +import java.util.function.Predicate; + +import org.springframework.http.HttpStatus; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@RequiredArgsConstructor +public enum ErrorCode { + _INTERNAL_SERVER_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, "COMMON000", "서버 에러, 관리자에게 문의 바랍니다."), + _BAD_REQUEST(HttpStatus.BAD_REQUEST, "COMMON001", "잘못된 요청입니다."), + _UNAUTHORIZED(HttpStatus.UNAUTHORIZED, "COMMON002", "로그인이 필요합니다."), + _METHOD_NOT_ALLOWED(HttpStatus.METHOD_NOT_ALLOWED, "COMMON003", "지원하지 않는 Http Method 입니다."), + _FORBIDDEN(HttpStatus.FORBIDDEN, "COMMON004", "금지된 요청입니다."), + + // 인증 관련 에러 + ForbiddenException(HttpStatus.UNAUTHORIZED, "AUTH002", "해당 요청에 대한 권한이 없습니다."), + UNAUTHORIZED_EXCEPTION(HttpStatus.UNAUTHORIZED, "AUTH003", "로그인 후 이용가능합니다. 토큰을 입력해 주세요"), + EXPIRED_JWT_EXCEPTION(HttpStatus.UNAUTHORIZED, "AUTH004", "기존 토큰이 만료되었습니다. 토큰을 재발급해주세요."), + RELOGIN_EXCEPTION(HttpStatus.UNAUTHORIZED, "AUTH005", "모든 토큰이 만료되었습니다. 다시 로그인해주세요."), + INVALID_TOKEN_EXCEPTION(HttpStatus.UNAUTHORIZED, "AUTH006", "토큰이 올바르지 않습니다."), + HIJACK_JWT_TOKEN_EXCEPTION(HttpStatus.UNAUTHORIZED, "AUTH007", "탈취된(로그아웃 된) 토큰입니다 다시 로그인 해주세요."), + INVALID_REFRESH_TOKEN(HttpStatus.BAD_REQUEST, "AUTH009", "리프레쉬 토큰이 유효하지 않습니다. 다시 로그인 해주세요"), + + // oauth 에러 + APPLE_BAD_REQUEST(HttpStatus.BAD_REQUEST, "OAUTH001", "애플 토큰이 잘못되었습니다."), + APPLE_SERVER_ERROR(HttpStatus.FORBIDDEN, "OAUTH002", "애플 서버와 통신에 실패 하였습니다."), + FAIL_TO_MAKE_APPLE_PUBLIC_KEY(HttpStatus.BAD_REQUEST, "OAUTH003", "새로운 애플 공개키 생성에 실패하였습니다."), + + // feign client 에러 + FEIGN_BAD_REQUEST(HttpStatus.BAD_REQUEST, "FEIGN_400_1", "Feign server bad request"), + FEIGN_UNAUTHORIZED(HttpStatus.BAD_REQUEST, "FEIGN_400_2", "Feign server unauthorized"), + FEIGN_FORBIDDEN(HttpStatus.BAD_REQUEST, "FEIGN_400_3", "Feign server forbidden"), + FEIGN_EXPIRED_TOKEN(HttpStatus.BAD_REQUEST, "FEIGN_400_4", "Feign server expired token"), + FEIGN_NOT_FOUND(HttpStatus.BAD_REQUEST, "FEIGN_400_5", "Feign server not found error"), + FEIGN_INTERNAL_SERVER_ERROR(HttpStatus.BAD_REQUEST, "FEIGN_400_6", "Feign server internal server error"), + FEIGN_METHOD_NOT_ALLOWED(HttpStatus.BAD_REQUEST, "FEIGN_400_7", "Feign server method not allowed"), + FEIGN_SERVER_ERROR(HttpStatus.BAD_REQUEST, "FEIGN_500", "Feign server error"), + + // member 관련 에러 + + MEMBER_NOT_FOUND(HttpStatus.BAD_REQUEST, "MEMBER_001", "사용자가 없습니다"), + MEMBER_NOT_SAME(HttpStatus.BAD_REQUEST, "MEMBER_002", "로그인 된 사용자와 대상 사용자가 일치하지 않습니다."), + + // member 에러 + + // scrap 에러 + SCRAP_ALREADY_EXISTS(HttpStatus.CONFLICT, "SCRAP_001", "이미 스크랩했습니다."), + SCRAP_NOT_FOUND(HttpStatus.NOT_FOUND, "SCRAP_002", "존재하지 않는 스크랩입니다."), + DUPLICATE_SCRAP(HttpStatus.CONFLICT, "SCRAP_003", "중복된 스크랩 요청입니다."), + + // briefing 에러 + NOT_FOUND_BRIEFING(HttpStatus.NOT_FOUND, "BRIEFING_001", "브리핑이 존재하지 않습니다."), + NOT_FOUND_TYPE(HttpStatus.BAD_REQUEST, "BRIEFING_002", "해당하는 type을 찾을 수 없습니다."), + + // chatting 에러 + + NOT_FOUND_CHATTING(HttpStatus.NOT_FOUND, "CHATTING_001", "해당하는 채팅을 찾을 수 없습니다."), + LAST_MESSAGE_NOT_EXIST(HttpStatus.BAD_REQUEST, "CHATTING_002", "마지막 메시지를 찾을 수 없습니다."), + BAD_LAST_MESSAGE_ROLE(HttpStatus.BAD_REQUEST, "CHATTING_003", "마지막 메시지의 역할이 user가 아닙니다."), + CAN_NOT_EMPTY_CONTENT(HttpStatus.BAD_REQUEST, "CHATTING_004", "content가 비어있습니다."), + NOT_FOUND_ROLE(HttpStatus.BAD_REQUEST, "CHATTING_005", "해당하는 role을 찾을 수 없습니다."), + NOT_FOUND_MODEL(HttpStatus.BAD_REQUEST, "CHATTING_006", "해당하는 mode을 찾을 수 없습니다."); + + private final HttpStatus httpStatus; + private final String code; + private final String message; + + public String getMessage(Throwable e) { + return this.getMessage(this.getMessage() + " - " + e.getMessage()); + // 결과 예시 - "Validation error - Reason why it isn't valid" + } + + public String getMessage(String message) { + return Optional.ofNullable(message) + .filter(Predicate.not(String::isBlank)) + .orElse(this.getMessage()); + } + + public static ErrorCode valueOf(HttpStatus httpStatus) { + if (httpStatus == null) { + throw new GeneralException("HttpStatus is null."); + } + + return Arrays.stream(values()) + .filter(errorCode -> errorCode.getHttpStatus() == httpStatus) + .findFirst() + .orElseGet( + () -> { + if (httpStatus.is4xxClientError()) { + return ErrorCode._BAD_REQUEST; + } else return ErrorCode._INTERNAL_SERVER_ERROR; + }); + } + + // @Override + // public String toString() { + // return String.format("%s (%d)", this.name(), this.getCode()); + // } +} diff --git a/src/main/java/briefing/common/exception/common/GeneralException.java b/core/Briefing-Common/src/main/java/com/example/briefingcommon/common/exception/common/GeneralException.java similarity index 96% rename from src/main/java/briefing/common/exception/common/GeneralException.java rename to core/Briefing-Common/src/main/java/com/example/briefingcommon/common/exception/common/GeneralException.java index 0fef5fd..8834799 100644 --- a/src/main/java/briefing/common/exception/common/GeneralException.java +++ b/core/Briefing-Common/src/main/java/com/example/briefingcommon/common/exception/common/GeneralException.java @@ -1,4 +1,5 @@ -package briefing.common.exception.common; +package com.example.briefingcommon.common.exception.common; + import lombok.Getter; diff --git a/src/main/java/briefing/common/presentation/converter/APIVersionRequestConverter.java b/core/Briefing-Common/src/main/java/com/example/briefingcommon/common/presentation/converter/APIVersionRequestConverter.java similarity index 70% rename from src/main/java/briefing/common/presentation/converter/APIVersionRequestConverter.java rename to core/Briefing-Common/src/main/java/com/example/briefingcommon/common/presentation/converter/APIVersionRequestConverter.java index d58c231..ae0d6cf 100644 --- a/src/main/java/briefing/common/presentation/converter/APIVersionRequestConverter.java +++ b/core/Briefing-Common/src/main/java/com/example/briefingcommon/common/presentation/converter/APIVersionRequestConverter.java @@ -1,9 +1,8 @@ -package briefing.common.presentation.converter; +package com.example.briefingcommon.common.presentation.converter; -import org.springframework.core.convert.converter.Converter; - -import briefing.common.enums.APIVersion; +import com.example.briefingcommon.entity.enums.APIVersion; import lombok.NonNull; +import org.springframework.core.convert.converter.Converter; public class APIVersionRequestConverter implements Converter { diff --git a/src/main/java/briefing/common/presentation/converter/BriefingTypeRequestConverter.java b/core/Briefing-Common/src/main/java/com/example/briefingcommon/common/presentation/converter/BriefingTypeRequestConverter.java similarity index 70% rename from src/main/java/briefing/common/presentation/converter/BriefingTypeRequestConverter.java rename to core/Briefing-Common/src/main/java/com/example/briefingcommon/common/presentation/converter/BriefingTypeRequestConverter.java index 8e744dd..fab96e7 100644 --- a/src/main/java/briefing/common/presentation/converter/BriefingTypeRequestConverter.java +++ b/core/Briefing-Common/src/main/java/com/example/briefingcommon/common/presentation/converter/BriefingTypeRequestConverter.java @@ -1,8 +1,7 @@ -package briefing.common.presentation.converter; +package com.example.briefingcommon.common.presentation.converter; +import com.example.briefingcommon.entity.enums.BriefingType; import org.springframework.core.convert.converter.Converter; - -import briefing.common.enums.BriefingType; import lombok.NonNull; public class BriefingTypeRequestConverter implements Converter { diff --git a/src/main/java/briefing/common/presentation/converter/GptModelRequestConverter.java b/core/Briefing-Common/src/main/java/com/example/briefingcommon/common/presentation/converter/GptModelRequestConverter.java similarity index 69% rename from src/main/java/briefing/common/presentation/converter/GptModelRequestConverter.java rename to core/Briefing-Common/src/main/java/com/example/briefingcommon/common/presentation/converter/GptModelRequestConverter.java index 688b146..b1289b0 100644 --- a/src/main/java/briefing/common/presentation/converter/GptModelRequestConverter.java +++ b/core/Briefing-Common/src/main/java/com/example/briefingcommon/common/presentation/converter/GptModelRequestConverter.java @@ -1,8 +1,9 @@ -package briefing.common.presentation.converter; +package com.example.briefingcommon.common.presentation.converter; +import com.example.briefingcommon.entity.enums.GptModel; import org.springframework.core.convert.converter.Converter; -import briefing.common.enums.GptModel; + import lombok.NonNull; public class GptModelRequestConverter implements Converter { diff --git a/src/main/java/briefing/common/presentation/converter/SocialTypeRequestConverter.java b/core/Briefing-Common/src/main/java/com/example/briefingcommon/common/presentation/converter/SocialTypeRequestConverter.java similarity index 67% rename from src/main/java/briefing/common/presentation/converter/SocialTypeRequestConverter.java rename to core/Briefing-Common/src/main/java/com/example/briefingcommon/common/presentation/converter/SocialTypeRequestConverter.java index 6a27acc..ce857b8 100644 --- a/src/main/java/briefing/common/presentation/converter/SocialTypeRequestConverter.java +++ b/core/Briefing-Common/src/main/java/com/example/briefingcommon/common/presentation/converter/SocialTypeRequestConverter.java @@ -1,8 +1,9 @@ -package briefing.common.presentation.converter; +package com.example.briefingcommon.common.presentation.converter; +import com.example.briefingcommon.entity.enums.SocialType; import org.springframework.core.convert.converter.Converter; -import briefing.common.enums.SocialType; + public class SocialTypeRequestConverter implements Converter { @Override diff --git a/src/main/java/briefing/common/presentation/converter/TimeOfDayConverter.java b/core/Briefing-Common/src/main/java/com/example/briefingcommon/common/presentation/converter/TimeOfDayConverter.java similarity index 69% rename from src/main/java/briefing/common/presentation/converter/TimeOfDayConverter.java rename to core/Briefing-Common/src/main/java/com/example/briefingcommon/common/presentation/converter/TimeOfDayConverter.java index 4d1f3c3..1c32e9c 100644 --- a/src/main/java/briefing/common/presentation/converter/TimeOfDayConverter.java +++ b/core/Briefing-Common/src/main/java/com/example/briefingcommon/common/presentation/converter/TimeOfDayConverter.java @@ -1,8 +1,9 @@ -package briefing.common.presentation.converter; +package com.example.briefingcommon.common.presentation.converter; +import com.example.briefingcommon.entity.enums.TimeOfDay; import org.springframework.core.convert.converter.Converter; -import briefing.common.enums.TimeOfDay; + import lombok.NonNull; public class TimeOfDayConverter implements Converter { diff --git a/src/main/java/briefing/common/presentation/response/CommonResponse.java b/core/Briefing-Common/src/main/java/com/example/briefingcommon/common/presentation/response/CommonResponse.java similarity index 79% rename from src/main/java/briefing/common/presentation/response/CommonResponse.java rename to core/Briefing-Common/src/main/java/com/example/briefingcommon/common/presentation/response/CommonResponse.java index ad0eac0..c83cfb5 100644 --- a/src/main/java/briefing/common/presentation/response/CommonResponse.java +++ b/core/Briefing-Common/src/main/java/com/example/briefingcommon/common/presentation/response/CommonResponse.java @@ -1,4 +1,4 @@ -package briefing.common.presentation.response; +package com.example.briefingcommon.common.presentation.response; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; @@ -29,6 +29,10 @@ public static CommonResponse onSuccess(T data) { return new CommonResponse<>(true, "요청에 성공하였습니다.", "1000", data); } + public static CommonResponse onSuccess() { + return new CommonResponse<>(true, "요청에 성공하였습니다.", "1000", null); + } + public static CommonResponse onFailure(String code, String message, T data) { return new CommonResponse<>(false, code, message, data); } diff --git a/src/main/java/briefing/common/presentation/response/PageResponse.java b/core/Briefing-Common/src/main/java/com/example/briefingcommon/common/presentation/response/PageResponse.java similarity index 76% rename from src/main/java/briefing/common/presentation/response/PageResponse.java rename to core/Briefing-Common/src/main/java/com/example/briefingcommon/common/presentation/response/PageResponse.java index 92b48ab..f809164 100644 --- a/src/main/java/briefing/common/presentation/response/PageResponse.java +++ b/core/Briefing-Common/src/main/java/com/example/briefingcommon/common/presentation/response/PageResponse.java @@ -1,4 +1,4 @@ -package briefing.common.presentation.response; +package com.example.briefingcommon.common.presentation.response; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/core/Briefing-Common/src/main/java/com/example/briefingcommon/domain/repository/FcmTokenRepository.java b/core/Briefing-Common/src/main/java/com/example/briefingcommon/domain/repository/FcmTokenRepository.java new file mode 100644 index 0000000..46b6471 --- /dev/null +++ b/core/Briefing-Common/src/main/java/com/example/briefingcommon/domain/repository/FcmTokenRepository.java @@ -0,0 +1,13 @@ +package com.example.briefingcommon.domain.repository; + +import com.example.briefingcommon.entity.FcmToken; +import com.example.briefingcommon.entity.Member; +import org.springframework.data.jpa.repository.JpaRepository; + +import java.util.List; +import java.util.Optional; + +public interface FcmTokenRepository extends JpaRepository { + + Optional findByMemberAndToken(Member member, String token); +} diff --git a/core/Briefing-Common/src/main/java/com/example/briefingcommon/domain/repository/article/ArticleRepository.java b/core/Briefing-Common/src/main/java/com/example/briefingcommon/domain/repository/article/ArticleRepository.java new file mode 100644 index 0000000..f84fd6f --- /dev/null +++ b/core/Briefing-Common/src/main/java/com/example/briefingcommon/domain/repository/article/ArticleRepository.java @@ -0,0 +1,9 @@ +package com.example.briefingcommon.domain.repository.article; + +import com.example.briefingcommon.entity.Article; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + + + +public interface ArticleRepository extends JpaRepository {} diff --git a/core/Briefing-Common/src/main/java/com/example/briefingcommon/domain/repository/article/BriefingArticleRepository.java b/core/Briefing-Common/src/main/java/com/example/briefingcommon/domain/repository/article/BriefingArticleRepository.java new file mode 100644 index 0000000..9853bf1 --- /dev/null +++ b/core/Briefing-Common/src/main/java/com/example/briefingcommon/domain/repository/article/BriefingArticleRepository.java @@ -0,0 +1,9 @@ +package com.example.briefingcommon.domain.repository.article; + +import com.example.briefingcommon.entity.BriefingArticle; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + + + +public interface BriefingArticleRepository extends JpaRepository {} diff --git a/src/main/java/briefing/briefing/domain/repository/BriefingCustomRepository.java b/core/Briefing-Common/src/main/java/com/example/briefingcommon/domain/repository/article/BriefingCustomRepository.java similarity index 58% rename from src/main/java/briefing/briefing/domain/repository/BriefingCustomRepository.java rename to core/Briefing-Common/src/main/java/com/example/briefingcommon/domain/repository/article/BriefingCustomRepository.java index 6522719..cf8a7cd 100644 --- a/src/main/java/briefing/briefing/domain/repository/BriefingCustomRepository.java +++ b/core/Briefing-Common/src/main/java/com/example/briefingcommon/domain/repository/article/BriefingCustomRepository.java @@ -1,12 +1,13 @@ -package briefing.briefing.domain.repository; +package com.example.briefingcommon.domain.repository.article; import java.time.LocalDateTime; import java.util.List; import java.util.Optional; +import com.example.briefingcommon.entity.Briefing; +import com.example.briefingcommon.entity.enums.BriefingType; +import com.example.briefingcommon.entity.enums.TimeOfDay; +import org.springframework.stereotype.Repository; -import briefing.briefing.domain.Briefing; -import briefing.common.enums.BriefingType; -import briefing.common.enums.TimeOfDay; public interface BriefingCustomRepository { List findBriefingsWithScrapCount( diff --git a/src/main/java/briefing/briefing/domain/repository/BriefingCustomRepositoryImpl.java b/core/Briefing-Common/src/main/java/com/example/briefingcommon/domain/repository/article/BriefingCustomRepositoryImpl.java similarity index 93% rename from src/main/java/briefing/briefing/domain/repository/BriefingCustomRepositoryImpl.java rename to core/Briefing-Common/src/main/java/com/example/briefingcommon/domain/repository/article/BriefingCustomRepositoryImpl.java index 85541ac..934757e 100644 --- a/src/main/java/briefing/briefing/domain/repository/BriefingCustomRepositoryImpl.java +++ b/core/Briefing-Common/src/main/java/com/example/briefingcommon/domain/repository/article/BriefingCustomRepositoryImpl.java @@ -1,23 +1,24 @@ -package briefing.briefing.domain.repository; +package com.example.briefingcommon.domain.repository.article; import java.time.LocalDate; import java.time.LocalDateTime; import java.util.*; import java.util.stream.Collectors; -import org.springframework.stereotype.Repository; - +import com.example.briefingcommon.entity.Briefing; +import com.example.briefingcommon.entity.QBriefing; +import com.example.briefingcommon.entity.QScrap; +import com.example.briefingcommon.entity.enums.BriefingType; +import com.example.briefingcommon.entity.enums.TimeOfDay; import com.querydsl.core.Tuple; import com.querydsl.core.types.dsl.DateTemplate; import com.querydsl.core.types.dsl.DateTimePath; import com.querydsl.core.types.dsl.Expressions; import com.querydsl.jpa.impl.JPAQueryFactory; +import org.springframework.stereotype.Repository; + + -import briefing.briefing.domain.Briefing; -import briefing.briefing.domain.QBriefing; -import briefing.common.enums.BriefingType; -import briefing.common.enums.TimeOfDay; -import briefing.scrap.domain.QScrap; import lombok.RequiredArgsConstructor; @Repository diff --git a/core/Briefing-Common/src/main/java/com/example/briefingcommon/domain/repository/article/BriefingRepository.java b/core/Briefing-Common/src/main/java/com/example/briefingcommon/domain/repository/article/BriefingRepository.java new file mode 100644 index 0000000..e88305c --- /dev/null +++ b/core/Briefing-Common/src/main/java/com/example/briefingcommon/domain/repository/article/BriefingRepository.java @@ -0,0 +1,24 @@ +package com.example.briefingcommon.domain.repository.article; + +import java.time.LocalDateTime; +import java.util.List; +import java.util.Optional; + +import com.example.briefingcommon.entity.Briefing; +import com.example.briefingcommon.entity.enums.BriefingType; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; + + +public interface BriefingRepository + extends JpaRepository, BriefingCustomRepository { + + List findAllByTypeAndCreatedAtBetweenOrderByRanks( + BriefingType type, LocalDateTime start, LocalDateTime end); + + @Query("SELECT b from Briefing b where b.ranks = 1 and b.type = :type order by b.createdAt desc") + Page getBestTodayBriefing(@Param("type") BriefingType type, Pageable pageable); +} diff --git a/src/main/java/briefing/member/domain/repository/MemberRepository.java b/core/Briefing-Common/src/main/java/com/example/briefingcommon/domain/repository/member/MemberRepository.java similarity index 58% rename from src/main/java/briefing/member/domain/repository/MemberRepository.java rename to core/Briefing-Common/src/main/java/com/example/briefingcommon/domain/repository/member/MemberRepository.java index 5a481ac..f393274 100644 --- a/src/main/java/briefing/member/domain/repository/MemberRepository.java +++ b/core/Briefing-Common/src/main/java/com/example/briefingcommon/domain/repository/member/MemberRepository.java @@ -1,11 +1,13 @@ -package briefing.member.domain.repository; +package com.example.briefingcommon.domain.repository.member; -import java.util.Optional; +import com.example.briefingcommon.entity.Member; +import com.example.briefingcommon.entity.enums.SocialType; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.Optional; -import briefing.common.enums.SocialType; -import briefing.member.domain.Member; public interface MemberRepository extends JpaRepository { Optional findBySocialIdAndSocialType(String socialId, SocialType socialType); diff --git a/core/Briefing-Common/src/main/java/com/example/briefingcommon/domain/repository/scrap/ScrapCustomRepository.java b/core/Briefing-Common/src/main/java/com/example/briefingcommon/domain/repository/scrap/ScrapCustomRepository.java new file mode 100644 index 0000000..d13f2ff --- /dev/null +++ b/core/Briefing-Common/src/main/java/com/example/briefingcommon/domain/repository/scrap/ScrapCustomRepository.java @@ -0,0 +1,3 @@ +package com.example.briefingcommon.domain.repository.scrap; + +public interface ScrapCustomRepository {} diff --git a/src/main/java/briefing/scrap/domain/repository/ScrapCustomRepositoryImpl.java b/core/Briefing-Common/src/main/java/com/example/briefingcommon/domain/repository/scrap/ScrapCustomRepositoryImpl.java similarity index 69% rename from src/main/java/briefing/scrap/domain/repository/ScrapCustomRepositoryImpl.java rename to core/Briefing-Common/src/main/java/com/example/briefingcommon/domain/repository/scrap/ScrapCustomRepositoryImpl.java index b8f0a48..32a49ff 100644 --- a/src/main/java/briefing/scrap/domain/repository/ScrapCustomRepositoryImpl.java +++ b/core/Briefing-Common/src/main/java/com/example/briefingcommon/domain/repository/scrap/ScrapCustomRepositoryImpl.java @@ -1,4 +1,4 @@ -package briefing.scrap.domain.repository; +package com.example.briefingcommon.domain.repository.scrap; import org.springframework.stereotype.Repository; diff --git a/src/main/java/briefing/scrap/domain/repository/ScrapRepository.java b/core/Briefing-Common/src/main/java/com/example/briefingcommon/domain/repository/scrap/ScrapRepository.java similarity index 74% rename from src/main/java/briefing/scrap/domain/repository/ScrapRepository.java rename to core/Briefing-Common/src/main/java/com/example/briefingcommon/domain/repository/scrap/ScrapRepository.java index 2616b2c..3ee7621 100644 --- a/src/main/java/briefing/scrap/domain/repository/ScrapRepository.java +++ b/core/Briefing-Common/src/main/java/com/example/briefingcommon/domain/repository/scrap/ScrapRepository.java @@ -1,11 +1,12 @@ -package briefing.scrap.domain.repository; +package com.example.briefingcommon.domain.repository.scrap; -import java.util.List; -import java.util.Optional; +import com.example.briefingcommon.entity.Scrap; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; -import briefing.scrap.domain.Scrap; +import java.util.List; +import java.util.Optional; public interface ScrapRepository extends JpaRepository, ScrapCustomRepository { diff --git a/src/main/java/briefing/briefing/domain/Article.java b/core/Briefing-Common/src/main/java/com/example/briefingcommon/entity/Article.java similarity index 90% rename from src/main/java/briefing/briefing/domain/Article.java rename to core/Briefing-Common/src/main/java/com/example/briefingcommon/entity/Article.java index cbe0aba..610aca7 100644 --- a/src/main/java/briefing/briefing/domain/Article.java +++ b/core/Briefing-Common/src/main/java/com/example/briefingcommon/entity/Article.java @@ -1,4 +1,4 @@ -package briefing.briefing.domain; +package com.example.briefingcommon.entity; import jakarta.persistence.Column; import jakarta.persistence.Entity; @@ -6,7 +6,7 @@ import jakarta.persistence.GenerationType; import jakarta.persistence.Id; -import briefing.common.domain.BaseDateTimeEntity; + import lombok.*; @Entity diff --git a/src/main/java/briefing/common/domain/BaseDateTimeEntity.java b/core/Briefing-Common/src/main/java/com/example/briefingcommon/entity/BaseDateTimeEntity.java similarity index 93% rename from src/main/java/briefing/common/domain/BaseDateTimeEntity.java rename to core/Briefing-Common/src/main/java/com/example/briefingcommon/entity/BaseDateTimeEntity.java index f772da7..9acf0e4 100644 --- a/src/main/java/briefing/common/domain/BaseDateTimeEntity.java +++ b/core/Briefing-Common/src/main/java/com/example/briefingcommon/entity/BaseDateTimeEntity.java @@ -1,4 +1,4 @@ -package briefing.common.domain; +package com.example.briefingcommon.entity; import java.time.LocalDateTime; diff --git a/src/main/java/briefing/briefing/domain/Briefing.java b/core/Briefing-Common/src/main/java/com/example/briefingcommon/entity/Briefing.java similarity index 88% rename from src/main/java/briefing/briefing/domain/Briefing.java rename to core/Briefing-Common/src/main/java/com/example/briefingcommon/entity/Briefing.java index e5fabd1..532d793 100644 --- a/src/main/java/briefing/briefing/domain/Briefing.java +++ b/core/Briefing-Common/src/main/java/com/example/briefingcommon/entity/Briefing.java @@ -1,15 +1,15 @@ -package briefing.briefing.domain; +package com.example.briefingcommon.entity; import java.util.ArrayList; import java.util.List; import java.util.Optional; +import com.example.briefingcommon.entity.enums.BriefingType; +import com.example.briefingcommon.entity.enums.GptModel; +import com.example.briefingcommon.entity.enums.TimeOfDay; import jakarta.persistence.*; -import briefing.common.domain.BaseDateTimeEntity; -import briefing.common.enums.BriefingType; -import briefing.common.enums.GptModel; -import briefing.common.enums.TimeOfDay; + import lombok.*; @Entity diff --git a/src/main/java/briefing/briefing/domain/BriefingArticle.java b/core/Briefing-Common/src/main/java/com/example/briefingcommon/entity/BriefingArticle.java similarity index 91% rename from src/main/java/briefing/briefing/domain/BriefingArticle.java rename to core/Briefing-Common/src/main/java/com/example/briefingcommon/entity/BriefingArticle.java index 2af2246..0b1e17a 100644 --- a/src/main/java/briefing/briefing/domain/BriefingArticle.java +++ b/core/Briefing-Common/src/main/java/com/example/briefingcommon/entity/BriefingArticle.java @@ -1,4 +1,4 @@ -package briefing.briefing.domain; +package com.example.briefingcommon.entity; import jakarta.persistence.Entity; import jakarta.persistence.FetchType; @@ -8,7 +8,6 @@ import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; -import briefing.common.domain.BaseDateTimeEntity; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/core/Briefing-Common/src/main/java/com/example/briefingcommon/entity/FcmToken.java b/core/Briefing-Common/src/main/java/com/example/briefingcommon/entity/FcmToken.java new file mode 100644 index 0000000..8ccf703 --- /dev/null +++ b/core/Briefing-Common/src/main/java/com/example/briefingcommon/entity/FcmToken.java @@ -0,0 +1,22 @@ +package com.example.briefingcommon.entity; + +import jakarta.persistence.*; +import lombok.*; + +@Entity +@Getter +@Builder +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor +public class FcmToken { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + private String token; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "member_id") + private Member member; +} diff --git a/src/main/java/briefing/member/domain/Member.java b/core/Briefing-Common/src/main/java/com/example/briefingcommon/entity/Member.java similarity index 78% rename from src/main/java/briefing/member/domain/Member.java rename to core/Briefing-Common/src/main/java/com/example/briefingcommon/entity/Member.java index ffd32dc..cdc21c3 100644 --- a/src/main/java/briefing/member/domain/Member.java +++ b/core/Briefing-Common/src/main/java/com/example/briefingcommon/entity/Member.java @@ -1,15 +1,13 @@ -package briefing.member.domain; +package com.example.briefingcommon.entity; import java.util.ArrayList; import java.util.List; +import com.example.briefingcommon.entity.enums.MemberRole; +import com.example.briefingcommon.entity.enums.MemberStatus; +import com.example.briefingcommon.entity.enums.SocialType; import jakarta.persistence.*; -import briefing.common.domain.BaseDateTimeEntity; -import briefing.common.enums.MemberRole; -import briefing.common.enums.MemberStatus; -import briefing.common.enums.SocialType; -import briefing.scrap.domain.Scrap; import lombok.*; @Entity diff --git a/src/main/java/briefing/scrap/domain/Scrap.java b/core/Briefing-Common/src/main/java/com/example/briefingcommon/entity/Scrap.java similarity index 82% rename from src/main/java/briefing/scrap/domain/Scrap.java rename to core/Briefing-Common/src/main/java/com/example/briefingcommon/entity/Scrap.java index 10b1731..36a3961 100644 --- a/src/main/java/briefing/scrap/domain/Scrap.java +++ b/core/Briefing-Common/src/main/java/com/example/briefingcommon/entity/Scrap.java @@ -1,10 +1,7 @@ -package briefing.scrap.domain; +package com.example.briefingcommon.entity; import jakarta.persistence.*; -import briefing.briefing.domain.Briefing; -import briefing.common.domain.BaseDateTimeEntity; -import briefing.member.domain.Member; import lombok.*; @Entity diff --git a/src/main/java/briefing/common/enums/APIVersion.java b/core/Briefing-Common/src/main/java/com/example/briefingcommon/entity/enums/APIVersion.java similarity index 76% rename from src/main/java/briefing/common/enums/APIVersion.java rename to core/Briefing-Common/src/main/java/com/example/briefingcommon/entity/enums/APIVersion.java index b4644ee..039361e 100644 --- a/src/main/java/briefing/common/enums/APIVersion.java +++ b/core/Briefing-Common/src/main/java/com/example/briefingcommon/entity/enums/APIVersion.java @@ -1,11 +1,11 @@ -package briefing.common.enums; +package com.example.briefingcommon.entity.enums; import java.util.Arrays; +import com.example.briefingcommon.common.exception.BriefingException; +import com.example.briefingcommon.common.exception.common.ErrorCode; import com.fasterxml.jackson.annotation.JsonValue; -import briefing.briefing.exception.BriefingException; -import briefing.common.exception.common.ErrorCode; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/briefing/common/enums/BriefingType.java b/core/Briefing-Common/src/main/java/com/example/briefingcommon/entity/enums/BriefingType.java similarity index 75% rename from src/main/java/briefing/common/enums/BriefingType.java rename to core/Briefing-Common/src/main/java/com/example/briefingcommon/entity/enums/BriefingType.java index 9bc1ff4..5b8e6d9 100644 --- a/src/main/java/briefing/common/enums/BriefingType.java +++ b/core/Briefing-Common/src/main/java/com/example/briefingcommon/entity/enums/BriefingType.java @@ -1,9 +1,9 @@ -package briefing.common.enums; +package com.example.briefingcommon.entity.enums; import java.util.Arrays; -import briefing.briefing.exception.BriefingException; -import briefing.common.exception.common.ErrorCode; +import com.example.briefingcommon.common.exception.BriefingException; +import com.example.briefingcommon.common.exception.common.ErrorCode; import lombok.Getter; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/briefing/common/enums/GptModel.java b/core/Briefing-Common/src/main/java/com/example/briefingcommon/entity/enums/GptModel.java similarity index 77% rename from src/main/java/briefing/common/enums/GptModel.java rename to core/Briefing-Common/src/main/java/com/example/briefingcommon/entity/enums/GptModel.java index cc7ff82..349da28 100644 --- a/src/main/java/briefing/common/enums/GptModel.java +++ b/core/Briefing-Common/src/main/java/com/example/briefingcommon/entity/enums/GptModel.java @@ -1,12 +1,12 @@ -package briefing.common.enums; +package com.example.briefingcommon.entity.enums; import java.util.Arrays; +import com.example.briefingcommon.common.exception.ChattingException; +import com.example.briefingcommon.common.exception.common.ErrorCode; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -import briefing.common.exception.ChattingException; -import briefing.common.exception.common.ErrorCode; import lombok.Getter; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/briefing/common/enums/MemberRole.java b/core/Briefing-Common/src/main/java/com/example/briefingcommon/entity/enums/MemberRole.java similarity index 82% rename from src/main/java/briefing/common/enums/MemberRole.java rename to core/Briefing-Common/src/main/java/com/example/briefingcommon/entity/enums/MemberRole.java index df30a4f..c0e2bf8 100644 --- a/src/main/java/briefing/common/enums/MemberRole.java +++ b/core/Briefing-Common/src/main/java/com/example/briefingcommon/entity/enums/MemberRole.java @@ -1,4 +1,4 @@ -package briefing.common.enums; +package com.example.briefingcommon.entity.enums; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/briefing/common/enums/MemberStatus.java b/core/Briefing-Common/src/main/java/com/example/briefingcommon/entity/enums/MemberStatus.java similarity index 80% rename from src/main/java/briefing/common/enums/MemberStatus.java rename to core/Briefing-Common/src/main/java/com/example/briefingcommon/entity/enums/MemberStatus.java index 34a06b1..08fa52c 100644 --- a/src/main/java/briefing/common/enums/MemberStatus.java +++ b/core/Briefing-Common/src/main/java/com/example/briefingcommon/entity/enums/MemberStatus.java @@ -1,4 +1,4 @@ -package briefing.common.enums; +package com.example.briefingcommon.entity.enums; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/briefing/common/enums/SocialType.java b/core/Briefing-Common/src/main/java/com/example/briefingcommon/entity/enums/SocialType.java similarity index 93% rename from src/main/java/briefing/common/enums/SocialType.java rename to core/Briefing-Common/src/main/java/com/example/briefingcommon/entity/enums/SocialType.java index 9ca4acc..34c72d5 100644 --- a/src/main/java/briefing/common/enums/SocialType.java +++ b/core/Briefing-Common/src/main/java/com/example/briefingcommon/entity/enums/SocialType.java @@ -1,4 +1,4 @@ -package briefing.common.enums; +package com.example.briefingcommon.entity.enums; import com.fasterxml.jackson.annotation.JsonValue; diff --git a/src/main/java/briefing/common/enums/TimeOfDay.java b/core/Briefing-Common/src/main/java/com/example/briefingcommon/entity/enums/TimeOfDay.java similarity index 77% rename from src/main/java/briefing/common/enums/TimeOfDay.java rename to core/Briefing-Common/src/main/java/com/example/briefingcommon/entity/enums/TimeOfDay.java index 7b87895..11d06ad 100644 --- a/src/main/java/briefing/common/enums/TimeOfDay.java +++ b/core/Briefing-Common/src/main/java/com/example/briefingcommon/entity/enums/TimeOfDay.java @@ -1,11 +1,12 @@ -package briefing.common.enums; +package com.example.briefingcommon.entity.enums; import java.util.Arrays; +import com.example.briefingcommon.common.exception.BriefingException; +import com.example.briefingcommon.common.exception.common.ErrorCode; import com.fasterxml.jackson.annotation.JsonValue; -import briefing.briefing.exception.BriefingException; -import briefing.common.exception.common.ErrorCode; + import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/briefing/infra/redis/domain/RefreshToken.java b/core/Briefing-Common/src/main/java/com/example/briefingcommon/entity/redis/RefreshToken.java similarity index 90% rename from src/main/java/briefing/infra/redis/domain/RefreshToken.java rename to core/Briefing-Common/src/main/java/com/example/briefingcommon/entity/redis/RefreshToken.java index 2580de2..523e98b 100644 --- a/src/main/java/briefing/infra/redis/domain/RefreshToken.java +++ b/core/Briefing-Common/src/main/java/com/example/briefingcommon/entity/redis/RefreshToken.java @@ -1,11 +1,11 @@ -package briefing.infra.redis.domain; +package com.example.briefingcommon.entity.redis; import java.time.LocalDateTime; import org.springframework.data.annotation.Id; -import org.springframework.data.redis.core.RedisHash; import lombok.*; +import org.springframework.data.redis.core.RedisHash; @RedisHash(value = "refreshToken_Breifing", timeToLive = 1800000) @Builder diff --git a/core/Briefing-Common/src/main/resources/application.properties b/core/Briefing-Common/src/main/resources/application.properties new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/core/Briefing-Common/src/main/resources/application.properties @@ -0,0 +1 @@ + diff --git a/core/Briefing-Common/src/test/java/com/example/briefingcommon/BriefingCommonApplicationTests.java b/core/Briefing-Common/src/test/java/com/example/briefingcommon/BriefingCommonApplicationTests.java new file mode 100644 index 0000000..64d0865 --- /dev/null +++ b/core/Briefing-Common/src/test/java/com/example/briefingcommon/BriefingCommonApplicationTests.java @@ -0,0 +1,13 @@ +package com.example.briefingcommon; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class BriefingCommonApplicationTests { + + @Test + void contextLoads() { + } + +} diff --git a/core/Briefing-Infra/build.gradle b/core/Briefing-Infra/build.gradle new file mode 100644 index 0000000..c726087 --- /dev/null +++ b/core/Briefing-Infra/build.gradle @@ -0,0 +1,23 @@ +bootJar { + enabled = false +} + +jar { + enabled = true +} + +repositories { + mavenCentral() +} + +dependencies { + implementation project(":core:Briefing-Common") + implementation 'org.springframework.boot:spring-boot-starter' + testImplementation 'org.springframework.boot:spring-boot-starter-test' + implementation 'org.springframework.cloud:spring-cloud-starter-openfeign' + implementation platform("org.springframework.cloud:spring-cloud-dependencies:2022.0.3") +} + +tasks.named('test') { + useJUnitPlatform() +} diff --git a/core/Briefing-Infra/gradle/wrapper/gradle-wrapper.jar b/core/Briefing-Infra/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..d64cd49 Binary files /dev/null and b/core/Briefing-Infra/gradle/wrapper/gradle-wrapper.jar differ diff --git a/core/Briefing-Infra/gradle/wrapper/gradle-wrapper.properties b/core/Briefing-Infra/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..1af9e09 --- /dev/null +++ b/core/Briefing-Infra/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/src/main/java/briefing/infra/feign/decoder/FeignClientExceptionErrorDecoder.java b/core/Briefing-Infra/src/main/java/com/example/briefinginfra/feign/decoder/FeignClientExceptionErrorDecoder.java similarity index 88% rename from src/main/java/briefing/infra/feign/decoder/FeignClientExceptionErrorDecoder.java rename to core/Briefing-Infra/src/main/java/com/example/briefinginfra/feign/decoder/FeignClientExceptionErrorDecoder.java index 746eace..6b9591d 100644 --- a/src/main/java/briefing/infra/feign/decoder/FeignClientExceptionErrorDecoder.java +++ b/core/Briefing-Infra/src/main/java/com/example/briefinginfra/feign/decoder/FeignClientExceptionErrorDecoder.java @@ -1,10 +1,10 @@ -package briefing.infra.feign.decoder; +package com.example.briefinginfra.feign.decoder; +import com.example.briefingcommon.common.exception.CustomFeignClientException; +import com.example.briefingcommon.common.exception.common.ErrorCode; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import briefing.common.exception.CustomFeignClientException; -import briefing.common.exception.common.ErrorCode; import feign.Response; import feign.codec.ErrorDecoder; import lombok.extern.slf4j.Slf4j; diff --git a/src/main/java/briefing/infra/feign/oauth/apple/client/AppleOauth2Client.java b/core/Briefing-Infra/src/main/java/com/example/briefinginfra/feign/oauth/apple/client/AppleOauth2Client.java similarity index 66% rename from src/main/java/briefing/infra/feign/oauth/apple/client/AppleOauth2Client.java rename to core/Briefing-Infra/src/main/java/com/example/briefinginfra/feign/oauth/apple/client/AppleOauth2Client.java index 4e5cf7f..ab03bc8 100644 --- a/src/main/java/briefing/infra/feign/oauth/apple/client/AppleOauth2Client.java +++ b/core/Briefing-Infra/src/main/java/com/example/briefinginfra/feign/oauth/apple/client/AppleOauth2Client.java @@ -1,17 +1,16 @@ -package briefing.infra.feign.oauth.apple.client; +package com.example.briefinginfra.feign.oauth.apple.client; +import com.example.briefinginfra.feign.oauth.apple.config.AppleOauth2FeignConfiguration; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.stereotype.Component; import org.springframework.web.bind.annotation.GetMapping; -import briefing.infra.feign.oauth.apple.config.AppleOauth2FeignConfiguration; -import briefing.infra.feign.oauth.apple.dto.ApplePublicKeyList; +import com.example.briefinginfra.feign.oauth.apple.dto.ApplePublicKeyList; @FeignClient( name = "apple-public-key-client", url = "https://appleid.apple.com/auth", configuration = AppleOauth2FeignConfiguration.class) -@Component public interface AppleOauth2Client { @GetMapping("/keys") ApplePublicKeyList getApplePublicKeys(); diff --git a/src/main/java/briefing/infra/feign/oauth/apple/config/AppleOauth2FeignConfiguration.java b/core/Briefing-Infra/src/main/java/com/example/briefinginfra/feign/oauth/apple/config/AppleOauth2FeignConfiguration.java similarity index 79% rename from src/main/java/briefing/infra/feign/oauth/apple/config/AppleOauth2FeignConfiguration.java rename to core/Briefing-Infra/src/main/java/com/example/briefinginfra/feign/oauth/apple/config/AppleOauth2FeignConfiguration.java index b5a6b93..46b1d19 100644 --- a/src/main/java/briefing/infra/feign/oauth/apple/config/AppleOauth2FeignConfiguration.java +++ b/core/Briefing-Infra/src/main/java/com/example/briefinginfra/feign/oauth/apple/config/AppleOauth2FeignConfiguration.java @@ -1,8 +1,8 @@ -package briefing.infra.feign.oauth.apple.config; +package com.example.briefinginfra.feign.oauth.apple.config; import org.springframework.context.annotation.Bean; -import briefing.infra.feign.decoder.FeignClientExceptionErrorDecoder; +import com.example.briefinginfra.feign.decoder.FeignClientExceptionErrorDecoder; import feign.Logger; import feign.RequestInterceptor; import feign.codec.ErrorDecoder; diff --git a/src/main/java/briefing/infra/feign/oauth/apple/dto/ApplePublicKey.java b/core/Briefing-Infra/src/main/java/com/example/briefinginfra/feign/oauth/apple/dto/ApplePublicKey.java similarity index 93% rename from src/main/java/briefing/infra/feign/oauth/apple/dto/ApplePublicKey.java rename to core/Briefing-Infra/src/main/java/com/example/briefinginfra/feign/oauth/apple/dto/ApplePublicKey.java index b774f66..42fe843 100644 --- a/src/main/java/briefing/infra/feign/oauth/apple/dto/ApplePublicKey.java +++ b/core/Briefing-Infra/src/main/java/com/example/briefinginfra/feign/oauth/apple/dto/ApplePublicKey.java @@ -1,4 +1,4 @@ -package briefing.infra.feign.oauth.apple.dto; +package com.example.briefinginfra.feign.oauth.apple.dto; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/briefing/infra/feign/oauth/apple/dto/ApplePublicKeyList.java b/core/Briefing-Infra/src/main/java/com/example/briefinginfra/feign/oauth/apple/dto/ApplePublicKeyList.java similarity index 72% rename from src/main/java/briefing/infra/feign/oauth/apple/dto/ApplePublicKeyList.java rename to core/Briefing-Infra/src/main/java/com/example/briefinginfra/feign/oauth/apple/dto/ApplePublicKeyList.java index 4cacc4f..aa5985f 100644 --- a/src/main/java/briefing/infra/feign/oauth/apple/dto/ApplePublicKeyList.java +++ b/core/Briefing-Infra/src/main/java/com/example/briefinginfra/feign/oauth/apple/dto/ApplePublicKeyList.java @@ -1,9 +1,9 @@ -package briefing.infra.feign.oauth.apple.dto; +package com.example.briefinginfra.feign.oauth.apple.dto; import java.util.List; -import briefing.common.exception.AppleOAuthException; -import briefing.common.exception.common.ErrorCode; +import com.example.briefingcommon.common.exception.AppleOAuthException; +import com.example.briefingcommon.common.exception.common.ErrorCode; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; diff --git a/src/main/java/briefing/infra/feign/oauth/google/client/GoogleOauth2Client.java b/core/Briefing-Infra/src/main/java/com/example/briefinginfra/feign/oauth/google/client/GoogleOauth2Client.java similarity index 63% rename from src/main/java/briefing/infra/feign/oauth/google/client/GoogleOauth2Client.java rename to core/Briefing-Infra/src/main/java/com/example/briefinginfra/feign/oauth/google/client/GoogleOauth2Client.java index d6755ea..35cb0e3 100644 --- a/src/main/java/briefing/infra/feign/oauth/google/client/GoogleOauth2Client.java +++ b/core/Briefing-Infra/src/main/java/com/example/briefinginfra/feign/oauth/google/client/GoogleOauth2Client.java @@ -1,16 +1,17 @@ -package briefing.infra.feign.oauth.google.client; +package com.example.briefinginfra.feign.oauth.google.client; +import com.example.briefinginfra.feign.oauth.google.config.GoogleOauth2FeignConfiguration; +import com.example.briefinginfra.feign.oauth.google.dto.GoogleUserInfo; import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.stereotype.Component; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; -import briefing.infra.feign.oauth.google.config.GoogleOauth2FeignConfiguration; -import briefing.infra.feign.oauth.google.dto.GoogleUserInfo; - @FeignClient( name = "googleOauth2Client", url = "https://www.googleapis.com/oauth2/v3", configuration = GoogleOauth2FeignConfiguration.class) +@Component public interface GoogleOauth2Client { @GetMapping("/tokeninfo") GoogleUserInfo verifyToken(@RequestParam("id_token") String id_token); diff --git a/src/main/java/briefing/infra/feign/oauth/google/config/GoogleOauth2FeignConfiguration.java b/core/Briefing-Infra/src/main/java/com/example/briefinginfra/feign/oauth/google/config/GoogleOauth2FeignConfiguration.java similarity index 79% rename from src/main/java/briefing/infra/feign/oauth/google/config/GoogleOauth2FeignConfiguration.java rename to core/Briefing-Infra/src/main/java/com/example/briefinginfra/feign/oauth/google/config/GoogleOauth2FeignConfiguration.java index db4c693..3eb69cb 100644 --- a/src/main/java/briefing/infra/feign/oauth/google/config/GoogleOauth2FeignConfiguration.java +++ b/core/Briefing-Infra/src/main/java/com/example/briefinginfra/feign/oauth/google/config/GoogleOauth2FeignConfiguration.java @@ -1,8 +1,8 @@ -package briefing.infra.feign.oauth.google.config; +package com.example.briefinginfra.feign.oauth.google.config; +import com.example.briefinginfra.feign.decoder.FeignClientExceptionErrorDecoder; import org.springframework.context.annotation.Bean; -import briefing.infra.feign.decoder.FeignClientExceptionErrorDecoder; import feign.Logger; import feign.RequestInterceptor; import feign.codec.ErrorDecoder; diff --git a/src/main/java/briefing/infra/feign/oauth/google/dto/GoogleUserInfo.java b/core/Briefing-Infra/src/main/java/com/example/briefinginfra/feign/oauth/google/dto/GoogleUserInfo.java similarity index 87% rename from src/main/java/briefing/infra/feign/oauth/google/dto/GoogleUserInfo.java rename to core/Briefing-Infra/src/main/java/com/example/briefinginfra/feign/oauth/google/dto/GoogleUserInfo.java index 69941e8..2c50bb6 100644 --- a/src/main/java/briefing/infra/feign/oauth/google/dto/GoogleUserInfo.java +++ b/core/Briefing-Infra/src/main/java/com/example/briefinginfra/feign/oauth/google/dto/GoogleUserInfo.java @@ -1,4 +1,4 @@ -package briefing.infra.feign.oauth.google.dto; +package com.example.briefinginfra.feign.oauth.google.dto; import lombok.Data; diff --git a/core/Briefing-Infra/src/main/resources/application.properties b/core/Briefing-Infra/src/main/resources/application.properties new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/core/Briefing-Infra/src/main/resources/application.properties @@ -0,0 +1 @@ + diff --git a/core/Briefing-Infra/src/test/java/com/example/briefinginfra/BriefingInfraApplicationTests.java b/core/Briefing-Infra/src/test/java/com/example/briefinginfra/BriefingInfraApplicationTests.java new file mode 100644 index 0000000..0b98a9a --- /dev/null +++ b/core/Briefing-Infra/src/test/java/com/example/briefinginfra/BriefingInfraApplicationTests.java @@ -0,0 +1,13 @@ +package com.example.briefinginfra; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class BriefingInfraApplicationTests { + + @Test + void contextLoads() { + } + +} diff --git a/settings.gradle b/settings.gradle index bea7b7f..4d18120 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1,11 @@ rootProject.name = 'briefing' + +include 'Briefing-Api' +include 'core:Briefing-Common' +include 'core:Briefing-Infra' + +/* ToDo + 모놀리딕으로 진행 후 두개를 묶어서 분리할 것 + */ +//include 'core:Briefing-Batch' +//include 'core:Briefing-FCM' \ No newline at end of file diff --git a/src/main/java/briefing/BriefingApplication.java b/src/main/java/briefing/BriefingApplication.java deleted file mode 100644 index 186981a..0000000 --- a/src/main/java/briefing/BriefingApplication.java +++ /dev/null @@ -1,30 +0,0 @@ -package briefing; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.ImportAutoConfiguration; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.cache.annotation.EnableCaching; -import org.springframework.cloud.openfeign.EnableFeignClients; -import org.springframework.cloud.openfeign.FeignAutoConfiguration; -import org.springframework.data.redis.repository.configuration.EnableRedisRepositories; - -import io.swagger.v3.oas.annotations.OpenAPIDefinition; -import io.swagger.v3.oas.annotations.servers.Server; - -@OpenAPIDefinition( - servers = { - @Server(url = "http://localhost:8080", description = "local server"), - @Server(url = "https://dev.briefing.store", description = "dev server"), - @Server(url = "https://api.newsbreifing.store", description = "release server") - }) -@SpringBootApplication -@EnableCaching -@EnableFeignClients -@EnableRedisRepositories -@ImportAutoConfiguration({FeignAutoConfiguration.class}) -public class BriefingApplication { - - public static void main(final String[] args) { - SpringApplication.run(BriefingApplication.class, args); - } -} diff --git a/src/main/java/briefing/briefing/domain/repository/ArticleRepository.java b/src/main/java/briefing/briefing/domain/repository/ArticleRepository.java deleted file mode 100644 index 498c00e..0000000 --- a/src/main/java/briefing/briefing/domain/repository/ArticleRepository.java +++ /dev/null @@ -1,7 +0,0 @@ -package briefing.briefing.domain.repository; - -import org.springframework.data.jpa.repository.JpaRepository; - -import briefing.briefing.domain.Article; - -public interface ArticleRepository extends JpaRepository {} diff --git a/src/main/java/briefing/briefing/domain/repository/BriefingArticleRepository.java b/src/main/java/briefing/briefing/domain/repository/BriefingArticleRepository.java deleted file mode 100644 index 846c688..0000000 --- a/src/main/java/briefing/briefing/domain/repository/BriefingArticleRepository.java +++ /dev/null @@ -1,7 +0,0 @@ -package briefing.briefing.domain.repository; - -import org.springframework.data.jpa.repository.JpaRepository; - -import briefing.briefing.domain.BriefingArticle; - -public interface BriefingArticleRepository extends JpaRepository {} diff --git a/src/main/java/briefing/briefing/domain/repository/BriefingRepository.java b/src/main/java/briefing/briefing/domain/repository/BriefingRepository.java deleted file mode 100644 index acd3667..0000000 --- a/src/main/java/briefing/briefing/domain/repository/BriefingRepository.java +++ /dev/null @@ -1,18 +0,0 @@ -package briefing.briefing.domain.repository; - -import java.time.LocalDateTime; -import java.util.List; - -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -import briefing.briefing.domain.Briefing; -import briefing.common.enums.BriefingType; - -@Repository -public interface BriefingRepository - extends JpaRepository, BriefingCustomRepository { - - List findAllByTypeAndCreatedAtBetweenOrderByRanks( - BriefingType type, LocalDateTime start, LocalDateTime end); -} diff --git a/src/main/java/briefing/briefing/exception/BriefingException.java b/src/main/java/briefing/briefing/exception/BriefingException.java deleted file mode 100644 index a504f64..0000000 --- a/src/main/java/briefing/briefing/exception/BriefingException.java +++ /dev/null @@ -1,10 +0,0 @@ -package briefing.briefing.exception; - -import briefing.common.exception.common.ErrorCode; -import briefing.common.exception.common.GeneralException; - -public class BriefingException extends GeneralException { - public BriefingException(ErrorCode errorCode) { - super(errorCode); - } -} diff --git a/src/main/java/briefing/common/exception/AppleOAuthException.java b/src/main/java/briefing/common/exception/AppleOAuthException.java deleted file mode 100644 index 3f5985d..0000000 --- a/src/main/java/briefing/common/exception/AppleOAuthException.java +++ /dev/null @@ -1,10 +0,0 @@ -package briefing.common.exception; - -import briefing.common.exception.common.ErrorCode; -import briefing.common.exception.common.GeneralException; - -public class AppleOAuthException extends GeneralException { - public AppleOAuthException(ErrorCode errorCode) { - super(errorCode); - } -} diff --git a/src/main/java/briefing/common/exception/ChattingException.java b/src/main/java/briefing/common/exception/ChattingException.java deleted file mode 100644 index 8b7e3dd..0000000 --- a/src/main/java/briefing/common/exception/ChattingException.java +++ /dev/null @@ -1,10 +0,0 @@ -package briefing.common.exception; - -import briefing.common.exception.common.ErrorCode; -import briefing.common.exception.common.GeneralException; - -public class ChattingException extends GeneralException { - public ChattingException(ErrorCode errorCode) { - super(errorCode); - } -} diff --git a/src/main/java/briefing/common/exception/CustomFeignClientException.java b/src/main/java/briefing/common/exception/CustomFeignClientException.java deleted file mode 100644 index 821d7bf..0000000 --- a/src/main/java/briefing/common/exception/CustomFeignClientException.java +++ /dev/null @@ -1,11 +0,0 @@ -package briefing.common.exception; - -import briefing.common.exception.common.ErrorCode; -import briefing.common.exception.common.GeneralException; - -public class CustomFeignClientException extends GeneralException { - - public CustomFeignClientException(ErrorCode errorCode) { - super(errorCode); - } -} diff --git a/src/main/java/briefing/common/exception/RefreshTokenException.java b/src/main/java/briefing/common/exception/RefreshTokenException.java deleted file mode 100644 index 8903afc..0000000 --- a/src/main/java/briefing/common/exception/RefreshTokenException.java +++ /dev/null @@ -1,10 +0,0 @@ -package briefing.common.exception; - -import briefing.common.exception.common.ErrorCode; -import briefing.common.exception.common.GeneralException; - -public class RefreshTokenException extends GeneralException { - public RefreshTokenException(ErrorCode errorCode) { - super(errorCode); - } -} diff --git a/src/main/java/briefing/common/exception/common/ErrorCode.java b/src/main/java/briefing/common/exception/common/ErrorCode.java deleted file mode 100644 index 47b3e66..0000000 --- a/src/main/java/briefing/common/exception/common/ErrorCode.java +++ /dev/null @@ -1,107 +0,0 @@ -package briefing.common.exception.common; - -import static org.springframework.http.HttpStatus.*; - -import java.util.Arrays; -import java.util.Optional; -import java.util.function.Predicate; - -import org.springframework.http.HttpStatus; - -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -@Getter -@RequiredArgsConstructor -public enum ErrorCode { - _INTERNAL_SERVER_ERROR(INTERNAL_SERVER_ERROR, "COMMON000", "서버 에러, 관리자에게 문의 바랍니다."), - _BAD_REQUEST(BAD_REQUEST, "COMMON001", "잘못된 요청입니다."), - _UNAUTHORIZED(UNAUTHORIZED, "COMMON002", "로그인이 필요합니다."), - _METHOD_NOT_ALLOWED(METHOD_NOT_ALLOWED, "COMMON003", "지원하지 않는 Http Method 입니다."), - _FORBIDDEN(FORBIDDEN, "COMMON004", "금지된 요청입니다."), - - // 인증 관련 에러 - ForbiddenException(UNAUTHORIZED, "AUTH002", "해당 요청에 대한 권한이 없습니다."), - UNAUTHORIZED_EXCEPTION(UNAUTHORIZED, "AUTH003", "로그인 후 이용가능합니다. 토큰을 입력해 주세요"), - EXPIRED_JWT_EXCEPTION(UNAUTHORIZED, "AUTH004", "기존 토큰이 만료되었습니다. 토큰을 재발급해주세요."), - RELOGIN_EXCEPTION(UNAUTHORIZED, "AUTH005", "모든 토큰이 만료되었습니다. 다시 로그인해주세요."), - INVALID_TOKEN_EXCEPTION(UNAUTHORIZED, "AUTH006", "토큰이 올바르지 않습니다."), - HIJACK_JWT_TOKEN_EXCEPTION(UNAUTHORIZED, "AUTH007", "탈취된(로그아웃 된) 토큰입니다 다시 로그인 해주세요."), - INVALID_REFRESH_TOKEN(BAD_REQUEST, "AUTH009", "리프레쉬 토큰이 유효하지 않습니다. 다시 로그인 해주세요"), - - // oauth 에러 - APPLE_BAD_REQUEST(BAD_REQUEST, "OAUTH001", "애플 토큰이 잘못되었습니다."), - APPLE_SERVER_ERROR(FORBIDDEN, "OAUTH002", "애플 서버와 통신에 실패 하였습니다."), - FAIL_TO_MAKE_APPLE_PUBLIC_KEY(BAD_REQUEST, "OAUTH003", "새로운 애플 공개키 생성에 실패하였습니다."), - - // feign client 에러 - FEIGN_BAD_REQUEST(BAD_REQUEST, "FEIGN_400_1", "Feign server bad request"), - FEIGN_UNAUTHORIZED(BAD_REQUEST, "FEIGN_400_2", "Feign server unauthorized"), - FEIGN_FORBIDDEN(BAD_REQUEST, "FEIGN_400_3", "Feign server forbidden"), - FEIGN_EXPIRED_TOKEN(BAD_REQUEST, "FEIGN_400_4", "Feign server expired token"), - FEIGN_NOT_FOUND(BAD_REQUEST, "FEIGN_400_5", "Feign server not found error"), - FEIGN_INTERNAL_SERVER_ERROR(BAD_REQUEST, "FEIGN_400_6", "Feign server internal server error"), - FEIGN_METHOD_NOT_ALLOWED(BAD_REQUEST, "FEIGN_400_7", "Feign server method not allowed"), - FEIGN_SERVER_ERROR(BAD_REQUEST, "FEIGN_500", "Feign server error"), - - // member 관련 에러 - - MEMBER_NOT_FOUND(BAD_REQUEST, "MEMBER_001", "사용자가 없습니다"), - MEMBER_NOT_SAME(BAD_REQUEST, "MEMBER_002", "로그인 된 사용자와 대상 사용자가 일치하지 않습니다."), - - // member 에러 - - // scrap 에러 - SCRAP_ALREADY_EXISTS(CONFLICT, "SCRAP_001", "이미 스크랩했습니다."), - SCRAP_NOT_FOUND(NOT_FOUND, "SCRAP_002", "존재하지 않는 스크랩입니다."), - DUPLICATE_SCRAP(CONFLICT, "SCRAP_003", "중복된 스크랩 요청입니다."), - - // briefing 에러 - NOT_FOUND_BRIEFING(NOT_FOUND, "BRIEFING_001", "브리핑이 존재하지 않습니다."), - NOT_FOUND_TYPE(BAD_REQUEST, "BRIEFING_002", "해당하는 type을 찾을 수 없습니다."), - - // chatting 에러 - - NOT_FOUND_CHATTING(NOT_FOUND, "CHATTING_001", "해당하는 채팅을 찾을 수 없습니다."), - LAST_MESSAGE_NOT_EXIST(BAD_REQUEST, "CHATTING_002", "마지막 메시지를 찾을 수 없습니다."), - BAD_LAST_MESSAGE_ROLE(BAD_REQUEST, "CHATTING_003", "마지막 메시지의 역할이 user가 아닙니다."), - CAN_NOT_EMPTY_CONTENT(BAD_REQUEST, "CHATTING_004", "content가 비어있습니다."), - NOT_FOUND_ROLE(BAD_REQUEST, "CHATTING_005", "해당하는 role을 찾을 수 없습니다."), - NOT_FOUND_MODEL(BAD_REQUEST, "CHATTING_006", "해당하는 mode을 찾을 수 없습니다."); - - private final HttpStatus httpStatus; - private final String code; - private final String message; - - public String getMessage(Throwable e) { - return this.getMessage(this.getMessage() + " - " + e.getMessage()); - // 결과 예시 - "Validation error - Reason why it isn't valid" - } - - public String getMessage(String message) { - return Optional.ofNullable(message) - .filter(Predicate.not(String::isBlank)) - .orElse(this.getMessage()); - } - - public static ErrorCode valueOf(HttpStatus httpStatus) { - if (httpStatus == null) { - throw new GeneralException("HttpStatus is null."); - } - - return Arrays.stream(values()) - .filter(errorCode -> errorCode.getHttpStatus() == httpStatus) - .findFirst() - .orElseGet( - () -> { - if (httpStatus.is4xxClientError()) { - return ErrorCode._BAD_REQUEST; - } else return ErrorCode._INTERNAL_SERVER_ERROR; - }); - } - - // @Override - // public String toString() { - // return String.format("%s (%d)", this.name(), this.getCode()); - // } -} diff --git a/src/main/java/briefing/config/JpaAuditingConfig.java b/src/main/java/briefing/config/JpaAuditingConfig.java deleted file mode 100644 index 3bacc72..0000000 --- a/src/main/java/briefing/config/JpaAuditingConfig.java +++ /dev/null @@ -1,8 +0,0 @@ -package briefing.config; - -import org.springframework.context.annotation.Configuration; -import org.springframework.data.jpa.repository.config.EnableJpaAuditing; - -@Configuration -@EnableJpaAuditing -public class JpaAuditingConfig {} diff --git a/src/main/java/briefing/member/exception/MemberException.java b/src/main/java/briefing/member/exception/MemberException.java deleted file mode 100644 index 05c8421..0000000 --- a/src/main/java/briefing/member/exception/MemberException.java +++ /dev/null @@ -1,10 +0,0 @@ -package briefing.member.exception; - -import briefing.common.exception.common.ErrorCode; -import briefing.common.exception.common.GeneralException; - -public class MemberException extends GeneralException { - public MemberException(ErrorCode errorCode) { - super(errorCode); - } -} diff --git a/src/main/java/briefing/scrap/domain/repository/ScrapCustomRepository.java b/src/main/java/briefing/scrap/domain/repository/ScrapCustomRepository.java deleted file mode 100644 index a764200..0000000 --- a/src/main/java/briefing/scrap/domain/repository/ScrapCustomRepository.java +++ /dev/null @@ -1,3 +0,0 @@ -package briefing.scrap.domain.repository; - -public interface ScrapCustomRepository {} diff --git a/src/main/java/briefing/scrap/exception/ScrapException.java b/src/main/java/briefing/scrap/exception/ScrapException.java deleted file mode 100644 index 0701926..0000000 --- a/src/main/java/briefing/scrap/exception/ScrapException.java +++ /dev/null @@ -1,10 +0,0 @@ -package briefing.scrap.exception; - -import briefing.common.exception.common.ErrorCode; -import briefing.common.exception.common.GeneralException; - -public class ScrapException extends GeneralException { - public ScrapException(ErrorCode errorCode) { - super(errorCode); - } -} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index a93b913..33cfba5 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -15,6 +15,8 @@ swagger: login: id: ${SWAGGER_ID} password : ${SWAGGER_PASS} +fcm: + key: ${FCM_KEY} --- spring: config: