-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
warehouse/src/main/java/warehouse/domain/goods/business/GoodsBusiness.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,57 @@ | ||
package warehouse.domain.goods.business; | ||
|
||
import db.domain.goods.GoodsEntity; | ||
import db.domain.image.ImageEntity; | ||
import db.domain.image.enums.ImageKind; | ||
import global.annotation.Business; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import warehouse.domain.goods.controller.model.GoodsResponse; | ||
import warehouse.domain.goods.converter.GoodsConverter; | ||
import warehouse.domain.goods.service.GoodsService; | ||
import warehouse.domain.image.controller.model.ImageListResponse; | ||
import warehouse.domain.image.controller.model.ImageResponse; | ||
import warehouse.domain.image.converter.ImageConverter; | ||
import warehouse.domain.image.service.ImageService; | ||
|
||
@Slf4j | ||
@Business | ||
@RequiredArgsConstructor | ||
public class GoodsBusiness { | ||
|
||
private final GoodsConverter goodsConverter; | ||
private final GoodsService goodsService; | ||
private final ImageService imageService; | ||
private final ImageConverter imageConverter; | ||
|
||
public List<List<GoodsResponse>> getGoodsList(Long requestId) { | ||
|
||
List<GoodsEntity> goodsList = goodsService.findAllByReceivingIdWithThrow(requestId); | ||
|
||
List<List<GoodsResponse>> goodsResponse = new ArrayList<>(); | ||
|
||
goodsList.forEach(goodsEntity -> { | ||
|
||
log.info("goodsId = {}", goodsEntity.getId()); | ||
|
||
List<ImageEntity> imageList = imageService.getImagesByGoodsId(goodsEntity.getId()); | ||
|
||
imageList.forEach(it -> log.info("imageList = {}", it.getId())); | ||
|
||
List<ImageEntity> basicList = imageService.getImageUrlListBy(goodsEntity.getId(), | ||
ImageKind.BASIC); | ||
List<ImageEntity> faultList = imageService.getImageUrlListBy(goodsEntity.getId(), | ||
ImageKind.FAULT); | ||
|
||
ImageListResponse imageListResponse = imageConverter.toImageListResponse(basicList, | ||
faultList); | ||
|
||
goodsResponse.add(goodsConverter.toResponseListBy(goodsList, imageListResponse)); | ||
|
||
}); | ||
|
||
return goodsResponse; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
warehouse/src/main/java/warehouse/domain/goods/controller/GoodsController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package warehouse.domain.goods.controller; | ||
|
||
import global.api.Api; | ||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import warehouse.domain.goods.business.GoodsBusiness; | ||
import warehouse.domain.goods.controller.model.GoodsResponse; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/api/goods") | ||
public class GoodsController { | ||
|
||
private final GoodsBusiness goodsBusiness; | ||
|
||
@GetMapping("/receiving/{requestId}") | ||
public Api<List<List<GoodsResponse>>> receiving(@PathVariable Long requestId) { | ||
List<List<GoodsResponse>> response = goodsBusiness.getGoodsList(requestId); | ||
return Api.OK(response); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters