package com.shkj.wms.controller.business;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.shkj.common.annotation.Log;
import com.shkj.common.core.controller.BaseController;
import com.shkj.common.core.domain.Result;
import com.shkj.common.core.page.TableDataInfo;
import com.shkj.common.enums.BusinessType;
import com.shkj.common.utils.poi.ExcelUtil;
import com.shkj.wms.domain.BusinDataTaskErrmsg;
import com.shkj.wms.service.IBusinDataTaskErrmsgService;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
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;

/**
 * 设备异常记录Controller
 * 
 * @author zjx
 * @date 2023-08-05
 */


@RequiredArgsConstructor(onConstructor_ =@Autowired)
@RestController
@RequestMapping("/wms/errmsg")
public class BusinDataTaskErrmsgController extends BaseController
{
    @Autowired
    private IBusinDataTaskErrmsgService businDataTaskErrmsgService;

    /**
     * 查询设备异常记录列表
     */
    @GetMapping("/list")
    public TableDataInfo list(BusinDataTaskErrmsg businDataTaskErrmsg)
    {
        startPage();
        List<BusinDataTaskErrmsg> list = businDataTaskErrmsgService.selectBusinDataTaskErrmsgList(businDataTaskErrmsg);
        return getDataTable(list);
    }

    /**
     * 导出设备异常记录列表
     */

    @Log(title = "设备异常记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BusinDataTaskErrmsg businDataTaskErrmsg)
    {
        List<BusinDataTaskErrmsg> list = businDataTaskErrmsgService.selectBusinDataTaskErrmsgList(businDataTaskErrmsg);
        ExcelUtil<BusinDataTaskErrmsg> util = new ExcelUtil<BusinDataTaskErrmsg>(BusinDataTaskErrmsg.class);
        util.exportExcel(response, list, "设备异常记录数据");
    }

    /**
     * 获取设备异常记录详细信息
     */
    @GetMapping(value = "/getInfo")
    public BusinDataTaskErrmsg getInfo(Long id)
    {
        return businDataTaskErrmsgService.selectBusinDataTaskErrmsgById(id);
    }

    /**
     * 新增设备异常记录
     */
    @Log(title = "设备异常记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public Result<Boolean> add(@RequestBody BusinDataTaskErrmsg businDataTaskErrmsg)
    {
        return businDataTaskErrmsgService.insertBusinDataTaskErrmsg(businDataTaskErrmsg);
    }

    /**
     * 修改设备异常记录
     */
    @PreAuthorize("@ss.hasPermi('system:errmsg:edit')")
    @Log(title = "设备异常记录", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public Result<Boolean> edit(@RequestBody BusinDataTaskErrmsg businDataTaskErrmsg)
    {
        return businDataTaskErrmsgService.updateBusinDataTaskErrmsg(businDataTaskErrmsg);
    }

    /**
     * 删除设备异常记录
     */
    @PreAuthorize("@ss.hasPermi('system:errmsg:remove')")
    @Log(title = "设备异常记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/del")
    public Result<Boolean> remove(@PathVariable Long id)
    {
        return businDataTaskErrmsgService.deleteBusinDataTaskErrmsgById(id);
    }
}
