package com.njzscloud.supervisory.route.controller;

import com.njzscloud.common.core.utils.R;
import com.njzscloud.common.mp.support.PageParam;
import com.njzscloud.common.mp.support.PageResult;
import com.njzscloud.supervisory.route.pojo.OrderRouteEntity;
import com.njzscloud.supervisory.route.service.OrderRouteService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 订单路线管理
 */
@Slf4j
@RestController
@RequestMapping("/order_route")
@RequiredArgsConstructor
public class OrderRouteController {

    private final OrderRouteService orderRouteService;

    /**
     * 新增
     */
    @PostMapping("/add")
    public R<?> add(@RequestBody OrderRouteEntity routeEntity) {
        orderRouteService.add(routeEntity);
        return R.success();
    }

    /**
     * 修改
     */
    @PostMapping("/modify")
    public R<?> modify(@RequestBody OrderRouteEntity routeEntity) {
        orderRouteService.modify(routeEntity);
        return R.success();
    }

    /**
     * 删除
     */
    @PostMapping("/del")
    public R<?> del(@RequestBody List<Long> ids) {
        orderRouteService.del(ids);
        return R.success();
    }

    /**
     * 详情
     */
    @GetMapping("/detail")
    public R<OrderRouteEntity> detail(@RequestParam Long id) {
        return R.success(orderRouteService.detail(id));
    }

    /**
     * 分页查询
     */
    @GetMapping("/paging")
    public R<PageResult<OrderRouteEntity>> paging(PageParam pageParam, OrderRouteEntity routeEntity) {
        return R.success(orderRouteService.paging(pageParam, routeEntity));
    }

    /**
     * 根据订单Id查看路线详情
     */
    @GetMapping("/getByOrderId")
    public R<OrderRouteEntity> getByOrderId(@RequestParam Long orderId) {
        return R.success(orderRouteService.getByOrderId(orderId));
    }

}

