From 33628655a96f37c138b906c5741875e1964a53b1 Mon Sep 17 00:00:00 2001 From: "LAPTOP-L3VE7KK2\\USER" Date: Wed, 30 Oct 2024 11:33:26 +0900 Subject: [PATCH] =?UTF-8?q?=ED=8C=90=EB=A7=A4=EC=A0=90=20=EB=AA=A9?= =?UTF-8?q?=EB=A1=9D=20=EA=B2=80=EC=83=89=20API=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../qcast/biz/object/ObjectController.java | 44 ++++++++----- .../qcast/biz/object/ObjectMapper.java | 4 +- .../qcast/biz/object/ObjectService.java | 61 +++++++++++-------- .../resources/mappers/object/objectMapper.xml | 10 ++- 4 files changed, 72 insertions(+), 47 deletions(-) diff --git a/src/main/java/com/interplug/qcast/biz/object/ObjectController.java b/src/main/java/com/interplug/qcast/biz/object/ObjectController.java index afbdfc82..49a81e6f 100644 --- a/src/main/java/com/interplug/qcast/biz/object/ObjectController.java +++ b/src/main/java/com/interplug/qcast/biz/object/ObjectController.java @@ -1,16 +1,5 @@ package com.interplug.qcast.biz.object; -import java.util.List; -import org.springframework.http.HttpStatus; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.RestController; import com.interplug.qcast.biz.object.dto.ObjectRequest; import com.interplug.qcast.biz.object.dto.ObjectResponse; import com.interplug.qcast.biz.object.dto.PlanReqRequest; @@ -24,8 +13,19 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; +import java.util.List; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; @Slf4j @RestController @@ -57,12 +57,20 @@ public class ObjectController { return objectService.selectWindSpeedList(city); } + @Operation(description = "1차점 판매점 목록을 조회한다.") + @GetMapping("/saleStore/{saleStoreId}/firstList") + @ResponseStatus(HttpStatus.OK) + public List selectFirstSaleStoreList( + @PathVariable String saleStoreId, String userId) throws Exception { + return objectService.selectFirstSaleStoreList(saleStoreId, userId); + } + @Operation(description = "판매점 목록을 조회한다.") @GetMapping("/saleStore/{saleStoreId}/list") @ResponseStatus(HttpStatus.OK) - public List selectSaleStoreList(@PathVariable String saleStoreId, - String userId) throws Exception { - return objectService.selectSaleStoreList(saleStoreId, userId); + public List selectSaleStoreList( + @PathVariable String saleStoreId, String firstFlg) throws Exception { + return objectService.selectSaleStoreList(saleStoreId, firstFlg); } @Operation(description = "물건정보 목록을 조회한다.") @@ -131,8 +139,12 @@ public class ObjectController { @Operation(description = "견적서 파일을 다운로드한다.") @PostMapping("/file/{objectNo}/{no}") @ResponseStatus(HttpStatus.OK) - public void fileDownload(HttpServletRequest request, HttpServletResponse response, - @PathVariable String objectNo, @PathVariable String no) throws Exception { + public void fileDownload( + HttpServletRequest request, + HttpServletResponse response, + @PathVariable String objectNo, + @PathVariable String no) + throws Exception { UploadRequest uploadRequest = new UploadRequest(); uploadRequest.setObjectNo(objectNo); diff --git a/src/main/java/com/interplug/qcast/biz/object/ObjectMapper.java b/src/main/java/com/interplug/qcast/biz/object/ObjectMapper.java index 2c0b0fc5..a0e5da8e 100644 --- a/src/main/java/com/interplug/qcast/biz/object/ObjectMapper.java +++ b/src/main/java/com/interplug/qcast/biz/object/ObjectMapper.java @@ -16,10 +16,10 @@ public interface ObjectMapper { public List selectWindSpeedList(String city); // 모든 판매점 목록 조회 - public List selectSaleStoreAllList(); + public List selectSaleStoreFirstList(); // 판매점 목록 조회 - public List selectSaleStoreList(String saleStoreId); + public List selectSaleStoreList(String saleStoreId, String firstFlg); // 판매점 정보 조회 public SaleStoreResponse selectSaleStoreInfo(String saleStoreId); diff --git a/src/main/java/com/interplug/qcast/biz/object/ObjectService.java b/src/main/java/com/interplug/qcast/biz/object/ObjectService.java index 12045911..7b8cbab8 100644 --- a/src/main/java/com/interplug/qcast/biz/object/ObjectService.java +++ b/src/main/java/com/interplug/qcast/biz/object/ObjectService.java @@ -1,25 +1,5 @@ package com.interplug.qcast.biz.object; -import java.io.BufferedInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.InputStream; -import java.net.URLConnection; -import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Comparator; -import java.util.List; -import java.util.Map; -import org.apache.commons.lang3.RandomStringUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.http.HttpMethod; -import org.springframework.stereotype.Service; -import org.springframework.util.FileCopyUtils; -import org.springframework.web.util.UriComponentsBuilder; import com.fasterxml.jackson.databind.DeserializationFeature; import com.interplug.qcast.biz.object.dto.ObjectRequest; import com.interplug.qcast.biz.object.dto.ObjectResponse; @@ -42,8 +22,28 @@ import com.interplug.qcast.util.InterfaceQsp; import io.micrometer.common.util.StringUtils; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; +import java.net.URLConnection; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Comparator; +import java.util.List; +import java.util.Map; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.RandomStringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.HttpMethod; +import org.springframework.stereotype.Service; +import org.springframework.util.FileCopyUtils; +import org.springframework.web.util.UriComponentsBuilder; @Slf4j @Service @@ -75,14 +75,14 @@ public class ObjectService { return objectMapper.selectWindSpeedList(city); } - public List selectSaleStoreList(String saleStoreId, String userId) + public List selectFirstSaleStoreList(String saleStoreId, String userId) throws Exception { // [0]. 판매점 목록 조회 List storeList = new ArrayList(); if ("T01".equals(saleStoreId)) { - storeList = objectMapper.selectSaleStoreAllList(); + storeList = objectMapper.selectSaleStoreFirstList(); // [1]. 판매점 목록 조회 결과 if (storeList.size() > 0) { @@ -106,6 +106,7 @@ public class ObjectService { String favStoreId = (String) storeFavorite.get("storeId"); if (storeId.equals(favStoreId)) { saleStore.setPriority("A" + (String) storeFavorite.get("priority")); + break; } } } @@ -113,18 +114,24 @@ public class ObjectService { storeList.sort(Comparator.comparing(SaleStoreResponse::getPriority)); } } else { - throw new QcastException(ErrorCode.INTERNAL_SERVER_ERROR, - (String) result.get("resultMsg")); + throw new QcastException( + ErrorCode.INTERNAL_SERVER_ERROR, (String) result.get("resultMsg")); } } - - } else { - storeList = objectMapper.selectSaleStoreList(saleStoreId); } return storeList; } + public List selectSaleStoreList(String saleStoreId, String firstFlg) + throws Exception { + // [0]. 판매점 목록 조회 + List storeList = new ArrayList(); + storeList = objectMapper.selectSaleStoreList(saleStoreId, firstFlg); + + return storeList; + } + public SaleStoreResponse selectSaleStoreInfo(String saleStoreId) throws Exception { return objectMapper.selectSaleStoreInfo(saleStoreId); } diff --git a/src/main/resources/mappers/object/objectMapper.xml b/src/main/resources/mappers/object/objectMapper.xml index 001b8c95..806b4ce4 100644 --- a/src/main/resources/mappers/object/objectMapper.xml +++ b/src/main/resources/mappers/object/objectMapper.xml @@ -33,8 +33,8 @@ ORDER BY A.STANDARD_WIND_SPEED_ID ASC, A.CITY ASC - + /* sqlid : com.interplug.qcast.biz.object.selectSaleStoreFirstList */ SELECT CASE WHEN SALE_STORE_LEVEL = '1' THEN 'Y' ELSE 'N' END AS FIRST_AGENT_YN , SALE_STORE_ID @@ -44,6 +44,7 @@ FROM M_SALES_STORE WITH(NOLOCK) WHERE APPROVE_FLG = '2' AND DEL_FLG = '0' + AND SALE_STORE_LEVEL = '1' ORDER BY SALE_STORE_LEVEL ASC, SALE_STORE_ID ASC @@ -74,6 +75,7 @@ AND A.DEL_FLG = '0' ) + SELECT 'Y' AS FIRST_AGENT_YN , A.SALE_STORE_ID @@ -85,6 +87,7 @@ AND APPROVE_FLG = '2' AND DEL_FLG = '0' UNION ALL + SELECT CASE WHEN SALE_STORE_LEVEL = '1' THEN 'Y' ELSE 'N' END AS FIRST_AGENT_YN , A.SALE_STORE_ID @@ -92,6 +95,9 @@ , A.SALE_STORE_LEVEL , A.FIRST_AGENT_ID FROM SALES_STORE_CTE A + + WHERE A.SALE_STORE_LEVEL ]]> '1' +