package com.ruoyi.web.controller.ems;

import com.huashe.common.domain.AjaxResult;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.ems.domain.ElecMeterH;
import com.ruoyi.ems.model.QueryMeter;
import com.ruoyi.ems.service.IElecMeterHService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
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.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

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

/**
 * 用电计量-小时Controller
 *
 * @author ruoyi
 * @date 2024-12-03
 */
@RestController
@RequestMapping("/ems/elecMeterH")
@Api(value = "ElecMeterHController", description = "用电计量-小时")
public class ElecMeterHController extends BaseController {
    @Autowired
    private IElecMeterHService elecMeterHService;

    /**
     * 新增用电计量-小时
     */
    @PreAuthorize("@ss.hasPermi('ems:elecMeterH:add')")
    @Log(title = "用电计量-小时", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ElecMeterH elecMeterH) {
        return toAjax(elecMeterHService.insertElecMeterH(elecMeterH));
    }

    /**
     * 修改用电计量-小时
     */
    @PreAuthorize("@ss.hasPermi('ems:elecMeterH:edit')")
    @Log(title = "用电计量-小时", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ElecMeterH elecMeterH) {
        return toAjax(elecMeterHService.updateElecMeterH(elecMeterH));
    }

    /**
     * 删除用电计量-小时
     */
    @PreAuthorize("@ss.hasPermi('ems:elecMeterH:remove')")
    @Log(title = "用电计量-小时", businessType = BusinessType.DELETE)
    @DeleteMapping("/delByDate")
    public AjaxResult removeByDate(@RequestParam(name = "date") String date) {
        return toAjax(elecMeterHService.deleteElecMeterHByDate(date));
    }
}
