package com.ruoyi.web.controller.fleet.orderPlan;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.orderPlan.service.IftmsorderbillsfeesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * 单趟费用Controller
 *
 * @author ruoyi
 * @date 2021-02-22
 */
@RestController
@RequestMapping("/fleet/ftmsorderbillsfees")
public class ftmsorderbillsfeesController extends BaseController {

    @Autowired
    private IftmsorderbillsfeesService iftmsorderbillsfeesService;


    /**
     * 根据id查询费用详细信息
     */
    @PreAuthorize("@ss.hasPermi('fleet:ftmsorderbillsfees:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        if (StringUtils.isNull(id)) {
            return AjaxResult.error("未找到查询条件，请确认");
        }
        return AjaxResult.success(iftmsorderbillsfeesService.selectFTmsorderbillsfeesByIdMap(id));
    }

    /**
     * 费用提交
     */
    @PreAuthorize("@ss.hasPermi('fleet:ftmsorderbillsfees:add')")
    @Log(title = "【车辆】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestParam("cars") String cars,
                          @RequestParam("status") long status,
                          @RequestParam("ftmsorderbillsfees") String ftmsorderbillsfees) {
        if (StringUtils.isEmpty(cars) || "{}".equals(cars)) {
            return AjaxResult.error("未找到主表数据，请确认");
        }
        return iftmsorderbillsfeesService.insertFTmsorderbillsfeesAdd(cars, status, ftmsorderbillsfees);
    }

}
