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.DmsRecordShutDown;
import com.hw.dms.service.IDmsRecordShutDownService;
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-01-15
 */
@RestController
@RequestMapping("/shutDown")
public class DmsRecordShutDownController extends BaseController
{
    @Autowired
    private IDmsRecordShutDownService dmsRecordShutDownService;

    /**
     * 查询停机记录列表
     */
    @RequiresPermissions("dms:shutDown:list")
    @GetMapping("/list")
    public TableDataInfo list(DmsRecordShutDown dmsRecordShutDown)
    {
        startPage();
        List<DmsRecordShutDown> list = dmsRecordShutDownService.selectDmsRecordShutDownList(dmsRecordShutDown);
        return getDataTable(list);
    }

    /**
     * 导出停机记录列表
     */
    @RequiresPermissions("dms:shutDown:export")
    @Log(title = "停机记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DmsRecordShutDown dmsRecordShutDown)
    {
        List<DmsRecordShutDown> list = dmsRecordShutDownService.selectDmsRecordShutDownList(dmsRecordShutDown);
        ExcelUtil<DmsRecordShutDown> util = new ExcelUtil<DmsRecordShutDown>(DmsRecordShutDown.class);
        util.exportExcel(response, list, "停机记录数据");
    }

    /**
     * 获取停机记录详细信息
     */
    @RequiresPermissions("dms:shutDown:query")
    @GetMapping(value = "/{recordShutDownId}")
    public AjaxResult getInfo(@PathVariable("recordShutDownId") Long recordShutDownId)
    {
        return success(dmsRecordShutDownService.selectDmsRecordShutDownByRecordShutDownId(recordShutDownId));
    }

    /**
     * 新增停机记录
     */
    @RequiresPermissions("dms:shutDown:add")
    @Log(title = "停机记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DmsRecordShutDown dmsRecordShutDown)
    {
        return toAjax(dmsRecordShutDownService.insertDmsRecordShutDown(dmsRecordShutDown));
    }

    /**
     * 修改停机记录
     */
    @RequiresPermissions("dms:shutDown:edit")
    @Log(title = "停机记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DmsRecordShutDown dmsRecordShutDown)
    {
        return toAjax(dmsRecordShutDownService.updateDmsRecordShutDown(dmsRecordShutDown));
    }

    /**
     * 删除停机记录
     */
    @RequiresPermissions("dms:shutDown:remove")
    @Log(title = "停机记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recordShutDownIds}")
    public AjaxResult remove(@PathVariable Long[] recordShutDownIds)
    {
        return toAjax(dmsRecordShutDownService.deleteDmsRecordShutDownByRecordShutDownIds(recordShutDownIds));
    }
}
