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.service.MaMachineService;
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("/machine")
public class MaMachineController extends BaseController {

    @Autowired
    private MaMachineService maMachineService;

    /**
     * 根据条件进行查询机具设备管理
     */
    @PostMapping("/getMachine")
    public TableDataInfo getMaMachine(@Validated @RequestBody MaMachine maMachine)
    {
        startPage();
        List<MaMachine> list = maMachineService.getMaMachine(maMachine);
        return getDataTable(list);
    }

    /**
     * 新增机具设备管理
     */
    @PostMapping
    public AjaxResult maMachineAdd(@Validated @RequestBody MaMachine maMachine)
    {
        return toAjax(maMachineService.maMachineAdd(maMachine));
    }

    /**
     * 删除机具设备管理
     */
    @DeleteMapping("/{maIds}")
    public AjaxResult remove(@PathVariable Long[] maIds)
    {
        maMachineService.remove(maIds);
        return success();
    }

    /**
     * 修改机具设备管理
     */
    @PutMapping
    public AjaxResult edit(@Validated @RequestBody MaMachine maMachine)
    {

        return toAjax(maMachineService.updateMaMachine(maMachine));
    }
}
