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.Schedule;
import com.xinda.itsm.service.IScheduleService;
import com.xinda.common.utils.poi.ExcelUtil;
import com.xinda.common.core.page.TableDataInfo;

/**
 * 调度计划管理Controller
 *
 * @author kerwincui
 * @date 2025-04-23
 */
@RestController
@RequestMapping("/itsm/schedule")
@Api(tags = "调度计划管理")
public class ScheduleController extends BaseController
{
    @Autowired
    private IScheduleService scheduleService;

/**
 * 查询调度计划管理列表
 */
@PreAuthorize("@ss.hasPermi('itsm:schedule:list')")
@GetMapping("/list")
@ApiOperation("查询调度计划管理列表")
    public TableDataInfo list(Schedule schedule)
    {
        startPage();
        List<Schedule> list = scheduleService.selectScheduleList(schedule);
        return getDataTable(list);
    }

    /**
     * 导出调度计划管理列表
     */
    @ApiOperation("导出调度计划管理列表")
    @PreAuthorize("@ss.hasPermi('itsm:schedule:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, Schedule schedule)
    {
        List<Schedule> list = scheduleService.selectScheduleList(schedule);
        ExcelUtil<Schedule> util = new ExcelUtil<Schedule>(Schedule.class);
        util.exportExcel(response, list, "调度计划管理数据");
    }

    /**
     * 获取调度计划管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('itsm:schedule:query')")
    @GetMapping(value = "/{scheduleId}")
    @ApiOperation("获取调度计划管理详细信息")
    public AjaxResult getInfo(@PathVariable("scheduleId") Long scheduleId)
    {
        return success(scheduleService.selectScheduleByScheduleId(scheduleId));
    }

    /**
     * 新增调度计划管理
     */
    @PreAuthorize("@ss.hasPermi('itsm:schedule:add')")
    @PostMapping
    @ApiOperation("新增调度计划管理")
    public AjaxResult add(@RequestBody Schedule schedule)
    {
        return toAjax(scheduleService.insertSchedule(schedule));
    }

    /**
     * 修改调度计划管理
     */
    @PreAuthorize("@ss.hasPermi('itsm:schedule:edit')")
    @PutMapping
    @ApiOperation("修改调度计划管理")
    public AjaxResult edit(@RequestBody Schedule schedule)
    {
        return toAjax(scheduleService.updateSchedule(schedule));
    }

    /**
     * 删除调度计划管理
     */
    @PreAuthorize("@ss.hasPermi('itsm:schedule:remove')")
    @DeleteMapping("/{scheduleIds}")
    @ApiOperation("删除调度计划管理")
    public AjaxResult remove(@PathVariable Long[] scheduleIds)
    {
        return toAjax(scheduleService.deleteScheduleByScheduleIds(scheduleIds));
    }
}
