-
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.
Merge branch 'develop' into feature/#16/orderhistory
- Loading branch information
Showing
20 changed files
with
528 additions
and
12 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
src/main/java/Weflo/backend/controller/orderpart/OrderPartController.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,12 +1,39 @@ | ||
package Weflo.backend.controller.orderpart; | ||
|
||
import Weflo.backend.dto.common.OrderPartsDto; | ||
import Weflo.backend.dto.part.response.AllOrderPartsResponse; | ||
import Weflo.backend.dto.part.response.OrderPartsDetailResponse; | ||
import Weflo.backend.global.ApiResponse; | ||
//import Weflo.backend.service.orderpart.OrderPartDetailService; | ||
//import Weflo.backend.service.orderpart.OrderPartDetailService; | ||
import Weflo.backend.service.orderpart.OrderPartService; | ||
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 java.util.List; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping(value = "/api") | ||
public class OrderPartController { | ||
private final OrderPartService orderPartService; | ||
// private final OrderPartDetailService orderPartDetailService; | ||
|
||
@GetMapping("/orders/{userId}") | ||
public ApiResponse<AllOrderPartsResponse> getAllOrderParts(@PathVariable Long userId) { | ||
AllOrderPartsResponse allOrderParts = orderPartService.getAllOrderParts(userId); | ||
return ApiResponse.onSuccess(allOrderParts); | ||
} | ||
|
||
@GetMapping("/orders/{userId}/{droneId}") | ||
public ApiResponse<OrderPartsDetailResponse> getOrderParts(@PathVariable Long userId, | ||
@PathVariable Long droneId) { | ||
OrderPartsDetailResponse orderPartDetailOfDrone = orderPartService.getOrderPart(userId, droneId); | ||
return ApiResponse.onSuccess(orderPartDetailOfDrone); | ||
} | ||
} | ||
|
||
|
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
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
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,22 +1,66 @@ | ||
package Weflo.backend.dto.common; | ||
|
||
import Weflo.backend.domain.Drone; | ||
import Weflo.backend.domain.OrderHistory; | ||
import Weflo.backend.domain.Product; | ||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
|
||
import java.time.LocalDate; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
@Data | ||
@Builder | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
public class OrderPartsDto { | ||
private Long id; | ||
private String droneImg; | ||
private String nickname; | ||
private Integer balanceScore; | ||
private Integer totalScore; | ||
private LocalDate orderDate; | ||
private LocalDate estimateDate; | ||
private List<ProductInfoDto> productsInfo; | ||
private List<AbnormalPartsDto> abnormalities; | ||
|
||
public static OrderPartsDto of(OrderHistory orderHistory, List<ProductInfoDto> productInfoDtoList) { | ||
return builder() | ||
.id(orderHistory.getDrone().getId()) | ||
.droneImg("https://weflo.s3.ap-northeast-2.amazonaws.com/%E1%84%89%E1%85%B3%E1%84%8F%E1%85%B3%E1%84%85%E1%85%B5%E1%86%AB%E1%84%89%E1%85%A3%E1%86%BA+2024-03-07+%E1%84%8B%E1%85%A9%E1%84%92%E1%85%AE+3.48.15.png") | ||
.nickname(orderHistory.getDrone().getNickname()) | ||
.balanceScore(orderHistory.getDrone().getCheckHistory().getBalanceScore()) | ||
.totalScore(orderHistory.getDrone().getCheckHistory().getTotalScore()) | ||
.orderDate(orderHistory.getOrderDate()) | ||
.estimateDate(orderHistory.getOrderDate().plusDays(3)) | ||
.productsInfo(productInfoDtoList) | ||
.build(); | ||
} | ||
|
||
public static OrderPartsDto of(OrderHistory orderHistory, List<ProductInfoDto> productInfoDtoList,List<AbnormalPartsDto> abnormalPartsDtos) { | ||
return builder() | ||
.id(orderHistory.getDrone().getId()) | ||
.droneImg("https://weflo.s3.ap-northeast-2.amazonaws.com/%E1%84%89%E1%85%B3%E1%84%8F%E1%85%B3%E1%84%85%E1%85%B5%E1%86%AB%E1%84%89%E1%85%A3%E1%86%BA+2024-03-07+%E1%84%8B%E1%85%A9%E1%84%92%E1%85%AE+3.48.15.png") | ||
.nickname(orderHistory.getDrone().getNickname()) | ||
.balanceScore(orderHistory.getDrone().getCheckHistory().getBalanceScore()) | ||
.totalScore(orderHistory.getDrone().getCheckHistory().getTotalScore()) | ||
.orderDate(orderHistory.getOrderDate()) | ||
.estimateDate(orderHistory.getOrderDate().plusDays(3)) | ||
.productsInfo(productInfoDtoList) | ||
.abnormalities(abnormalPartsDtos) | ||
.build(); | ||
} | ||
|
||
public OrderPartsDto(Long id, String droneImg, String nickname, Integer balanceScore, Integer totalScore, LocalDate orderDate, LocalDate estimateDate, List<ProductInfoDto> productsInfo, List<AbnormalPartsDto> abnormalities) { | ||
this.id = id; | ||
this.droneImg = droneImg; | ||
this.nickname = nickname; | ||
this.balanceScore = balanceScore; | ||
this.totalScore = totalScore; | ||
this.orderDate = orderDate; | ||
this.estimateDate = estimateDate; | ||
this.productsInfo = productsInfo; | ||
this.abnormalities = abnormalities; | ||
} | ||
} |
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
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
26 changes: 26 additions & 0 deletions
26
src/main/java/Weflo/backend/dto/common/ProductInfoListDto.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 Weflo.backend.dto.common; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
|
||
@Data | ||
@Builder | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
public class ProductInfoListDto { | ||
private ProductInfoDto bladeInfoDto; | ||
private ProductInfoDto motorInfoDto; | ||
private ProductInfoDto escInfoDto; | ||
|
||
public static ProductInfoListDto of(ProductInfoDto bladeInfoDto, ProductInfoDto motorInfoDto, ProductInfoDto escInfoDto) { | ||
// this.bladeInfoDto = bladeInfoDto; | ||
// this.motorInfoDto = motorInfoDto; | ||
// this.escInfoDto = escInfoDto; | ||
return ProductInfoListDto.builder() | ||
.bladeInfoDto(bladeInfoDto) | ||
.motorInfoDto(motorInfoDto) | ||
.escInfoDto(escInfoDto) | ||
.build(); | ||
|
||
} | ||
} |
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
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
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
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
15 changes: 15 additions & 0 deletions
15
src/main/java/Weflo/backend/repository/orderhistory/OrderHistoryRepository.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,15 @@ | ||
package Weflo.backend.repository.orderhistory; | ||
|
||
|
||
import Weflo.backend.domain.Drone; | ||
import Weflo.backend.domain.OrderHistory; | ||
import org.hibernate.query.Order; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.List; | ||
|
||
@Repository | ||
public interface OrderHistoryRepository extends JpaRepository<OrderHistory, Long> { | ||
List<OrderHistory> findByDrone(Drone droneId); | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/Weflo/backend/repository/orderpart/OrderPartRepository.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,12 @@ | ||
package Weflo.backend.repository.orderpart; | ||
|
||
import Weflo.backend.domain.OrderHistory; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.Optional; | ||
|
||
@Repository | ||
public interface OrderPartRepository extends JpaRepository<OrderHistory, Long> { | ||
Optional<OrderHistory> findById(Long droneId); | ||
} |
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
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
7 changes: 7 additions & 0 deletions
7
src/main/java/Weflo/backend/service/orderpart/OrderPartDetailService.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,7 @@ | ||
//package Weflo.backend.service.orderpart; | ||
// | ||
//import Weflo.backend.dto.part.response.OrderPartsDetailResponse; | ||
// | ||
//public interface OrderPartDetailService { | ||
// OrderPartsDetailResponse getOrderPartDetailOfDrone(Long userId, Long droneId); | ||
//} |
Oops, something went wrong.