판매점 즐겨찾기 api 추가 및 물건 판매점 목록 조회 수정

This commit is contained in:
LEEYONGJAE 2024-10-28 17:01:27 +09:00
parent fcfeb23523
commit c056b7efdb
6 changed files with 251 additions and 137 deletions

View File

@ -1,15 +1,31 @@
package com.interplug.qcast.biz.object; package com.interplug.qcast.biz.object;
import com.interplug.qcast.biz.object.dto.*; 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;
import com.interplug.qcast.biz.object.dto.PlanReqResponse;
import com.interplug.qcast.biz.object.dto.PlanRequest;
import com.interplug.qcast.biz.object.dto.PrefResponse;
import com.interplug.qcast.biz.object.dto.SaleStoreResponse;
import com.interplug.qcast.biz.object.dto.UploadRequest;
import com.interplug.qcast.biz.object.dto.WindSpeedResponse;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import java.util.List;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
@Slf4j @Slf4j
@RestController @RestController
@ -17,7 +33,7 @@ import org.springframework.web.bind.annotation.*;
@RequiredArgsConstructor @RequiredArgsConstructor
@Tag(name = "ObjectController", description = "물건정보 관련 API") @Tag(name = "ObjectController", description = "물건정보 관련 API")
public class ObjectController { public class ObjectController {
// @Autowired private ObjectService objectService; // @Autowired private ObjectService objectService;
private final ObjectService objectService; private final ObjectService objectService;
@Operation(description = "물건정보 도도부현을 조회한다.") @Operation(description = "물건정보 도도부현을 조회한다.")
@ -44,9 +60,9 @@ public class ObjectController {
@Operation(description = "판매점 목록을 조회한다.") @Operation(description = "판매점 목록을 조회한다.")
@GetMapping("/saleStore/{saleStoreId}/list") @GetMapping("/saleStore/{saleStoreId}/list")
@ResponseStatus(HttpStatus.OK) @ResponseStatus(HttpStatus.OK)
public List<SaleStoreResponse> selectSaleStoreList(@PathVariable String saleStoreId) public List<SaleStoreResponse> selectSaleStoreList(@PathVariable String saleStoreId,
throws Exception { String userId) throws Exception {
return objectService.selectSaleStoreList(saleStoreId); return objectService.selectSaleStoreList(saleStoreId, userId);
} }
@Operation(description = "물건정보 목록을 조회한다.") @Operation(description = "물건정보 목록을 조회한다.")
@ -115,12 +131,8 @@ public class ObjectController {
@Operation(description = "견적서 파일을 다운로드한다.") @Operation(description = "견적서 파일을 다운로드한다.")
@PostMapping("/file/{objectNo}/{no}") @PostMapping("/file/{objectNo}/{no}")
@ResponseStatus(HttpStatus.OK) @ResponseStatus(HttpStatus.OK)
public void fileDownload( public void fileDownload(HttpServletRequest request, HttpServletResponse response,
HttpServletRequest request, @PathVariable String objectNo, @PathVariable String no) throws Exception {
HttpServletResponse response,
@PathVariable String objectNo,
@PathVariable String no)
throws Exception {
UploadRequest uploadRequest = new UploadRequest(); UploadRequest uploadRequest = new UploadRequest();
uploadRequest.setObjectNo(objectNo); uploadRequest.setObjectNo(objectNo);

View File

@ -1,14 +1,5 @@
package com.interplug.qcast.biz.object; package com.interplug.qcast.biz.object;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.interplug.qcast.biz.object.dto.*;
import com.interplug.qcast.config.Exception.ErrorCode;
import com.interplug.qcast.config.Exception.QcastException;
import com.interplug.qcast.config.message.Messages;
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.BufferedInputStream;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
@ -17,11 +8,11 @@ import java.net.URLConnection;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.lang3.RandomStringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
@ -29,6 +20,30 @@ import org.springframework.http.HttpMethod;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.FileCopyUtils; import org.springframework.util.FileCopyUtils;
import org.springframework.web.util.UriComponentsBuilder; 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;
import com.interplug.qcast.biz.object.dto.PlanReqRequest;
import com.interplug.qcast.biz.object.dto.PlanReqResponse;
import com.interplug.qcast.biz.object.dto.PlanRequest;
import com.interplug.qcast.biz.object.dto.PlanResponse;
import com.interplug.qcast.biz.object.dto.PrefResponse;
import com.interplug.qcast.biz.object.dto.SaleStoreResponse;
import com.interplug.qcast.biz.object.dto.UploadRequest;
import com.interplug.qcast.biz.object.dto.UploadResponse;
import com.interplug.qcast.biz.object.dto.WindSpeedResponse;
import com.interplug.qcast.biz.storeFavorite.StoreFavoriteService;
import com.interplug.qcast.biz.storeFavorite.dto.StoreFavoriteRequest;
import com.interplug.qcast.biz.storeFavorite.dto.StoreFavoriteResponse;
import com.interplug.qcast.config.Exception.ErrorCode;
import com.interplug.qcast.config.Exception.QcastException;
import com.interplug.qcast.config.message.Messages;
import com.interplug.qcast.util.InterfaceQsp;
import io.micrometer.common.util.StringUtils;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@Slf4j @Slf4j
@Service @Service
@ -36,7 +51,8 @@ import org.springframework.web.util.UriComponentsBuilder;
public class ObjectService { public class ObjectService {
private final InterfaceQsp interfaceQsp; private final InterfaceQsp interfaceQsp;
@Autowired Messages message; @Autowired
Messages message;
@Value("${file.ini.root.path}") @Value("${file.ini.root.path}")
private String baseDirPath; private String baseDirPath;
@ -46,6 +62,8 @@ public class ObjectService {
private final ObjectMapper objectMapper; private final ObjectMapper objectMapper;
private final StoreFavoriteService storeFavoriteService;
public List<PrefResponse> selectPrefList() throws Exception { public List<PrefResponse> selectPrefList() throws Exception {
return objectMapper.selectPrefList(); return objectMapper.selectPrefList();
} }
@ -58,12 +76,53 @@ public class ObjectService {
return objectMapper.selectWindSpeedList(city); return objectMapper.selectWindSpeedList(city);
} }
public List<SaleStoreResponse> selectSaleStoreList(String saleStoreId) throws Exception { public List<SaleStoreResponse> selectSaleStoreList(String saleStoreId, String userId)
throws Exception {
// [0]. 판매점 목록 조회
List<SaleStoreResponse> storeList = new ArrayList<SaleStoreResponse>();
if ("T01".equals(saleStoreId)) { if ("T01".equals(saleStoreId)) {
return objectMapper.selectSaleStoreAllList(); storeList = objectMapper.selectSaleStoreAllList();
} else { } else {
return objectMapper.selectSaleStoreList(saleStoreId); storeList = objectMapper.selectSaleStoreList(saleStoreId);
} }
// [1]. 판매점 목록 조회 결과
if (storeList.size() > 0) {
StoreFavoriteRequest storeFavoriteReq = new StoreFavoriteRequest();
storeFavoriteReq.setUserId(userId);
// [2]. 사용자 판매점 즐겨찾기 목록 조회 (QSP -> QCAST)
StoreFavoriteResponse storeFavoriteRes = new StoreFavoriteResponse();
storeFavoriteRes = storeFavoriteService.getStoreFavoriteList(storeFavoriteReq);
List<Map<String, Object>> data = (List<Map<String, Object>>) storeFavoriteRes.getData();
Map<String, Object> result = (Map<String, Object>) storeFavoriteRes.getResult();
// [3]. 판매점 목록 , 즐겨찾기 판매점에 해당하는 경우 정렬 기준 셋팅
if ("S".equals(result.get("resultCode"))) {
if (data.size() > 0) {
for (SaleStoreResponse saleStore : storeList) {
String storeId = saleStore.getSaleStoreId();
saleStore.setPriority("B");
for (Map<String, Object> storeFavorite : data) {
String favStoreId = (String) storeFavorite.get("storeId");
if (storeId.equals(favStoreId)) {
saleStore.setPriority("A" + (String) storeFavorite.get("priority"));
}
}
}
// [4]. 정렬 기준 sort (오름차순)
storeList.sort(Comparator.comparing(SaleStoreResponse::getPriority));
}
} else {
throw new QcastException(ErrorCode.INTERNAL_SERVER_ERROR, (String) result.get("resultMsg"));
}
}
return storeList;
} }
public SaleStoreResponse selectSaleStoreInfo(String saleStoreId) throws Exception { public SaleStoreResponse selectSaleStoreInfo(String saleStoreId) throws Exception {
@ -96,13 +155,11 @@ public class ObjectService {
// Validation // Validation
if (StringUtils.isEmpty(objectRequest.getSaleStoreId())) { if (StringUtils.isEmpty(objectRequest.getSaleStoreId())) {
throw new QcastException( throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "Sale Store ID")); message.getMessage("common.message.required.data", "Sale Store ID"));
} }
if (StringUtils.isEmpty(objectRequest.getSaleStoreLevel())) { if (StringUtils.isEmpty(objectRequest.getSaleStoreLevel())) {
throw new QcastException( throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "Sale Store Level")); message.getMessage("common.message.required.data", "Sale Store Level"));
} }
@ -131,11 +188,8 @@ public class ObjectService {
objectRequest.setObjectNo(objectNo); objectRequest.setObjectNo(objectNo);
// 물건정보 등록 // 물건정보 등록
objectRequest.setAddress( objectRequest.setAddress(objectRequest.getPrefName()
objectRequest.getPrefName() + ((!StringUtils.isEmpty(objectRequest.getAddress())) ? objectRequest.getAddress() : ""));
+ ((!StringUtils.isEmpty(objectRequest.getAddress()))
? objectRequest.getAddress()
: ""));
objectRequest.setAddresseeCompanyName( objectRequest.setAddresseeCompanyName(
objectRequest.getObjectName() + ' ' + objectRequest.getObjectNameOmit()); objectRequest.getObjectName() + ' ' + objectRequest.getObjectNameOmit());
objectRequest.setAddresseeCompanyNameOmit(objectRequest.getObjectNameOmit()); objectRequest.setAddresseeCompanyNameOmit(objectRequest.getObjectNameOmit());
@ -167,9 +221,8 @@ public class ObjectService {
planReqRequest.setPlanReqNo(objectRequest.getPlanReqNo()); planReqRequest.setPlanReqNo(objectRequest.getPlanReqNo());
planReqRequest.setObjectNo(objectRequest.getObjectNo()); planReqRequest.setObjectNo(objectRequest.getObjectNo());
String strResponse = String strResponse = interfaceQsp.callApi(HttpMethod.POST,
interfaceQsp.callApi( QSP_API_URL + "/api/planReq/updateObjectNo", planReqRequest);
HttpMethod.POST, QSP_API_URL + "/api/planReq/updateObjectNo", planReqRequest);
if (!"".equals(strResponse)) { if (!"".equals(strResponse)) {
com.fasterxml.jackson.databind.ObjectMapper om = com.fasterxml.jackson.databind.ObjectMapper om =
new com.fasterxml.jackson.databind.ObjectMapper() new com.fasterxml.jackson.databind.ObjectMapper()
@ -178,8 +231,8 @@ public class ObjectService {
Map<String, Object> map = (Map<String, Object>) response.getResult(); Map<String, Object> map = (Map<String, Object>) response.getResult();
if ("E".equals(String.valueOf(map.get("resultCode")))) { if ("E".equals(String.valueOf(map.get("resultCode")))) {
throw new QcastException( throw new QcastException(ErrorCode.INTERNAL_SERVER_ERROR,
ErrorCode.INTERNAL_SERVER_ERROR, String.valueOf(map.get("resultMsg"))); String.valueOf(map.get("resultMsg")));
} }
} }
} }
@ -198,13 +251,11 @@ public class ObjectService {
// Validation // Validation
if (StringUtils.isEmpty(objectRequest.getSaleStoreId())) { if (StringUtils.isEmpty(objectRequest.getSaleStoreId())) {
throw new QcastException( throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "Sale Store ID")); message.getMessage("common.message.required.data", "Sale Store ID"));
} }
if (StringUtils.isEmpty(objectRequest.getSaleStoreLevel())) { if (StringUtils.isEmpty(objectRequest.getSaleStoreLevel())) {
throw new QcastException( throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "Sale Store Level")); message.getMessage("common.message.required.data", "Sale Store Level"));
} }
@ -221,18 +272,13 @@ public class ObjectService {
} }
// 물건정보 수정 // 물건정보 수정
objectRequest.setAddress( objectRequest.setAddress(objectRequest.getPrefName()
objectRequest.getPrefName() + ((!StringUtils.isEmpty(objectRequest.getAddress())) ? objectRequest.getAddress() : ""));
+ ((!StringUtils.isEmpty(objectRequest.getAddress()))
? objectRequest.getAddress()
: ""));
objectRequest.setAddresseeCompanyName( objectRequest.setAddresseeCompanyName(
objectRequest.getObjectName() + ' ' + objectRequest.getObjectNameOmit()); objectRequest.getObjectName() + ' ' + objectRequest.getObjectNameOmit());
objectRequest.setAddresseeCompanyNameOmit(objectRequest.getObjectNameOmit()); objectRequest.setAddresseeCompanyNameOmit(objectRequest.getObjectNameOmit());
objectRequest.setContentsPath( objectRequest.setContentsPath(baseDirPath + "\\\\"
baseDirPath + (tempChgFlg ? objectRequest.getNewObjectNo() : objectRequest.getObjectNo()));
+ "\\\\"
+ (tempChgFlg ? objectRequest.getNewObjectNo() : objectRequest.getObjectNo()));
result += objectMapper.updateObject(objectRequest); result += objectMapper.updateObject(objectRequest);
// 임시저장에서 저장상태로 돌리기 // 임시저장에서 저장상태로 돌리기
@ -250,9 +296,8 @@ public class ObjectService {
planReqRequest.setPlanReqNo(objectRequest.getPlanReqNo()); planReqRequest.setPlanReqNo(objectRequest.getPlanReqNo());
planReqRequest.setObjectNo(objectRequest.getNewObjectNo()); planReqRequest.setObjectNo(objectRequest.getNewObjectNo());
String strResponse = String strResponse = interfaceQsp.callApi(HttpMethod.POST,
interfaceQsp.callApi( QSP_API_URL + "/api/planReq/updateObjectNo", planReqRequest);
HttpMethod.POST, QSP_API_URL + "/api/planReq/updateObjectNo", planReqRequest);
if (!"".equals(strResponse)) { if (!"".equals(strResponse)) {
com.fasterxml.jackson.databind.ObjectMapper om = com.fasterxml.jackson.databind.ObjectMapper om =
new com.fasterxml.jackson.databind.ObjectMapper() new com.fasterxml.jackson.databind.ObjectMapper()
@ -261,8 +306,8 @@ public class ObjectService {
Map<String, Object> map = (Map<String, Object>) response.getResult(); Map<String, Object> map = (Map<String, Object>) response.getResult();
if ("E".equals(String.valueOf(map.get("resultCode")))) { if ("E".equals(String.valueOf(map.get("resultCode")))) {
throw new QcastException( throw new QcastException(ErrorCode.INTERNAL_SERVER_ERROR,
ErrorCode.INTERNAL_SERVER_ERROR, String.valueOf(map.get("resultMsg"))); String.valueOf(map.get("resultMsg")));
} }
} }
} }
@ -270,9 +315,8 @@ public class ObjectService {
} }
// 모든 변경 완료 재호출 // 모든 변경 완료 재호출
objectResponse = objectResponse = objectMapper.selectObjectDetail(
objectMapper.selectObjectDetail( (tempChgFlg ? objectRequest.getNewObjectNo() : objectRequest.getObjectNo()));
(tempChgFlg ? objectRequest.getNewObjectNo() : objectRequest.getObjectNo()));
return objectResponse; return objectResponse;
} }
@ -281,8 +325,7 @@ public class ObjectService {
// Validation // Validation
if (StringUtils.isEmpty(objectRequest.getObjectNo())) { if (StringUtils.isEmpty(objectRequest.getObjectNo())) {
throw new QcastException( throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "Object No")); message.getMessage("common.message.required.data", "Object No"));
} }
@ -295,8 +338,7 @@ public class ObjectService {
public String insertPlan(PlanRequest planRequest) throws Exception { public String insertPlan(PlanRequest planRequest) throws Exception {
// Validation // Validation
if (StringUtils.isEmpty(planRequest.getObjectNo())) { if (StringUtils.isEmpty(planRequest.getObjectNo())) {
throw new QcastException( throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "Object No")); message.getMessage("common.message.required.data", "Object No"));
} }
@ -322,60 +364,44 @@ public class ObjectService {
// Validation // Validation
if (StringUtils.isEmpty(planReqRequest.getSaleStoreId())) { if (StringUtils.isEmpty(planReqRequest.getSaleStoreId())) {
throw new QcastException( throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "Sale Store ID")); message.getMessage("common.message.required.data", "Sale Store ID"));
} }
if (StringUtils.isEmpty(planReqRequest.getSaleStoreLevel())) { if (StringUtils.isEmpty(planReqRequest.getSaleStoreLevel())) {
throw new QcastException( throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "Sale Store Level")); message.getMessage("common.message.required.data", "Sale Store Level"));
} }
PlanReqResponse response = null; PlanReqResponse response = null;
/* [1]. QSP API (url + param) Setting */ /* [1]. QSP API (url + param) Setting */
String encodedSchTitle = String encodedSchTitle = URLEncoder.encode(
URLEncoder.encode( StringUtils.isEmpty(planReqRequest.getSchTitle()) ? "" : planReqRequest.getSchTitle(),
StringUtils.isEmpty(planReqRequest.getSchTitle()) ? "" : planReqRequest.getSchTitle(), StandardCharsets.UTF_8);
StandardCharsets.UTF_8); String encodedSchAddress = URLEncoder.encode(
String encodedSchAddress = StringUtils.isEmpty(planReqRequest.getSchAddress()) ? "" : planReqRequest.getSchAddress(),
URLEncoder.encode( StandardCharsets.UTF_8);
StringUtils.isEmpty(planReqRequest.getSchAddress())
? ""
: planReqRequest.getSchAddress(),
StandardCharsets.UTF_8);
String encodedSchSaleStoreName = String encodedSchSaleStoreName =
URLEncoder.encode( URLEncoder.encode(StringUtils.isEmpty(planReqRequest.getSchSaleStoreName()) ? ""
StringUtils.isEmpty(planReqRequest.getSchSaleStoreName()) : planReqRequest.getSchSaleStoreName(), StandardCharsets.UTF_8);
? ""
: planReqRequest.getSchSaleStoreName(),
StandardCharsets.UTF_8);
String encodedSchPlanReqName = String encodedSchPlanReqName =
URLEncoder.encode( URLEncoder.encode(StringUtils.isEmpty(planReqRequest.getSchPlanReqName()) ? ""
StringUtils.isEmpty(planReqRequest.getSchPlanReqName()) : planReqRequest.getSchPlanReqName(), StandardCharsets.UTF_8);
? ""
: planReqRequest.getSchPlanReqName(),
StandardCharsets.UTF_8);
String url = QSP_API_URL + "/api/planReq/list"; String url = QSP_API_URL + "/api/planReq/list";
String apiUrl = String apiUrl = UriComponentsBuilder.fromHttpUrl(url)
UriComponentsBuilder.fromHttpUrl(url) .queryParam("saleStoreId", planReqRequest.getSaleStoreId())
.queryParam("saleStoreId", planReqRequest.getSaleStoreId()) .queryParam("saleStoreLevel", planReqRequest.getSaleStoreLevel())
.queryParam("saleStoreLevel", planReqRequest.getSaleStoreLevel()) .queryParam("schPlanReqNo", planReqRequest.getSchPlanReqNo())
.queryParam("schPlanReqNo", planReqRequest.getSchPlanReqNo()) .queryParam("schTitle", encodedSchTitle).queryParam("schAddress", encodedSchAddress)
.queryParam("schTitle", encodedSchTitle) .queryParam("schSaleStoreName", encodedSchSaleStoreName)
.queryParam("schAddress", encodedSchAddress) .queryParam("schPlanReqName", encodedSchPlanReqName)
.queryParam("schSaleStoreName", encodedSchSaleStoreName) .queryParam("schPlanStatCd", planReqRequest.getSchPlanStatCd())
.queryParam("schPlanReqName", encodedSchPlanReqName) .queryParam("schDateGbn", planReqRequest.getSchDateGbn())
.queryParam("schPlanStatCd", planReqRequest.getSchPlanStatCd()) .queryParam("schStartDt", planReqRequest.getSchStartDt())
.queryParam("schDateGbn", planReqRequest.getSchDateGbn()) .queryParam("schEndDt", planReqRequest.getSchEndDt())
.queryParam("schStartDt", planReqRequest.getSchStartDt()) .queryParam("startRow", planReqRequest.getStartRow())
.queryParam("schEndDt", planReqRequest.getSchEndDt()) .queryParam("endRow", planReqRequest.getEndRow()).build().toUriString();
.queryParam("startRow", planReqRequest.getStartRow())
.queryParam("endRow", planReqRequest.getEndRow())
.build()
.toUriString();
/* [2]. QSP API CALL -> Response */ /* [2]. QSP API CALL -> Response */
String strResponse = interfaceQsp.callApi(HttpMethod.GET, apiUrl, null); String strResponse = interfaceQsp.callApi(HttpMethod.GET, apiUrl, null);
@ -394,9 +420,8 @@ public class ObjectService {
return response; return response;
} }
public void fileDownload( public void fileDownload(HttpServletRequest request, HttpServletResponse response,
HttpServletRequest request, HttpServletResponse response, UploadRequest uploadRequest) UploadRequest uploadRequest) throws Exception {
throws Exception {
InputStream inputStream = null; InputStream inputStream = null;
@ -406,12 +431,8 @@ public class ObjectService {
if (uploadResponse != null) { if (uploadResponse != null) {
// 첨부파일 물리적 경로 // 첨부파일 물리적 경로
String filePath = String filePath = baseDirPath + File.separator + uploadResponse.getObjectNo()
baseDirPath + File.separator + uploadResponse.getFaileName();
+ File.separator
+ uploadResponse.getObjectNo()
+ File.separator
+ uploadResponse.getFaileName();
File file = new File(filePath); File file = new File(filePath);
if (file.exists()) { if (file.exists()) {

View File

@ -32,4 +32,8 @@ public class SaleStoreResponse {
@Schema(description = "영업사원 메일주소") @Schema(description = "영업사원 메일주소")
private String businessChargerMail; private String businessChargerMail;
@Schema(description = "정렬")
private String priority;
} }

View File

@ -1,13 +1,20 @@
package com.interplug.qcast.biz.storeFavorite; package com.interplug.qcast.biz.storeFavorite;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
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.storeFavorite.dto.StoreFavoriteRequest; import com.interplug.qcast.biz.storeFavorite.dto.StoreFavoriteRequest;
import com.interplug.qcast.biz.storeFavorite.dto.StoreFavoriteResponse;
import com.interplug.qcast.biz.user.dto.UserResponse; import com.interplug.qcast.biz.user.dto.UserResponse;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
@Slf4j @Slf4j
@RestController @RestController
@ -15,20 +22,30 @@ import org.springframework.web.bind.annotation.*;
@RequiredArgsConstructor @RequiredArgsConstructor
@Tag(name = "StoreFavorite", description = "Store Favorite 관련 API") @Tag(name = "StoreFavorite", description = "Store Favorite 관련 API")
public class StoreFavoriteController { public class StoreFavoriteController {
private final StoreFavoriteService storeFavService; private final StoreFavoriteService storeFavService;
@Operation(description = "Store Favorite 정보를 등록/수정 한다.(동기화)") @Operation(description = "Store Favorite 정보를 등록/수정 한다.(동기화)")
@PutMapping("/store-favorite-save") @PutMapping("/store-favorite-save")
@ResponseStatus(HttpStatus.OK) @ResponseStatus(HttpStatus.OK)
public UserResponse setStoreFavoriteSave(@RequestBody StoreFavoriteRequest req) throws Exception { public UserResponse setStoreFavoriteSave(@RequestBody StoreFavoriteRequest req) throws Exception {
UserResponse userResponse = new UserResponse(); UserResponse userResponse = new UserResponse();
int resultCnt = storeFavService.setStoreFavoriteSave(req); int resultCnt = storeFavService.setStoreFavoriteSave(req);
if (resultCnt > 0) userResponse.setCode("200"); if (resultCnt > 0)
else userResponse.setCode("500"); userResponse.setCode("200");
else
userResponse.setCode("500");
return userResponse; return userResponse;
} }
@Operation(description = "User Store Favorite 목록을 조회한다.")
@GetMapping("/list")
@ResponseStatus(HttpStatus.OK)
public StoreFavoriteResponse getStoreFavoriteList(@ModelAttribute StoreFavoriteRequest req)
throws Exception {
return storeFavService.getStoreFavoriteList(req);
}
} }

View File

@ -1,17 +1,64 @@
package com.interplug.qcast.biz.storeFavorite; package com.interplug.qcast.biz.storeFavorite;
import com.interplug.qcast.biz.storeFavorite.dto.StoreFavoriteRequest; import org.springframework.beans.factory.annotation.Autowired;
import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpMethod;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.util.UriComponentsBuilder;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.interplug.qcast.biz.storeFavorite.dto.StoreFavoriteRequest;
import com.interplug.qcast.biz.storeFavorite.dto.StoreFavoriteResponse;
import com.interplug.qcast.config.Exception.ErrorCode;
import com.interplug.qcast.config.Exception.QcastException;
import com.interplug.qcast.config.message.Messages;
import com.interplug.qcast.util.InterfaceQsp;
import lombok.RequiredArgsConstructor;
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
public class StoreFavoriteService { public class StoreFavoriteService {
private final StoreFavoriteMapper storeFavoriteMapper; private final StoreFavoriteMapper storeFavoriteMapper;
public int setStoreFavoriteSave(StoreFavoriteRequest req) throws Exception { private final InterfaceQsp interfaceQsp;
return storeFavoriteMapper.setStoreFavoriteSave(req);
@Autowired
Messages message;
@Value("${qsp.url}")
private String QSP_API_URL;
public int setStoreFavoriteSave(StoreFavoriteRequest req) throws Exception {
return storeFavoriteMapper.setStoreFavoriteSave(req);
}
public StoreFavoriteResponse getStoreFavoriteList(StoreFavoriteRequest req) throws Exception {
StoreFavoriteResponse response = null;
/* [0]. Validation Check */
if ("".equals(req.getUserId())) {
// [msg] {0} is required input value.
throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
message.getMessage("common.message.required.data", "User Id"));
} }
/* [1]. QSP API (url + param) Setting */
String url = QSP_API_URL + "/api/user/storeFavoriteInfoList";
String apiUrl = UriComponentsBuilder.fromHttpUrl(url).queryParam("userId", req.getUserId())
.build().toUriString();
/* [2]. QSP API CALL -> Response */
String strResponse = interfaceQsp.callApi(HttpMethod.GET, apiUrl, null);
if (!"".equals(strResponse)) {
ObjectMapper om =
new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
response = om.readValue(strResponse, StoreFavoriteResponse.class);
} else {
// [msg] No data
throw new QcastException(ErrorCode.NOT_FOUND, message.getMessage("common.message.no.data"));
}
return response;
}
} }

View File

@ -0,0 +1,13 @@
package com.interplug.qcast.biz.storeFavorite.dto;
import lombok.Data;
@Data
public class StoreFavoriteResponse {
/** API response result */
private Object result;
/** API response data */
private Object data;
}