package com.huashe.park.application.web.controller.cons;

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

import com.huashe.common.domain.AjaxResult;
import com.huashe.park.core.service.IConsMachineCmdHisService;
import com.huashe.park.domain.entity.ConsMachineCmdHis;
import com.ruoyi.common.utils.poi.ExcelUtil;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
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.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 桩机指令下发历史Controller
 * 
 * @author ruoyi
 * @date 2025-02-12
 */
@RestController
@RequestMapping("/cons/machineCmdHis")
public class ConsMachineCmdHisController extends BaseController {
    @Autowired
    private IConsMachineCmdHisService consMachineCmdHisService;

    /**
     * 查询桩机指令下发历史列表
     */
    @PreAuthorize("@ss.hasPermi('cons:machineCmdHis:list')")
    @GetMapping("/list")
    public TableDataInfo list(ConsMachineCmdHis consMachineCmdHis) {
        startPage();
        List<ConsMachineCmdHis> list = consMachineCmdHisService.selectConsMachineCmdHisList(consMachineCmdHis);
        return getDataTable(list);
    }

    /**
     * 导出桩机指令下发历史列表
     */
    @PreAuthorize("@ss.hasPermi('cons:machineCmdHis:export')")
    @Log(title = "桩机指令下发历史", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ConsMachineCmdHis consMachineCmdHis) {
        List<ConsMachineCmdHis> list = consMachineCmdHisService.selectConsMachineCmdHisList(consMachineCmdHis);
        ExcelUtil<ConsMachineCmdHis> util = new ExcelUtil<ConsMachineCmdHis>(ConsMachineCmdHis.class);
        util.exportExcel(response, list, "桩机指令下发历史数据");
    }

    /**
     * 获取桩机指令下发历史详细信息
     */
    @PreAuthorize("@ss.hasPermi('cons:machineCmdHis:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(consMachineCmdHisService.selectConsMachineCmdHisById(id));
    }

    /**
     * 新增桩机指令下发历史
     */
    @PreAuthorize("@ss.hasPermi('cons:machineCmdHis:add')")
    @Log(title = "桩机指令下发历史", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ConsMachineCmdHis consMachineCmdHis) {
        return toAjax(consMachineCmdHisService.insertConsMachineCmdHis(consMachineCmdHis));
    }

    /**
     * 修改桩机指令下发历史
     */
    @PreAuthorize("@ss.hasPermi('cons:machineCmdHis:edit')")
    @Log(title = "桩机指令下发历史", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ConsMachineCmdHis consMachineCmdHis) {
        return toAjax(consMachineCmdHisService.updateConsMachineCmdHis(consMachineCmdHis));
    }

    /**
     * 删除桩机指令下发历史
     */
    @PreAuthorize("@ss.hasPermi('cons:machineCmdHis:remove')")
    @Log(title = "桩机指令下发历史", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(consMachineCmdHisService.deleteConsMachineCmdHisByIds(ids));
    }
}
