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.CmcSettle;
import com.ruoyi.oa.service.ICmcSettleService;
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/settle")
public class CmcSettleController extends BaseController
{
    @Autowired
    private ICmcSettleService cmcSettleService;

    /**
     * 查询cmc结算审批列表
     */
    @GetMapping("/list")
    public TableDataInfo list(CmcSettle cmcSettle)
    {
        startPage();
        List<CmcSettle> list = cmcSettleService.selectCmcSettleList(cmcSettle);
        return getDataTable(list);
    }

    /**
     * 导出cmc结算审批列表
     */
    @Log(title = "cmc结算审批", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CmcSettle cmcSettle)
    {
        List<CmcSettle> list = cmcSettleService.selectCmcSettleList(cmcSettle);
        ExcelUtil<CmcSettle> util = new ExcelUtil<CmcSettle>(CmcSettle.class);
        util.exportExcel(response, list, "cmc结算审批数据");
    }

    /**
     * 获取cmc结算审批详细信息
     */
    @GetMapping(value = "/{settleId}")
    public AjaxResult getInfo(@PathVariable("settleId") String settleId)
    {
        return success(cmcSettleService.selectCmcSettleBySettleId(settleId));
    }

    /**
     * 新增cmc结算审批
     */
    @Log(title = "cmc结算审批", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CmcSettle cmcSettle)
    {
        return toAjax(cmcSettleService.insertCmcSettle(cmcSettle));
    }

    /**
     * 修改cmc结算审批
     */
    @Log(title = "cmc结算审批", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CmcSettle cmcSettle)
    {
        return toAjax(cmcSettleService.updateCmcSettle(cmcSettle));
    }

    /**
     * 删除cmc结算审批
     */
    @Log(title = "cmc结算审批", businessType = BusinessType.DELETE)
	@DeleteMapping("/{settleIds}")
    public AjaxResult remove(@PathVariable String[] settleIds)
    {
        return success(cmcSettleService.deleteCmcSettleBySettleIds(settleIds));
    }
}
