package com.aucma.report.controller;

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

import com.aucma.common.utils.DateUtils;
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.aucma.common.annotation.Log;
import com.aucma.common.core.controller.BaseController;
import com.aucma.common.core.domain.AjaxResult;
import com.aucma.common.enums.BusinessType;
import com.aucma.report.domain.RecordElectricalInspection;
import com.aucma.report.service.IRecordElectricalInspectionService;
import com.aucma.common.utils.poi.ExcelUtil;
import com.aucma.common.core.page.TableDataInfo;

/**
 * 电检数据记录Controller
 *
 * @author Yinq
 * @date 2023-11-09
 */
@RestController
@RequestMapping("/report/electricalInspection" )
public class RecordElectricalInspectionController extends BaseController {
    @Autowired
    private IRecordElectricalInspectionService recordElectricalInspectionService;

    /**
     * 查询电检数据记录列表
     */
    @PreAuthorize("@ss.hasPermi('report:electricalInspection:list')" )
    @GetMapping("/list" )
    public TableDataInfo list(RecordElectricalInspection recordElectricalInspection) {
        startPage();
        List<RecordElectricalInspection> list = recordElectricalInspectionService.selectRecordElectricalInspectionList(recordElectricalInspection);
        return getDataTable(list);
    }

    /**
     * 导出电检数据记录列表
     */
    @PreAuthorize("@ss.hasPermi('report:electricalInspection:export')" )
    @Log(title = "电检数据记录" , businessType = BusinessType.EXPORT)
    @PostMapping("/export" )
    public void export(HttpServletResponse response, RecordElectricalInspection recordElectricalInspection) {
        List<RecordElectricalInspection> list = recordElectricalInspectionService.selectRecordElectricalInspectionList(recordElectricalInspection);
        ExcelUtil<RecordElectricalInspection> util = new ExcelUtil<RecordElectricalInspection>(RecordElectricalInspection. class);
        util.exportExcel(response, list, "电检数据记录数据" );
    }

    /**
     * 获取电检数据记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('report:electricalInspection:query')" )
    @GetMapping(value = "/{uuid}" )
    public AjaxResult getInfo(@PathVariable("uuid" ) String uuid) {
        return success(recordElectricalInspectionService.selectRecordElectricalInspectionByUuid(uuid));
    }

    /**
     * 新增电检数据记录
     */
    @PreAuthorize("@ss.hasPermi('report:electricalInspection:add')" )
    @Log(title = "电检数据记录" , businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RecordElectricalInspection recordElectricalInspection) {
        return toAjax(recordElectricalInspectionService.insertRecordElectricalInspection(recordElectricalInspection));
    }

    /**
     * 修改电检数据记录
     */
    @PreAuthorize("@ss.hasPermi('report:electricalInspection:edit')" )
    @Log(title = "电检数据记录" , businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RecordElectricalInspection recordElectricalInspection) {
        return toAjax(recordElectricalInspectionService.updateRecordElectricalInspection(recordElectricalInspection));
    }

    /**
     * 删除电检数据记录
     */
    @PreAuthorize("@ss.hasPermi('report:electricalInspection:remove')" )
    @Log(title = "电检数据记录" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{uuids}" )
    public AjaxResult remove(@PathVariable String[] uuids) {
        return toAjax(recordElectricalInspectionService.deleteRecordElectricalInspectionByUuids(uuids));
    }
}
