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

/**
 * 工作填报Controller
 * 
 * @author cmc
 * @date 2024-08-14
 */
@RestController
@RequestMapping("/oa/declare")
public class CmcDeclareController extends BaseController
{
    @Autowired
    private ICmcDeclareService cmcDeclareService;

    /**
     * 查询工作填报列表
     */
    @GetMapping("/list")
    public TableDataInfo list(CmcDeclare cmcDeclare)
    {
        startPage();
        List<CmcDeclare> list = cmcDeclareService.selectCmcDeclareList(cmcDeclare);
        return getDataTable(list);
    }

    /**
     * 导出工作填报列表
     */
    @Log(title = "工作填报", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CmcDeclare cmcDeclare)
    {
        List<CmcDeclare> list = cmcDeclareService.selectCmcDeclareList(cmcDeclare);
        ExcelUtil<CmcDeclare> util = new ExcelUtil<CmcDeclare>(CmcDeclare.class);
        util.exportExcel(response, list, "工作填报数据");
    }

    /**
     * 获取工作填报详细信息
     */
    @GetMapping(value = "/{formId}")
    public AjaxResult getInfo(@PathVariable("formId") String formId)
    {
        return success(cmcDeclareService.selectCmcDeclareByFormId(formId));
    }

    /**
     * 新增工作填报
     */
    @Log(title = "工作填报", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CmcDeclare cmcDeclare)
    {
        return toAjax(cmcDeclareService.insertCmcDeclare(cmcDeclare));
    }

    /**
     * 修改工作填报
     */
    @Log(title = "工作填报", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CmcDeclare cmcDeclare)
    {
        return toAjax(cmcDeclareService.updateCmcDeclare(cmcDeclare));
    }

    /**
     * 删除工作填报
     */
    @Log(title = "工作填报", businessType = BusinessType.DELETE)
	@DeleteMapping("/{formIds}")
    public AjaxResult remove(@PathVariable String[] formIds)
    {
        return success(cmcDeclareService.deleteCmcDeclareByFormIds(formIds));
    }
}
