260921_02_ENH: survey short url 쓸모가 없어서 폐기

This commit is contained in:
2026-09-21 14:03:10 +09:00
parent bf448d57f4
commit b30f7604bf
3 changed files with 49 additions and 25 deletions

View File

@@ -48,10 +48,6 @@ public class ProjectSurveyDto {
@Schema(description = "설문 Full URL")
private String surveyFullUrl;
@Size(max = 1024)
@Schema(description = "설문 Short URL")
private String surveyShortUrl;
@Size(max = 1024)
@Schema(description = "외부 설문 대시보드 URL. surveyTy가 99(EXTERNAL)일 때만 사용")
private String surveyDashboardUrl;
@@ -68,7 +64,6 @@ public class ProjectSurveyDto {
.surveyPrjctCd(entity.getSurveyPrjctCd())
.surveyUrl(entity.getSurveyUrl())
.surveyFullUrl(entity.getSurveyFullUrl())
.surveyShortUrl(entity.getSurveyShortUrl())
.surveyDashboardUrl(entity.getSurveyDashboardUrl())
.build();
}

View File

@@ -63,10 +63,6 @@ public class TPrjctSurveyEntity {
@Column(name = "survey_full_url", length = 1024)
private String surveyFullUrl;
@Size(max = 1024)
@Column(name = "survey_short_url", length = 1024)
private String surveyShortUrl;
@Size(max = 1024)
@Column(name = "survey_dashboard_url", length = 1024)
private String surveyDashboardUrl;
@@ -102,7 +98,6 @@ public class TPrjctSurveyEntity {
.surveyPrjctCd(dto.getSurveyPrjctCd())
.surveyUrl(dto.getSurveyUrl())
.surveyFullUrl(dto.getSurveyFullUrl())
.surveyShortUrl(dto.getSurveyShortUrl())
.surveyDashboardUrl(resolveSurveyDashboardUrl(dto.getSurveyTy(), dto.getSurveyDashboardUrl()))
.regUser(regUser)
.regDt(regDt)
@@ -115,8 +110,8 @@ public class TPrjctSurveyEntity {
this.surveyTy = dto.getSurveyTy().getCode();
this.surveyPrjctCd = dto.getSurveyPrjctCd();
this.surveyUrl = dto.getSurveyUrl();
this.surveyFullUrl = dto.getSurveyFullUrl();
this.surveyShortUrl = dto.getSurveyShortUrl();
// surveyFullUrl은 서버가 파생하는 값이므로 요청 값으로 덮어쓰지 않고,
// 기존 저장값을 유지한 뒤 resolveSurveyUrl에서 재계산한다(재저장 시 KON/KIWI 판별 근거).
this.surveyDashboardUrl = resolveSurveyDashboardUrl(dto.getSurveyTy(), dto.getSurveyDashboardUrl());
this.modUser = modUser;
this.modDt = modDt;

View File

@@ -357,7 +357,6 @@ public class ProjectService {
}
survey.setSurveyUrl(resolved.finalUrl());
survey.setSurveyFullUrl(resolved.fullUrl());
survey.setSurveyShortUrl(resolved.shortUrl());
}
}
@@ -365,42 +364,72 @@ public class ProjectService {
String requestedUrl = survey.getSurveyUrl();
if (requestedUrl == null || requestedUrl.isBlank()) {
survey.setSurveyFullUrl(null);
survey.setSurveyShortUrl(null);
return null;
}
String baseUrl = resolveSurveyBaseUrl(survey);
if (baseUrl == null) {
// 토큰이 없어 baseUrl을 재구성할 수 없는 경우(예: 재저장 시 이미 확정된 URL)에는
// 기존에 저장된 surveyFullUrl/surveyShortUrl을 그대로 유지한다.
// KON/KIWI를 판별할 수 없어 baseUrl을 재구성할 수 없는 경우에는
// 기존에 저장된 surveyUrl/surveyFullUrl을 그대로 유지한다.
return null;
}
String queryString = extractQueryString(requestedUrl);
String fullUrl = appendQueryString(baseUrl, queryString);
String shortUrl = shortUrlApiClient.createShortUrl(baseUrl, ctx)
.map(url -> appendQueryString(url, queryString))
.orElse(null);
return new ResolvedSurveyUrl(shortUrl == null ? fullUrl : shortUrl, fullUrl, shortUrl);
String finalUrl;
if (isResolvedShortUrl(requestedUrl)) {
// 재저장 시 이미 발급된 short URL은 재발급하지 않고 쿼리스트링만 새 요청 값으로 교체한다.
finalUrl = appendQueryString(stripQueryString(requestedUrl), queryString);
} else {
// 최초 저장(토큰) 또는 short URL 미발급 상태(full URL)일 때만 새로 발급한다.
finalUrl = shortUrlApiClient.createShortUrl(baseUrl, ctx)
.map(url -> appendQueryString(url, queryString))
.orElse(fullUrl);
}
return new ResolvedSurveyUrl(finalUrl, fullUrl);
}
// 토큰이 남아있으면 최초 저장, KON/KIWI full URL로 시작하면 short 미발급 상태이므로,
// 둘 다 아니면 이미 발급된 short URL(재저장)로 간주한다.
private boolean isResolvedShortUrl(String requestedUrl) {
boolean hasToken = requestedUrl.contains(KON_URL_TOKEN) || requestedUrl.contains(KIWI_URL_TOKEN);
boolean isFullUrl = requestedUrl.startsWith(KON_SURVEY_BASE_URL)
|| requestedUrl.startsWith(KIWI_SURVEY_BASE_URL);
return !hasToken && !isFullUrl;
}
private String resolveSurveyBaseUrl(TPrjctSurveyEntity survey) {
String surveyUrl = survey.getSurveyUrl();
String surveyPrjctCd = survey.getSurveyPrjctCd();
Long prjctSurveyIdx = survey.getPrjctSurveyIdx();
if (surveyUrl == null || surveyPrjctCd == null || surveyPrjctCd.isBlank() || prjctSurveyIdx == null) {
if (surveyPrjctCd == null || surveyPrjctCd.isBlank() || prjctSurveyIdx == null) {
return null;
}
if (surveyUrl.contains(KON_URL_TOKEN)) {
if (isKonSurvey(survey)) {
return KON_SURVEY_BASE_URL + surveyPrjctCd + "/INDEX.asp?psidx=" + prjctSurveyIdx;
}
if (surveyUrl.contains(KIWI_URL_TOKEN)) {
if (isKiwiSurvey(survey)) {
return KIWI_SURVEY_BASE_URL + surveyPrjctCd + "/INDEX.asp?psidx=" + prjctSurveyIdx;
}
return null;
}
// 최초 저장 시에는 surveyUrl의 토큰으로, 재저장 시에는 이미 확정된 surveyFullUrl prefix로 판별한다.
private boolean isKonSurvey(TPrjctSurveyEntity survey) {
String surveyUrl = survey.getSurveyUrl();
String surveyFullUrl = survey.getSurveyFullUrl();
return (surveyUrl != null && surveyUrl.contains(KON_URL_TOKEN))
|| (surveyFullUrl != null && surveyFullUrl.startsWith(KON_SURVEY_BASE_URL));
}
private boolean isKiwiSurvey(TPrjctSurveyEntity survey) {
String surveyUrl = survey.getSurveyUrl();
String surveyFullUrl = survey.getSurveyFullUrl();
return (surveyUrl != null && surveyUrl.contains(KIWI_URL_TOKEN))
|| (surveyFullUrl != null && surveyFullUrl.startsWith(KIWI_SURVEY_BASE_URL));
}
private String extractQueryString(String url) {
int queryIndex = url.indexOf('?');
if (queryIndex < 0 || queryIndex + 1 >= url.length()) {
@@ -409,6 +438,11 @@ public class ProjectService {
return url.substring(queryIndex + 1);
}
private String stripQueryString(String url) {
int queryIndex = url.indexOf('?');
return queryIndex < 0 ? url : url.substring(0, queryIndex);
}
private String appendQueryString(String baseUrl, String queryString) {
if (queryString == null || queryString.isBlank()) {
return baseUrl;
@@ -416,7 +450,7 @@ public class ProjectService {
return baseUrl + (baseUrl.contains("?") ? "&" : "?") + queryString;
}
private record ResolvedSurveyUrl(String finalUrl, String fullUrl, String shortUrl) {
private record ResolvedSurveyUrl(String finalUrl, String fullUrl) {
}
private boolean isTeamUserRole(Integer userRole) {