package com.xinda.itsm.controller;

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

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.xinda.common.core.controller.BaseController;
import com.xinda.common.core.domain.AjaxResult;
import com.xinda.itsm.domain.ExampleReport;
import com.xinda.itsm.service.IExampleReportService;
import com.xinda.common.utils.poi.ExcelUtil;
import com.xinda.common.core.page.TableDataInfo;

/**
 * 例报管理Controller
 *
 * @author kerwincui
 * @date 2025-04-23
 */
@RestController
@RequestMapping("/itsm/report")
@Api(tags = "例报管理")
public class ExampleReportController extends BaseController
{
    @Autowired
    private IExampleReportService exampleReportService;

    /**
     * 查询例报管理列表
     */
    @PreAuthorize("@ss.hasPermi('itsm:report:list')")
    @GetMapping("/list")
    @ApiOperation("查询例报管理列表")
    public TableDataInfo list(ExampleReport exampleReport)
    {
        startPage();
        List<ExampleReport> list = exampleReportService.selectExampleReportList(exampleReport);
        return getDataTable(list);
    }

    /**
     * 导出例报管理列表
     */
    @ApiOperation("导出例报管理列表")
    @PreAuthorize("@ss.hasPermi('itsm:report:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, ExampleReport exampleReport)
    {
        List<ExampleReport> list = exampleReportService.selectExampleReportList(exampleReport);
        ExcelUtil<ExampleReport> util = new ExcelUtil<ExampleReport>(ExampleReport.class);
        util.exportExcel(response, list, "例报管理数据");
    }

    /**
     * 获取例报管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('itsm:report:query')")
    @GetMapping(value = "/{exampleReportId}")
    @ApiOperation("获取例报管理详细信息")
    public AjaxResult getInfo(@PathVariable("exampleReportId") Long exampleReportId)
    {
        return success(exampleReportService.selectExampleReportByExampleReportId(exampleReportId));
    }

    /**
     * 新增例报管理
     */
    @PreAuthorize("@ss.hasPermi('itsm:report:add')")
    @PostMapping
    @ApiOperation("新增例报管理")
    public AjaxResult add(@RequestBody ExampleReport exampleReport)
    {
        return toAjax(exampleReportService.insertExampleReport(exampleReport));
    }

    /**
     * 修改例报管理
     */
    @PreAuthorize("@ss.hasPermi('itsm:report:edit')")
    @PutMapping
    @ApiOperation("修改例报管理")
    public AjaxResult edit(@RequestBody ExampleReport exampleReport)
    {
        return toAjax(exampleReportService.updateExampleReport(exampleReport));
    }

    /**
     * 删除例报管理
     */
    @PreAuthorize("@ss.hasPermi('itsm:report:remove')")
    @DeleteMapping("/{exampleReportIds}")
    @ApiOperation("删除例报管理")
    public AjaxResult remove(@PathVariable Long[] exampleReportIds)
    {
        return toAjax(exampleReportService.deleteExampleReportByExampleReportIds(exampleReportIds));
    }
}
