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

import java.util.List;

/**
 * 路线管理
 */
@Slf4j
@RestController
@RequestMapping("/route")
@RequiredArgsConstructor
public class RouteController {

    private final RouteService routeService;

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

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

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

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

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

}

