Skip to content

Commit

Permalink
SB-214 (!HOTFIX) : /api/goods 요청 결과 값에서 body의 2차원 배열을 1차원 배열로 수정
Browse files Browse the repository at this point in the history
SB-214 (!HOTFIX) : `/api/goods` 요청 결과 값에서 body의 2차원 배열을 1차원 배열로 수정

1. 불필요 차원 축소
 - 2차원 -> 1차원
2. /api/goods/{strategy}/{requestId} 동일 적용
3. Goods Import 수정
  • Loading branch information
shinywoon committed Jul 24, 2024
1 parent f211a34 commit f2bc64f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package warehouse.common.exception.goods;
package warehouse.common.exception.Goods;

import global.errorcode.ErrorCodeIfs;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import warehouse.common.error.GoodsErrorCode;
import warehouse.common.exception.goods.InvalidGoodsStatusException;
import warehouse.common.exception.Goods.InvalidGoodsStatusException;
import warehouse.common.exception.goods.GoodsNotFoundException;

@Slf4j
Expand All @@ -24,8 +24,7 @@ public ResponseEntity<Api<Object>> imageException(GoodsNotFoundException e) {
}

@ExceptionHandler(value = InvalidGoodsStatusException.class)
public ResponseEntity<Api<Object>> InvalidGoodsStatus(
warehouse.common.exception.goods.InvalidGoodsStatusException e) {
public ResponseEntity<Api<Object>> InvalidGoodsStatus(InvalidGoodsStatusException e) {
log.info("", e);
return ResponseEntity.status(HttpStatus.BAD_REQUEST)
.body(Api.ERROR(GoodsErrorCode.INVALID_GOODS_STATUS));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,23 @@ public class GoodsBusiness {
private final ImageService imageService;
private final ImageConverter imageConverter;

public List<List<GoodsResponse>> getGoodsList(GetGoodsStrategy strategy,Long requestId) {
public List<GoodsResponse> getGoodsList(GetGoodsStrategy strategy,Long requestId) {

List<GoodsEntity> goodsList = findGoodsListById(strategy,requestId);

return getGoodsResponsesBy(goodsList);
}

public List<List<GoodsResponse>> getGoodsList(GoodsStatus status) {
public List<GoodsResponse> getGoodsList(GoodsStatus status) {

List<GoodsEntity> goodsList = goodsService.findAllByGoodsStatusWithThrow(status);

return getGoodsResponsesBy(goodsList);
}

private List<List<GoodsResponse>> getGoodsResponsesBy(List<GoodsEntity> goodsList) {
private List<GoodsResponse> getGoodsResponsesBy(List<GoodsEntity> goodsList) {

List<List<GoodsResponse>> goodsResponse = new ArrayList<>();
List<GoodsResponse> goodsResponse = new ArrayList<>();

goodsList.forEach(goodsEntity -> {

Expand All @@ -63,7 +63,7 @@ private List<List<GoodsResponse>> getGoodsResponsesBy(List<GoodsEntity> goodsLis
ImageListResponse imageListResponse = imageConverter.toImageListResponse(basicList,
faultList);

goodsResponse.add(goodsConverter.toResponseListBy(goodsList, imageListResponse));
goodsResponse.add(goodsConverter.toResponse(goodsEntity, imageListResponse));

});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ public class GoodsController {
private final GoodsBusiness goodsBusiness;

@GetMapping("/{strategy}/{requestId}")
public Api<List<List<GoodsResponse>>> receiving(@PathVariable GetGoodsStrategy strategy, @PathVariable Long requestId) {
List<List<GoodsResponse>> response = goodsBusiness.getGoodsList(strategy,requestId);
public Api<List<GoodsResponse>> receiving(@PathVariable GetGoodsStrategy strategy, @PathVariable Long requestId) {
List<GoodsResponse> response = goodsBusiness.getGoodsList(strategy,requestId);
return Api.OK(response);
}

@GetMapping()
public Api<List<List<GoodsResponse>>> getGoodsByStatus(@RequestParam GoodsStatus status) {
List<List<GoodsResponse>> response = goodsBusiness.getGoodsList(status);
public Api<List<GoodsResponse>> getGoodsByStatus(@RequestParam GoodsStatus status) {
List<GoodsResponse> response = goodsBusiness.getGoodsList(status);
return Api.OK(response);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import warehouse.common.error.GoodsErrorCode;
import warehouse.common.exception.Goods.InvalidGoodsStatusException;
import warehouse.common.exception.goods.GoodsNotFoundException;
import warehouse.common.exception.goods.InvalidGoodsStatusException;

@Service
@RequiredArgsConstructor
Expand Down

0 comments on commit f2bc64f

Please sign in to comment.