|
@@ -1,18 +1,28 @@
|
|
|
package com.chelvc.cloud.maintain.controller;
|
|
|
|
|
|
-import javax.validation.Valid;
|
|
|
-import javax.validation.constraints.Min;
|
|
|
-
|
|
|
+import com.chelvc.cloud.maintain.copier.MerchantCopier;
|
|
|
+import com.chelvc.cloud.maintain.copier.ReservationCopier;
|
|
|
+import com.chelvc.cloud.maintain.vo.ReservationVO;
|
|
|
+import com.chelvc.cloud.vehicle.api.dto.ReservationDTO;
|
|
|
import com.chelvc.cloud.vehicle.api.param.ReservationModifyParam;
|
|
|
+import com.chelvc.cloud.vehicle.api.param.ReservationQueryParam;
|
|
|
import com.chelvc.cloud.vehicle.api.service.ReservationService;
|
|
|
import com.chelvc.framework.base.annotation.ResponseWrapping;
|
|
|
import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
+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.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import javax.validation.Valid;
|
|
|
+import javax.validation.constraints.Min;
|
|
|
+import java.util.Collections;
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
/**
|
|
|
* 预约接口
|
|
|
*
|
|
@@ -37,4 +47,26 @@ public class ReservationController {
|
|
|
@RequestBody @Valid ReservationModifyParam param) {
|
|
|
this.reservationService.addReservation(merchantId, param);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询用户预约列表
|
|
|
+ *
|
|
|
+ * @param param 查询参数
|
|
|
+ * @return 用户预约列表
|
|
|
+ */
|
|
|
+ @GetMapping("/reservations")
|
|
|
+ public List<ReservationVO> listUserReservations(@Valid ReservationQueryParam param) {
|
|
|
+ List<ReservationDTO> reservations = this.reservationService.listUserReservations(param);
|
|
|
+ if (CollectionUtils.isEmpty(reservations)) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+ return reservations
|
|
|
+ .stream()
|
|
|
+ .map(o -> {
|
|
|
+ ReservationVO reservationVO = ReservationCopier.INSTANCE.copying(o);
|
|
|
+ reservationVO.setSimpleMerchantVO(MerchantCopier.INSTANCE
|
|
|
+ .merchantDTOToSimpleMerchantVO(o.getMerchant()));
|
|
|
+ return reservationVO;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ }
|
|
|
}
|