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

/**
 * cmc安全交底Controller
 * 
 * @author cmc
 * @date 2024-04-03
 */
@RestController
@RequestMapping("/oa/safe")
public class CmcSafeController extends BaseController
{
    @Autowired
    private ICmcSafeService cmcSafeService;

    /**
     * 查询cmc安全交底列表
     */
    @GetMapping("/list")
    public TableDataInfo list(CmcSafe cmcSafe)
    {
        startPage();
        List<CmcSafe> list = cmcSafeService.selectCmcSafeList(cmcSafe);
        return getDataTable(list);
    }

    /**
     * 导出cmc安全交底列表
     */
    @Log(title = "cmc安全交底", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CmcSafe cmcSafe)
    {
        List<CmcSafe> list = cmcSafeService.selectCmcSafeList(cmcSafe);
        ExcelUtil<CmcSafe> util = new ExcelUtil<CmcSafe>(CmcSafe.class);
        util.exportExcel(response, list, "cmc安全交底数据");
    }

    /**
     * 获取cmc安全交底详细信息
     */
    @GetMapping(value = "/{safeId}")
    public AjaxResult getInfo(@PathVariable("safeId") String safeId)
    {
        return success(cmcSafeService.selectCmcSafeBySafeId(safeId));
    }

    /**
     * 新增cmc安全交底
     */
    @Log(title = "cmc安全交底", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CmcSafe cmcSafe)
    {
        return toAjax(cmcSafeService.insertCmcSafe(cmcSafe));
    }

    /**
     * 修改cmc安全交底
     */
    @Log(title = "cmc安全交底", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CmcSafe cmcSafe)
    {
        return toAjax(cmcSafeService.updateCmcSafe(cmcSafe));
    }

    /**
     * 删除cmc安全交底
     */
    @Log(title = "cmc安全交底", businessType = BusinessType.DELETE)
	@DeleteMapping("/{safeIds}")
    public AjaxResult remove(@PathVariable String[] safeIds)
    {
        return success(cmcSafeService.deleteCmcSafeBySafeIds(safeIds));
    }
}
