package com.ruoyi.project.production.controller;

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.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.production.domain.TPrdRecordItem;
import com.ruoyi.project.production.service.ITPrdRecordItemService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 生产记录详情Controller
 *
 * @author ssy
 * @date 2024-10-10
 */
@RestController
@RequestMapping("/production/item")
public class TPrdRecordItemController extends BaseController
{
    @Autowired
    private ITPrdRecordItemService tPrdRecordItemService;

    /**
     * 查询生产记录详情列表
     */
    @PreAuthorize("@ss.hasPermi('production:item:list')")
    @GetMapping("/list")
    public TableDataInfo list(TPrdRecordItem tPrdRecordItem)
    {
        startPage();
        List<TPrdRecordItem> list = tPrdRecordItemService.selectTPrdRecordItemList(tPrdRecordItem);
        return getDataTable(list);
    }

    /**
     * 导出生产记录详情列表
     */
    @PreAuthorize("@ss.hasPermi('production:item:export')")
    @Log(title = "生产记录详情", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TPrdRecordItem tPrdRecordItem)
    {
        List<TPrdRecordItem> list = tPrdRecordItemService.selectTPrdRecordItemList(tPrdRecordItem);
        ExcelUtil<TPrdRecordItem> util = new ExcelUtil<TPrdRecordItem>(TPrdRecordItem.class);
        return util.exportExcel(list, "item");
    }

    /**
     * 获取生产记录详情详细信息
     */
    @PreAuthorize("@ss.hasPermi('production:item:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tPrdRecordItemService.selectTPrdRecordItemById(id));
    }

    /**
     * 新增生产记录详情
     */
    @PreAuthorize("@ss.hasPermi('production:item:add')")
    @Log(title = "生产记录详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TPrdRecordItem tPrdRecordItem)
    {
        return toAjax(tPrdRecordItemService.insertTPrdRecordItem(tPrdRecordItem));
    }

    /**
     * 修改生产记录详情
     */
    @PreAuthorize("@ss.hasPermi('production:item:edit')")
    @Log(title = "生产记录详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TPrdRecordItem tPrdRecordItem)
    {
        return toAjax(tPrdRecordItemService.updateTPrdRecordItem(tPrdRecordItem));
    }

    /**
     * 删除生产记录详情
     */
    @PreAuthorize("@ss.hasPermi('production:item:remove')")
    @Log(title = "生产记录详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tPrdRecordItemService.deleteTPrdRecordItemByIds(ids));
    }
}
