package com.aucma.dms.controller;

//import com.hw.common.core.utils.poi.ExcelUtil;
//import com.hw.common.core.web.controller.BaseController;
//import com.hw.common.core.web.domain.AjaxResult;
//import com.hw.common.core.web.page.TableDataInfo;
//import com.hw.common.log.annotation.Log;
//import com.hw.common.log.enums.BusinessType;
//import com.hw.common.security.annotation.RequiresPermissions;
//import com.aucma.dms.domain.*;
//import com.aucma.dms.service.IDmsBaseDeviceSuppliesService;

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.DmsBaseDeviceSupplies;
import com.aucma.dms.service.IDmsBaseDeviceSuppliesService;
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 zangch
 * @date 2024-09-19
 */
@RestController
@RequestMapping("/dms/dmsBaseDeviceSupplies")
public class DmsBaseDeviceSuppliesController extends BaseController
{
    @Autowired
    private IDmsBaseDeviceSuppliesService dmsBaseDeviceSuppliesService;

    /**
     * 查询设备配套信息列表
     */
    //@PreAuthorize("@ss.hasPermi('dms:ledger:editSupplies')" )
    @GetMapping("/list")
    public TableDataInfo list(DmsBaseDeviceSupplies dmsBaseDeviceSupplies)
    {
        startPage();
        List<DmsBaseDeviceSupplies> list = dmsBaseDeviceSuppliesService.selectDmsBaseDeviceSuppliesList(dmsBaseDeviceSupplies);
        return getDataTable(list);
    }

    /**
     * 导出设备配套信息列表
     */
    //@PreAuthorize("@ss.hasPermi('dms:ledger:editSupplies')" )
    //@Log(title = "设备配套信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DmsBaseDeviceSupplies dmsBaseDeviceSupplies)
    {
        List<DmsBaseDeviceSupplies> list = dmsBaseDeviceSuppliesService.selectDmsBaseDeviceSuppliesList(dmsBaseDeviceSupplies);
        ExcelUtil<DmsBaseDeviceSupplies> util = new ExcelUtil<DmsBaseDeviceSupplies>(DmsBaseDeviceSupplies.class);
        util.exportExcel(response, list, "设备配套信息数据");
    }

    /**
     * 获取设备配套信息详细信息
     */
    //@PreAuthorize("@ss.hasPermi('dms:ledger:editSupplies')" )
    @GetMapping(value = "/{deviceSuppliesId}")
    public AjaxResult getInfo(@PathVariable("deviceSuppliesId") Long deviceSuppliesId)
    {
        return success(dmsBaseDeviceSuppliesService.selectDmsBaseDeviceSuppliesByDeviceSuppliesId(deviceSuppliesId));
    }

    /**
     * 新增设备配套信息
     */
    //@PreAuthorize("@ss.hasPermi('dms:ledger:editSupplies')" )
    //@Log(title = "设备配套信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DmsBaseDeviceSupplies dmsBaseDeviceSupplies)
    {
        return toAjax(dmsBaseDeviceSuppliesService.insertDmsBaseDeviceSupplies(dmsBaseDeviceSupplies));
    }

    /**
     * 修改设备配套信息
     */
    //@PreAuthorize("@ss.hasPermi('dms:ledger:editSupplies')" )
    //@Log(title = "设备配套信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DmsBaseDeviceSupplies dmsBaseDeviceSupplies)
    {
        return toAjax(dmsBaseDeviceSuppliesService.updateDmsBaseDeviceSupplies(dmsBaseDeviceSupplies));
    }

    /**
     * 删除设备配套信息
     */
    //@PreAuthorize("@ss.hasPermi('dms:ledger:editSupplies')" )
    //@Log(title = "设备配套信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{deviceSuppliesIds}")
    public AjaxResult remove(@PathVariable Long[] deviceSuppliesIds)
    {
        return toAjax(dmsBaseDeviceSuppliesService.deleteDmsBaseDeviceSuppliesByDeviceSuppliesIds(deviceSuppliesIds));
    }


    /**
     * 根据设备id查询设备配套信息列表
     */
    //@PreAuthorize("@ss.hasPermi('dms:ledger:editSupplies')" )
    @GetMapping("/listByDeviceId/{deviceId}")
    public AjaxResult listByDeviceId(@PathVariable("deviceId") Long deviceId)
    {
        return success(dmsBaseDeviceSuppliesService.selectDmsBaseDeviceSuppliesListByDeviceId(deviceId));
    }

}
