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

/**
 * cmc项目分包合同Controller
 * 
 * @author cmc
 * @date 2024-06-19
 */
@RestController
@RequestMapping("/oa/projectSubcontract")
public class CmcProjectSubContractController extends BaseController
{
    @Autowired
    private ICmcProjectSubContractService cmcProjectSubContractService;

    /**
     * 查询cmc项目分包合同列表
     */
    @GetMapping("/list")
    public TableDataInfo list(CmcProjectSubContract cmcProjectSubContract)
    {
        startPage();
        List<CmcProjectSubContract> list = cmcProjectSubContractService.selectCmcProjectSubContractList(cmcProjectSubContract);
        return getDataTable(list);
    }

    /**
     * 导出cmc项目分包合同列表
     */
    @Log(title = "cmc项目分包合同", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CmcProjectSubContract cmcProjectSubContract)
    {
        List<CmcProjectSubContract> list = cmcProjectSubContractService.selectCmcProjectSubContractList(cmcProjectSubContract);
        ExcelUtil<CmcProjectSubContract> util = new ExcelUtil<CmcProjectSubContract>(CmcProjectSubContract.class);
        util.exportExcel(response, list, "cmc项目分包合同数据");
    }

    /**
     * 获取cmc项目分包合同详细信息
     */
    @GetMapping(value = "/{projectId}")
    public AjaxResult getInfo(@PathVariable("projectId") String projectId)
    {
        return success(cmcProjectSubContractService.selectCmcProjectSubContractByProjectId(projectId));
    }

    /**
     * 新增cmc项目分包合同
     */
    @Log(title = "cmc项目分包合同", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CmcProjectSubContract cmcProjectSubContract)
    {
        return toAjax(cmcProjectSubContractService.insertCmcProjectSubContract(cmcProjectSubContract));
    }

    /**
     * 修改cmc项目分包合同
     */
    @Log(title = "cmc项目分包合同", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CmcProjectSubContract cmcProjectSubContract)
    {
        return toAjax(cmcProjectSubContractService.updateCmcProjectSubContract(cmcProjectSubContract));
    }

    /**
     * 删除cmc项目分包合同
     */
    @Log(title = "cmc项目分包合同", businessType = BusinessType.DELETE)
	@DeleteMapping("/{subContractIds}")
    public AjaxResult remove(@PathVariable String[] subContractIds)
    {
        return success(cmcProjectSubContractService.deleteCmcProjectSubContractBySubContractIds(subContractIds));
    }
}
