package com.hw.dms.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
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.hw.common.log.annotation.Log;
import com.hw.common.log.enums.BusinessType;
import com.hw.common.security.annotation.RequiresPermissions;
import com.hw.dms.domain.DmsFaultInstanceFile;
import com.hw.dms.service.IDmsFaultInstanceFileService;
import com.hw.common.core.web.controller.BaseController;
import com.hw.common.core.web.domain.AjaxResult;
import com.hw.common.core.utils.poi.ExcelUtil;
import com.hw.common.core.web.page.TableDataInfo;

/**
 * 故障文件;手工创建，从故障报修开始Controller
 * 
 * @author Open Platform
 * @date 2024-02-29
 */
@RestController
@RequestMapping("/dmsFaultInstanceFile")
public class DmsFaultInstanceFileController extends BaseController
{
    @Autowired
    private IDmsFaultInstanceFileService dmsFaultInstanceFileService;

    /**
     * 查询故障文件;手工创建，从故障报修开始列表
     */
    @RequiresPermissions("dms:dmsFaultInstanceFile:list")
    @GetMapping("/list")
    public TableDataInfo list(DmsFaultInstanceFile dmsFaultInstanceFile)
    {
        startPage();
        List<DmsFaultInstanceFile> list = dmsFaultInstanceFileService.selectDmsFaultInstanceFileList(dmsFaultInstanceFile);
        return getDataTable(list);
    }

    /**
     * 导出故障文件;手工创建，从故障报修开始列表
     */
    @RequiresPermissions("dms:dmsFaultInstanceFile:export")
    @Log(title = "故障文件;手工创建，从故障报修开始", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DmsFaultInstanceFile dmsFaultInstanceFile)
    {
        List<DmsFaultInstanceFile> list = dmsFaultInstanceFileService.selectDmsFaultInstanceFileList(dmsFaultInstanceFile);
        ExcelUtil<DmsFaultInstanceFile> util = new ExcelUtil<DmsFaultInstanceFile>(DmsFaultInstanceFile.class);
        util.exportExcel(response, list, "故障文件;手工创建，从故障报修开始数据");
    }

    /**
     * 获取故障文件;手工创建，从故障报修开始详细信息
     */
    @RequiresPermissions("dms:dmsFaultInstanceFile:query")
    @GetMapping(value = "/{repairInstanceFileId}")
    public AjaxResult getInfo(@PathVariable("repairInstanceFileId") Long repairInstanceFileId)
    {
        return success(dmsFaultInstanceFileService.selectDmsFaultInstanceFileByRepairInstanceFileId(repairInstanceFileId));
    }

    /**
     * 新增故障文件;手工创建，从故障报修开始
     */
    @RequiresPermissions("dms:dmsFaultInstanceFile:add")
    @Log(title = "故障文件;手工创建，从故障报修开始", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DmsFaultInstanceFile dmsFaultInstanceFile)
    {
        return toAjax(dmsFaultInstanceFileService.insertDmsFaultInstanceFile(dmsFaultInstanceFile));
    }

    /**
     * 修改故障文件;手工创建，从故障报修开始
     */
    @RequiresPermissions("dms:dmsFaultInstanceFile:edit")
    @Log(title = "故障文件;手工创建，从故障报修开始", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DmsFaultInstanceFile dmsFaultInstanceFile)
    {
        return toAjax(dmsFaultInstanceFileService.updateDmsFaultInstanceFile(dmsFaultInstanceFile));
    }

    /**
     * 删除故障文件;手工创建，从故障报修开始
     */
    @RequiresPermissions("dms:dmsFaultInstanceFile:remove")
    @Log(title = "故障文件;手工创建，从故障报修开始", businessType = BusinessType.DELETE)
	@DeleteMapping("/{repairInstanceFileIds}")
    public AjaxResult remove(@PathVariable Long[] repairInstanceFileIds)
    {
        return toAjax(dmsFaultInstanceFileService.deleteDmsFaultInstanceFileByRepairInstanceFileIds(repairInstanceFileIds));
    }
}
