261022_01_ENH: Class에서 record로 변경가능한 Dto들 record로 변경
This commit is contained in:
@@ -31,7 +31,7 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation "com.kri.common:starter:beta.1.6.7"
|
||||
implementation "com.kri.common:starter:beta.1.7.0"
|
||||
|
||||
implementation 'org.springframework.boot:spring-boot-starter-web'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-security'
|
||||
|
||||
@@ -1,25 +1,18 @@
|
||||
package com.kri.shorturl.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Builder
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Schema(description = "단축 URL 생성 요청 DTO")
|
||||
public class ShortUrlCreateRequestDto {
|
||||
public record ShortUrlCreateRequestDto(
|
||||
|
||||
@Schema(description = "요청 Url")
|
||||
private String orgUrl;
|
||||
String orgUrl,
|
||||
|
||||
@Schema(description = "파라미터 사용 여부")
|
||||
private boolean useParam;
|
||||
boolean useParam
|
||||
) {
|
||||
|
||||
public static ShortUrlCreateRequestDto of(String orgUrl, boolean useParam) {
|
||||
return ShortUrlCreateRequestDto.builder()
|
||||
|
||||
@@ -56,8 +56,8 @@ public class TShortUrlEntity {
|
||||
|
||||
public static TShortUrlEntity create(ShortUrlCreateRequestDto req, String regUser, LocalDateTime regDt) {
|
||||
return TShortUrlEntity.builder()
|
||||
.orgUrl(req.getOrgUrl())
|
||||
.useParam(req.isUseParam())
|
||||
.orgUrl(req.orgUrl())
|
||||
.useParam(req.useParam())
|
||||
.regUser(regUser)
|
||||
.regDt(regDt)
|
||||
.build();
|
||||
|
||||
@@ -35,11 +35,12 @@ public class ShortUrlService {
|
||||
|
||||
@Transactional(transactionManager = "transactionManager")
|
||||
public String createShortUrl(ShortUrlCreateRequestDto req, String regUser, LocalDateTime regDt) {
|
||||
req.setOrgUrl(normalizeUrl(req.getOrgUrl()));
|
||||
ShortUrlCreateRequestDto normalizedReq =
|
||||
ShortUrlCreateRequestDto.of(normalizeUrl(req.orgUrl()), req.useParam());
|
||||
|
||||
return shortUrlRepository.findByOrgUrlAndUseParam(req.getOrgUrl(), req.isUseParam())
|
||||
return shortUrlRepository.findByOrgUrlAndUseParam(normalizedReq.orgUrl(), normalizedReq.useParam())
|
||||
.map(entity -> makeShortUrl(entity.getShortCode()))
|
||||
.orElseGet(() -> createNewShortUrl(req, regUser, regDt));
|
||||
.orElseGet(() -> createNewShortUrl(normalizedReq, regUser, regDt));
|
||||
}
|
||||
|
||||
public byte[] exportShortUrlsTemplate() {
|
||||
|
||||
Reference in New Issue
Block a user