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

/**
 * 作业规范Controller
 *
 * @author kerwincui
 * @date 2025-04-27
 */
@RestController
@RequestMapping("/itsm/standardInfo")
@Api(tags = "作业规范")
public class StandardInfoController extends BaseController
{
    @Autowired
    private IStandardInfoService standardInfoService;

/**
 * 查询作业规范列表
 */
@PreAuthorize("@ss.hasPermi('itsm:standardInfo:list')")
@GetMapping("/list")
@ApiOperation("查询作业规范列表")
    public TableDataInfo list(StandardInfo standardInfo)
    {
        startPage();
        List<StandardInfo> list = standardInfoService.selectStandardInfoList(standardInfo);
        return getDataTable(list);
    }

    /**
     * 导出作业规范列表
     */
    @ApiOperation("导出作业规范列表")
    @PreAuthorize("@ss.hasPermi('itsm:standardInfo:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, StandardInfo standardInfo)
    {
        List<StandardInfo> list = standardInfoService.selectStandardInfoList(standardInfo);
        ExcelUtil<StandardInfo> util = new ExcelUtil<StandardInfo>(StandardInfo.class);
        util.exportExcel(response, list, "作业规范数据");
    }

    /**
     * 获取作业规范详细信息
     */
    @PreAuthorize("@ss.hasPermi('itsm:standardInfo:query')")
    @GetMapping(value = "/{standardId}")
    @ApiOperation("获取作业规范详细信息")
    public AjaxResult getInfo(@PathVariable("standardId") Long standardId)
    {
        return success(standardInfoService.selectStandardInfoByStandardId(standardId));
    }

    /**
     * 新增作业规范
     */
    @PreAuthorize("@ss.hasPermi('itsm:standardInfo:add')")
    @PostMapping
    @ApiOperation("新增作业规范")
    public AjaxResult add(@RequestBody StandardInfo standardInfo)
    {
        return toAjax(standardInfoService.insertStandardInfo(standardInfo));
    }

    /**
     * 修改作业规范
     */
    @PreAuthorize("@ss.hasPermi('itsm:standardInfo:edit')")
    @PutMapping
    @ApiOperation("修改作业规范")
    public AjaxResult edit(@RequestBody StandardInfo standardInfo)
    {
        return toAjax(standardInfoService.updateStandardInfo(standardInfo));
    }

    /**
     * 删除作业规范
     */
    @PreAuthorize("@ss.hasPermi('itsm:standardInfo:remove')")
    @DeleteMapping("/{standardIds}")
    @ApiOperation("删除作业规范")
    public AjaxResult remove(@PathVariable Long[] standardIds)
    {
        return toAjax(standardInfoService.deleteStandardInfoByStandardIds(standardIds));
    }
}
