package com.zbf.web.controller.system;

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

import com.zbf.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
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.TAgv;
import com.zbf.system.service.ITAgvService;
import com.zbf.common.utils.poi.ExcelUtil;
import com.zbf.common.core.page.TableDataInfo;

/**
 * agv列表Controller
 *
 * @author tony
 * @date 2024-06-17
 */
@CrossOrigin
@RestController
@RequestMapping("/system/agv")
public class TAgvController extends BaseController
{
    @Autowired
    private ITAgvService tAgvService;

/**
 * 查询agv列表列表
 */
@GetMapping("/list")
    public TableDataInfo list(TAgv tAgv)
    {
        startPage();
        List<TAgv> list = tAgvService.selectTAgvList(tAgv);
        return getDataTable(list);
    }

    /**
     * 导出agv列表列表
     */
/*
    @PreAuthorize("@ss.hasPermi('system:agv:export')")
*/
    @Log(title = "agv列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TAgv tAgv)
    {
        List<TAgv> list = tAgvService.selectTAgvList(tAgv);
        ExcelUtil<TAgv> util = new ExcelUtil<TAgv>(TAgv.class);
        util.exportExcel(response, list, "agv列表数据");
    }

    /**
     * 获取agv列表详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:agv:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tAgvService.selectTAgvById(id));
    }

    /**
     * 新增agv列表
     */
    @PreAuthorize("@ss.hasPermi('system:agv:add')")
    @Log(title = "agv列表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TAgv tAgv)
    {
        return toAjax(tAgvService.insertTAgv(tAgv));
    }

    /**
     * 修改agv列表
     */
    @PreAuthorize("@ss.hasPermi('system:agv:edit')")
    @Log(title = "agv列表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TAgv tAgv)
    {
        return toAjax(tAgvService.updateTAgv(tAgv));
    }

    /**
     * 删除agv列表
     */
    @PreAuthorize("@ss.hasPermi('system:agv:remove')")
    @Log(title = "agv列表", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tAgvService.deleteTAgvByIds(ids));
    }

    /**
     * 启用
     */
    @PreAuthorize("@ss.hasPermi('system:agv:remove')")
    @Log(title = "agv列表", businessType = BusinessType.UPDATE)
    @DeleteMapping("/disable/{ids}")
    public AjaxResult disable(@PathVariable Long[] ids)
    {
        return toAjax(tAgvService.disabledTAgvByIds(ids));
    }

    /**
     * 禁用
     */
    @PreAuthorize("@ss.hasPermi('system:agv:edit')")
    @Log(title = "agv列表", businessType = BusinessType.UPDATE)
    @DeleteMapping("/enable/{ids}")
    public AjaxResult enable(@PathVariable Long[] ids)
    {
        return toAjax(tAgvService.enableTAgvByIds(ids));
    }

    /**
     * 修改状态
     */
    @PreAuthorize("@ss.hasPermi('system:agv:edit')")
    @Log(title = "agv列表", businessType = BusinessType.UPDATE)
    @PutMapping("/changeStatus")
    public AjaxResult changeStatus(@RequestBody TAgv tAgv) {
        return toAjax(tAgvService.updateStatus(tAgv));
    }

}

