package com.ruoyi.ems.controller;

import com.huashe.common.domain.AjaxResult;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.ems.domain.EmsObjEvent;
import com.ruoyi.ems.service.IEmsObjEventService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
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.RestController;

import java.util.List;

/**
 * 能源对象事件Controller
 * 
 * @author ruoyi
 * @date 2024-09-23
 */
@RestController
@RequestMapping("/object/event")
@Api(value = "EmsObjEventController", description = "能源对象属性管理")
public class EmsObjEventController extends BaseController
{
    @Autowired
    private IEmsObjEventService objEventService;

    /**
     * 查询能源对象事件列表
     */
    @GetMapping("/list")
    public TableDataInfo list(EmsObjEvent objEvent)
    {
        startPage();
        List<EmsObjEvent> list = objEventService.selectObjEventList(objEvent);
        return getDataTable(list);
    }

    /**
     * 获取能源对象事件详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(objEventService.selectObjEventById(id));
    }

    /**
     * 新增能源对象事件
     */
    @Log(title = "能源对象事件", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EmsObjEvent objEvent)
    {
        return toAjax(objEventService.insertObjEvent(objEvent));
    }

    /**
     * 新增能源对象事件
     */
    @Log(title = "能源对象事件", businessType = BusinessType.INSERT)
    @PostMapping("/batch")
    public AjaxResult addBatch(@RequestBody List<EmsObjEvent> list)
    {
        return toAjax(objEventService.insertBatch(list));
    }

    /**
     * 修改能源对象事件
     */
    @Log(title = "能源对象事件", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EmsObjEvent objEvent)
    {
        return toAjax(objEventService.updateObjEvent(objEvent));
    }

    /**
     * 删除能源对象事件
     */
    @Log(title = "能源对象事件", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(objEventService.deleteObjEventByIds(ids));
    }
}
