package com.shzg.project.unique.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.shzg.framework.aspectj.lang.annotation.Log;
import com.shzg.framework.aspectj.lang.enums.BusinessType;
import com.shzg.project.unique.domain.WornUniqueCodeMaterial;
import com.shzg.project.unique.service.IWornUniqueCodeMaterialService;
import com.shzg.framework.web.controller.BaseController;
import com.shzg.framework.web.domain.AjaxResult;
import com.shzg.common.utils.poi.ExcelUtil;
import com.shzg.framework.web.page.TableDataInfo;

/**
 * 唯一码物料信息Controller
 * 
 * @author shzg
 * @date 2026-03-17
 */
@RestController
@RequestMapping("/unique/information")
public class WornUniqueCodeMaterialController extends BaseController
{
    @Autowired
    private IWornUniqueCodeMaterialService wornUniqueCodeMaterialService;

    /**
     * 查询唯一码物料信息列表
     */
    @PreAuthorize("@ss.hasPermi('unique:information:list')")
    @GetMapping("/list")
    public TableDataInfo list(WornUniqueCodeMaterial wornUniqueCodeMaterial)
    {
        startPage();
        List<WornUniqueCodeMaterial> list = wornUniqueCodeMaterialService.selectWornUniqueCodeMaterialList(wornUniqueCodeMaterial);
        return getDataTable(list);
    }

    /**
     * 导出唯一码物料信息列表
     */
    @PreAuthorize("@ss.hasPermi('unique:information:export')")
    @Log(title = "唯一码物料信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WornUniqueCodeMaterial wornUniqueCodeMaterial)
    {
        List<WornUniqueCodeMaterial> list = wornUniqueCodeMaterialService.selectWornUniqueCodeMaterialList(wornUniqueCodeMaterial);
        ExcelUtil<WornUniqueCodeMaterial> util = new ExcelUtil<WornUniqueCodeMaterial>(WornUniqueCodeMaterial.class);
        util.exportExcel(response, list, "唯一码物料信息数据");
    }

    /**
     * 获取唯一码物料信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('unique:information:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(wornUniqueCodeMaterialService.selectWornUniqueCodeMaterialById(id));
    }

    /**
     * 新增唯一码物料信息
     */
    @PreAuthorize("@ss.hasPermi('unique:information:add')")
    @Log(title = "唯一码物料信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WornUniqueCodeMaterial wornUniqueCodeMaterial)
    {
        return toAjax(wornUniqueCodeMaterialService.insertWornUniqueCodeMaterial(wornUniqueCodeMaterial));
    }

    /**
     * 修改唯一码物料信息
     */
    @PreAuthorize("@ss.hasPermi('unique:information:edit')")
    @Log(title = "唯一码物料信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WornUniqueCodeMaterial wornUniqueCodeMaterial)
    {
        return toAjax(wornUniqueCodeMaterialService.updateWornUniqueCodeMaterial(wornUniqueCodeMaterial));
    }

    /**
     * 删除唯一码物料信息
     */
    @PreAuthorize("@ss.hasPermi('unique:information:remove')")
    @Log(title = "唯一码物料信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wornUniqueCodeMaterialService.deleteWornUniqueCodeMaterialByIds(ids));
    }
}
