package com.ruoyi.ems.report.controller;

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

import org.springframework.security.access.prepost.PreAuthorize;
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.ems.report.domain.EmsReportPointDnb;
import com.ruoyi.ems.report.service.IEmsReportPointDnbService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 电整点数据Controller
 *
 * @author Yinq
 * @date 2024-05-22
 */
@RestController
@RequestMapping("/ems/report/reportPointDnb")
public class EmsReportPointDnbController extends BaseController {
    @Autowired
    private IEmsReportPointDnbService emsReportPointDnbService;

    /**
     * 查询电整点数据列表
     */
    @PreAuthorize("@ss.hasPermi('ems/report:reportPointDnb:list')")
    @GetMapping("/list")
    public TableDataInfo list(EmsReportPointDnb emsReportPointDnb) {
        startPage();
        List<EmsReportPointDnb> list = emsReportPointDnbService.selectEmsReportPointDnbList(emsReportPointDnb);
        return getDataTable(list);
    }

    /**
     * 导出电整点数据列表
     */
    @PreAuthorize("@ss.hasPermi('ems/report:reportPointDnb:export')")
    @Log(title = "电整点数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EmsReportPointDnb emsReportPointDnb) {
        List<EmsReportPointDnb> list = emsReportPointDnbService.selectEmsReportPointDnbList(emsReportPointDnb);
        ExcelUtil<EmsReportPointDnb> util = new ExcelUtil<EmsReportPointDnb>(EmsReportPointDnb.class);
        util.exportExcel(response, list, "电整点数据数据");
    }

    /**
     * 获取电整点数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('ems/report:reportPointDnb:query')")
    @GetMapping(value = "/{objId}")
    public AjaxResult getInfo(@PathVariable("objId") Long objId) {
        return success(emsReportPointDnbService.selectEmsReportPointDnbByObjId(objId));
    }

    /**
     * 新增电整点数据
     */
    @PreAuthorize("@ss.hasPermi('ems/report:reportPointDnb:add')")
    @Log(title = "电整点数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EmsReportPointDnb emsReportPointDnb) {
        return toAjax(emsReportPointDnbService.insertEmsReportPointDnb(emsReportPointDnb));
    }

    /**
     * 修改电整点数据
     */
    @PreAuthorize("@ss.hasPermi('ems/report:reportPointDnb:edit')")
    @Log(title = "电整点数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EmsReportPointDnb emsReportPointDnb) {
        emsReportPointDnb.setUpdateBy(getUsername());
        return toAjax(emsReportPointDnbService.updateEmsReportPointDnb(emsReportPointDnb));
    }

    /**
     * 删除电整点数据
     */
    @PreAuthorize("@ss.hasPermi('ems/report:reportPointDnb:remove')")
    @Log(title = "电整点数据", businessType = BusinessType.DELETE)
    @DeleteMapping("/{objIds}")
    public AjaxResult remove(@PathVariable Long[] objIds) {
        return toAjax(emsReportPointDnbService.deleteEmsReportPointDnbByObjIds(objIds));
    }
}
