package org.dromara.ems.report.controller;

import org.dromara.common.log.annotation.Log;
import org.dromara.ems.common.web.EmsBaseController;
import org.dromara.common.core.domain.R;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.log.enums.BusinessType;
import org.dromara.common.excel.utils.ExcelUtil;
import org.dromara.ems.report.domain.EmsReportPointDnb;
import org.dromara.ems.report.service.IEmsReportPointDnbService;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 电整点数据Controller
 *
 * @author Yinq
 * @date 2024-05-22
 */
@RestController
@RequiredArgsConstructor

@RequestMapping("/ems/report/reportPointDnb")
public class EmsReportPointDnbController extends EmsBaseController {

    private final IEmsReportPointDnbService emsReportPointDnbService;

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

    /**
     * 导出电整点数据列表
     */
    @SaCheckPermission("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.exportExcel(list, "电整点数据数据", EmsReportPointDnb.class, response);
    }

    /**
     * 获取电整点数据详细信息
     */
    @SaCheckPermission("ems/report:reportPointDnb:query")
    @GetMapping(value = "/{objId}")
    public R<?> getInfo(@PathVariable("objId") Long objId) {
        return success(emsReportPointDnbService.selectEmsReportPointDnbByObjId(objId));
    }

    /**
     * 新增电整点数据
     */
    @SaCheckPermission("ems/report:reportPointDnb:add")
    @Log(title = "电整点数据", businessType = BusinessType.INSERT)
    @PostMapping
    public R<?> add(@RequestBody EmsReportPointDnb emsReportPointDnb) {
        return toAjax(emsReportPointDnbService.insertEmsReportPointDnb(emsReportPointDnb));
    }

    /**
     * 修改电整点数据
     */
    @SaCheckPermission("ems/report:reportPointDnb:edit")
    @Log(title = "电整点数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public R<?> edit(@RequestBody EmsReportPointDnb emsReportPointDnb) {
        return toAjax(emsReportPointDnbService.updateEmsReportPointDnb(emsReportPointDnb));
    }

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