package org.dromara.ems.record.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.record.domain.EmsVibrationInstant;
import org.dromara.ems.record.service.IEmsVibrationInstantService;
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 ZangCH
 * @date 2024-08-22
 */
@RestController
@RequiredArgsConstructor

@RequestMapping("/ems/record/recordVibrationInstant")
public class EmsVibrationInstantController extends EmsBaseController
{
    
    private final IEmsVibrationInstantService emsVibrationInstantService;

    /**
     * 查询震动实时数据列表
     */
    @SaCheckPermission("ems/record:recordVibrationInstant:list")
    @GetMapping("/list")
    public TableDataInfo list(EmsVibrationInstant emsVibrationInstant)
    {
        startPage();
        List<EmsVibrationInstant> list = emsVibrationInstantService.selectEmsVibrationInstantList(emsVibrationInstant);
        return getDataTable(list);
    }

    /**
     * 导出震动实时数据列表
     */
    @SaCheckPermission("ems/record:recordVibrationInstant:export")
    @Log(title = "震动实时数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EmsVibrationInstant emsVibrationInstant)
    {
        List<EmsVibrationInstant> list = emsVibrationInstantService.selectEmsVibrationInstantList(emsVibrationInstant);
        ExcelUtil.exportExcel(list, "震动实时数据数据", EmsVibrationInstant.class, response);
    }

    /**
     * 获取震动实时数据详细信息
     */
    @SaCheckPermission("ems/record:recordVibrationInstant:query")
    @GetMapping(value = "/{objId}")
    public R<?> getInfo(@PathVariable("objId") Long objId)
    {
        return success(emsVibrationInstantService.selectEmsVibrationInstantByObjId(objId));
    }

    /**
     * 新增震动实时数据
     */
    @SaCheckPermission("ems/record:recordVibrationInstant:add")
    @Log(title = "震动实时数据", businessType = BusinessType.INSERT)
    @PostMapping
    public R<?> add(@RequestBody EmsVibrationInstant emsVibrationInstant)
    {
        return toAjax(emsVibrationInstantService.insertEmsVibrationInstant(emsVibrationInstant));
    }

    /**
     * 修改震动实时数据
     */
    @SaCheckPermission("ems/record:recordVibrationInstant:edit")
    @Log(title = "震动实时数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public R<?> edit(@RequestBody EmsVibrationInstant emsVibrationInstant)
    {
        return toAjax(emsVibrationInstantService.updateEmsVibrationInstant(emsVibrationInstant));
    }

    /**
     * 删除震动实时数据
     */
    @SaCheckPermission("ems/record:recordVibrationInstant:remove")
    @Log(title = "震动实时数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{objIds}")
    public R<?> remove(@PathVariable Long[] objIds)
    {
        return toAjax(emsVibrationInstantService.deleteEmsVibrationInstantByObjIds(objIds));
    }

    /**
     * 查询震动实时数据
     * @param emsVibrationInstant
     * @return
     */
    @GetMapping("/vibrationInstantList")
    public R<?> vibrationInstantList(EmsVibrationInstant emsVibrationInstant) {
        List<EmsVibrationInstant> list = emsVibrationInstantService
                .selectVibrationInstantList(emsVibrationInstant);
        return success(list);
    }
}
