package com.njzscloud.dispose.cst.truck.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.dispose.cst.truck.pojo.entity.TruckEntity;
import com.njzscloud.dispose.cst.truck.pojo.param.DelTruckParam;
import com.njzscloud.dispose.cst.truck.service.TruckService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * 车辆信息
 *
 * @author ljw
 */
@Slf4j
@RestController
@RequestMapping("/truck")
@RequiredArgsConstructor
public class TruckController {

    private final TruckService truckService;

    /**
     * 新增
     */
    @PostMapping("/add")
    public R<?> add(@RequestBody TruckEntity truckEntity) {
        truckService.add(truckEntity);
        return R.success();
    }

    /**
     * 修改
     */
    @PostMapping("/modify")
    public R<?> modify(@RequestBody TruckEntity truckEntity) {
        truckService.modify(truckEntity);
        return R.success();
    }

    /**
     * 删除
     */
    @PostMapping("/del")
    public R<?> del(@RequestBody DelTruckParam param) {
        truckService.del(param.getIds(), param.getManager());
        return R.success();
    }

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

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


