package com.ruoyi.web.controller.oa;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.oa.domain.CmcPerformance;
import com.ruoyi.oa.service.ICmcPerformanceService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 绩效审批Controller
 *
 * @author cmc
 * @date 2024-09-23
 */
@RestController
@RequestMapping("/oa/performance")
public class CmcPerformanceController extends BaseController
{
    @Autowired
    private ICmcPerformanceService cmcPerformanceService;

    /**
     * 查询绩效审批列表
     */
    @GetMapping("/list")
    public TableDataInfo list(CmcPerformance cmcPerformance)
    {
        startPage();
        List<CmcPerformance> list = cmcPerformanceService.selectCmcPerformanceList(cmcPerformance);
        return getDataTable(list);
    }

    /**
     * 导出绩效审批列表
     */
    @Log(title = "绩效审批", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CmcPerformance cmcPerformance)
    {
        List<CmcPerformance> list = cmcPerformanceService.selectCmcPerformanceList(cmcPerformance);
        ExcelUtil<CmcPerformance> util = new ExcelUtil<CmcPerformance>(CmcPerformance.class);
        util.exportExcel(response, list, "绩效审批数据");
    }

    /**
     * 获取绩效审批详细信息
     */
    @GetMapping(value = "/{performanceId}")
    public AjaxResult getInfo(@PathVariable("performanceId") String performanceId)
    {
        return success(cmcPerformanceService.selectCmcPerformanceByPerformanceId(performanceId));
    }

    /**
     * 新增绩效审批
     */
    @Log(title = "绩效审批", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CmcPerformance cmcPerformance)
    {
        return toAjax(cmcPerformanceService.insertCmcPerformance(cmcPerformance));
    }

    /**
     * 修改绩效审批
     */
    @Log(title = "绩效审批", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CmcPerformance cmcPerformance)
    {
        return toAjax(cmcPerformanceService.updateCmcPerformance(cmcPerformance));
    }

    /**
     * 删除绩效审批
     */
    @Log(title = "绩效审批", businessType = BusinessType.DELETE)
    @DeleteMapping("/{performanceIds}")
    public AjaxResult remove(@PathVariable String[] performanceIds)
    {
        return success(cmcPerformanceService.deleteCmcPerformanceByPerformanceIds(performanceIds));
    }
}