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.annotation.Log;
import com.xinda.common.core.controller.BaseController;
import com.xinda.common.core.domain.AjaxResult;
import com.xinda.common.enums.BusinessType;
import com.xinda.itsm.domain.PrePlan;
import com.xinda.itsm.service.IPrePlanService;
import com.xinda.common.utils.poi.ExcelUtil;
import com.xinda.common.core.page.TableDataInfo;

/**
 * 预案管理Controller
 *
 * @author kerwincui
 * @date 2025-04-27
 */
@RestController
@RequestMapping("/itsm/prePlan")
@Api(tags = "预案管理")
public class PrePlanController extends BaseController
{
    @Autowired
    private IPrePlanService prePlanService;

/**
 * 查询预案管理列表
 */
@PreAuthorize("@ss.hasPermi('itsm:prePlan:list')")
@GetMapping("/list")
@ApiOperation("查询预案管理列表")
    public TableDataInfo list(PrePlan prePlan)
    {
        startPage();
        List<PrePlan> list = prePlanService.selectPrePlanList(prePlan);
        return getDataTable(list);
    }

    /**
     * 导出预案管理列表
     */
    @ApiOperation("导出预案管理列表")
    @PreAuthorize("@ss.hasPermi('itsm:prePlan:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, PrePlan prePlan)
    {
        List<PrePlan> list = prePlanService.selectPrePlanList(prePlan);
        ExcelUtil<PrePlan> util = new ExcelUtil<PrePlan>(PrePlan.class);
        util.exportExcel(response, list, "预案管理数据");
    }

    /**
     * 获取预案管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('itsm:prePlan:query')")
    @GetMapping(value = "/{prePlanId}")
    @ApiOperation("获取预案管理详细信息")
    public AjaxResult getInfo(@PathVariable("prePlanId") Long prePlanId)
    {
        return success(prePlanService.selectPrePlanByPrePlanId(prePlanId));
    }

    /**
     * 新增预案管理
     */
    @PreAuthorize("@ss.hasPermi('itsm:prePlan:add')")
    @PostMapping
    @ApiOperation("新增预案管理")
    public AjaxResult add(@RequestBody PrePlan prePlan)
    {
        return toAjax(prePlanService.insertPrePlan(prePlan));
    }

    /**
     * 修改预案管理
     */
    @PreAuthorize("@ss.hasPermi('itsm:prePlan:edit')")
    @PutMapping
    @ApiOperation("修改预案管理")
    public AjaxResult edit(@RequestBody PrePlan prePlan)
    {
        return toAjax(prePlanService.updatePrePlan(prePlan));
    }

    /**
     * 删除预案管理
     */
    @PreAuthorize("@ss.hasPermi('itsm:prePlan:remove')")
    @DeleteMapping("/{prePlanIds}")
    @ApiOperation("删除预案管理")
    public AjaxResult remove(@PathVariable Long[] prePlanIds)
    {
        return toAjax(prePlanService.deletePrePlanByPrePlanIds(prePlanIds));
    }
}
