package com.zg.project.Inventory.AutoInventory.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.zg.framework.aspectj.lang.annotation.Log;
import com.zg.framework.aspectj.lang.enums.BusinessType;
import com.zg.project.Inventory.AutoInventory.domain.entity.PrintRfid;
import com.zg.project.Inventory.AutoInventory.service.IPrintRfidService;
import com.zg.framework.web.controller.BaseController;
import com.zg.framework.web.domain.AjaxResult;
import com.zg.common.utils.poi.ExcelUtil;
import com.zg.framework.web.page.TableDataInfo;

/**
 * 打印rfidController
 * 
 * @author zg
 * @date 2025-04-17
 */
@RestController
@RequestMapping("/system/rfid")
public class PrintRfidController extends BaseController
{
    @Autowired
    private IPrintRfidService printRfidService;

    /**
     * 查询打印rfid列表
     */
    @PreAuthorize("@ss.hasPermi('system:rfid:list')")
    @GetMapping("/list")
    public TableDataInfo list(PrintRfid printRfid)
    {
        startPage();
        List<PrintRfid> list = printRfidService.selectPrintRfidList(printRfid);
        return getDataTable(list);
    }

    /**
     * 导出打印rfid列表
     */
    @PreAuthorize("@ss.hasPermi('system:rfid:export')")
    @Log(title = "打印rfid", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PrintRfid printRfid)
    {
        List<PrintRfid> list = printRfidService.selectPrintRfidList(printRfid);
        ExcelUtil<PrintRfid> util = new ExcelUtil<PrintRfid>(PrintRfid.class);
        util.exportExcel(response, list, "打印rfid数据");
    }

    /**
     * 获取打印rfid详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:rfid:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(printRfidService.selectPrintRfidById(id));
    }

    /**
     * 新增打印rfid
     */
    @PreAuthorize("@ss.hasPermi('system:rfid:add')")
    @Log(title = "打印rfid", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PrintRfid printRfid)
    {
        return toAjax(printRfidService.insertPrintRfid(printRfid));
    }

    /**
     * 修改打印rfid
     */
    @PreAuthorize("@ss.hasPermi('system:rfid:edit')")
    @Log(title = "打印rfid", businessType = BusinessType.UPDATE)
    @PutMapping
//    public AjaxResult edit(@RequestBody PrintRfid printRfid)
    public AjaxResult edit(Long id)
    {
        return toAjax(printRfidService.updatePrintRfid(id));
    }

    /**
     * 删除打印rfid
     */
    @PreAuthorize("@ss.hasPermi('system:rfid:remove')")
    @Log(title = "打印rfid", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(printRfidService.deletePrintRfidByIds(ids));
    }
}
