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

/**
 * 投标管理Controller
 * 
 * @author cmc
 * @date 2024-03-14
 */
@RestController
@RequestMapping("/oa/tender")
public class CmcTenderController extends BaseController
{
    @Autowired
    private ICmcTenderService cmcTenderService;

    /**
     * 查询投标管理列表
     */
    @GetMapping("/list")
    public TableDataInfo list(CmcTender cmcTender)
    {
        startPage();
        List<CmcTender> list = cmcTenderService.selectCmcTenderList(cmcTender);
        return getDataTable(list);
    }

    /**
     * 导出投标管理列表
     */
    @Log(title = "投标管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CmcTender cmcTender)
    {
        List<CmcTender> list = cmcTenderService.selectCmcTenderList(cmcTender);
        ExcelUtil<CmcTender> util = new ExcelUtil<CmcTender>(CmcTender.class);
        util.exportExcel(response, list, "投标管理数据");
    }

    /**
     * 获取投标管理详细信息
     */
    @GetMapping(value = "/{tenderId}")
    public AjaxResult getInfo(@PathVariable("tenderId") String tenderId)
    {
        return success(cmcTenderService.selectCmcTenderByTenderId(tenderId));
    }

    /**
     * 新增投标管理
     */
    @Log(title = "投标管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CmcTender cmcTender)
    {
        return toAjax(cmcTenderService.insertCmcTender(cmcTender));
    }

    /**
     * 修改投标管理
     */
    @Log(title = "投标管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CmcTender cmcTender)
    {
        return toAjax(cmcTenderService.updateCmcTender(cmcTender));
    }

    /**
     * 删除投标管理
     */
    @Log(title = "投标管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{tenderIds}")
    public AjaxResult remove(@PathVariable String[] tenderIds)
    {
        return success(cmcTenderService.deleteCmcTenderByTenderIds(tenderIds));
    }
}
