package com.xinyilu.web.controller.checkReportFailInfo;

import com.xinyilu.common.annotation.Log;
import com.xinyilu.common.core.controller.BaseController;
import com.xinyilu.common.core.domain.AjaxResult;
import com.xinyilu.common.enums.BusinessType;
import com.xinyilu.common.utils.poi.ExcelUtil;
import com.xinyilu.system.domain.checkReportFailInfo.CheckReportFailInfo;
import com.xinyilu.system.domain.dto.CheckReportFailInfoDTO;
import com.xinyilu.system.domain.vo.checkReportFailInfo.CheckReportFailInfoVO;
import com.xinyilu.system.service.checkReportFailInfo.ICheckReportFailInfoService;
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 xinyilu
 * @date 2023-07-31
 */
@RestController
@RequestMapping("/system/checkReportFailInfo")
public class CheckReportFailInfoController extends BaseController {
    @Autowired
    private ICheckReportFailInfoService checkReportFailInfoService;

    /**
     * 查询个人报告和幼儿园报告审核失败信息记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:info:list')")
    @GetMapping("/list")
    public AjaxResult list(CheckReportFailInfo checkReportFailInfo) {
        return AjaxResult.success(checkReportFailInfoService.selectCheckReportFailInfoList(checkReportFailInfo));
    }

    /**
     * 导出个人报告和幼儿园报告审核失败信息记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:info:export')")
    @Log(title = "个人报告和幼儿园报告审核失败信息记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CheckReportFailInfo checkReportFailInfo) {
        List<CheckReportFailInfoDTO> list = checkReportFailInfoService.selectCheckReportFailInfoList(checkReportFailInfo);
        ExcelUtil<CheckReportFailInfoDTO> util = new ExcelUtil<CheckReportFailInfoDTO>(CheckReportFailInfoDTO.class);
        util.exportExcel(response, list, "个人报告和幼儿园报告审核失败信息记录数据");
    }

    /**
     * 获取个人报告和幼儿园报告审核失败信息记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:info:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(checkReportFailInfoService.selectCheckReportFailInfoById(id));
    }

    /**
     * 新增个人报告和幼儿园报告审核失败信息记录
     */
    @Log(title = "个人报告和幼儿园报告审核失败信息记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CheckReportFailInfoVO checkReportFailInfoVO) {
        return checkReportFailInfoService.insertCheckReportFailInfo(checkReportFailInfoVO);
    }

    /**
     * 修改个人报告和幼儿园报告审核失败信息记录
     */
    @PreAuthorize("@ss.hasPermi('system:info:edit')")
    @Log(title = "个人报告和幼儿园报告审核失败信息记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CheckReportFailInfo checkReportFailInfo) {
        return toAjax(checkReportFailInfoService.updateCheckReportFailInfo(checkReportFailInfo));
    }

    /**
     * 删除个人报告和幼儿园报告审核失败信息记录
     */
    @PreAuthorize("@ss.hasPermi('system:info:remove')")
    @Log(title = "个人报告和幼儿园报告审核失败信息记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(checkReportFailInfoService.deleteCheckReportFailInfoByIds(ids));
    }
}
