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

/**
 * cmc经费计算Controller
 * 
 * @author cmc
 * @date 2024-04-29
 */
@RestController
@RequestMapping("/oa/settleWork")
public class CmcSettleWorkController extends BaseController
{
    @Autowired
    private ICmcSettleWorkService cmcSettleWorkService;

    /**
     * 查询cmc经费计算列表
     */
    @GetMapping("/list")
    public TableDataInfo list(CmcSettleWork cmcSettleWork)
    {
        startPage();
        List<CmcSettleWork> list = cmcSettleWorkService.selectCmcSettleWorkList(cmcSettleWork);
        return getDataTable(list);
    }

    /**
     * 导出cmc经费计算列表
     */
    @Log(title = "cmc经费计算", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CmcSettleWork cmcSettleWork)
    {
        List<CmcSettleWork> list = cmcSettleWorkService.selectCmcSettleWorkList(cmcSettleWork);
        ExcelUtil<CmcSettleWork> util = new ExcelUtil<CmcSettleWork>(CmcSettleWork.class);
        util.exportExcel(response, list, "cmc经费计算数据");
    }

    /**
     * 获取cmc经费计算详细信息
     */
    @GetMapping(value = "/{settleId}")
    public AjaxResult getInfo(@PathVariable("settleId") String settleId)
    {
        return success(cmcSettleWorkService.selectCmcSettleWorkBySettleId(settleId));
    }

    /**
     * 新增cmc经费计算
     */
    @Log(title = "cmc经费计算", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CmcSettleWork cmcSettleWork)
    {
        return toAjax(cmcSettleWorkService.insertCmcSettleWork(cmcSettleWork));
    }

    /**
     * 修改cmc经费计算
     */
    @Log(title = "cmc经费计算", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CmcSettleWork cmcSettleWork)
    {
        return toAjax(cmcSettleWorkService.updateCmcSettleWork(cmcSettleWork));
    }

    /**
     * 删除cmc经费计算
     */
    @Log(title = "cmc经费计算", businessType = BusinessType.DELETE)
	@DeleteMapping("/{settleIds}")
    public AjaxResult remove(@PathVariable String[] settleIds)
    {
        return success(cmcSettleWorkService.deleteCmcSettleWorkBySettleIds(settleIds));
    }
}
