2차점 판매점 API 즐겨찾기 로직 추가
This commit is contained in:
parent
fff3cfa50f
commit
0f8444d312
@ -69,8 +69,8 @@ public class ObjectController {
|
||||
@GetMapping("/saleStore/{saleStoreId}/list")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public List<SaleStoreResponse> selectSaleStoreList(
|
||||
@PathVariable String saleStoreId, String firstFlg) throws Exception {
|
||||
return objectService.selectSaleStoreList(saleStoreId, firstFlg);
|
||||
@PathVariable String saleStoreId, String firstFlg, String userId) throws Exception {
|
||||
return objectService.selectSaleStoreList(saleStoreId, firstFlg, userId);
|
||||
}
|
||||
|
||||
@Operation(description = "물건정보 목록을 조회한다.")
|
||||
|
||||
@ -77,6 +77,17 @@ public class ObjectService {
|
||||
|
||||
public List<SaleStoreResponse> selectFirstSaleStoreList(String saleStoreId, String userId)
|
||||
throws Exception {
|
||||
// Validation
|
||||
if (StringUtils.isEmpty(saleStoreId)) {
|
||||
throw new QcastException(
|
||||
ErrorCode.INVALID_INPUT_VALUE,
|
||||
message.getMessage("common.message.required.data", "Sale Store ID"));
|
||||
}
|
||||
if (StringUtils.isEmpty(userId)) {
|
||||
throw new QcastException(
|
||||
ErrorCode.INVALID_INPUT_VALUE,
|
||||
message.getMessage("common.message.required.data", "User ID"));
|
||||
}
|
||||
|
||||
// [0]. 판매점 목록 조회
|
||||
List<SaleStoreResponse> storeList = new ArrayList<SaleStoreResponse>();
|
||||
@ -123,12 +134,62 @@ public class ObjectService {
|
||||
return storeList;
|
||||
}
|
||||
|
||||
public List<SaleStoreResponse> selectSaleStoreList(String saleStoreId, String firstFlg)
|
||||
throws Exception {
|
||||
public List<SaleStoreResponse> selectSaleStoreList(
|
||||
String saleStoreId, String firstFlg, String userId) throws Exception {
|
||||
// Validation
|
||||
if (StringUtils.isEmpty(saleStoreId)) {
|
||||
throw new QcastException(
|
||||
ErrorCode.INVALID_INPUT_VALUE,
|
||||
message.getMessage("common.message.required.data", "Sale Store ID"));
|
||||
}
|
||||
if (StringUtils.isEmpty(userId)) {
|
||||
throw new QcastException(
|
||||
ErrorCode.INVALID_INPUT_VALUE,
|
||||
message.getMessage("common.message.required.data", "User ID"));
|
||||
}
|
||||
|
||||
// [0]. 판매점 목록 조회
|
||||
List<SaleStoreResponse> storeList = new ArrayList<SaleStoreResponse>();
|
||||
storeList = objectMapper.selectSaleStoreList(saleStoreId, firstFlg);
|
||||
|
||||
// [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();
|
||||
if ("1".equals(saleStore.getSaleStoreLevel())) {
|
||||
saleStore.setPriority("A0");
|
||||
} else {
|
||||
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"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// [4]. 정렬 기준 sort (오름차순)
|
||||
storeList.sort(Comparator.comparing(SaleStoreResponse::getPriority));
|
||||
}
|
||||
} else {
|
||||
throw new QcastException(ErrorCode.INTERNAL_SERVER_ERROR, (String) result.get("resultMsg"));
|
||||
}
|
||||
}
|
||||
|
||||
return storeList;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user