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.RouteDetailEntity;
import com.njzscloud.supervisory.route.service.RouteDetailService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 路线详情管理
 */
@Slf4j
@RestController
@RequestMapping("/route_detail")
@RequiredArgsConstructor
public class RouteDetailController {

    private final RouteDetailService routeDetailService;

    /**
     * 新增
     */
    @PostMapping("/add")
    public R<?> add(@RequestBody RouteDetailEntity detailEntity) {
        routeDetailService.add(detailEntity);
        return R.success();
    }

    /**
     * 修改
     */
    @PostMapping("/modify")
    public R<?> modify(@RequestBody RouteDetailEntity detailEntity) {
        routeDetailService.modify(detailEntity);
        return R.success();
    }

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

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

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

}

