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.DmsFlowCheckplanDetail;
import com.hw.dms.service.IDmsFlowCheckplanDetailService;
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 xins
 * @date 2024-01-02
 */
@RestController
@RequestMapping("/detail")
public class DmsFlowCheckplanDetailController extends BaseController
{
    @Autowired
    private IDmsFlowCheckplanDetailService dmsFlowCheckplanDetailService;

    /**
     * 查询设备盘点明细列表
     */
    @RequiresPermissions("dms:detail:list")
    @GetMapping("/list")
    public TableDataInfo list(DmsFlowCheckplanDetail dmsFlowCheckplanDetail)
    {
        startPage();
        List<DmsFlowCheckplanDetail> list = dmsFlowCheckplanDetailService.selectDmsFlowCheckplanDetailList(dmsFlowCheckplanDetail);
        return getDataTable(list);
    }

    /**
     * 导出设备盘点明细列表
     */
    @RequiresPermissions("dms:detail:export")
    @Log(title = "设备盘点明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DmsFlowCheckplanDetail dmsFlowCheckplanDetail)
    {
        List<DmsFlowCheckplanDetail> list = dmsFlowCheckplanDetailService.selectDmsFlowCheckplanDetailList(dmsFlowCheckplanDetail);
        ExcelUtil<DmsFlowCheckplanDetail> util = new ExcelUtil<DmsFlowCheckplanDetail>(DmsFlowCheckplanDetail.class);
        util.exportExcel(response, list, "设备盘点明细数据");
    }

    /**
     * 获取设备盘点明细详细信息
     */
    @RequiresPermissions("dms:detail:query")
    @GetMapping(value = "/{checkplanDetailId}")
    public AjaxResult getInfo(@PathVariable("checkplanDetailId") Long checkplanDetailId)
    {
        return success(dmsFlowCheckplanDetailService.selectDmsFlowCheckplanDetailByCheckplanDetailId(checkplanDetailId));
    }

    /**
     * 新增设备盘点明细
     */
    @RequiresPermissions("dms:detail:add")
    @Log(title = "设备盘点明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DmsFlowCheckplanDetail dmsFlowCheckplanDetail)
    {
        return toAjax(dmsFlowCheckplanDetailService.insertDmsFlowCheckplanDetail(dmsFlowCheckplanDetail));
    }

    /**
     * 修改设备盘点明细
     */
    @RequiresPermissions("dms:detail:edit")
    @Log(title = "设备盘点明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DmsFlowCheckplanDetail dmsFlowCheckplanDetail)
    {
        return toAjax(dmsFlowCheckplanDetailService.updateDmsFlowCheckplanDetail(dmsFlowCheckplanDetail));
    }

    /**
     * 删除设备盘点明细
     */
    @RequiresPermissions("dms:detail:remove")
    @Log(title = "设备盘点明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{checkplanDetailIds}")
    public AjaxResult remove(@PathVariable Long[] checkplanDetailIds)
    {
        return toAjax(dmsFlowCheckplanDetailService.deleteDmsFlowCheckplanDetailByCheckplanDetailIds(checkplanDetailIds));
    }
}
