package com.ruoyi.project.pssr.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.pssr.domain.TPssrTurndown;
import com.ruoyi.project.pssr.service.ITPssrTurndownService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * PSSR驳回原因Controller
 *
 * @author ssy
 * @date 2024-11-25
 */
@RestController
@RequestMapping("/pssr/turndown")
public class TPssrTurndownController extends BaseController
{
    @Autowired
    private ITPssrTurndownService tPssrTurndownService;

    /**
     * 查询PSSR驳回原因列表
     */
    @GetMapping("/list")
    public TableDataInfo list(TPssrTurndown tPssrTurndown)
    {
        startPage();
        List<TPssrTurndown> list = tPssrTurndownService.selectTPssrTurndownList(tPssrTurndown);
        return getDataTable(list);
    }

    /**
     * 导出PSSR驳回原因列表
     */
    @Log(title = "PSSR驳回原因", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TPssrTurndown tPssrTurndown)
    {
        List<TPssrTurndown> list = tPssrTurndownService.selectTPssrTurndownList(tPssrTurndown);
        ExcelUtil<TPssrTurndown> util = new ExcelUtil<TPssrTurndown>(TPssrTurndown.class);
        return util.exportExcel(list, "turndown");
    }

    /**
     * 获取PSSR驳回原因详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tPssrTurndownService.selectTPssrTurndownById(id));
    }

    /**
     * 新增PSSR驳回原因
     */
    @Log(title = "PSSR驳回原因", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TPssrTurndown tPssrTurndown)
    {
        return toAjax(tPssrTurndownService.insertTPssrTurndown(tPssrTurndown));
    }

    /**
     * 修改PSSR驳回原因
     */
    @Log(title = "PSSR驳回原因", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TPssrTurndown tPssrTurndown)
    {
        return toAjax(tPssrTurndownService.updateTPssrTurndown(tPssrTurndown));
    }

    /**
     * 删除PSSR驳回原因
     */
    @Log(title = "PSSR驳回原因", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tPssrTurndownService.deleteTPssrTurndownByIds(ids));
    }
}
