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

/**
 * cmc项目内容Controller
 * 
 * @author cmc
 * @date 2024-04-07
 */
@RestController
@RequestMapping("/oa/projectWork")
public class CmcProjectWorkController extends BaseController
{
    @Autowired
    private ICmcProjectWorkService cmcProjectWorkService;

    /**
     * 查询cmc项目内容列表
     */
    @GetMapping("/list")
    public TableDataInfo list(CmcProjectWork cmcProjectWork)
    {
        startPage();
        List<CmcProjectWork> list = cmcProjectWorkService.selectCmcProjectWorkList(cmcProjectWork);
        return getDataTable(list);
    }

    /**
     * 导出cmc项目内容列表
     */
    @Log(title = "cmc项目内容", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CmcProjectWork cmcProjectWork)
    {
        List<CmcProjectWork> list = cmcProjectWorkService.selectCmcProjectWorkList(cmcProjectWork);
        ExcelUtil<CmcProjectWork> util = new ExcelUtil<CmcProjectWork>(CmcProjectWork.class);
        util.exportExcel(response, list, "cmc项目内容数据");
    }

    /**
     * 获取cmc项目内容详细信息
     */
    @GetMapping(value = "/{projectId}")
    public AjaxResult getInfo(@PathVariable("projectId") String projectId)
    {
        return success(cmcProjectWorkService.selectCmcProjectWorkListByProjectId(projectId));
    }

    /**
     * 新增cmc项目内容
     */
    @Log(title = "cmc项目内容", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CmcProjectWork cmcProjectWork)
    {
        return toAjax(cmcProjectWorkService.insertCmcProjectWork(cmcProjectWork));
    }

    /**
     * 修改cmc项目内容
     */
    @Log(title = "cmc项目内容", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CmcProjectWork cmcProjectWork)
    {
        return toAjax(cmcProjectWorkService.updateCmcProjectWork(cmcProjectWork));
    }

    /**
     * 删除cmc项目内容
     */
    @Log(title = "cmc项目内容", businessType = BusinessType.DELETE)
	@DeleteMapping("/{projectId}")
    public AjaxResult remove(@PathVariable String[] projectId)
    {
        return success(cmcProjectWorkService.deleteCmcProjectWorkByProjectIds(projectId));
    }
}
