package com.jjt.inventory.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.inventory.domain.TwinCalcHourPt;
import com.jjt.inventory.service.ITwinCalcHourPtService;
import com.jjt.common.utils.poi.ExcelUtil;
import com.jjt.common.core.page.TableDataInfo;

/**
 * 盘头仓库小时数据Controller
 *
 * @author wukai
 * @date 2025-06-10
 */
@Api(tags="盘头仓库小时数据")
@RestController
@RequestMapping("/inventory/ptHour")
public class TwinCalcHourPtController extends BaseController{
    @Resource
    private ITwinCalcHourPtService twinCalcHourPtService;

    /**
     * 查询盘头仓库小时数据列表
     */
    @ApiOperation("查询盘头仓库小时数据列表")
    //@PreAuthorize("@ss.hasPermi('inventory:ptHour:list')")
    @GetMapping("/list")
    public TableDataInfo list(TwinCalcHourPt twinCalcHourPt)
    {
        startPage();
        List<TwinCalcHourPt> list = twinCalcHourPtService.selectTwinCalcHourPtList(twinCalcHourPt);
        return getDataTable(list);
    }

    /**
     * 导出盘头仓库小时数据列表
     */
    @ApiOperation("导出盘头仓库小时数据列表")
    //@PreAuthorize("@ss.hasPermi('inventory:ptHour:export')")
    @Log(title = "盘头仓库小时数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TwinCalcHourPt twinCalcHourPt)
    {
        List<TwinCalcHourPt> list = twinCalcHourPtService.selectTwinCalcHourPtList(twinCalcHourPt);
        ExcelUtil<TwinCalcHourPt> util = new ExcelUtil<TwinCalcHourPt>(TwinCalcHourPt.class);
        util.exportExcel(response, list, "盘头仓库小时数据数据");
    }

    /**
     * 获取盘头仓库小时数据详细信息
     */
    @ApiOperation("获取盘头仓库小时数据详细信息")
    //@PreAuthorize("@ss.hasPermi('inventory:ptHour:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(twinCalcHourPtService.selectTwinCalcHourPtById(id));
    }

    /**
     * 新增盘头仓库小时数据
     */
    @ApiOperation("新增盘头仓库小时数据")
    //@PreAuthorize("@ss.hasPermi('inventory:ptHour:add')")
    @Log(title = "盘头仓库小时数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TwinCalcHourPt twinCalcHourPt)
    {
        return toAjax(twinCalcHourPtService.insertTwinCalcHourPt(twinCalcHourPt));
    }

    /**
     * 修改盘头仓库小时数据
     */
    @ApiOperation("修改盘头仓库小时数据")
    //@PreAuthorize("@ss.hasPermi('inventory:ptHour:edit')")
    @Log(title = "盘头仓库小时数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TwinCalcHourPt twinCalcHourPt)
    {
        return toAjax(twinCalcHourPtService.updateTwinCalcHourPt(twinCalcHourPt));
    }

    /**
     * 删除盘头仓库小时数据
     */
    @ApiOperation("删除盘头仓库小时数据")
    //@PreAuthorize("@ss.hasPermi('inventory:ptHour:remove')")
    @Log(title = "盘头仓库小时数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(twinCalcHourPtService.deleteTwinCalcHourPtByIds(ids));
    }
}
