package com.zehong.web.controller.track;

import java.util.List;

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.zehong.common.annotation.Log;
import com.zehong.common.core.controller.BaseController;
import com.zehong.common.core.domain.AjaxResult;
import com.zehong.common.enums.BusinessType;
import com.zehong.system.domain.track.TProductDeviceTest;
import com.zehong.system.service.track.ITProductDeviceTestService;
import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.common.core.page.TableDataInfo;

/**
 * 设备检测Controller
 * 
 * @author zehong
 * @date 2024-08-29
 */
@RestController
@RequestMapping("/track/test")
public class TProductDeviceTestController extends BaseController
{
    @Autowired
    private ITProductDeviceTestService tProductDeviceTestService;

    /**
     * 查询设备检测列表
     */
   // @PreAuthorize("@ss.hasPermi('system:test:list')")
    @GetMapping("/list")
    public TableDataInfo list(TProductDeviceTest tProductDeviceTest)
    {
        startPage();
        List<TProductDeviceTest> list = tProductDeviceTestService.selectTProductDeviceTestList(tProductDeviceTest);
        return getDataTable(list);
    }

    /**
     * 导出设备检测列表
     */
    //@PreAuthorize("@ss.hasPermi('system:test:export')")
    @Log(title = "设备检测", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TProductDeviceTest tProductDeviceTest)
    {
        List<TProductDeviceTest> list = tProductDeviceTestService.selectTProductDeviceTestList(tProductDeviceTest);
        ExcelUtil<TProductDeviceTest> util = new ExcelUtil<TProductDeviceTest>(TProductDeviceTest.class);
        return util.exportExcel(list, "设备检测数据");
    }

    /**
     * 获取设备检测详细信息
     */
    //@PreAuthorize("@ss.hasPermi('system:test:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tProductDeviceTestService.selectTProductDeviceTestById(id));
    }

    /**
     * 新增设备检测
     */
    //@PreAuthorize("@ss.hasPermi('system:test:add')")
    @Log(title = "设备检测", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TProductDeviceTest tProductDeviceTest)
    {
        return toAjax(tProductDeviceTestService.insertTProductDeviceTest(tProductDeviceTest));
    }

    /**
     * 修改设备检测
     */
    //@PreAuthorize("@ss.hasPermi('system:test:edit')")
    @Log(title = "设备检测", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TProductDeviceTest tProductDeviceTest)
    {
        return toAjax(tProductDeviceTestService.updateTProductDeviceTest(tProductDeviceTest));
    }

    /**
     * 删除设备检测
     */
    //@PreAuthorize("@ss.hasPermi('system:test:remove')")
    @Log(title = "设备检测", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tProductDeviceTestService.deleteTProductDeviceTestByIds(ids));
    }
}
