diff --git a/build.gradle b/build.gradle index 2f7791f..8698263 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ plugins { id 'org.jetbrains.kotlin.jvm' } -group = 'org.service' +group = 'com' version = '0.0.1-SNAPSHOT' java { diff --git a/sql/DDL.sql b/sql/DDL.sql index e69de29..4484c0c 100644 --- a/sql/DDL.sql +++ b/sql/DDL.sql @@ -0,0 +1,6 @@ +CREATE TABLE `short_url` ( + `id` BIGINT NOT NULL AUTO_INCREMENT, + `origin_url` VARCHAR(255) NOT NULL, + `create_at` DATETIME DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT = 20000; diff --git a/sql/DML.sql b/sql/DML.sql index e69de29..fe54561 100644 --- a/sql/DML.sql +++ b/sql/DML.sql @@ -0,0 +1 @@ +INSERT INTO `short_url` (`origin_url`) VALUES ('https://example.com'); diff --git a/src/main/java/org/service/urlshortener/Application.java b/src/main/java/com/urlshortener/Application.java similarity index 96% rename from src/main/java/org/service/urlshortener/Application.java rename to src/main/java/com/urlshortener/Application.java index 58dd980..20895bb 100644 --- a/src/main/java/org/service/urlshortener/Application.java +++ b/src/main/java/com/urlshortener/Application.java @@ -1,4 +1,4 @@ -package org.service.urlshortener; +package com.urlshortener; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; diff --git a/src/main/java/org/service/urlshortener/batch/job/UrlDeleteJob.java b/src/main/java/com/urlshortener/batch/job/UrlDeleteJob.java similarity index 57% rename from src/main/java/org/service/urlshortener/batch/job/UrlDeleteJob.java rename to src/main/java/com/urlshortener/batch/job/UrlDeleteJob.java index f42f21b..ad0fe5a 100644 --- a/src/main/java/org/service/urlshortener/batch/job/UrlDeleteJob.java +++ b/src/main/java/com/urlshortener/batch/job/UrlDeleteJob.java @@ -1,9 +1,9 @@ -package org.service.urlshortener.batch.job; +package com.urlshortener.batch.job; import jakarta.transaction.Transactional; import lombok.RequiredArgsConstructor; -import org.service.urlshortener.shortener.domain.OriginUrl; -import org.service.urlshortener.shortener.repository.OriginUrlRepository; +import com.urlshortener.shortener.domain.ShortUrl; +import com.urlshortener.shortener.repository.ShortUrlRepository; import org.springframework.stereotype.Component; import java.time.LocalDateTime; @@ -12,12 +12,12 @@ @Component @RequiredArgsConstructor public class UrlDeleteJob { - private final OriginUrlRepository OriginUrlRepository; + private final ShortUrlRepository OriginUrlRepository; @Transactional public void removeSixMonthsOldData() { LocalDateTime sixMonthsAgo = LocalDateTime.now().minusMonths(6); - List oldDates = OriginUrlRepository.findByCreatedAtBefore(sixMonthsAgo); + List oldDates = OriginUrlRepository.findByCreatedAtBefore(sixMonthsAgo); OriginUrlRepository.deleteAll(oldDates); } } diff --git a/src/main/java/org/service/urlshortener/batch/scheudler/UrlDeleteScheduler.java b/src/main/java/com/urlshortener/batch/scheudler/UrlDeleteScheduler.java similarity index 67% rename from src/main/java/org/service/urlshortener/batch/scheudler/UrlDeleteScheduler.java rename to src/main/java/com/urlshortener/batch/scheudler/UrlDeleteScheduler.java index 4996b19..5d60ba7 100644 --- a/src/main/java/org/service/urlshortener/batch/scheudler/UrlDeleteScheduler.java +++ b/src/main/java/com/urlshortener/batch/scheudler/UrlDeleteScheduler.java @@ -1,10 +1,10 @@ -package org.service.urlshortener.batch.scheudler; +package com.urlshortener.batch.scheudler; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.service.urlshortener.batch.job.UrlDeleteJob; -import org.service.urlshortener.error.dto.ErrorMessage; -import org.service.urlshortener.error.exception.url.NotFinishRemoveSixMonthsOldDataException; +import com.urlshortener.batch.job.UrlDeleteJob; +import com.urlshortener.error.dto.ErrorMessage; +import com.urlshortener.error.exception.url.NotFinishRemoveSixMonthsOldDataException; import org.springframework.scheduling.annotation.Scheduled; @Slf4j diff --git a/src/main/java/org/service/urlshortener/cache/Cache.java b/src/main/java/com/urlshortener/cache/Cache.java similarity index 87% rename from src/main/java/org/service/urlshortener/cache/Cache.java rename to src/main/java/com/urlshortener/cache/Cache.java index 0d9c751..efc2a5a 100644 --- a/src/main/java/org/service/urlshortener/cache/Cache.java +++ b/src/main/java/com/urlshortener/cache/Cache.java @@ -1,4 +1,4 @@ -package org.service.urlshortener.cache; +package com.urlshortener.cache; import lombok.AllArgsConstructor; import lombok.Data; diff --git a/src/main/java/org/service/urlshortener/cache/CacheFactory.java b/src/main/java/com/urlshortener/cache/CacheFactory.java similarity index 73% rename from src/main/java/org/service/urlshortener/cache/CacheFactory.java rename to src/main/java/com/urlshortener/cache/CacheFactory.java index b951ad2..e17ba91 100644 --- a/src/main/java/org/service/urlshortener/cache/CacheFactory.java +++ b/src/main/java/com/urlshortener/cache/CacheFactory.java @@ -1,6 +1,6 @@ -package org.service.urlshortener.cache; +package com.urlshortener.cache; -import org.service.urlshortener.shortener.dto.ShortUrlModel; +import com.urlshortener.shortener.dto.model.ShortUrlModel; import java.time.Duration; diff --git a/src/main/java/org/service/urlshortener/cache/CacheService.java b/src/main/java/com/urlshortener/cache/CacheService.java similarity index 94% rename from src/main/java/org/service/urlshortener/cache/CacheService.java rename to src/main/java/com/urlshortener/cache/CacheService.java index 62052d7..2dac370 100644 --- a/src/main/java/org/service/urlshortener/cache/CacheService.java +++ b/src/main/java/com/urlshortener/cache/CacheService.java @@ -1,8 +1,8 @@ -package org.service.urlshortener.cache; +package com.urlshortener.cache; import lombok.RequiredArgsConstructor; import lombok.SneakyThrows; -import org.service.urlshortener.util.MapperUtil; +import com.urlshortener.util.MapperUtil; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Service; diff --git a/src/main/java/org/service/urlshortener/common/entity/BaseEntity.java b/src/main/java/com/urlshortener/common/entity/BaseEntity.java similarity index 94% rename from src/main/java/org/service/urlshortener/common/entity/BaseEntity.java rename to src/main/java/com/urlshortener/common/entity/BaseEntity.java index 753a2b8..2dfb7f3 100644 --- a/src/main/java/org/service/urlshortener/common/entity/BaseEntity.java +++ b/src/main/java/com/urlshortener/common/entity/BaseEntity.java @@ -1,4 +1,4 @@ -package org.service.urlshortener.common.entity; +package com.urlshortener.common.entity; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; diff --git a/src/main/java/com/urlshortener/common/response/ResponseDto.java b/src/main/java/com/urlshortener/common/response/ResponseDto.java new file mode 100644 index 0000000..461e0b3 --- /dev/null +++ b/src/main/java/com/urlshortener/common/response/ResponseDto.java @@ -0,0 +1,29 @@ +package com.urlshortener.common.response; + +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; + +import java.io.Serializable; + +@Data +@AllArgsConstructor +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class ResponseDto implements Serializable { + private T data; + + public static ResponseEntity> ok(T data) { + return ResponseEntity.ok(new ResponseDto(data)); + } + + public static ResponseEntity> created(T data) { + return ResponseEntity.status(HttpStatus.CREATED).body(new ResponseDto(data)); + } + + public static ResponseEntity noContent() { + return ResponseEntity.status(HttpStatus.NO_CONTENT).build(); + } +} \ No newline at end of file diff --git a/src/main/java/org/service/urlshortener/config/database/JpaConfig.java b/src/main/java/com/urlshortener/config/database/JpaConfig.java similarity index 79% rename from src/main/java/org/service/urlshortener/config/database/JpaConfig.java rename to src/main/java/com/urlshortener/config/database/JpaConfig.java index 54355c8..840c27e 100644 --- a/src/main/java/org/service/urlshortener/config/database/JpaConfig.java +++ b/src/main/java/com/urlshortener/config/database/JpaConfig.java @@ -1,4 +1,4 @@ -package org.service.urlshortener.config.database; +package com.urlshortener.config.database; import org.springframework.context.annotation.Configuration; import org.springframework.data.jpa.repository.config.EnableJpaAuditing; diff --git a/src/main/java/org/service/urlshortener/config/database/RedisConfig.java b/src/main/java/com/urlshortener/config/database/RedisConfig.java similarity index 98% rename from src/main/java/org/service/urlshortener/config/database/RedisConfig.java rename to src/main/java/com/urlshortener/config/database/RedisConfig.java index 947fd9c..5aa5033 100644 --- a/src/main/java/org/service/urlshortener/config/database/RedisConfig.java +++ b/src/main/java/com/urlshortener/config/database/RedisConfig.java @@ -1,4 +1,4 @@ -package org.service.urlshortener.config.database; +package com.urlshortener.config.database; import lombok.Getter; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/org/service/urlshortener/config/scheduler/SchedulerConfig.java b/src/main/java/com/urlshortener/config/scheduler/SchedulerConfig.java similarity index 79% rename from src/main/java/org/service/urlshortener/config/scheduler/SchedulerConfig.java rename to src/main/java/com/urlshortener/config/scheduler/SchedulerConfig.java index b0673d5..a8394ec 100644 --- a/src/main/java/org/service/urlshortener/config/scheduler/SchedulerConfig.java +++ b/src/main/java/com/urlshortener/config/scheduler/SchedulerConfig.java @@ -1,4 +1,4 @@ -package org.service.urlshortener.config.scheduler; +package com.urlshortener.config.scheduler; import org.springframework.context.annotation.Configuration; import org.springframework.scheduling.annotation.EnableScheduling; diff --git a/src/main/java/org/service/urlshortener/config/web/WebConfig.java b/src/main/java/com/urlshortener/config/web/WebConfig.java similarity index 82% rename from src/main/java/org/service/urlshortener/config/web/WebConfig.java rename to src/main/java/com/urlshortener/config/web/WebConfig.java index 905ece6..2bc281a 100644 --- a/src/main/java/org/service/urlshortener/config/web/WebConfig.java +++ b/src/main/java/com/urlshortener/config/web/WebConfig.java @@ -1,11 +1,12 @@ -package org.service.urlshortener.config.web; +package com.urlshortener.config.web; +import com.urlshortener.ratelimit.interceptor.ClientIdInterceptor; import lombok.RequiredArgsConstructor; -import org.service.urlshortener.ratelimit.interceptor.ClientIdInterceptor; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + @Configuration @RequiredArgsConstructor public class WebConfig implements WebMvcConfigurer { diff --git a/src/main/java/org/service/urlshortener/error/GlobalExceptionHandler.java b/src/main/java/com/urlshortener/error/GlobalExceptionHandler.java similarity index 78% rename from src/main/java/org/service/urlshortener/error/GlobalExceptionHandler.java rename to src/main/java/com/urlshortener/error/GlobalExceptionHandler.java index b09c96b..17535bb 100644 --- a/src/main/java/org/service/urlshortener/error/GlobalExceptionHandler.java +++ b/src/main/java/com/urlshortener/error/GlobalExceptionHandler.java @@ -1,10 +1,9 @@ -package org.service.urlshortener.error; - +package com.urlshortener.error; import lombok.extern.slf4j.Slf4j; -import org.service.urlshortener.error.dto.ErrorMessage; -import org.service.urlshortener.error.dto.ErrorResponseDto; -import org.service.urlshortener.error.exception.BusinessException; +import com.urlshortener.error.dto.ErrorMessage; +import com.urlshortener.error.dto.ErrorResponseDto; +import com.urlshortener.error.exception.BusinessException; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.RestControllerAdvice; diff --git a/src/main/java/org/service/urlshortener/error/dto/ErrorMessage.java b/src/main/java/com/urlshortener/error/dto/ErrorMessage.java similarity index 94% rename from src/main/java/org/service/urlshortener/error/dto/ErrorMessage.java rename to src/main/java/com/urlshortener/error/dto/ErrorMessage.java index 7139bab..9847645 100644 --- a/src/main/java/org/service/urlshortener/error/dto/ErrorMessage.java +++ b/src/main/java/com/urlshortener/error/dto/ErrorMessage.java @@ -1,4 +1,4 @@ -package org.service.urlshortener.error.dto; +package com.urlshortener.error.dto; import lombok.Getter; import org.springframework.http.HttpStatus; diff --git a/src/main/java/org/service/urlshortener/error/dto/ErrorResponseDto.java b/src/main/java/com/urlshortener/error/dto/ErrorResponseDto.java similarity index 92% rename from src/main/java/org/service/urlshortener/error/dto/ErrorResponseDto.java rename to src/main/java/com/urlshortener/error/dto/ErrorResponseDto.java index 1107357..422beaa 100644 --- a/src/main/java/org/service/urlshortener/error/dto/ErrorResponseDto.java +++ b/src/main/java/com/urlshortener/error/dto/ErrorResponseDto.java @@ -1,4 +1,4 @@ -package org.service.urlshortener.error.dto; +package com.urlshortener.error.dto; import lombok.Data; import org.springframework.http.ResponseEntity; diff --git a/src/main/java/org/service/urlshortener/error/exception/BusinessException.java b/src/main/java/com/urlshortener/error/exception/BusinessException.java similarity index 71% rename from src/main/java/org/service/urlshortener/error/exception/BusinessException.java rename to src/main/java/com/urlshortener/error/exception/BusinessException.java index be4e66b..627aa98 100644 --- a/src/main/java/org/service/urlshortener/error/exception/BusinessException.java +++ b/src/main/java/com/urlshortener/error/exception/BusinessException.java @@ -1,8 +1,8 @@ -package org.service.urlshortener.error.exception; +package com.urlshortener.error.exception; import lombok.Getter; -import org.service.urlshortener.error.dto.ErrorMessage; +import com.urlshortener.error.dto.ErrorMessage; @Getter public class BusinessException extends RuntimeException{ diff --git a/src/main/java/org/service/urlshortener/error/exception/InvalidJsonDataException.java b/src/main/java/com/urlshortener/error/exception/InvalidJsonDataException.java similarity index 60% rename from src/main/java/org/service/urlshortener/error/exception/InvalidJsonDataException.java rename to src/main/java/com/urlshortener/error/exception/InvalidJsonDataException.java index 976dc97..f322a3b 100644 --- a/src/main/java/org/service/urlshortener/error/exception/InvalidJsonDataException.java +++ b/src/main/java/com/urlshortener/error/exception/InvalidJsonDataException.java @@ -1,6 +1,6 @@ -package org.service.urlshortener.error.exception; +package com.urlshortener.error.exception; -import org.service.urlshortener.error.dto.ErrorMessage; +import com.urlshortener.error.dto.ErrorMessage; public class InvalidJsonDataException extends BusinessException { public InvalidJsonDataException(ErrorMessage message) { diff --git a/src/main/java/com/urlshortener/error/exception/health/ExampleException.java b/src/main/java/com/urlshortener/error/exception/health/ExampleException.java new file mode 100644 index 0000000..e929f27 --- /dev/null +++ b/src/main/java/com/urlshortener/error/exception/health/ExampleException.java @@ -0,0 +1,11 @@ +package com.urlshortener.error.exception.health; + + +import com.urlshortener.error.dto.ErrorMessage; +import com.urlshortener.error.exception.BusinessException; + +public class ExampleException extends BusinessException { + public ExampleException(ErrorMessage message) { + super(message); + } +} \ No newline at end of file diff --git a/src/main/java/org/service/urlshortener/error/exception/url/NotFinishRemoveSixMonthsOldDataException.java b/src/main/java/com/urlshortener/error/exception/url/NotFinishRemoveSixMonthsOldDataException.java similarity index 52% rename from src/main/java/org/service/urlshortener/error/exception/url/NotFinishRemoveSixMonthsOldDataException.java rename to src/main/java/com/urlshortener/error/exception/url/NotFinishRemoveSixMonthsOldDataException.java index bee3eaf..ff12dda 100644 --- a/src/main/java/org/service/urlshortener/error/exception/url/NotFinishRemoveSixMonthsOldDataException.java +++ b/src/main/java/com/urlshortener/error/exception/url/NotFinishRemoveSixMonthsOldDataException.java @@ -1,7 +1,7 @@ -package org.service.urlshortener.error.exception.url; +package com.urlshortener.error.exception.url; -import org.service.urlshortener.error.dto.ErrorMessage; -import org.service.urlshortener.error.exception.BusinessException; +import com.urlshortener.error.dto.ErrorMessage; +import com.urlshortener.error.exception.BusinessException; public class NotFinishRemoveSixMonthsOldDataException extends BusinessException { public NotFinishRemoveSixMonthsOldDataException(ErrorMessage message) { diff --git a/src/main/java/com/urlshortener/error/exception/url/NotFoundUrlException.java b/src/main/java/com/urlshortener/error/exception/url/NotFoundUrlException.java new file mode 100644 index 0000000..b2a37d8 --- /dev/null +++ b/src/main/java/com/urlshortener/error/exception/url/NotFoundUrlException.java @@ -0,0 +1,10 @@ +package com.urlshortener.error.exception.url; + +import com.urlshortener.error.dto.ErrorMessage; +import com.urlshortener.error.exception.BusinessException; + +public class NotFoundUrlException extends BusinessException { + public NotFoundUrlException(ErrorMessage message) { + super(message); + } +} \ No newline at end of file diff --git a/src/main/java/com/urlshortener/error/exception/url/RateLimitExceededException.java b/src/main/java/com/urlshortener/error/exception/url/RateLimitExceededException.java new file mode 100644 index 0000000..d893f7a --- /dev/null +++ b/src/main/java/com/urlshortener/error/exception/url/RateLimitExceededException.java @@ -0,0 +1,11 @@ +package com.urlshortener.error.exception.url; + +import com.urlshortener.error.dto.ErrorMessage; +import com.urlshortener.error.exception.BusinessException; + +public class RateLimitExceededException extends BusinessException { + + public RateLimitExceededException(ErrorMessage message) { + super(message); + } +} diff --git a/src/main/java/org/service/urlshortener/health/controller/HealthRestController.java b/src/main/java/com/urlshortener/health/controller/HealthRestController.java similarity index 53% rename from src/main/java/org/service/urlshortener/health/controller/HealthRestController.java rename to src/main/java/com/urlshortener/health/controller/HealthRestController.java index fe8cc1d..364f9f6 100644 --- a/src/main/java/org/service/urlshortener/health/controller/HealthRestController.java +++ b/src/main/java/com/urlshortener/health/controller/HealthRestController.java @@ -1,7 +1,6 @@ -package org.service.urlshortener.health.controller; +package com.urlshortener.health.controller; -import org.service.urlshortener.common.response.ResponseDto; -import org.service.urlshortener.common.response.ResponseMessage; +import com.urlshortener.common.response.ResponseDto; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @@ -10,6 +9,6 @@ public class HealthRestController { @GetMapping("/api/v1/health") public ResponseEntity getHealth() { - return ResponseDto.toResponseEntity(ResponseMessage.SUCCESS, "health good~~!"); + return ResponseDto.ok("health good~~!"); } } \ No newline at end of file diff --git a/src/main/java/org/service/urlshortener/health/controller/ViewHealthController.java b/src/main/java/com/urlshortener/health/controller/ViewHealthController.java similarity index 82% rename from src/main/java/org/service/urlshortener/health/controller/ViewHealthController.java rename to src/main/java/com/urlshortener/health/controller/ViewHealthController.java index 0c068aa..edf0ab7 100644 --- a/src/main/java/org/service/urlshortener/health/controller/ViewHealthController.java +++ b/src/main/java/com/urlshortener/health/controller/ViewHealthController.java @@ -1,4 +1,4 @@ -package org.service.urlshortener.health.controller; +package com.urlshortener.health.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; diff --git a/src/main/java/org/service/urlshortener/ratelimit/interceptor/ClientIdInterceptor.java b/src/main/java/com/urlshortener/ratelimit/interceptor/ClientIdInterceptor.java similarity index 87% rename from src/main/java/org/service/urlshortener/ratelimit/interceptor/ClientIdInterceptor.java rename to src/main/java/com/urlshortener/ratelimit/interceptor/ClientIdInterceptor.java index 6081f5f..379787d 100644 --- a/src/main/java/org/service/urlshortener/ratelimit/interceptor/ClientIdInterceptor.java +++ b/src/main/java/com/urlshortener/ratelimit/interceptor/ClientIdInterceptor.java @@ -1,4 +1,4 @@ -package org.service.urlshortener.ratelimit.interceptor; +package com.urlshortener.ratelimit.interceptor; import jakarta.servlet.http.Cookie; import jakarta.servlet.http.HttpServletRequest; @@ -6,9 +6,9 @@ import lombok.NonNull; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.service.urlshortener.error.dto.ErrorMessage; -import org.service.urlshortener.error.exception.url.RateLimitExceededException; -import org.service.urlshortener.ratelimit.service.RateLimitService; +import com.urlshortener.error.dto.ErrorMessage; +import com.urlshortener.error.exception.url.RateLimitExceededException; +import com.urlshortener.ratelimit.service.RateLimitService; import org.springframework.stereotype.Component; import org.springframework.web.servlet.HandlerInterceptor; diff --git a/src/main/java/org/service/urlshortener/ratelimit/service/RateLimitService.java b/src/main/java/com/urlshortener/ratelimit/service/RateLimitService.java similarity index 93% rename from src/main/java/org/service/urlshortener/ratelimit/service/RateLimitService.java rename to src/main/java/com/urlshortener/ratelimit/service/RateLimitService.java index 61c0f10..5f47ed0 100644 --- a/src/main/java/org/service/urlshortener/ratelimit/service/RateLimitService.java +++ b/src/main/java/com/urlshortener/ratelimit/service/RateLimitService.java @@ -1,4 +1,4 @@ -package org.service.urlshortener.ratelimit.service; +package com.urlshortener.ratelimit.service; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; diff --git a/src/main/java/org/service/urlshortener/shortener/comtroller/rest/ShortenerRestController.java b/src/main/java/com/urlshortener/shortener/comtroller/rest/ShortenerRestController.java similarity index 53% rename from src/main/java/org/service/urlshortener/shortener/comtroller/rest/ShortenerRestController.java rename to src/main/java/com/urlshortener/shortener/comtroller/rest/ShortenerRestController.java index 44ce471..c54d61c 100644 --- a/src/main/java/org/service/urlshortener/shortener/comtroller/rest/ShortenerRestController.java +++ b/src/main/java/com/urlshortener/shortener/comtroller/rest/ShortenerRestController.java @@ -1,17 +1,14 @@ -package org.service.urlshortener.shortener.comtroller.rest; +package com.urlshortener.shortener.comtroller.rest; +import com.urlshortener.common.response.ResponseDto; +import com.urlshortener.shortener.dto.request.OriginUrlRequest; +import com.urlshortener.shortener.dto.request.ShortCodeRequest; +import com.urlshortener.shortener.service.ShortenerService; import jakarta.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.service.urlshortener.common.response.ResponseDto; -import org.service.urlshortener.common.response.ResponseMessage; -import org.service.urlshortener.shortener.domain.vo.UrlDomain; -import org.service.urlshortener.shortener.dto.request.OriginUrlRequest; -import org.service.urlshortener.shortener.dto.request.ShortCodeRequest; -import org.service.urlshortener.shortener.service.ShortenerService; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; -import org.springframework.web.servlet.view.RedirectView; import java.io.IOException; @@ -31,10 +28,10 @@ public class ShortenerRestController { public ResponseEntity createShortUrl( @RequestBody OriginUrlRequest originUrlRequest ) { - var shortUrl = UrlDomain.URL + shortenerService.createShortUrl(originUrlRequest).getShortCode(); + var shortUrl = shortenerService.createShortUrl(originUrlRequest).getShortCode(); log.debug("short={}", shortUrl); - return ResponseDto.toResponseEntity(ResponseMessage.SUCCESS, shortUrl); + return ResponseDto.created(shortUrl); } /** @@ -46,21 +43,13 @@ public ResponseEntity createShortUrl( */ @GetMapping("{shortCode}") public void getOriginUrl( - @PathVariable("shortCode") String shortCode, + @PathVariable("shortCode") ShortCodeRequest shortCode, HttpServletResponse response ) throws IOException { log.debug("shortCode = {}", shortCode); - var originUrl = shortenerService.getOriginUrl(new ShortCodeRequest(shortCode)).getOriginUrl(); + var originUrl = shortenerService.getOriginUrl(shortCode).getOriginUrl(); log.debug("originUrl = {}", originUrl); response.sendRedirect(originUrl); } - - /** - * 메인 페이지로 리다이렉드하는 API - */ - @GetMapping() - public RedirectView getPage() { - return new RedirectView("/main"); - } } \ No newline at end of file diff --git a/src/main/java/org/service/urlshortener/shortener/comtroller/view/ShortenerViewController.java b/src/main/java/com/urlshortener/shortener/comtroller/view/ShortenerViewController.java similarity index 54% rename from src/main/java/org/service/urlshortener/shortener/comtroller/view/ShortenerViewController.java rename to src/main/java/com/urlshortener/shortener/comtroller/view/ShortenerViewController.java index f774b98..af89ad2 100644 --- a/src/main/java/org/service/urlshortener/shortener/comtroller/view/ShortenerViewController.java +++ b/src/main/java/com/urlshortener/shortener/comtroller/view/ShortenerViewController.java @@ -1,4 +1,4 @@ -package org.service.urlshortener.shortener.comtroller.view; +package com.urlshortener.shortener.comtroller.view; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Controller; @@ -8,10 +8,18 @@ @Controller public class ShortenerViewController { /** - * @return (main.jsp) 메인 화면을 반환합니다. + * @return 메인 화면을 반환합니다. */ @GetMapping("/main") public String page() { return "main"; } + + /** + * @return 메인 화면을 반환합니다. + */ + @GetMapping("/") + public String homePage() { + return "main"; + } } \ No newline at end of file diff --git a/src/main/java/com/urlshortener/shortener/domain/ShortUrl.java b/src/main/java/com/urlshortener/shortener/domain/ShortUrl.java new file mode 100644 index 0000000..c277447 --- /dev/null +++ b/src/main/java/com/urlshortener/shortener/domain/ShortUrl.java @@ -0,0 +1,37 @@ +package com.urlshortener.shortener.domain; + +import jakarta.persistence.*; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; +import com.urlshortener.common.entity.BaseEntity; + +@Entity +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@Getter +public class ShortUrl extends BaseEntity { + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "short_url_generator") + @SequenceGenerator(name = "short_url_generator", sequenceName = "id", initialValue = 20000, allocationSize = 1) + private Long id; + + /** + * 요청한 url + */ + @Column(name = "origin_url") + private String originUrl; + + /** + * + * ShortUrl Entity 생성 method + * + * @param originUrl + * @return ShortUrl + */ + public static ShortUrl from(String originUrl) { + ShortUrl shortUrl = new ShortUrl(); + shortUrl.originUrl = originUrl; + + return shortUrl; + } +} \ No newline at end of file diff --git a/src/main/java/com/urlshortener/shortener/dto/model/ShortUrlModel.java b/src/main/java/com/urlshortener/shortener/dto/model/ShortUrlModel.java new file mode 100644 index 0000000..97ec1cf --- /dev/null +++ b/src/main/java/com/urlshortener/shortener/dto/model/ShortUrlModel.java @@ -0,0 +1,23 @@ +package com.urlshortener.shortener.dto.model; + +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.time.LocalDateTime; + +@Getter +@NoArgsConstructor +public class ShortUrlModel { + private Long id; + private String originalUrl; + private LocalDateTime createAtl; + + public static ShortUrlModel from(Long id, String originalUrl, LocalDateTime createAtl){ + ShortUrlModel shortUrlModel = new ShortUrlModel(); + shortUrlModel.id = id; + shortUrlModel.originalUrl = originalUrl; + shortUrlModel.createAtl = createAtl; + + return shortUrlModel; + } +} \ No newline at end of file diff --git a/src/main/java/org/service/urlshortener/shortener/dto/request/OriginUrlRequest.java b/src/main/java/com/urlshortener/shortener/dto/request/OriginUrlRequest.java similarity index 67% rename from src/main/java/org/service/urlshortener/shortener/dto/request/OriginUrlRequest.java rename to src/main/java/com/urlshortener/shortener/dto/request/OriginUrlRequest.java index 900c900..44ebd06 100644 --- a/src/main/java/org/service/urlshortener/shortener/dto/request/OriginUrlRequest.java +++ b/src/main/java/com/urlshortener/shortener/dto/request/OriginUrlRequest.java @@ -1,12 +1,15 @@ -package org.service.urlshortener.shortener.dto.request; +package com.urlshortener.shortener.dto.request; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; @Getter -@AllArgsConstructor @NoArgsConstructor +@AllArgsConstructor public class OriginUrlRequest { + /** + * 요청받은 원본 url + */ private String originUrl; } \ No newline at end of file diff --git a/src/main/java/org/service/urlshortener/shortener/dto/request/ShortCodeRequest.java b/src/main/java/com/urlshortener/shortener/dto/request/ShortCodeRequest.java similarity index 66% rename from src/main/java/org/service/urlshortener/shortener/dto/request/ShortCodeRequest.java rename to src/main/java/com/urlshortener/shortener/dto/request/ShortCodeRequest.java index 76425e8..4df8ebc 100644 --- a/src/main/java/org/service/urlshortener/shortener/dto/request/ShortCodeRequest.java +++ b/src/main/java/com/urlshortener/shortener/dto/request/ShortCodeRequest.java @@ -1,12 +1,15 @@ -package org.service.urlshortener.shortener.dto.request; +package com.urlshortener.shortener.dto.request; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; @Getter -@AllArgsConstructor @NoArgsConstructor +@AllArgsConstructor public class ShortCodeRequest { + /** + * 요청 받은 최적화 code + */ private String shortCode; } diff --git a/src/main/java/com/urlshortener/shortener/dto/response/OriginUrlResponse.java b/src/main/java/com/urlshortener/shortener/dto/response/OriginUrlResponse.java new file mode 100644 index 0000000..ed2264c --- /dev/null +++ b/src/main/java/com/urlshortener/shortener/dto/response/OriginUrlResponse.java @@ -0,0 +1,15 @@ +package com.urlshortener.shortener.dto.response; + +import lombok.Getter; + +@Getter +public class OriginUrlResponse { + private String originUrl; + + public static OriginUrlResponse from(String originUrl){ + OriginUrlResponse originUrlResponse = new OriginUrlResponse(); + originUrlResponse.originUrl = originUrl; + + return originUrlResponse; + } +} \ No newline at end of file diff --git a/src/main/java/com/urlshortener/shortener/dto/response/ShortCodeResponse.java b/src/main/java/com/urlshortener/shortener/dto/response/ShortCodeResponse.java new file mode 100644 index 0000000..b1f0f8d --- /dev/null +++ b/src/main/java/com/urlshortener/shortener/dto/response/ShortCodeResponse.java @@ -0,0 +1,15 @@ +package com.urlshortener.shortener.dto.response; + +import lombok.Getter; + +@Getter +public class ShortCodeResponse { + private String shortCode; + + public static ShortCodeResponse from(String shortCode){ + ShortCodeResponse shortCodeResponse = new ShortCodeResponse(); + shortCodeResponse.shortCode = shortCode; + + return shortCodeResponse; + } +} \ No newline at end of file diff --git a/src/main/java/com/urlshortener/shortener/repository/ShortUrlRepository.java b/src/main/java/com/urlshortener/shortener/repository/ShortUrlRepository.java new file mode 100644 index 0000000..beffe61 --- /dev/null +++ b/src/main/java/com/urlshortener/shortener/repository/ShortUrlRepository.java @@ -0,0 +1,13 @@ +package com.urlshortener.shortener.repository; + +import com.urlshortener.shortener.domain.ShortUrl; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.transaction.annotation.Transactional; + +import java.time.LocalDateTime; +import java.util.List; + +@Transactional(readOnly = true) +public interface ShortUrlRepository extends JpaRepository { + List findByCreatedAtBefore(LocalDateTime date); +} \ No newline at end of file diff --git a/src/main/java/org/service/urlshortener/shortener/service/EncryptionService.java b/src/main/java/com/urlshortener/shortener/service/EncryptionService.java similarity index 95% rename from src/main/java/org/service/urlshortener/shortener/service/EncryptionService.java rename to src/main/java/com/urlshortener/shortener/service/EncryptionService.java index ace663f..ce662db 100644 --- a/src/main/java/org/service/urlshortener/shortener/service/EncryptionService.java +++ b/src/main/java/com/urlshortener/shortener/service/EncryptionService.java @@ -1,4 +1,4 @@ -package org.service.urlshortener.shortener.service; +package com.urlshortener.shortener.service; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; diff --git a/src/main/java/org/service/urlshortener/shortener/service/ShortenerService.java b/src/main/java/com/urlshortener/shortener/service/ShortenerService.java similarity index 55% rename from src/main/java/org/service/urlshortener/shortener/service/ShortenerService.java rename to src/main/java/com/urlshortener/shortener/service/ShortenerService.java index 9228f97..f49bf1a 100644 --- a/src/main/java/org/service/urlshortener/shortener/service/ShortenerService.java +++ b/src/main/java/com/urlshortener/shortener/service/ShortenerService.java @@ -1,18 +1,19 @@ -package org.service.urlshortener.shortener.service; +package com.urlshortener.shortener.service; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.service.urlshortener.cache.CacheFactory; -import org.service.urlshortener.cache.CacheService; -import org.service.urlshortener.error.dto.ErrorMessage; -import org.service.urlshortener.error.exception.url.NotFoundUrlException; -import org.service.urlshortener.shortener.domain.OriginUrl; -import org.service.urlshortener.shortener.dto.ShortUrlModel; -import org.service.urlshortener.shortener.dto.request.OriginUrlRequest; -import org.service.urlshortener.shortener.dto.request.ShortCodeRequest; -import org.service.urlshortener.shortener.dto.response.OriginUrlResponse; -import org.service.urlshortener.shortener.dto.response.ShortCodeResponse; -import org.service.urlshortener.shortener.repository.OriginUrlRepository; +import com.urlshortener.cache.CacheFactory; +import com.urlshortener.cache.CacheService; +import com.urlshortener.error.dto.ErrorMessage; +import com.urlshortener.error.exception.url.NotFoundUrlException; +import com.urlshortener.shortener.domain.ShortUrl; +import com.urlshortener.shortener.dto.model.ShortUrlModel; +import com.urlshortener.shortener.dto.request.OriginUrlRequest; +import com.urlshortener.shortener.dto.request.ShortCodeRequest; +import com.urlshortener.shortener.dto.response.OriginUrlResponse; +import com.urlshortener.shortener.dto.response.ShortCodeResponse; +import com.urlshortener.shortener.repository.ShortUrlRepository; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -20,27 +21,31 @@ @Service @RequiredArgsConstructor public class ShortenerService { - private final OriginUrlRepository originUrlRepository; + private final ShortUrlRepository originUrlRepository; private final CacheService cacheService; private final EncryptionService encryptionService; + @Value("${server.domain}") + private String domain; + /** * @param request 는 변경 할 OriginUrl * @return originUrl -> shortUrl 로 변환 값을 'ShortUrlResponse' 로 반환합니다. */ @Transactional public ShortCodeResponse createShortUrl(OriginUrlRequest request) { - OriginUrl url = originUrlRepository.save(new OriginUrl(request.getOriginUrl())); + ShortUrl url = originUrlRepository.save(ShortUrl.from(request.getOriginUrl())); cacheService .asyncSet(CacheFactory .makeCachedQuiz( url.getId()), - new ShortUrlModel( + ShortUrlModel.from( url.getId(), url.getOriginUrl(), url.getCreatedAt())); + var shortCode = encryptionService.encode(url.getId()); - return new ShortCodeResponse(encryptionService.encode(url.getId())); + return ShortCodeResponse.from(domain + shortCode); } /** @@ -59,9 +64,12 @@ public OriginUrlResponse getOriginUrl(ShortCodeRequest request) { .findById(originUrlId) .orElseThrow(() -> new NotFoundUrlException(ErrorMessage.NOT_FOUND_URL)); - return new ShortUrlModel(findUrl.getId(), findUrl.getOriginUrl(), findUrl.getCreatedAt()); - }); + return ShortUrlModel.from( + findUrl.getId(), + findUrl.getOriginUrl(), + findUrl.getCreatedAt()); + }).getOriginalUrl(); - return new OriginUrlResponse(resultUrl.getOriginalUrl()); + return OriginUrlResponse.from(resultUrl); } } \ No newline at end of file diff --git a/src/main/java/org/service/urlshortener/util/MapperUtil.java b/src/main/java/com/urlshortener/util/MapperUtil.java similarity index 93% rename from src/main/java/org/service/urlshortener/util/MapperUtil.java rename to src/main/java/com/urlshortener/util/MapperUtil.java index 7b6d3aa..9ad4e93 100644 --- a/src/main/java/org/service/urlshortener/util/MapperUtil.java +++ b/src/main/java/com/urlshortener/util/MapperUtil.java @@ -1,4 +1,4 @@ -package org.service.urlshortener.util; +package com.urlshortener.util; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.type.TypeReference; @@ -7,8 +7,8 @@ import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import lombok.extern.slf4j.Slf4j; -import org.service.urlshortener.error.dto.ErrorMessage; -import org.service.urlshortener.error.exception.InvalidJsonDataException; +import com.urlshortener.error.dto.ErrorMessage; +import com.urlshortener.error.exception.InvalidJsonDataException; import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL; import static com.fasterxml.jackson.databind.SerializationFeature.WRITE_DATES_AS_TIMESTAMPS; diff --git a/src/main/java/org/service/urlshortener/common/response/ResponseDto.java b/src/main/java/org/service/urlshortener/common/response/ResponseDto.java deleted file mode 100644 index 3ccc5a3..0000000 --- a/src/main/java/org/service/urlshortener/common/response/ResponseDto.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.service.urlshortener.common.response; - -import java.time.LocalDate; -import java.time.format.DateTimeFormatter; - -import lombok.Getter; -import org.springframework.http.ResponseEntity; - -@Getter -public class ResponseDto { - - private final String message; - private final String serverDateTime; - private final T data; - - public ResponseDto(ResponseMessage message, T data) { - this.message = message.name(); - this.data = data; - this.serverDateTime = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")); - } - - public static ResponseEntity> toResponseEntity(ResponseMessage message, T data) { - return ResponseEntity - .status(message.getStatus()) - .body(new ResponseDto<>(message, data)); - } -} \ No newline at end of file diff --git a/src/main/java/org/service/urlshortener/common/response/ResponseMessage.java b/src/main/java/org/service/urlshortener/common/response/ResponseMessage.java deleted file mode 100644 index 10c3bfb..0000000 --- a/src/main/java/org/service/urlshortener/common/response/ResponseMessage.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.service.urlshortener.common.response; - -import lombok.Getter; -import org.springframework.http.HttpStatus; - -@Getter -public enum ResponseMessage { - SUCCESS(HttpStatus.OK, "SUCCESS"), - ; - - private final HttpStatus status; - private final String message; - - ResponseMessage(HttpStatus status, String message) { - this.status = status; - this.message = message; - } -} \ No newline at end of file diff --git a/src/main/java/org/service/urlshortener/error/exception/health/ExampleException.java b/src/main/java/org/service/urlshortener/error/exception/health/ExampleException.java deleted file mode 100644 index dc3d897..0000000 --- a/src/main/java/org/service/urlshortener/error/exception/health/ExampleException.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.service.urlshortener.error.exception.health; - - -import org.service.urlshortener.error.dto.ErrorMessage; -import org.service.urlshortener.error.exception.BusinessException; - -public class ExampleException extends BusinessException { - public ExampleException(ErrorMessage message) { - super(message); - } -} \ No newline at end of file diff --git a/src/main/java/org/service/urlshortener/error/exception/url/NotFoundUrlException.java b/src/main/java/org/service/urlshortener/error/exception/url/NotFoundUrlException.java deleted file mode 100644 index 48c94e1..0000000 --- a/src/main/java/org/service/urlshortener/error/exception/url/NotFoundUrlException.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.service.urlshortener.error.exception.url; - -import org.service.urlshortener.error.dto.ErrorMessage; -import org.service.urlshortener.error.exception.BusinessException; - -public class NotFoundUrlException extends BusinessException { - public NotFoundUrlException(ErrorMessage message) { - super(message); - } -} \ No newline at end of file diff --git a/src/main/java/org/service/urlshortener/error/exception/url/RateLimitExceededException.java b/src/main/java/org/service/urlshortener/error/exception/url/RateLimitExceededException.java deleted file mode 100644 index 93ac114..0000000 --- a/src/main/java/org/service/urlshortener/error/exception/url/RateLimitExceededException.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.service.urlshortener.error.exception.url; - -import org.service.urlshortener.error.dto.ErrorMessage; -import org.service.urlshortener.error.exception.BusinessException; - -public class RateLimitExceededException extends BusinessException { - - public RateLimitExceededException(ErrorMessage message) { - super(message); - } -} diff --git a/src/main/java/org/service/urlshortener/shortener/domain/OriginUrl.java b/src/main/java/org/service/urlshortener/shortener/domain/OriginUrl.java deleted file mode 100644 index f90bb38..0000000 --- a/src/main/java/org/service/urlshortener/shortener/domain/OriginUrl.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.service.urlshortener.shortener.domain; - -import jakarta.persistence.*; -import lombok.AccessLevel; -import lombok.Getter; -import lombok.NoArgsConstructor; -import org.service.urlshortener.common.entity.BaseEntity; - -@Entity -@NoArgsConstructor(access = AccessLevel.PROTECTED) -@Getter -public class OriginUrl extends BaseEntity { - @Id - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "url_generator") - @SequenceGenerator(name = "url_generator", sequenceName = "url_id", initialValue = 20000, allocationSize = 1) - private Long id; - - @Column(name = "origin_url") - private String originUrl; - - public OriginUrl(String originUrl) { - this.originUrl = originUrl; - } -} \ No newline at end of file diff --git a/src/main/java/org/service/urlshortener/shortener/domain/vo/UrlDomain.java b/src/main/java/org/service/urlshortener/shortener/domain/vo/UrlDomain.java deleted file mode 100644 index 01bd757..0000000 --- a/src/main/java/org/service/urlshortener/shortener/domain/vo/UrlDomain.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.service.urlshortener.shortener.domain.vo; - -public class UrlDomain { - public static final String URL = "https://readys.link/"; -} \ No newline at end of file diff --git a/src/main/java/org/service/urlshortener/shortener/dto/ShortUrlModel.java b/src/main/java/org/service/urlshortener/shortener/dto/ShortUrlModel.java deleted file mode 100644 index fe91a1c..0000000 --- a/src/main/java/org/service/urlshortener/shortener/dto/ShortUrlModel.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.service.urlshortener.shortener.dto; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; - -import java.time.LocalDateTime; - -@Getter -@AllArgsConstructor -@NoArgsConstructor -public class ShortUrlModel { - private Long id; - private String originalUrl; - private LocalDateTime createAtl; -} \ No newline at end of file diff --git a/src/main/java/org/service/urlshortener/shortener/dto/response/OriginUrlResponse.java b/src/main/java/org/service/urlshortener/shortener/dto/response/OriginUrlResponse.java deleted file mode 100644 index 575e0da..0000000 --- a/src/main/java/org/service/urlshortener/shortener/dto/response/OriginUrlResponse.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.service.urlshortener.shortener.dto.response; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -@Getter -@AllArgsConstructor -public class OriginUrlResponse { - private String originUrl; -} \ No newline at end of file diff --git a/src/main/java/org/service/urlshortener/shortener/dto/response/ShortCodeResponse.java b/src/main/java/org/service/urlshortener/shortener/dto/response/ShortCodeResponse.java deleted file mode 100644 index 545011c..0000000 --- a/src/main/java/org/service/urlshortener/shortener/dto/response/ShortCodeResponse.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.service.urlshortener.shortener.dto.response; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -@Getter -@AllArgsConstructor -public class ShortCodeResponse { - private String shortCode; -} \ No newline at end of file diff --git a/src/main/java/org/service/urlshortener/shortener/repository/OriginUrlRepository.java b/src/main/java/org/service/urlshortener/shortener/repository/OriginUrlRepository.java deleted file mode 100644 index 974c37b..0000000 --- a/src/main/java/org/service/urlshortener/shortener/repository/OriginUrlRepository.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.service.urlshortener.shortener.repository; - -import org.service.urlshortener.shortener.domain.OriginUrl; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.transaction.annotation.Transactional; - -import java.time.LocalDateTime; -import java.util.List; -import java.util.Optional; - -@Transactional(readOnly = true) -public interface OriginUrlRepository extends JpaRepository { - List findByCreatedAtBefore(LocalDateTime date); - - Optional findByOriginUrl(String originUrl); - - Boolean existsByOriginUrl(String originUrl); -} \ No newline at end of file diff --git a/src/test/java/org/service/urlshortener/UrlShortenerApplicationTests.java b/src/test/java/org/service/urlshortener/UrlShortenerApplicationTests.java deleted file mode 100644 index 66a3ebb..0000000 --- a/src/test/java/org/service/urlshortener/UrlShortenerApplicationTests.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.service.urlshortener; - -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.context.SpringBootTest; - -@SpringBootTest -class UrlShortenerApplicationTests { - - @Test - void contextLoads() { - } - -}