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

/**
 * cmc技术交底Controller
 * 
 * @author cmc
 * @date 2024-07-04
 */
@RestController
@RequestMapping("/oa/technical")
public class CmcTechnicalController extends BaseController
{
    @Autowired
    private ICmcTechnicalService cmcTechnicalService;

    /**
     * 查询cmc技术交底列表
     */
    @GetMapping("/list")
    public TableDataInfo list(CmcTechnical cmcTechnical)
    {
        startPage();
        List<CmcTechnical> list = cmcTechnicalService.selectCmcTechnicalList(cmcTechnical);
        return getDataTable(list);
    }

    /**
     * 导出cmc技术交底列表
     */
    @Log(title = "cmc技术交底", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CmcTechnical cmcTechnical)
    {
        List<CmcTechnical> list = cmcTechnicalService.selectCmcTechnicalList(cmcTechnical);
        ExcelUtil<CmcTechnical> util = new ExcelUtil<CmcTechnical>(CmcTechnical.class);
        util.exportExcel(response, list, "cmc技术交底数据");
    }

    /**
     * 获取cmc技术交底详细信息
     */
    @GetMapping(value = "/{technicalId}")
    public AjaxResult getInfo(@PathVariable("technicalId") String technicalId)
    {
        return success(cmcTechnicalService.selectCmcTechnicalByTechnicalId(technicalId));
    }

    /**
     * 新增cmc技术交底
     */
    @Log(title = "cmc技术交底", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CmcTechnical cmcTechnical)
    {
        return toAjax(cmcTechnicalService.insertCmcTechnical(cmcTechnical));
    }

    /**
     * 修改cmc技术交底
     */
    @Log(title = "cmc技术交底", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CmcTechnical cmcTechnical)
    {
        return toAjax(cmcTechnicalService.updateCmcTechnical(cmcTechnical));
    }

    /**
     * 删除cmc技术交底
     */
    @Log(title = "cmc技术交底", businessType = BusinessType.DELETE)
	@DeleteMapping("/{technicalIds}")
    public AjaxResult remove(@PathVariable String[] technicalIds)
    {
        return success(cmcTechnicalService.deleteCmcTechnicalByTechnicalIds(technicalIds));
    }
}
