package com.ruoyi.project.production.controller;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.production.domain.TFivesRecordDetails;
import com.ruoyi.project.production.service.ITFivesRecordDetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 整改记录详情Controller
 *
 * @author ruoyi
 * @date 2023-04-04
 */
@RestController
@RequestMapping("/production/details")
public class TFivesRecordDetailsController extends BaseController
{
    @Autowired
    private ITFivesRecordDetailsService tFivesRecordDetailsService;

    /**
     * 查询整改记录详情列表
     */
    //@PreAuthorize("@ss.hasPermi('production:details:list')")
    @GetMapping("/list")
    public TableDataInfo list(TFivesRecordDetails tFivesRecordDetails)
    {
        startPage();
        List<TFivesRecordDetails> list = tFivesRecordDetailsService.selectTFivesRecordDetailsList(tFivesRecordDetails);
        return getDataTable(list);
    }

    /**
     * 导出整改记录详情列表
     */
   // @PreAuthorize("@ss.hasPermi('production:details:export')")
    @Log(title = "整改记录详情", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TFivesRecordDetails tFivesRecordDetails)
    {
        List<TFivesRecordDetails> list = tFivesRecordDetailsService.selectTFivesRecordDetailsList(tFivesRecordDetails);
        ExcelUtil<TFivesRecordDetails> util = new ExcelUtil<TFivesRecordDetails>(TFivesRecordDetails.class);
        return util.exportExcel(list, "details");
    }

    /**
     * 获取整改记录详情详细信息
     */
   // @PreAuthorize("@ss.hasPermi('production:details:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tFivesRecordDetailsService.selectTFivesRecordDetailsById(id));
    }

    /**
     * 新增整改记录详情
     */
    //@PreAuthorize("@ss.hasPermi('production:details:add')")
    @Log(title = "整改记录详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TFivesRecordDetails tFivesRecordDetails)
    {
        return toAjax(tFivesRecordDetailsService.insertTFivesRecordDetails(tFivesRecordDetails));
    }

    /**
     * 修改整改记录详情
     */
   // @PreAuthorize("@ss.hasPermi('production:details:edit')")
    @Log(title = "整改记录详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TFivesRecordDetails tFivesRecordDetails)
    {
        return toAjax(tFivesRecordDetailsService.updateTFivesRecordDetails(tFivesRecordDetails));
    }

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