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

/**
 * 职称评审Controller
 * 
 * @author cmc
 * @date 2025-08-18
 */
@RestController
@RequestMapping("/oa/titleEval")
public class CmcTitleEvalController extends BaseController
{
    @Autowired
    private ICmcTitleEvalService cmcTitleEvalService;

    /**
     * 查询职称评审列表
     */
    @GetMapping("/list")
    public TableDataInfo list(CmcTitleEval cmcTitleEval)
    {
        startPage();
        List<CmcTitleEval> list = cmcTitleEvalService.selectCmcTitleEvalList(cmcTitleEval);
        return getDataTable(list);
    }

    /**
     * 导出职称评审列表
     */
    @Log(title = "职称评审", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CmcTitleEval cmcTitleEval)
    {
        List<CmcTitleEval> list = cmcTitleEvalService.selectCmcTitleEvalList(cmcTitleEval);
        ExcelUtil<CmcTitleEval> util = new ExcelUtil<CmcTitleEval>(CmcTitleEval.class);
        util.exportExcel(response, list, "职称评审数据");
    }

    /**
     * 获取职称评审详细信息
     */
    @GetMapping(value = "/{titleEvalId}")
    public AjaxResult getInfo(@PathVariable("titleEvalId") String titleEvalId)
    {
        return success(cmcTitleEvalService.selectCmcTitleEvalByTitleEvalId(titleEvalId));
    }

    /**
     * 新增职称评审
     */
    @Log(title = "职称评审", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CmcTitleEval cmcTitleEval)
    {
        return toAjax(cmcTitleEvalService.insertCmcTitleEval(cmcTitleEval));
    }

    /**
     * 修改职称评审
     */
    @Log(title = "职称评审", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CmcTitleEval cmcTitleEval)
    {
        return toAjax(cmcTitleEvalService.updateCmcTitleEval(cmcTitleEval));
    }

    /**
     * 删除职称评审
     */
    @Log(title = "职称评审", businessType = BusinessType.DELETE)
	@DeleteMapping("/{titleEvalIds}")
    public AjaxResult remove(@PathVariable String[] titleEvalIds)
    {
        return success(cmcTitleEvalService.deleteCmcTitleEvalByTitleEvalIds(titleEvalIds));
    }
}
