diff --git a/build.gradle b/build.gradle index 33864b5..e88747a 100644 --- a/build.gradle +++ b/build.gradle @@ -37,7 +37,7 @@ repositories { } dependencies { - implementation "com.kri.common:starter:beta.1.1.13" + implementation "com.kri.common:starter:beta.1.1.23" implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'org.springframework.boot:spring-boot-starter-security' diff --git a/src/main/java/com/kri/intranet/extension/controller/ShortUrlController.java b/src/main/java/com/kri/intranet/extension/controller/ShortUrlController.java new file mode 100644 index 0000000..30b9597 --- /dev/null +++ b/src/main/java/com/kri/intranet/extension/controller/ShortUrlController.java @@ -0,0 +1,45 @@ +package com.kri.intranet.extension.controller; + +import io.swagger.v3.oas.annotations.tags.Tag; +import java.net.URI; +import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.util.MultiValueMap; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.util.UriComponentsBuilder; + +@RestController +@RequestMapping("/api/v1/short-url") +@RequiredArgsConstructor +@Tag(name = "ShortUrl", description = "단축 URL API") +public class ShortUrlController { + + @PostMapping("/{shortKey}") + public ResponseEntity redirectShortUrl( + @PathVariable String shortKey, + @RequestParam MultiValueMap params + ) { + //String targetUrl = shortUrlService.findTargetUrl(shortKey); + String targetUrl = "https://kon.kric.com/project/2606002_A/INDEX.asp"; + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(targetUrl); + + params.forEach((key, values) -> { + for (String value : values) { + builder.queryParam(key, value); + } + }); + + URI redirectUri = builder.build(true).toUri(); + + return ResponseEntity + .status(HttpStatus.FOUND) + .location(redirectUri) + .build(); + } + +} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 212624c..df83227 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -30,8 +30,6 @@ kri: # 내부 운영용(원하면) admin-api-enabled: true admin-allow-ips: - - 127.0.0.1/32 - - 0:0:0:0:0:0:0:1 - 211.254.145.130/32 # apikey 보관 DB(MySQL) db: @@ -60,8 +58,6 @@ kri: web: enabled: true # 공통 Web 구성 사용 여부 (기본 true) - webmvc: - enabled: true # 공통 Webmvc 구성 사용 여부 (기본 true) redis: enabled: false # RedisQueueHelper 사용 시 true scheduling: