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

/**
 * cmc项目工作量Controller
 *
 * @author cmc
 * @date 2024-09-02
 */
@RestController
@RequestMapping("/oa/projectWorkload")
public class CmcProjectWorkloadController extends BaseController
{
    @Autowired
    private ICmcProjectWorkloadService cmcProjectWorkloadService;

    /**
     * 查询cmc项目工作量列表
     */
    @GetMapping("/list")
    public TableDataInfo list(CmcProjectWorkload cmcProjectWorkload)
    {
        startPage();
        List<CmcProjectWorkload> list = cmcProjectWorkloadService.selectCmcProjectWorkloadList(cmcProjectWorkload);
        return getDataTable(list);
    }

    /**
     * 导出cmc项目工作量列表
     */
    @Log(title = "cmc项目工作量", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CmcProjectWorkload cmcProjectWorkload)
    {
        List<CmcProjectWorkload> list = cmcProjectWorkloadService.selectCmcProjectWorkloadList(cmcProjectWorkload);
        ExcelUtil<CmcProjectWorkload> util = new ExcelUtil<CmcProjectWorkload>(CmcProjectWorkload.class);
        util.exportExcel(response, list, "cmc项目工作量数据");
    }

    /**
     * 获取cmc项目工作量详细信息
     */
    @GetMapping(value = "/{projectId}")
    public AjaxResult getInfo(@PathVariable("projectId") String projectId)
    {
        return success(cmcProjectWorkloadService.selectCmcProjectWorkloadListByProjectId(projectId));
    }

    /**
     * 新增cmc项目工作量
     */
    @Log(title = "cmc项目工作量", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CmcProjectWorkload cmcProjectWorkload)
    {
        return toAjax(cmcProjectWorkloadService.insertCmcProjectWorkload(cmcProjectWorkload));
    }

    /**
     * 修改cmc项目工作量
     */
    @Log(title = "cmc项目工作量", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CmcProjectWorkload cmcProjectWorkload)
    {
        return toAjax(cmcProjectWorkloadService.updateCmcProjectWorkload(cmcProjectWorkload));
    }

    /**
     * 删除cmc项目工作量
     */
    @Log(title = "cmc项目工作量", businessType = BusinessType.DELETE)
    @DeleteMapping("/{projectId}")
    public AjaxResult remove(@PathVariable String[] projectId)
    {
        return success(cmcProjectWorkloadService.deleteCmcProjectWorkloadByProjectIds(projectId));
    }
}
