package com.zehong.web.controller.equipment;

import java.util.List;
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;
import com.zehong.common.annotation.Log;
import com.zehong.common.core.controller.BaseController;
import com.zehong.common.core.domain.AjaxResult;
import com.zehong.common.enums.BusinessType;
import com.zehong.system.domain.ReceivedNbFailureHistory;
import com.zehong.system.service.IReceivedNbFailureHistoryService;
import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.common.core.page.TableDataInfo;

/**
 * 获取NB码失败记录Controller
 *
 * @author zehong
 * @date 2026-07-18
 */
@RestController
@RequestMapping("/received/nb/failure/history")
public class ReceivedNbFailureHistoryController extends BaseController
{
    @Autowired
    private IReceivedNbFailureHistoryService receivedNbFailureHistoryService;

    /**
     * 查询获取NB码失败记录列表
     */
    @GetMapping("/list")
    public TableDataInfo list(ReceivedNbFailureHistory receivedNbFailureHistory)
    {
        startPage();
        List<ReceivedNbFailureHistory> list = receivedNbFailureHistoryService.selectReceivedNbFailureHistoryList(receivedNbFailureHistory);
        return getDataTable(list);
    }

    /**
     * 导出获取NB码失败记录列表
     */
    @GetMapping("/export")
    public AjaxResult export(ReceivedNbFailureHistory receivedNbFailureHistory)
    {
        List<ReceivedNbFailureHistory> list = receivedNbFailureHistoryService.selectReceivedNbFailureHistoryList(receivedNbFailureHistory);
        ExcelUtil<ReceivedNbFailureHistory> util = new ExcelUtil<ReceivedNbFailureHistory>(ReceivedNbFailureHistory.class);
        return util.exportExcel(list, "获取NB码失败记录数据");
    }

    /**
     * 获取获取NB码失败记录详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(receivedNbFailureHistoryService.selectReceivedNbFailureHistoryById(id));
    }

    /**
     * 新增获取NB码失败记录
     */
    @PostMapping
    public AjaxResult add(@RequestBody ReceivedNbFailureHistory receivedNbFailureHistory)
    {
        return toAjax(receivedNbFailureHistoryService.insertReceivedNbFailureHistory(receivedNbFailureHistory));
    }

    /**
     * 修改获取NB码失败记录
     */
    @PutMapping
    public AjaxResult edit(@RequestBody ReceivedNbFailureHistory receivedNbFailureHistory)
    {
        return toAjax(receivedNbFailureHistoryService.updateReceivedNbFailureHistory(receivedNbFailureHistory));
    }

    /**
     * 删除获取NB码失败记录
     */
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(receivedNbFailureHistoryService.deleteReceivedNbFailureHistoryByIds(ids));
    }
}
