package com.zbf.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.zbf.common.annotation.Log;
import com.zbf.common.core.controller.BaseController;
import com.zbf.common.core.domain.AjaxResult;
import com.zbf.common.enums.BusinessType;
import com.zbf.system.domain.TErrorLog;
import com.zbf.system.service.ITErrorLogService;
import com.zbf.common.utils.poi.ExcelUtil;
import com.zbf.common.core.page.TableDataInfo;

/**
 * agv报警信息Controller
 *
 * @author tony
 * @date 2024-06-17
 */
@RestController
@RequestMapping("/system/agvErrorlog")
public class TErrorLogController extends BaseController
{
    @Autowired
    private ITErrorLogService tErrorLogService;

/**
 * 查询agv报警信息列表
 */
@PreAuthorize("@ss.hasPermi('system:agvErrorlog:list')")
@GetMapping("/list")
    public TableDataInfo list(TErrorLog tErrorLog)
    {
        startPage();
        List<TErrorLog> list = tErrorLogService.selectTErrorLogList(tErrorLog);
        return getDataTable(list);
    }

    /**
     * 导出agv报警信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:agvErrorlog:export')")
    @Log(title = "agv报警信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TErrorLog tErrorLog)
    {
        List<TErrorLog> list = tErrorLogService.selectTErrorLogList(tErrorLog);
        ExcelUtil<TErrorLog> util = new ExcelUtil<TErrorLog>(TErrorLog.class);
        util.exportExcel(response, list, "agv报警信息数据");
    }

    /**
     * 获取agv报警信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:agvErrorlog:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tErrorLogService.selectTErrorLogById(id));
    }

    /**
     * 新增agv报警信息
     */
    @PreAuthorize("@ss.hasPermi('system:agvErrorlog:add')")
    @Log(title = "agv报警信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TErrorLog tErrorLog)
    {
        return toAjax(tErrorLogService.insertTErrorLog(tErrorLog));
    }

    /**
     * 修改agv报警信息
     */
    @PreAuthorize("@ss.hasPermi('system:agvErrorlog:edit')")
    @Log(title = "agv报警信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TErrorLog tErrorLog)
    {
        return toAjax(tErrorLogService.updateTErrorLog(tErrorLog));
    }

    /**
     * 删除agv报警信息
     */
    @PreAuthorize("@ss.hasPermi('system:agvErrorlog:remove')")
    @Log(title = "agv报警信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tErrorLogService.deleteTErrorLogByIds(ids));
    }

    /**
     * 启用
     */
    @PreAuthorize("@ss.hasPermi('system:agvErrorlog:remove')")
    @Log(title = "agv报警信息", businessType = BusinessType.UPDATE)
    @DeleteMapping("/disable/{ids}")
    public AjaxResult disable(@PathVariable Long[] ids)
    {
        return toAjax(tErrorLogService.disabledTErrorLogByIds(ids));
    }

    /**
     * 禁用
     */
    @PreAuthorize("@ss.hasPermi('system:agvErrorlog:edit')")
    @Log(title = "agv报警信息", businessType = BusinessType.UPDATE)
    @DeleteMapping("/enable/{ids}")
    public AjaxResult enable(@PathVariable Long[] ids)
    {
        return toAjax(tErrorLogService.enableTErrorLogByIds(ids));
    }

    /**
     * 修改状态
     */
    @PreAuthorize("@ss.hasPermi('system:agvErrorlog:edit')")
    @Log(title = "agv报警信息", businessType = BusinessType.UPDATE)
    @PutMapping("/changeStatus")
    public AjaxResult changeStatus(@RequestBody TErrorLog tErrorLog) {
        return toAjax(tErrorLogService.updateStatus(tErrorLog));
    }

}

