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.CmcTrainApproval;
import com.ruoyi.oa.service.ICmcTrainApprovalService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 参培审核Controller
 * 
 * @author cmc
 * @date 2025-03-04
 */
@RestController
@RequestMapping("/oa/trainApproval")
public class CmcTrainApprovalController extends BaseController
{
    @Autowired
    private ICmcTrainApprovalService cmcTrainApprovalService;

    /**
     * 查询参培审核列表
     */
    @GetMapping("/list")
    public TableDataInfo list(CmcTrainApproval cmcTrainApproval)
    {
        startPage();
        List<CmcTrainApproval> list = cmcTrainApprovalService.selectCmcTrainApprovalList(cmcTrainApproval);
        return getDataTable(list);
    }

    /**
     * 导出参培审核列表
     */
    @Log(title = "参培审核", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CmcTrainApproval cmcTrainApproval)
    {
        List<CmcTrainApproval> list = cmcTrainApprovalService.selectCmcTrainApprovalList(cmcTrainApproval);
        ExcelUtil<CmcTrainApproval> util = new ExcelUtil<CmcTrainApproval>(CmcTrainApproval.class);
        util.exportExcel(response, list, "参培审核数据");
    }

    /**
     * 获取参培审核详细信息
     */
    @GetMapping(value = "/{participateId}")
    public AjaxResult getInfo(@PathVariable("participateId") String participateId)
    {
        return success(cmcTrainApprovalService.selectCmcTrainApprovalByParticipateId(participateId));
    }

    /**
     * 新增参培审核
     */
    @Log(title = "参培审核", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CmcTrainApproval cmcTrainApproval)
    {
        return toAjax(cmcTrainApprovalService.insertCmcTrainApproval(cmcTrainApproval));
    }

    /**
     * 修改参培审核
     */
    @Log(title = "参培审核", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CmcTrainApproval cmcTrainApproval)
    {
        return toAjax(cmcTrainApprovalService.updateCmcTrainApproval(cmcTrainApproval));
    }

    /**
     * 删除参培审核
     */
    @Log(title = "参培审核", businessType = BusinessType.DELETE)
	@DeleteMapping("/{participateIds}")
    public AjaxResult remove(@PathVariable String[] participateIds)
    {
        return toAjax(cmcTrainApprovalService.deleteCmcTrainApprovalByParticipateIds(participateIds));
    }
}
