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

/**
 * cmc安全要求Controller
 * 
 * @author cmc
 * @date 2024-07-08
 */
@RestController
@RequestMapping("/oa/safeRequest")
public class CmcSafeRequestController extends BaseController
{
    @Autowired
    private ICmcSafeRequestService cmcSafeRequestService;

    /**
     * 查询cmc安全要求列表
     */
    @GetMapping("/list")
    public TableDataInfo list(CmcSafeRequest cmcSafeRequest)
    {
        startPage();
        List<CmcSafeRequest> list = cmcSafeRequestService.selectCmcSafeRequestList(cmcSafeRequest);
        return getDataTable(list);
    }

    /**
     * 导出cmc安全要求列表
     */
    @Log(title = "cmc安全要求", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CmcSafeRequest cmcSafeRequest)
    {
        List<CmcSafeRequest> list = cmcSafeRequestService.selectCmcSafeRequestList(cmcSafeRequest);
        ExcelUtil<CmcSafeRequest> util = new ExcelUtil<CmcSafeRequest>(CmcSafeRequest.class);
        util.exportExcel(response, list, "cmc安全要求数据");
    }

    /**
     * 获取cmc安全要求详细信息
     */
    @GetMapping(value = "/{requestId}")
    public AjaxResult getInfo(@PathVariable("requestId") Integer requestId)
    {
        return success(cmcSafeRequestService.selectCmcSafeRequestByRequestId(requestId));
    }

    /**
     * 新增cmc安全要求
     */
    @Log(title = "cmc安全要求", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CmcSafeRequest cmcSafeRequest)
    {
        return toAjax(cmcSafeRequestService.insertCmcSafeRequest(cmcSafeRequest));
    }

    /**
     * 修改cmc安全要求
     */
    @Log(title = "cmc安全要求", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CmcSafeRequest cmcSafeRequest)
    {
        return toAjax(cmcSafeRequestService.updateCmcSafeRequest(cmcSafeRequest));
    }

    /**
     * 删除cmc安全要求
     */
    @Log(title = "cmc安全要求", businessType = BusinessType.DELETE)
	@DeleteMapping("/{requestIds}")
    public AjaxResult remove(@PathVariable Integer[] requestIds)
    {
        return success(cmcSafeRequestService.deleteCmcSafeRequestByRequestIds(requestIds));
    }
}
