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.MaTypeHisNum;
import com.bonus.sgzb.machine.damain.MaTypeHisPrice;
import com.bonus.sgzb.machine.service.MaTypeHisNumService;
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("/typeHisNum")
public class MaTypeHisNumController extends BaseController {

    @Autowired
    private MaTypeHisNumService maTypeHisNumService;

    /**
     * 根据条件进行查询机具历史库存
     */
    @PostMapping("/getTypeHisNum")
    public TableDataInfo getTypeHisNum(@Validated @RequestBody MaTypeHisNum maTypeHisNum)
    {
        startPage();
        List<MaTypeHisNum> list = maTypeHisNumService.getTypeHisNum(maTypeHisNum);
        return getDataTable(list);
    }

    /**
     * 新增机具历史库存
     */
    @PostMapping
    public AjaxResult typeHisNumAdd(@Validated @RequestBody MaTypeHisNum maTypeHisNum)
    {
        return toAjax(maTypeHisNumService.typeHisNumAdd(maTypeHisNum));
    }

    /**
     * 修改机具历史库存
     */
    @PutMapping
    public AjaxResult updateTypeHisNum(@Validated @RequestBody MaTypeHisNum maTypeHisNum)
    {

        return toAjax(maTypeHisNumService.updateTypeHisNum(maTypeHisNum));
    }

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