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

/**
 * 制度管理Controller
 *
 * @author kerwincui
 * @date 2025-04-27
 */
@RestController
@RequestMapping("/itsm/regulation")
@Api(tags = "制度管理")
public class RegulationInfoController extends BaseController
{
    @Autowired
    private IRegulationInfoService regulationInfoService;

/**
 * 查询制度管理列表
 */
@PreAuthorize("@ss.hasPermi('itsm:regulation:list')")
@GetMapping("/list")
@ApiOperation("查询制度管理列表")
    public TableDataInfo list(RegulationInfo regulationInfo)
    {
        startPage();
        List<RegulationInfo> list = regulationInfoService.selectRegulationInfoList(regulationInfo);
        return getDataTable(list);
    }

    /**
     * 导出制度管理列表
     */
    @ApiOperation("导出制度管理列表")
    @PreAuthorize("@ss.hasPermi('itsm:regulation:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, RegulationInfo regulationInfo)
    {
        List<RegulationInfo> list = regulationInfoService.selectRegulationInfoList(regulationInfo);
        ExcelUtil<RegulationInfo> util = new ExcelUtil<RegulationInfo>(RegulationInfo.class);
        util.exportExcel(response, list, "制度管理数据");
    }

    /**
     * 获取制度管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('itsm:regulation:query')")
    @GetMapping(value = "/{regulationId}")
    @ApiOperation("获取制度管理详细信息")
    public AjaxResult getInfo(@PathVariable("regulationId") Long regulationId)
    {
        return success(regulationInfoService.selectRegulationInfoByRegulationId(regulationId));
    }

    /**
     * 新增制度管理
     */
    @PreAuthorize("@ss.hasPermi('itsm:regulation:add')")
    @PostMapping
    @ApiOperation("新增制度管理")
    public AjaxResult add(@RequestBody RegulationInfo regulationInfo)
    {
        return toAjax(regulationInfoService.insertRegulationInfo(regulationInfo));
    }

    /**
     * 修改制度管理
     */
    @PreAuthorize("@ss.hasPermi('itsm:regulation:edit')")
    @PutMapping
    @ApiOperation("修改制度管理")
    public AjaxResult edit(@RequestBody RegulationInfo regulationInfo)
    {
        return toAjax(regulationInfoService.updateRegulationInfo(regulationInfo));
    }

    /**
     * 删除制度管理
     */
    @PreAuthorize("@ss.hasPermi('itsm:regulation:remove')")
    @DeleteMapping("/{regulationIds}")
    @ApiOperation("删除制度管理")
    public AjaxResult remove(@PathVariable Long[] regulationIds)
    {
        return toAjax(regulationInfoService.deleteRegulationInfoByRegulationIds(regulationIds));
    }
}
