package com.aucma.dms.controller;

import com.aucma.common.core.controller.BaseController;
import com.aucma.common.core.domain.AjaxResult;
import com.aucma.common.core.page.TableDataInfo;
import com.aucma.common.utils.poi.ExcelUtil;
import com.aucma.dms.domain.DmsRecordInspect;
import com.aucma.dms.service.IDmsRecordInspectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

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




/**
 * 巡检记录Controller
 * 
 * @author Open Platform
 * @date 2024-01-16
 */
@RestController
@RequestMapping("/dms/dmsRecordInspect")
public class DmsRecordInspectController extends BaseController
{

    @Autowired
    private IDmsRecordInspectService dmsRecordInspectService;

    /**
     * 查询巡检记录列表
     */
    //@PreAuthorize("@ss.hasPermi('dms:dmsRecordInspect:list')" )
    @GetMapping("/list")
    public TableDataInfo list(DmsRecordInspect dmsRecordInspect)
    {
        startPage();
        List<DmsRecordInspect> list = dmsRecordInspectService.selectDmsRecordInspectList(dmsRecordInspect);
        return getDataTable(list);
    }

    /**
     * 查询巡检记录列表（不分页）
     */
    //@PreAuthorize("@ss.hasPermi('dms:dmsRecordInspect:list')" )
    @GetMapping("/listAll")
    public AjaxResult listAll(DmsRecordInspect dmsRecordInspect)
    {
        List<DmsRecordInspect> list = dmsRecordInspectService.selectDmsRecordInspectList(dmsRecordInspect);
        return success(list);
    }

    /**
     * 导出巡检记录列表
     */
    //@PreAuthorize("@ss.hasPermi('dms:dmsRecordInspect:export')" )
    ////@Log(title = "巡检记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DmsRecordInspect dmsRecordInspect)
    {
        List<DmsRecordInspect> list = dmsRecordInspectService.selectDmsRecordInspectList(dmsRecordInspect);
        ExcelUtil<DmsRecordInspect> util = new ExcelUtil<DmsRecordInspect>(DmsRecordInspect.class);
        util.exportExcel(response, list, "巡检记录数据");
    }

    /**
     * 获取巡检记录详细信息
     */
    //@PreAuthorize("@ss.hasPermi('dms:dmsRecordInspect:query')" )
    @GetMapping(value = "/{recordInspectId}")
    public AjaxResult getInfo(@PathVariable("recordInspectId") Long recordInspectId)
    {
        return success(dmsRecordInspectService.selectDmsRecordInspectByRecordInspectId(recordInspectId));
    }

    /**
     * 新增巡检记录
     */
    //@PreAuthorize("@ss.hasPermi('dms:dmsRecordInspect:add')" )
    ////@Log(title = "巡检记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DmsRecordInspect dmsRecordInspect)
    {
        return toAjax(dmsRecordInspectService.insertDmsRecordInspect(dmsRecordInspect));
    }

    /**
     * 修改巡检记录
     */
    //@PreAuthorize("@ss.hasPermi('dms:dmsRecordInspect:edit')" )
    ////@Log(title = "巡检记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DmsRecordInspect dmsRecordInspect)
    {
        return toAjax(dmsRecordInspectService.updateDmsRecordInspect(dmsRecordInspect));
    }

    /**
     * 删除巡检记录
     */
    //@PreAuthorize("@ss.hasPermi('dms:dmsRecordInspect:remove')" )
    ////@Log(title = "巡检记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recordInspectIds}")
    public AjaxResult remove(@PathVariable Long[] recordInspectIds)
    {
        return toAjax(dmsRecordInspectService.deleteDmsRecordInspectByRecordInspectIds(recordInspectIds));
    }
}
