package com.bonus.sgzb.machine.controller;


import com.bonus.sgzb.common.core.web.controller.BaseController;
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
import com.bonus.sgzb.common.core.web.page.TableDataInfo;
import com.bonus.sgzb.machine.damain.MaMachine;
import com.bonus.sgzb.machine.damain.MaTypeHisPrice;
import com.bonus.sgzb.machine.service.MaTypeHisPriceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 机具历史租赁价格
 */
@RestController
@RequestMapping("/typeHisPrice")
public class MaTypeHisPriceController extends BaseController {

    @Autowired
    private MaTypeHisPriceService maTypeHisPriceService;

    /**
     * 根据条件进行查询机具历史租赁价格
     */
    @PostMapping("/getTypeHisPrice")
    public TableDataInfo getTypeHisPrice(@Validated @RequestBody MaTypeHisPrice maTypeHisPrice)
    {
        startPage();
        List<MaTypeHisPrice> list = maTypeHisPriceService.getTypeHisPrice(maTypeHisPrice);
        return getDataTable(list);
    }

    /**
     * 新增机具历史租赁价格
     */
    @PostMapping
    public AjaxResult typeHisPriceAdd(@Validated @RequestBody MaTypeHisPrice maTypeHisPrice)
    {
        return toAjax(maTypeHisPriceService.typeHisPriceAdd(maTypeHisPrice));
    }

    /**
     * 删除机具历史租赁价格
     */
    @DeleteMapping("/{typeIds}")
    public AjaxResult remove(@PathVariable Long[] typeIds)
    {
        maTypeHisPriceService.remove(typeIds);
        return success();
    }

    /**
     * 修改机机具历史租赁价格
     */
    @PutMapping
    public AjaxResult updateTypeHisPrice(@Validated @RequestBody MaTypeHisPrice maTypeHisPrice)
    {

        return toAjax(maTypeHisPriceService.updateTypeHisPrice(maTypeHisPrice));
    }

}
