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.TwinPanHeadInfo;
import com.jjt.calc.service.ITwinPanHeadInfoService;
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/panInfo")
public class TwinPanHeadInfoController extends BaseController{
    @Resource
    private ITwinPanHeadInfoService twinPanHeadInfoService;

    /**
     * 查询设备盘头信息列表
     */
    @ApiOperation("查询设备盘头信息列表")
    @PreAuthorize("@ss.hasPermi('calc:panInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(TwinPanHeadInfo twinPanHeadInfo)
    {
        startPage();
        List<TwinPanHeadInfo> list = twinPanHeadInfoService.selectTwinPanHeadInfoList(twinPanHeadInfo);
        return getDataTable(list);
    }

    /**
     * 导出设备盘头信息列表
     */
    @ApiOperation("导出设备盘头信息列表")
    @PreAuthorize("@ss.hasPermi('calc:panInfo:export')")
    @Log(title = "设备盘头信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TwinPanHeadInfo twinPanHeadInfo)
    {
        List<TwinPanHeadInfo> list = twinPanHeadInfoService.selectTwinPanHeadInfoList(twinPanHeadInfo);
        ExcelUtil<TwinPanHeadInfo> util = new ExcelUtil<TwinPanHeadInfo>(TwinPanHeadInfo.class);
        util.exportExcel(response, list, "设备盘头信息数据");
    }

    /**
     * 获取设备盘头信息详细信息
     */
    @ApiOperation("获取设备盘头信息详细信息")
    @PreAuthorize("@ss.hasPermi('calc:panInfo:query')")
    @GetMapping(value = "/{infoId}")
    public AjaxResult getInfo(@PathVariable("infoId") Long infoId)
    {
        return success(twinPanHeadInfoService.selectTwinPanHeadInfoByInfoId(infoId));
    }

    /**
     * 新增设备盘头信息
     */
    @ApiOperation("新增设备盘头信息")
    @PreAuthorize("@ss.hasPermi('calc:panInfo:add')")
    @Log(title = "设备盘头信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TwinPanHeadInfo twinPanHeadInfo)
    {
        return toAjax(twinPanHeadInfoService.insertTwinPanHeadInfo(twinPanHeadInfo));
    }

    /**
     * 修改设备盘头信息
     */
    @ApiOperation("修改设备盘头信息")
    @PreAuthorize("@ss.hasPermi('calc:panInfo:edit')")
    @Log(title = "设备盘头信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TwinPanHeadInfo twinPanHeadInfo)
    {
        return toAjax(twinPanHeadInfoService.updateTwinPanHeadInfo(twinPanHeadInfo));
    }

    /**
     * 删除设备盘头信息
     */
    @ApiOperation("删除设备盘头信息")
    @PreAuthorize("@ss.hasPermi('calc:panInfo:remove')")
    @Log(title = "设备盘头信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{infoIds}")
    public AjaxResult remove(@PathVariable Long[] infoIds)
    {
        return toAjax(twinPanHeadInfoService.deleteTwinPanHeadInfoByInfoIds(infoIds));
    }
}
