package com.ruoyi.szxc.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.szxc.domain.SzxcXyAuditRecard;
import com.ruoyi.szxc.service.ISzxcXyAuditRecardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 审核记录Controller
 *
 * @author hs
 * @date 2024-04-15
 */
@RestController
@RequestMapping("/szxc/xyrecard")
public class SzxcXyAuditRecardController extends BaseController
{
    @Autowired
    private ISzxcXyAuditRecardService szxcXyAuditRecardService;

    /**
     * 查询审核记录列表
     */
    @PreAuthorize("@ss.hasPermi('szxc:xyrecard:list')")
    @GetMapping("/list")
    public TableDataInfo list(SzxcXyAuditRecard szxcXyAuditRecard)
    {
        startPage();
        List<SzxcXyAuditRecard> list = szxcXyAuditRecardService.selectSzxcXyAuditRecardList(szxcXyAuditRecard);
        return getDataTable(list);
    }

    /**
     * 导出审核记录列表
     */
    @PreAuthorize("@ss.hasPermi('szxc:xyrecard:export')")
    @Log(title = "审核记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SzxcXyAuditRecard szxcXyAuditRecard)
    {
        List<SzxcXyAuditRecard> list = szxcXyAuditRecardService.selectSzxcXyAuditRecardList(szxcXyAuditRecard);
        ExcelUtil<SzxcXyAuditRecard> util = new ExcelUtil<SzxcXyAuditRecard>(SzxcXyAuditRecard.class);
        util.exportExcel(response, list, "审核记录数据");
    }

    /**
     * 获取审核记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('szxc:xyrecard:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(szxcXyAuditRecardService.selectSzxcXyAuditRecardById(id));
    }

    /**
     * 新增审核记录
     */
    @PreAuthorize("@ss.hasPermi('szxc:xyrecard:add')")
    @Log(title = "审核记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SzxcXyAuditRecard szxcXyAuditRecard)
    {
        return toAjax(szxcXyAuditRecardService.insertSzxcXyAuditRecard(szxcXyAuditRecard));
    }

    /**
     * 修改审核记录
     */
    @PreAuthorize("@ss.hasPermi('szxc:xyrecard:edit')")
    @Log(title = "审核记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SzxcXyAuditRecard szxcXyAuditRecard)
    {
        return toAjax(szxcXyAuditRecardService.updateSzxcXyAuditRecard(szxcXyAuditRecard));
    }

    /**
     * 删除审核记录
     */
    @PreAuthorize("@ss.hasPermi('szxc:xyrecard:remove')")
    @Log(title = "审核记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(szxcXyAuditRecardService.deleteSzxcXyAuditRecardByIds(ids));
    }
}
