Skip to content

Commit

Permalink
!hotfix: comparisonStatus response ์ˆ˜์ •
Browse files Browse the repository at this point in the history
  • Loading branch information
daeun084 committed Sep 7, 2024
1 parent 78a14d2 commit ec74f71
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 85 deletions.
49 changes: 0 additions & 49 deletions src/main/java/FITPET/dev/controller/ComparisonController.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,9 @@
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import java.util.List;
import lombok.AllArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

@Tag(name = "๊ฒฌ์ ์„œ API")
@RestController
Expand Down Expand Up @@ -88,49 +82,6 @@ public ApiResponse patchPetInfoStatus(
}


@GetMapping("/comparison")
@Operation(summary = "๊ฒฌ์  ์š”์ฒญ ํ™”๋ฉด์„ ๋ฆฌ๋‹ค์ด๋ ‰ํŠธํ•˜๋Š” API", description = "์‚ฌ์šฉ์ž์˜ ๊ธฐ๋ณธ ์ •๋ณด๋ฅผ ํŒŒ๋ผ๋ฏธํ„ฐ๋กœ ๋„˜๊ธด ํ›„, ๊ฒฌ์ ์„œ ์ƒ์„ฑ ํ™”๋ฉด์œผ๋กœ ๋ฆฌ๋‹ค์ด๋ ‰ํŠธํ•œ๋‹ค")
public ResponseEntity<Void> getComparisonView(
@RequestParam(value = "petName") String petName,
@RequestParam(value = "petType") String petType,
@RequestParam(value = "petSpecies") String petSpecies,
@RequestParam(value = "petAge") String petAge,
@RequestParam(value = "phoneNumber") String phoneNumber,
@RequestParam(value = "referSite", required = false) String referSite,
@RequestParam(value = "referUserId", required = false) String referUserId,
HttpServletResponse response
) throws IOException {

Map<String, String> params = new HashMap<>();
params.put("petName", String.valueOf(petName));
params.put("petType", String.valueOf(petType));
params.put("petSpecies", String.valueOf(petSpecies));
params.put("petAge", String.valueOf(petAge));
params.put("phoneNumber", String.valueOf(phoneNumber));
params.put("referSite", String.valueOf(referSite));
params.put("referUserId", String.valueOf(referUserId));

// redirectํ•  url ์ƒ์„ฑ
String redirectUrl = comparisonService.makeRedirectUrl(params);

response.sendRedirect(redirectUrl);
return ResponseEntity.status(HttpStatus.FOUND).build();
}

// @GetMapping("/comparison/form")
// @Operation(summary = "๊ฒฌ์  ์š”์ฒญ ํ™”๋ฉด์„ ์กฐํšŒํ•˜๋Š” API", description = "์‚ฌ์šฉ์ž์˜ ๊ธฐ๋ณธ ์ •๋ณด๋ฅผ ํŒŒ๋ผ๋ฏธํ„ฐ๋กœ ๋„˜๊ธด ํ›„, ๊ฒฌ์ ์„œ ์ƒ์„ฑ ํ™”๋ฉด์„ ์กฐํšŒํ•œ๋‹ค")
// public ApiResponse<?> getComparisonForm(
// @RequestParam(value = "petName") String petName,
// @RequestParam(value = "petType") String petType,
// @RequestParam(value = "petSpecies") String petSpecies,
// @RequestParam(value = "petAge") String petAge,
// @RequestParam(value = "phoneNumber") String phoneNumber,
// @RequestParam(value = "referSite", required = false) String referSite,
// @RequestParam(value = "referUserId", required = false) String referUserId
// ){
// return ApiResponse.SuccessResponse(SuccessStatus.GET_COMPARISON_VIEW);
// }

@DeleteMapping("/admin/comparison/{comparisonId}")
@Operation(summary = "๊ฒฌ์  ์š”์ฒญ ์‚ญ์ œ API", description = "ํŠน์ • ๊ฒฌ์  ์š”์ฒญ ์ •๋ณด๋ฅผ ์‚ญ์ œ")
public ApiResponse deleteComparison(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public static ComparisonResponse.ComparisonDto toComparisonDto(Comparison compar
.petType(pet.getPetType().toString())
.petSpecies(pet.getPetSpecies())
.comment(comparison.getComment())
.status(comparison.getStatus().getLabel())
.status(comparison.getStatus().toString())
.referSite(referSite)
.referUserId(comparison.getReferUserId())
.build();
Expand Down
35 changes: 0 additions & 35 deletions src/main/java/FITPET/dev/service/ComparisonService.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package FITPET.dev.service;

import FITPET.dev.common.enums.ComparisonStatus;
import FITPET.dev.common.enums.PetType;
import FITPET.dev.common.status.ErrorStatus;
import FITPET.dev.common.exception.GeneralException;
import FITPET.dev.common.utils.ApachePdfUtils;
Expand All @@ -13,7 +12,6 @@
import FITPET.dev.dto.response.ComparisonResponse;
import FITPET.dev.dto.response.InsuranceResponse;
import FITPET.dev.entity.Comparison;
import FITPET.dev.entity.Insurance;
import FITPET.dev.entity.Pet;
import FITPET.dev.entity.PetInfo;
import FITPET.dev.entity.ReferSite;
Expand All @@ -22,19 +20,13 @@
import FITPET.dev.repository.PetRepository;

import FITPET.dev.repository.ReferSiteRepository;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;

import jakarta.servlet.http.HttpServletResponse;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
Expand Down Expand Up @@ -228,33 +220,6 @@ public void deleteComparison(Long comparisonId) {
}



/*
* redirect url ์ƒ์„ฑ
* @param params
* @return
* @throws UnsupportedEncodingException
* @throws MalformedURLException
*/
public String makeRedirectUrl(Map<String, String> params) throws UnsupportedEncodingException, MalformedURLException {

// TODO: ๋ฐฐํฌ ํ›„ domain ์ˆ˜์ •
String endpoint = "http://localhost:8080/api/v1/comparison/form";
StringBuilder urlBuilder = new StringBuilder(endpoint);
urlBuilder.append("?");

for (Map.Entry<String, String> entry : params.entrySet()) {
urlBuilder.append(URLEncoder.encode(entry.getKey(), "UTF-8"))
.append("=")
.append(URLEncoder.encode(entry.getValue(), "UTF-8"))
.append("&");
}

URL url = new URL(urlBuilder.toString());
return url.toString();
}


private Comparison findComparisonById(Long comparisonId) {
return comparisonRepository.findById(comparisonId)
.orElseThrow(() -> new GeneralException(ErrorStatus.NOT_EXIST_COMPARISON));
Expand Down

0 comments on commit ec74f71

Please sign in to comment.