

package com.tmerclub.cloud.delivery.controller.app;

import com.tmerclub.cloud.api.delivery.vo.DeliveryOrderFeignVO;
import com.tmerclub.cloud.api.order.feign.OrderFeignClient;
import com.tmerclub.cloud.common.response.ServerResponseEntity;
import com.tmerclub.cloud.delivery.service.DeliveryOrderService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
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;

/**
 * @author
 */
@RestController("appMyDeliveryController")
@RequestMapping("/myDelivery")
@Tag(name = "app-我的物流接口")
public class MyDeliveryController {

    @Autowired
    private DeliveryOrderService deliveryOrderService;

    @DubboReference
    private OrderFeignClient orderFeignClient;

    /**
     * 物流查询接口
     */
    @GetMapping("/orderInfo/{orderId}")
    @Operation(summary = "物流查询接口", description = "根据orderNumber查询订单所有包裹信息")
    public ServerResponseEntity<List<DeliveryOrderFeignVO>> info(@PathVariable("orderId") String orderId) {
        List<DeliveryOrderFeignVO> deliveryOrders = deliveryOrderService.getByDeliveryByOrderId(Long.parseLong(orderId));
        return ServerResponseEntity.success(deliveryOrders);
    }

    @GetMapping("/deliveryPackage/{deliveryOrderId}")
    @Operation(summary = "物流包裹查询接口", description = "根据orderDeliveryId查询订单包裹信息")
    @Parameter(name = "deliveryOrderId", description = "订单物流包裹id")
    public ServerResponseEntity<DeliveryOrderFeignVO> info(@PathVariable("deliveryOrderId") Long deliveryOrderId) {
        DeliveryOrderFeignVO deliveryOrder = deliveryOrderService.deliveryOrderItemInfo(deliveryOrderId);
        return ServerResponseEntity.success(deliveryOrder);
    }


}
