package com.jjt.calc.controller;

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

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
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.jjt.common.annotation.Log;
import com.jjt.common.core.controller.BaseController;
import com.jjt.common.core.domain.AjaxResult;
import com.jjt.common.enums.BusinessType;
import com.jjt.calc.domain.TwinRecordStop;
import com.jjt.calc.service.ITwinRecordStopService;
import com.jjt.common.utils.poi.ExcelUtil;
import com.jjt.common.core.page.TableDataInfo;

/**
 * 停机数据记录Controller
 *
 * @author wukai
 * @date 2025-01-18
 */
@Api(tags="停机数据记录")
@RestController
@RequestMapping("/calc/recordStop")
public class TwinRecordStopController extends BaseController{
    @Resource
    private ITwinRecordStopService twinRecordStopService;

    /**
     * 查询停机数据记录列表
     */
    @ApiOperation("查询停机数据记录列表")
    @PreAuthorize("@ss.hasPermi('calc:recordStop:list')")
    @GetMapping("/list")
    public TableDataInfo list(TwinRecordStop twinRecordStop)
    {
        startPage();
        List<TwinRecordStop> list = twinRecordStopService.selectTwinRecordStopList(twinRecordStop);
        return getDataTable(list);
    }

    /**
     * 导出停机数据记录列表
     */
    @ApiOperation("导出停机数据记录列表")
    @PreAuthorize("@ss.hasPermi('calc:recordStop:export')")
    @Log(title = "停机数据记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TwinRecordStop twinRecordStop)
    {
        List<TwinRecordStop> list = twinRecordStopService.selectTwinRecordStopList(twinRecordStop);
        ExcelUtil<TwinRecordStop> util = new ExcelUtil<TwinRecordStop>(TwinRecordStop.class);
        util.exportExcel(response, list, "停机数据记录数据");
    }

    /**
     * 获取停机数据记录详细信息
     */
    @ApiOperation("获取停机数据记录详细信息")
    @PreAuthorize("@ss.hasPermi('calc:recordStop:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(twinRecordStopService.selectTwinRecordStopById(id));
    }

    /**
     * 新增停机数据记录
     */
    @ApiOperation("新增停机数据记录")
    @PreAuthorize("@ss.hasPermi('calc:recordStop:add')")
    @Log(title = "停机数据记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TwinRecordStop twinRecordStop)
    {
        return toAjax(twinRecordStopService.insertTwinRecordStop(twinRecordStop));
    }

    /**
     * 修改停机数据记录
     */
    @ApiOperation("修改停机数据记录")
    @PreAuthorize("@ss.hasPermi('calc:recordStop:edit')")
    @Log(title = "停机数据记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TwinRecordStop twinRecordStop)
    {
        return toAjax(twinRecordStopService.updateTwinRecordStop(twinRecordStop));
    }

    /**
     * 删除停机数据记录
     */
    @ApiOperation("删除停机数据记录")
    @PreAuthorize("@ss.hasPermi('calc:recordStop:remove')")
    @Log(title = "停机数据记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(twinRecordStopService.deleteTwinRecordStopByIds(ids));
    }
}
