package com.ruoyi.web.controller.kaoqin;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ProcessConfiguration;
import com.ruoyi.system.service.IProcessConfigurationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 补卡、请假流程配置Controller
 * 
 * @author ruoyi
 * @date 2023-02-08
 */
@RestController
@RequestMapping("/system/configuration")
public class ProcessConfigurationController extends BaseController
{
    @Autowired
    private IProcessConfigurationService processConfigurationService;

    /**
     * 查询补卡、请假流程配置列表
     */
    @PreAuthorize("@ss.hasPermi('system:configuration:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProcessConfiguration processConfiguration)
    {
        startPage();
        List<ProcessConfiguration> list = processConfigurationService.selectProcessConfigurationList(processConfiguration);
        return getDataTable(list);
    }

    /**
     * 导出补卡、请假流程配置列表
     */
    @PreAuthorize("@ss.hasPermi('system:configuration:export')")
    @Log(title = "补卡、请假流程配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProcessConfiguration processConfiguration)
    {
        List<ProcessConfiguration> list = processConfigurationService.selectProcessConfigurationList(processConfiguration);
        ExcelUtil<ProcessConfiguration> util = new ExcelUtil<ProcessConfiguration>(ProcessConfiguration.class);
        util.exportExcel(response, list, "补卡、请假流程配置数据");
    }

    /**
     * 获取补卡、请假流程配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:configuration:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(processConfigurationService.selectProcessConfigurationById(id));
    }

    /**
     * 新增补卡、请假流程配置
     */
    @PreAuthorize("@ss.hasPermi('system:configuration:add')")
    @Log(title = "补卡、请假流程配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProcessConfiguration processConfiguration)
    {
        return toAjax(processConfigurationService.insertProcessConfiguration(processConfiguration));
    }

    /**
     * 修改补卡、请假流程配置
     */
    @PreAuthorize("@ss.hasPermi('system:configuration:edit')")
    @Log(title = "补卡、请假流程配置", businessType = BusinessType.UPDATE)
    @PostMapping("put")
    public AjaxResult edit(@RequestBody ProcessConfiguration processConfiguration)
    {
        return toAjax(processConfigurationService.updateProcessConfiguration(processConfiguration));
    }

    /**
     * 删除补卡、请假流程配置
     */
    @PreAuthorize("@ss.hasPermi('system:configuration:remove')")
    @Log(title = "补卡、请假流程配置", businessType = BusinessType.DELETE)
    @GetMapping(value = "/delete/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(processConfigurationService.deleteProcessConfigurationByIds(ids));
    }
}
