package com.meas.system.controller;

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

/**
 * 热像仪测试数据Controller
 *
 * @author wgk
 * @date 2024-06-13
 */
@RestController
@RequestMapping("/meas/thermalImagerTesDdata")
public class MeasThermalImagerTestDataController extends BaseController {
    @Autowired
    private IMeasThermalImagerTestDataService measThermalImagerTestDataService;

    /**
     * 查询热像仪测试数据列表
     */
    @PreAuthorize("@ss.hasPermi('meas:thermalImagerTesDdata:list')")
    @GetMapping("/list")
    public TableDataInfo list(MeasThermalImagerTestData measThermalImagerTestData) {
        startPage();
        List<MeasThermalImagerTestData> list = measThermalImagerTestDataService.selectMeasThermalImagerTestDataList(measThermalImagerTestData);
        return getDataTable(list);
    }

    /**
     * 导出热像仪测试数据列表
     */
    @PreAuthorize("@ss.hasPermi('meas:thermalImagerTesDdata:export')")
    @Log(title = "热像仪测试数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MeasThermalImagerTestData measThermalImagerTestData) {
        List<MeasThermalImagerTestData> list = measThermalImagerTestDataService.selectMeasThermalImagerTestDataList(measThermalImagerTestData);
        ExcelUtil<MeasThermalImagerTestData> util = new ExcelUtil<MeasThermalImagerTestData>(MeasThermalImagerTestData.class);
        util.exportExcel(response, list, "热像仪测试数据数据");
    }

    /**
     * 获取热像仪测试数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('meas:thermalImagerTesDdata:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(measThermalImagerTestDataService.selectMeasThermalImagerTestDataById(id));
    }

    /**
     * 新增热像仪测试数据
     */
    @PreAuthorize("@ss.hasPermi('meas:thermalImagerTesDdata:add')")
    @Log(title = "热像仪测试数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MeasThermalImagerTestData measThermalImagerTestData) {
        MeasThermalImagerTestData returnValue = measThermalImagerTestDataService.insertMeasThermalImagerTestData(measThermalImagerTestData);
        if (returnValue == null) {
            return error();
        } else {
            return success(returnValue);
        }
    }

    /**
     * 修改热像仪测试数据
     */
    @PreAuthorize("@ss.hasPermi('meas:thermalImagerTesDdata:edit')")
    @Log(title = "热像仪测试数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MeasThermalImagerTestData measThermalImagerTestData) {
        return toAjax(measThermalImagerTestDataService.updateMeasThermalImagerTestData(measThermalImagerTestData));
    }

    /**
     * 删除热像仪测试数据
     */
    @PreAuthorize("@ss.hasPermi('meas:thermalImagerTesDdata:remove')")
    @Log(title = "热像仪测试数据", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(measThermalImagerTestDataService.deleteMeasThermalImagerTestDataByIds(ids));
    }

    @PreAuthorize("@ss.hasPermi('meas:thermalImagerTesDdata:query')")
    @GetMapping(value = "/getInfoByEnvDataId/{envDataId}")
    public AjaxResult selectResultsByEnvDataId(@PathVariable("envDataId") Long envDataId) {
        return success(measThermalImagerTestDataService.selectResultsByEnvDataId(envDataId));
    }
}
