package com.bonus.material.ma.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.bonus.common.log.enums.OperaType;
import com.bonus.material.common.annotation.PreventRepeatSubmit;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bonus.common.log.annotation.SysLog;
import com.bonus.common.security.annotation.RequiresPermissions;
import com.bonus.material.ma.domain.MachineAppend;
import com.bonus.material.ma.service.IMachineAppendService;
import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.core.utils.poi.ExcelUtil;
import com.bonus.common.core.web.page.TableDataInfo;

/**
 * 机具设备最近领退信息Controller
 * 
 * @author xsheng
 * @date 2024-09-27
 */
@Api(tags = "机具设备最近领退信息接口")
@RestController
@RequestMapping("/ma_machine_append")
public class MachineAppendController extends BaseController
{
    @Autowired
    private IMachineAppendService machineAppendService;

    /**
     * 查询机具设备最近领退信息列表
     */
    @ApiOperation(value = "查询机具设备最近领退信息列表")
    @RequiresPermissions("ma:append:list")
    @GetMapping("/list")
    public TableDataInfo list(MachineAppend machineAppend)
    {
        startPage();
        List<MachineAppend> list = machineAppendService.selectMachineAppendList(machineAppend);
        return getDataTable(list);
    }

    /**
     * 导出机具设备最近领退信息列表
     */
    @ApiOperation(value = "导出机具设备最近领退信息列表")
    @PreventRepeatSubmit
    @RequiresPermissions("ma:append:export")
    @SysLog(title = "机具设备最近领退信息", businessType = OperaType.EXPORT, logType = 1,module = "仓储管理->导出机具设备最近领退信息")
    @PostMapping("/export")
    public void export(HttpServletResponse response, MachineAppend machineAppend)
    {
        List<MachineAppend> list = machineAppendService.selectMachineAppendList(machineAppend);
        ExcelUtil<MachineAppend> util = new ExcelUtil<MachineAppend>(MachineAppend.class);
        util.exportExcel(response, list, "机具设备最近领退信息数据");
    }

    /**
     * 获取机具设备最近领退信息详细信息
     */
    @ApiOperation(value = "获取机具设备最近领退信息详细信息")
    @RequiresPermissions("ma:append:query")
    @GetMapping(value = "/{maId}")
    public AjaxResult getInfo(@PathVariable("maId") Long maId)
    {
        return success(machineAppendService.selectMachineAppendByMaId(maId));
    }

    /**
     * 新增机具设备最近领退信息
     */
    @ApiOperation(value = "新增机具设备最近领退信息")
    @PreventRepeatSubmit
    @RequiresPermissions("ma:append:add")
    @SysLog(title = "机具设备最近领退信息", businessType = OperaType.INSERT, logType = 1,module = "仓储管理->新增机具设备最近领退信息")
    @PostMapping
    public AjaxResult add(@RequestBody MachineAppend machineAppend)
    {
        return toAjax(machineAppendService.insertMachineAppend(machineAppend));
    }

    /**
     * 修改机具设备最近领退信息
     */
    @ApiOperation(value = "修改机具设备最近领退信息")
    @PreventRepeatSubmit
    @RequiresPermissions("ma:append:edit")
    @SysLog(title = "机具设备最近领退信息", businessType = OperaType.UPDATE, logType = 1,module = "仓储管理->修改机具设备最近领退信息")
    @PutMapping
    public AjaxResult edit(@RequestBody MachineAppend machineAppend)
    {
        return toAjax(machineAppendService.updateMachineAppend(machineAppend));
    }

    /**
     * 删除机具设备最近领退信息
     */
    @ApiOperation(value = "删除机具设备最近领退信息")
    @PreventRepeatSubmit
    @RequiresPermissions("ma:append:remove")
    @SysLog(title = "机具设备最近领退信息", businessType = OperaType.DELETE, logType = 1,module = "仓储管理->删除机具设备最近领退信息")
	@DeleteMapping("/{maIds}")
    public AjaxResult remove(@PathVariable Long[] maIds)
    {
        return toAjax(machineAppendService.deleteMachineAppendByMaIds(maIds));
    }
}
