package com.hw.ems.base.controller;


import com.hw.common.core.utils.poi.ExcelUtil;
import com.hw.common.core.web.controller.BaseController;
import com.hw.common.core.web.domain.AjaxResult;
import com.hw.common.core.web.page.TableDataInfo;
import com.hw.common.log.annotation.Log;
import com.hw.common.log.enums.BusinessType;
import com.hw.common.security.annotation.RequiresPermissions;
import com.hw.ems.base.domain.CbsMonitorReport;
import com.hw.ems.base.service.ICbsMonitorReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * CBS抄报Controller
 *
 * @author YinQ
 * @date 2023-10-20
 */
@RestController
@RequestMapping("/base/cbsMonitorReport")
public class CbsMonitorReportController extends BaseController
{
    @Autowired
    private ICbsMonitorReportService cbsMonitorReportService;

    /**
     * 查询CBS抄报列表
     */
    @RequiresPermissions("base:cbsMonitorReport:list")
    @GetMapping("/list")
    public TableDataInfo list(CbsMonitorReport cbsMonitorReport)
    {
        startPage();
        List<CbsMonitorReport> list = cbsMonitorReportService.selectCbsMonitorReportList(cbsMonitorReport);
        return getDataTable(list);
    }

    /**
     * 导出CBS抄报列表
     */
    @RequiresPermissions("base:cbsMonitorReport:export")
    @Log(title = "CBS抄报", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CbsMonitorReport cbsMonitorReport)
    {
        List<CbsMonitorReport> list = cbsMonitorReportService.selectCbsMonitorReportList(cbsMonitorReport);
        ExcelUtil<CbsMonitorReport> util = new ExcelUtil<CbsMonitorReport>(CbsMonitorReport.class);
        util.exportExcel(response, list, "CBS抄报数据");
    }

    /**
     * 获取CBS抄报详细信息
     */
    @RequiresPermissions("base:cbsMonitorReport:query")
    @GetMapping(value = "/{objId}")
    public AjaxResult getInfo(@PathVariable("objId") Long objId)
    {
        return success(cbsMonitorReportService.selectCbsMonitorReportByObjId(objId));
    }

    /**
     * 新增CBS抄报
     */
    @RequiresPermissions("base:cbsMonitorReport:add")
    @Log(title = "CBS抄报", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CbsMonitorReport cbsMonitorReport)
    {
        return toAjax(cbsMonitorReportService.insertCbsMonitorReport(cbsMonitorReport));
    }

    /**
     * 修改CBS抄报
     */
    @RequiresPermissions("base:cbsMonitorReport:edit")
    @Log(title = "CBS抄报", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CbsMonitorReport cbsMonitorReport)
    {
        return toAjax(cbsMonitorReportService.updateCbsMonitorReport(cbsMonitorReport));
    }

    /**
     * 删除CBS抄报
     */
    @RequiresPermissions("base:cbsMonitorReport:remove")
    @Log(title = "CBS抄报", businessType = BusinessType.DELETE)
	@DeleteMapping("/{objIds}")
    public AjaxResult remove(@PathVariable Long[] objIds)
    {
        return toAjax(cbsMonitorReportService.deleteCbsMonitorReportByObjIds(objIds));
    }
}
